Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Youssefi
otb
Commits
81906fa5
Commit
81906fa5
authored
18 years ago
by
Thomas Feuvrier
Browse files
Options
Downloads
Patches
Plain Diff
Mise a jour avec méthodes sur le CommandLineParserArgument : IntputImage et OutputImage
parent
e5c1cc02
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Common/otbCommandLineArgumentParser.cxx
+33
-6
33 additions, 6 deletions
Code/Common/otbCommandLineArgumentParser.cxx
Code/Common/otbCommandLineArgumentParser.h
+12
-4
12 additions, 4 deletions
Code/Common/otbCommandLineArgumentParser.h
with
45 additions
and
10 deletions
Code/Common/otbCommandLineArgumentParser.cxx
+
33
−
6
View file @
81906fa5
...
...
@@ -58,6 +58,19 @@ CommandLineArgumentParseResult
return
(
lString
);
}
std
::
string
CommandLineArgumentParseResult
::
GetInputImage
(
void
)
const
{
return
(
GetParameterString
(
"--InputImage"
));
}
std
::
string
CommandLineArgumentParseResult
::
GetOutputImage
(
void
)
const
{
return
(
GetParameterString
(
"--OutputImage"
));
}
int
CommandLineArgumentParseResult
::
GetNumberOfParameters
(
const
char
*
option
)
...
...
@@ -102,6 +115,20 @@ CommandLineArgumentParser
AddOption
(
"--version"
,
"Version"
,
"-v"
,
0
,
false
);
}
void
CommandLineArgumentParser
::
AddInputImage
(
void
)
{
AddOption
(
"--InputImage"
,
"input image file name "
,
"-in"
,
1
,
true
);
}
void
CommandLineArgumentParser
::
AddOutputImage
(
void
)
{
AddOption
(
"--OutputImage"
,
"output image file name "
,
"-out"
,
1
,
true
);
}
void
CommandLineArgumentParser
::
AddOption
(
const
char
*
name
,
const
char
*
comment
,
char
*
synonim
,
int
nParameters
,
bool
obligatory
)
...
...
@@ -207,7 +234,7 @@ CommandLineArgumentParser
}
//Check the option
m_OptionList
[
index
].
Finded
=
true
;
// Si le nombre de parametres est pr
édé
fini :
// Si le nombre de parametres est pr
�d�fini
:
if
(
m_OptionList
[
index
].
NumberOfParametersFixed
==
true
)
{
// Check if the number of parameters is correct
...
...
@@ -230,7 +257,7 @@ CommandLineArgumentParser
outResult
->
AddParameter
(
m_OptionList
[
index
].
CommonName
,
std
::
string
(
argv
[
i
+
1
]));
}
}
// Si le nombre de parametres n'est pas pr
édé
fini, lecture jusqu'a la prochaine option ou fin argv :
// Si le nombre de parametres n'est pas pr
�d�fini
, lecture jusqu'a la prochaine option ou fin argv :
else
{
// Tell the result that the option has been encountered
...
...
@@ -261,7 +288,7 @@ CommandLineArgumentParser
}
// Controle que toutes les options obligatoire sont pr
é
sentes dans la ligne d'argument
// Controle que toutes les options obligatoire sont pr
�se
ntes dans la ligne d'argument
for
(
unsigned
int
cpt
=
0
;
cpt
<
m_OptionList
.
size
()
;
cpt
++
)
{
if
(
(
m_OptionList
[
cpt
].
Obligatory
==
true
)
&&
(
m_OptionList
[
cpt
].
Finded
==
false
)
)
...
...
@@ -283,7 +310,7 @@ bool
CommandLineArgumentParser
::
FindOption
(
const
std
::
string
&
option
,
int
&
index
)
{
//Cherche dans la liste des options install
é
es
//Cherche dans la liste des options install
�es
bool
trouve
(
false
);
bool
continuer
(
true
);
unsigned
int
cpt
(
0
);
...
...
@@ -321,7 +348,7 @@ CommandLineArgumentParser
if
(
largeur
>
largeurmax
)
largeurmax
=
largeur
;
}
// Controle que toutes les options obligatoire sont pr
é
sentes dans la ligne d'argument
// Controle que toutes les options obligatoire sont pr
�se
ntes dans la ligne d'argument
for
(
i
=
0
;
i
<
m_OptionList
.
size
()
;
i
++
)
{
int
largeur
=
m_OptionList
[
i
].
CommonName
.
size
()
+
m_OptionList
[
i
].
Synonim
.
size
();
...
...
@@ -335,7 +362,7 @@ CommandLineArgumentParser
}
if
(
m_OptionList
[
i
].
Obligatory
==
false
)
os
<<
"]"
;
else
os
<<
" "
;
//Aligne le texte avec la diff
é
rence en blanc
//Aligne le texte avec la diff
�re
nce en blanc
for
(
int
b
=
largeur
;
b
<
largeurmax
;
b
++
)
os
<<
" "
;
os
<<
" : "
<<
m_OptionList
[
i
].
Description
;
if
(
m_OptionList
[
i
].
NumberOfParametersFixed
==
true
)
...
...
This diff is collapsed.
Click to expand it.
Code/Common/otbCommandLineArgumentParser.h
+
12
−
4
View file @
81906fa5
...
...
@@ -40,7 +40,7 @@ namespace otb
/**
* \class CommandLineArgumentParseResult
* \brief Objet retourn
par lCommandLineArgumentParser
* \brief Objet retourn
� p
ar lCommandLineArgumentParser
* \see CommandLineArgumentParser
*/
class
ITK_EXPORT
CommandLineArgumentParseResult
:
public
itk
::
ProcessObject
...
...
@@ -95,6 +95,9 @@ public:
*/
std
::
string
GetParameterString
(
const
char
*
option
,
unsigned
int
number
=
0
)
const
;
std
::
string
GetInputImage
(
void
)
const
;
std
::
string
GetOutputImage
(
void
)
const
;
protected:
CommandLineArgumentParseResult
(){};
...
...
@@ -119,7 +122,7 @@ private:
/**
* \class CommandLineArgumentParser
* \brief Utilis
pour parser une ligne de commande contenant des arguments et la traduit en liste de paramt
r
es.
* \brief Utilis
� p
our parser une ligne de commande contenant des arguments et la traduit en liste de param�t
res
.
* Usage:
* \code
* // Initialise le parser
...
...
@@ -149,12 +152,17 @@ public:
itkNewMacro
(
Self
);
itkTypeMacro
(
CommandLineArgumentParser
,
itk
::
ProcessObject
);
/** Add an input image option */
void
AddInputImage
(
void
);
/** Add an output image option */
void
AddOutputImage
(
void
);
/** Add an option with 0 or more parameters (words that follow it) */
// void AddOption(const char *name, const int nParameters, const char * comment);
// Au moins une valeur
void
AddOption
(
const
char
*
name
,
const
char
*
comment
,
char
*
synonim
=
NULL
,
int
nParameters
=
1
,
bool
obligatory
=
true
);
// Si -1, alors on ne connait pas le nombre de parametres
l'avance.
// Si -1, alors on ne connait pas le nombre de parametres
� l
'avance.
void
AddOptionNParams
(
const
char
*
name
,
const
char
*
comment
,
char
*
synonim
=
NULL
,
bool
obligatory
=
true
);
/** Add a different string that envokes the same option (--file and -f) */
...
...
@@ -188,7 +196,7 @@ private:
bool
NumberOfParametersFixed
;
//Precise si le nombre de valeurs attendues est connu
int
NumberOfParameters
;
//Nombre de valeurs pour cette option
bool
Obligatory
;
//Precise si l'option est obligatoire
bool
Finded
;
//Precise si l'option a
t t
rouve
d
ans la ligne de commande
bool
Finded
;
//Precise si l'option a
�t� tro
uv�e d
ans
la ligne de commande
}
OptionType
;
// typedef std::map< std::string, OptionType> OptionMapType;
typedef
std
::
vector
<
OptionType
>
ListOptionType
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment