PhoenixMock  1.8.7
Tools to split/merge/print mock used in Phoenix
main.cpp
Go to the documentation of this file.
1 
2 /***************************************
3  Auteur : Pierre Aubert
4  Mail : pierre.aubert@lapp.in2p3.fr
5  Licence : CeCILL-C
6 ****************************************/
7 
8 #include "phoenix_assert.h"
9 #include "phoenix_check.h"
10 #include "print_string.h"
11 
12 #include "Option.h"
13 
15 
17 void printValueOfOptConst(const Option & opt){
18  phoenix_print(opt.getDocString(), "", "Docstring : ");
19  phoenix_print(opt.getLongName(), "", "LongName : ");
20  phoenix_print(opt.getShortName(), "", "ShortName : ");
21  phoenix_print(opt.getValue().getValue(), "", "Value : ");
22  phoenix_print(opt.isRequired(), "", "IsRequired : ");
23  phoenix_print(opt.isAllowEmpty(), "", "IsAllowEmpty : ");
24 }
25 
27 
29 void printValueOfOpt(Option & opt){
30  phoenix_print(opt.getDocString(), "", "Docstring : ");
31  phoenix_print(opt.getLongName(), "", "LongName : ");
32  phoenix_print(opt.getShortName(), "", "ShortName : ");
33  phoenix_print(opt.getValue().getValue(), "", "Value : ");
34  phoenix_print(opt.isRequired(), "", "IsRequired : ");
35  phoenix_print(opt.isAllowEmpty(), "", "IsAllowEmpty : ");
36 }
37 
39 void testOption(){
40  Option opt("long", "short", "value", "some doc");
41  printValueOfOpt(opt);
43 
44  Option optReq("long", "short", true, "some doc");
45  printValueOfOptConst(optReq);
46 
47  Option optSet;
48  optSet.setDocString("Some doc");
49  optSet.setLongName("long");
50  optSet.setShortName("short");
51  optSet.setValue(OptionValue("Value", OptionType::STRING));
52  optSet.setIsRequired(true);
53  optSet.setIsAllowEmpty(true);
54  optSet.setIsParsed(false);
55  printValueOfOptConst(optSet);
56 }
57 
58 int main(int argc, char** argv){
59  testOption();
60  return 0;
61 }
62 
63 
Option.h
Option::isRequired
bool isRequired() const
Get if the option is required.
Definition: Option.cpp:212
Option::setIsParsed
void setIsParsed(bool isParsed)
Say if the Option has been parsed or not.
Definition: Option.cpp:172
phoenix_print
void phoenix_print(const T &data, const std::string &suffix="", const std::string &prefix="")
Print data.
Definition: print_string_impl.h:18
printValueOfOpt
void printValueOfOpt(Option &opt)
Print value of Option.
Definition: main.cpp:29
OptionType::STRING
@ STRING
Definition: OptionType.h:25
Option::setDocString
void setDocString(const std::string &docString)
Set the documentation string of the Option.
Definition: Option.cpp:167
Option::getValue
const OptionValue & getValue() const
Get the value of the Option.
Definition: Option.cpp:202
printValueOfOptConst
void printValueOfOptConst(const Option &opt)
Print value of Option.
Definition: main.cpp:17
Option::isAllowEmpty
bool isAllowEmpty() const
Get if the option value can be empty.
Definition: Option.cpp:222
Option::setLongName
void setLongName(const std::string &longName)
Set the long name of the option.
Definition: Option.cpp:147
Option::setValue
void setValue(const OptionValue &value)
Set the value of the option.
Definition: Option.cpp:157
testOption
void testOption()
Test the option type.
Definition: main.cpp:39
print_string.h
Option::getShortName
const std::string & getShortName() const
Get the short name of the Option.
Definition: Option.cpp:192
Option::setShortName
void setShortName(const std::string &shortName)
Set the short name of the option.
Definition: Option.cpp:152
Option::getLongName
const std::string & getLongName() const
Get the long name of the Option.
Definition: Option.cpp:182
Option
Definition: Option.h:13
OptionValue::getValue
const VecValue & getValue() const
Get the vector of values.
Definition: OptionValue.cpp:131
Option::setIsAllowEmpty
void setIsAllowEmpty(bool isAllowEmpty)
Say if the option can be empty or not.
Definition: Option.cpp:177
OptionValue
Describe the value of an option passed to a program.
Definition: OptionValue.h:20
Option::setIsRequired
void setIsRequired(bool isRequired)
Set if the option is required.
Definition: Option.cpp:162
phoenix_assert.h
main
int main(int argc, char **argv)
Definition: main.cpp:85
Option::getDocString
const std::string & getDocString() const
Get the documentation string of the Option.
Definition: Option.cpp:232
phoenix_check.h