STK++ 0.9.13
STK::Option Class Reference

the Option class allow to store the value of an option from a IPage. More...

#include <STK_Option.h>

Public Types

enum  TypeOption {
  unknown_ =0 , string_ , real_ , integer_ ,
  range_ , lstring_ , lreal_ , linteger_ ,
  lrange_ , page_
}
 A TypeOption is the kind of options that can read or write a program in a file. More...
 

Public Member Functions

 Option (String const &name, TypeOption type=string_, bool isOptional=true)
 constructor.
 
 Option (IPage const &page)
 Special constructor.
 
 Option (Option const &opt)
 Copy constructor.
 
 ~Option ()
 Destructor.
 
Optionoperator= (const Option &opt)
 Assignment operator.
 
String constname () const
 name of the option.
 
TypeOption type () const
 type of the option.
 
bool isOptional () const
 check if the option is optional of the option.
 
void setListSeparator (Char const &sep)
 set the separator to use in the list of options.
 
void write (ostream &os) const
 write out the options in the output stream
 
void read (istream &is)
 read in the options from the input stream.
 
bool setValue (String const &str)
 Convert a string in a value.
 
void setPage (IPage const &value)
 set a value from a Page.
 
String constget (String const &value) const
 get the option as a String
 
Real constget (Real const &value) const
 get the option as a Real
 
int get (int const &value) const
 get the option as an int
 
Range constget (Range const &value) const
 get the option as a Range
 
std::list< String > constget (std::list< String > const &value) const
 get the option as a list of String
 
std::list< Real > constget (std::list< Real > const &value) const
 get the option as a list of Real
 
std::list< int > constget (std::list< int > const &value) const
 get the option as a list of int
 
std::list< Range > constget (std::list< Range > const &value) const
 get the option as a list of Range
 
IPage constget (IPage const &value) const
 get the option as a page
 

Protected Member Functions

void set (String const &value)
 set a value from string.
 
void set (Real const &value)
 set a value from a Real.
 
void set (int const &value)
 set a value from an int.
 
void set (Range const &value)
 set a value from a Range.
 
void set (std::list< String > const &value)
 set a value from a list of String.
 
void set (std::list< Real > const &value)
 set a value from a list of Real.
 
void set (std::list< int > const &value)
 set a value from a list of int.
 
void set (std::list< Range > const &value)
 set a value from a list of Range.
 

Private Member Functions

void deleteValue ()
 Remove the value of the option.
 
void setDefaultValue ()
 set a default value of the option.
 

Private Attributes

String name_
 name of the option
 
Char sep_
 Char used for the option list.
 
TypeOption type_
 type of the option
 
bool isOptional_
 true if the option is optional, false otherwise
 
bool isValued_
 true if the option is valued, false otherwise.
 
union { 
 
   String *   p_String_ 
 
   Real *   p_Real_ 
 
   int *   p_int_ 
 
   Range *   p_Range_ 
 
   std::list< String > *   p_lString_ 
 
   std::list< Real > *   p_lReal_ 
 
   std::list< int > *   p_lint_ 
 
   std::list< Range > *   p_lRange_ 
 
   IPage *   p_Page_ 
 
};  
 value of the option.
 

Detailed Description

the Option class allow to store the value of an option from a IPage.

An Option is essentially a variant type. TODO add error message handling

Definition at line 55 of file STK_Option.h.

Constructor & Destructor Documentation

◆ Option() [1/3]

STK::Option::Option ( String const name,
TypeOption  type = string_,
bool  isOptional = true 
)

constructor.

Parameters
namethe name of the Option
typethe type of the Option
isOptionaltrue if the parameter is optional, false otherwise

Definition at line 47 of file STK_Option.cpp.

48 : name_(name)
49 , sep_(CHAR_SEP)
50 , type_(type)
52 , isValued_(false)
53 , p_String_(0)
54{
57}
String const & name() const
name of the option.
Definition STK_Option.h:116
void setDefaultValue()
set a default value of the option.
String * p_String_
Definition STK_Option.h:252
Char sep_
Char used for the option list.
Definition STK_Option.h:241
TypeOption type_
type of the option
Definition STK_Option.h:243
bool isOptional_
true if the option is optional, false otherwise
Definition STK_Option.h:245
bool isOptional() const
check if the option is optional of the option.
Definition STK_Option.h:124
bool isValued_
true if the option is valued, false otherwise.
Definition STK_Option.h:248
TypeOption type() const
type of the option.
Definition STK_Option.h:120
String name_
name of the option
Definition STK_Option.h:239
String const & toUpperString(String &s)
convert the characters of the String to upper case
Definition STK_String.h:134

References name_, setDefaultValue(), and STK::toUpperString().

Referenced by Option().

◆ Option() [2/3]

STK::Option::Option ( IPage const page)

Special constructor.

This will construct an option as a sub-page. The name of the option will be the name of the page.

Parameters
pagethe page to set as option

Definition at line 63 of file STK_Option.cpp.

64 : name_(page.name())
65 , sep_(CHAR_SEP)
66 , type_(page_)
67 , isOptional_(page.isOptional())
68 , isValued_(true)
69 , p_Page_(page.clone())
70{
72}
IPage * p_Page_
Definition STK_Option.h:260
@ page_
a page option
Definition STK_Option.h:82

References name_, and STK::toUpperString().

◆ Option() [3/3]

STK::Option::Option ( Option const opt)

Copy constructor.

Parameters
optthe Option to copy

Definition at line 77 of file STK_Option.cpp.

78 : name_(opt.name_)
79 , sep_(opt.sep_)
80 , type_(opt.type_)
81 , isOptional_(opt.isOptional_)
82 , isValued_(opt.isOptional_)
83 , p_String_(0)
84{
85 // copy rhs value
86 switch (type_)
87 {
88 case string_:
89 if (opt.p_String_) set(*(opt.p_String_));
90 else p_String_ = 0;
91 break;
92 case real_:
93 if (opt.p_Real_) set(*(opt.p_Real_));
94 else p_Real_ = 0;
95 break;
96 case integer_:
97 if (opt.p_int_) set(*(opt.p_int_));
98 else p_int_ = 0;
99 break;
100 case range_:
101 if (opt.p_Range_) set(*(opt.p_Range_));
102 else p_Range_ = 0;
103 break;
104 case lstring_:
105 if (opt.p_lString_) set(*(opt.p_lString_));
106 else p_lString_ = 0;
107 break;
108 case lreal_:
109 if (opt.p_lReal_) set(*(opt.p_lReal_));
110 else p_lReal_ = 0;
111 break;
112 case linteger_:
113 if (opt.p_lint_) set(*(opt.p_lint_));
114 else p_lint_ = 0;
115 break;
116 case lrange_:
117 if (opt.p_lRange_) set(*(opt.p_lRange_));
118 else p_lRange_ = 0;
119 break;
120 case page_:
121 if (opt.p_Page_) setPage(*(opt.p_Page_));
122 else p_Page_ = 0;
123 break;
124 case unknown_:
126 break; // avoid warning
127 };
128}
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:138
Range * p_Range_
Definition STK_Option.h:255
void setPage(IPage const &value)
set a value from a Page.
std::list< int > * p_lint_
Definition STK_Option.h:258
Real * p_Real_
Definition STK_Option.h:253
std::list< String > * p_lString_
Definition STK_Option.h:256
Option(String const &name, TypeOption type=string_, bool isOptional=true)
constructor.
std::list< Range > * p_lRange_
Definition STK_Option.h:259
std::list< Real > * p_lReal_
Definition STK_Option.h:257
void set(String const &value)
set a value from string.
@ linteger_
list of discrete numbers separated by commas
Definition STK_Option.h:80
@ range_
range of number
Definition STK_Option.h:77
@ lstring_
list of strings separated by commas
Definition STK_Option.h:78
@ lreal_
list of floating numbers separated by commas
Definition STK_Option.h:79
@ integer_
discrete number
Definition STK_Option.h:76
@ lrange_
list of range of number separated by commas
Definition STK_Option.h:81
@ string_
characters
Definition STK_Option.h:74
@ real_
floating
Definition STK_Option.h:75

References integer_, linteger_, lrange_, lreal_, lstring_, Option(), p_int_, p_lint_, p_lRange_, p_lReal_, p_lString_, p_Page_, p_Range_, p_Real_, p_String_, page_, range_, real_, set(), setPage(), STKRUNTIME_ERROR_NO_ARG, string_, type(), type_, and unknown_.

◆ ~Option()

STK::Option::~Option ( )

Destructor.

Definition at line 131 of file STK_Option.cpp.

131{ deleteValue();}
void deleteValue()
Remove the value of the option.

References deleteValue().

Member Function Documentation

◆ deleteValue()

void STK::Option::deleteValue ( )
private

Remove the value of the option.

Definition at line 424 of file STK_Option.cpp.

425{
426 switch (type_)
427 {
428 case string_:
429 if (p_String_) delete p_String_;
430 p_String_ = 0;
431 break;
432 case real_:
433 if (p_Real_) delete p_Real_;
434 p_Real_ = 0;
435 break;
436 case integer_:
437 if (p_int_) delete p_int_;
438 p_int_ = 0;
439 break;
440 case range_:
441 if (p_Range_) delete p_Range_;
442 p_Range_ = 0;
443 break;
444 case lstring_:
445 if (p_lString_) delete p_lString_;
446 p_lString_ = 0;
447 break;
448 case lreal_:
449 if (p_lReal_) delete p_lReal_;
450 p_lReal_ = 0;
451 break;
452 case linteger_:
453 if (p_lint_) delete p_lint_;
454 p_lint_ = 0;
455 break;
456 case lrange_:
457 if (p_lRange_) delete p_lRange_;
458 p_lRange_ = 0;
459 break;
460 case page_:
461 if (p_Page_) delete p_Page_;
462 p_Page_ = 0;
463 break;
464 default:
465 break;
466 };
467 isValued_ = false;
468}

References integer_, isValued_, linteger_, lrange_, lreal_, lstring_, p_int_, p_lint_, p_lRange_, p_lReal_, p_lString_, p_Page_, p_Range_, p_Real_, p_String_, page_, range_, real_, string_, and type_.

Referenced by set(), set(), set(), set(), set(), set(), set(), set(), setPage(), and ~Option().

◆ get() [1/9]

int STK::Option::get ( int const value) const
inline

get the option as an int

Parameters
valueany int (will not be used)

Definition at line 170 of file STK_Option.h.

171 { return *p_int_;}

References p_int_.

◆ get() [2/9]

IPage const & STK::Option::get ( IPage const value) const
inline

get the option as a page

Parameters
valueany page (will not be used)

Definition at line 200 of file STK_Option.h.

201 { return *p_Page_;}

References p_Page_.

◆ get() [3/9]

Range const & STK::Option::get ( Range const value) const
inline

get the option as a Range

Parameters
valueany Range (will not be used)

Definition at line 175 of file STK_Option.h.

176 { return *p_Range_;}

References p_Range_.

◆ get() [4/9]

Real const & STK::Option::get ( Real const value) const
inline

get the option as a Real

Parameters
valueany Real (will not be used)

Definition at line 165 of file STK_Option.h.

166 { return *p_Real_;}

References p_Real_.

◆ get() [5/9]

std::list< int > const & STK::Option::get ( std::list< int > const value) const
inline

get the option as a list of int

Parameters
valueany list of int (will not be used)

Definition at line 190 of file STK_Option.h.

191 { return *p_lint_;}

References p_lint_.

◆ get() [6/9]

std::list< Range > const & STK::Option::get ( std::list< Range > const value) const
inline

get the option as a list of Range

Parameters
valueany list of Range (will not be used)

Definition at line 195 of file STK_Option.h.

196 { return *p_lRange_;}

References p_lRange_.

◆ get() [7/9]

std::list< Real > const & STK::Option::get ( std::list< Real > const value) const
inline

get the option as a list of Real

Parameters
valueany list of Real (will not be used)

Definition at line 185 of file STK_Option.h.

186 { return *p_lReal_;}

References p_lReal_.

◆ get() [8/9]

std::list< String > const & STK::Option::get ( std::list< String > const value) const
inline

get the option as a list of String

Parameters
valueany list of String (will not be used)

Definition at line 180 of file STK_Option.h.

181 { return *p_lString_;}

References p_lString_.

◆ get() [9/9]

String const & STK::Option::get ( String const value) const
inline

get the option as a String

Parameters
valueany String (will not be used)

Definition at line 160 of file STK_Option.h.

161 { return *p_String_;}

References p_String_.

◆ isOptional()

bool STK::Option::isOptional ( ) const
inline

check if the option is optional of the option.

Returns
ture if the option s optional, false otherwise

Definition at line 124 of file STK_Option.h.

124{ return isOptional_;}

References isOptional_.

◆ name()

String const & STK::Option::name ( ) const
inline

name of the option.

If the option is a IPage, the name have to be the keyword.

Returns
the name of the option

Definition at line 116 of file STK_Option.h.

116{ return name_;}

References name_.

◆ operator=()

Option & STK::Option::operator= ( const Option opt)

Assignment operator.

We need to overload this operator otherwise the variant union containing the value of the Option will not be copied correctly.

Parameters
optthe Option to copy
Returns
a reference o this

Definition at line 134 of file STK_Option.cpp.

135{
136 // Do the assignment operation of the members
137 name_ = opt.name_;
138 sep_ = opt.sep_;
139 type_ = opt.type_;
140 isOptional_ = opt.isOptional_;
141 isValued_ = opt.isValued_;
142 // copy rhs value
143 switch (type_)
144 {
145 case string_:
146 if (opt.p_String_) set(*(opt.p_String_));
147 else p_String_ = 0;
148 break;
149 case real_:
150 if (opt.p_Real_) set(*(opt.p_Real_));
151 else p_Real_ = 0;
152 break;
153 case integer_:
154 if (opt.p_int_) set(*(opt.p_int_));
155 else p_int_ = 0;
156 break;
157 case range_:
158 if (opt.p_Range_) set(*(opt.p_Range_));
159 else p_Range_ = 0;
160 break;
161 case lstring_:
162 if (opt.p_lString_) set(*(opt.p_lString_));
163 else p_lString_ = 0;
164 break;
165 case lreal_:
166 if (opt.p_lReal_) set(*(opt.p_lReal_));
167 else p_lReal_ = 0;
168 break;
169 case linteger_:
170 if (opt.p_lint_) set(*(opt.p_lint_));
171 else p_lint_ = 0;
172 break;
173 case lrange_:
174 if (opt.p_lRange_) set(*(opt.p_lRange_));
175 else p_lRange_ = 0;
176 break;
177 case page_:
178 if (opt.p_Page_) setPage(*(opt.p_Page_));
179 else p_Page_ = 0;
180 break;
181 case unknown_:
182 STKRUNTIME_ERROR_NO_ARG(Option::operator=,Unknown type option.);
183 break; // avoid warning
184 };
185 // return this
186 return *this; // Return a reference to myself.
187}

References integer_, isOptional_, isValued_, linteger_, lrange_, lreal_, lstring_, name_, p_int_, p_lint_, p_lRange_, p_lReal_, p_lString_, p_Page_, p_Range_, p_Real_, p_String_, page_, range_, real_, sep_, set(), setPage(), STKRUNTIME_ERROR_NO_ARG, string_, type(), type_, and unknown_.

◆ read()

void STK::Option::read ( istream is)

read in the options from the input stream.

This method is only used for reading the pages options. All the other options are read outside and set using the set and setValue methods.

Parameters
isthe input stream to read

Definition at line 330 of file STK_Option.cpp.

331{
332 // read option value
333 if (type_ == page_)
334 {
335 if (p_Page_)
336 {
337 p_Page_->read(is);
338 if (!p_Page_->validate())
340 }
341 };
342}
virtual bool validate()
validate the page.
Definition STK_IPage.h:193
String const & msg_error() const
name of the IPage.
Definition STK_IPage.h:132
void read(istream &is)
read in options from an input steam stream
void read(istream &is)
read in the options from the input stream.

References STK::IPage::msg_error(), p_Page_, page_, STK::IPage::read(), read(), STKRUNTIME_ERROR_NO_ARG, type_, and STK::IPage::validate().

Referenced by read().

◆ set() [1/8]

void STK::Option::set ( int const value)
protected

set a value from an int.

Parameters
valuethe int value to set

Definition at line 367 of file STK_Option.cpp.

368{
369 deleteValue();
370 p_int_ = new int(value);
371 isValued_ = true;
372}

References deleteValue(), isValued_, and p_int_.

◆ set() [2/8]

void STK::Option::set ( Range const value)
protected

set a value from a Range.

Parameters
valuethe Range value to set

Definition at line 377 of file STK_Option.cpp.

378{
379 deleteValue();
380 p_Range_ = new Range(value);
381 isValued_ = true;
382}
TRange< UnknownSize > Range
Definition STK_Range.h:59

References deleteValue(), isValued_, and p_Range_.

◆ set() [3/8]

void STK::Option::set ( Real const value)
protected

set a value from a Real.

Parameters
valuethe Real value to set

Definition at line 357 of file STK_Option.cpp.

358{
359 deleteValue();
360 p_Real_ = new Real(value);
361 isValued_ = true;
362}
double Real
STK fundamental type of Real values.

References deleteValue(), isValued_, and p_Real_.

◆ set() [4/8]

void STK::Option::set ( std::list< int > const value)
protected

set a value from a list of int.

Parameters
valuethe list of int values to set

Definition at line 407 of file STK_Option.cpp.

408{
409 deleteValue();
410 p_lint_ = new std::list<int>(value);
411 isValued_ = true;
412}

References deleteValue(), isValued_, and p_lint_.

◆ set() [5/8]

void STK::Option::set ( std::list< Range > const value)
protected

set a value from a list of Range.

Parameters
valuethe list of Range values to set

Definition at line 416 of file STK_Option.cpp.

417{
418 deleteValue();
419 p_lRange_ = new std::list<Range>(value);
420 isValued_ = true;
421}

References deleteValue(), isValued_, and p_lRange_.

◆ set() [6/8]

void STK::Option::set ( std::list< Real > const value)
protected

set a value from a list of Real.

Parameters
valuethe list of Real values to set

Definition at line 397 of file STK_Option.cpp.

398{
399 deleteValue();
400 p_lReal_ = new std::list<Real>(value);
401 isValued_ = true;
402}

References deleteValue(), isValued_, and p_lReal_.

◆ set() [7/8]

void STK::Option::set ( std::list< String > const value)
protected

set a value from a list of String.

Parameters
valuethe list of string values to set

Definition at line 387 of file STK_Option.cpp.

388{
389 deleteValue();
390 p_lString_ = new std::list<String>(value);
391 isValued_ = true;
392}

References deleteValue(), isValued_, and p_lString_.

◆ set() [8/8]

void STK::Option::set ( String const value)
protected

set a value from string.

Parameters
valuethe string value to set

Definition at line 347 of file STK_Option.cpp.

348{
349 deleteValue();
350 p_String_ = new String(value);
351 isValued_ = true;
352}
std::basic_string< Char > String
STK fundamental type of a String.

References deleteValue(), isValued_, and p_String_.

Referenced by operator=(), Option(), and setValue().

◆ setDefaultValue()

void STK::Option::setDefaultValue ( )
private

set a default value of the option.

This method is used only once when the object is created.

Definition at line 472 of file STK_Option.cpp.

473{
474 //deleteValue();
475 switch (type_)
476 {
477 case string_:
478 p_String_ = new String;
480 break;
481 case real_:
482 p_Real_ = new Real;
484 break;
485 case integer_:
486 p_int_ = new int;
488 break;
489 case range_:
490 p_Range_ = new Range;
491 break;
492 case lstring_:
493 p_lString_ = new std::list<String>;
494 break;
495 case lreal_:
496 p_lReal_ = new std::list<Real>;
497 break;
498 case linteger_:
499 p_lint_ = new std::list<int>;
500 break;
501 case lrange_:
502 p_lRange_ = new std::list<Range>;
503 break;
504 case page_:
505 p_Page_ = 0;
506 break;
507 default:
508 break;
509 };
510}
String stringNa
Representation of a Not Available value.
static Type NA()
Adding a Non Available (NA) special number.

References integer_, linteger_, lrange_, lreal_, lstring_, STK::Arithmetic< Type >::NA(), p_int_, p_lint_, p_lRange_, p_lReal_, p_lString_, p_Page_, p_Range_, p_Real_, p_String_, page_, range_, real_, string_, STK::stringNa, and type_.

Referenced by Option().

◆ setListSeparator()

void STK::Option::setListSeparator ( Char const sep)
inline

set the separator to use in the list of options.

Parameters
septhe separator to use

Definition at line 129 of file STK_Option.h.

130 { sep_ = sep;}

References sep_.

◆ setPage()

void STK::Option::setPage ( IPage const value)

set a value from a Page.

The field type_ of the class is set to DManager::page_.

Parameters
valuethe Page to set

Definition at line 263 of file STK_Option.cpp.

264{
265 deleteValue();
266 p_Page_ = value.clone();
267 isValued_ = true;
268 type_ = page_;
269}
virtual IPage * clone() const
Definition STK_IPage.h:195

References STK::IPage::clone(), deleteValue(), isValued_, p_Page_, page_, and type_.

Referenced by operator=(), and Option().

◆ setValue()

bool STK::Option::setValue ( String const str)

Convert a string in a value.

The conversion is done using the field type_ of the class.

Parameters
strthe string to convert
Returns
true if the conversion success, false otherwise

Definition at line 192 of file STK_Option.cpp.

193{
194 // choose type
195 switch (type_)
196 {
197 case string_:
198 set(str);
199 break;
200 case real_:
201 {
202 Real realValue;
203 if (stringToType(realValue, str)) { set(realValue);}
204 else STKRUNTIME_ERROR_1ARG(Option::setValue,str,Real convertion failed.);
205 }
206 break;
207 case integer_:
208 {
209 int integerValue;
210 if (stringToType(integerValue, str)) { set(integerValue);}
211 else STKRUNTIME_ERROR_1ARG(Option::setValue,str,Integer convertion failed.);
212 }
213 break;
214 case range_:
215 {
216 Range rangeValue;
217 if (stringToType(rangeValue, str)) { set(rangeValue);}
218 else STKRUNTIME_ERROR_1ARG(Option::setValue,str,Range convertion failed.);
219 }
220 break;
221 case lstring_:
222 {
223 std::list<String> lStringValue;
224 DManager::readList(str, lStringValue);
225 set(lStringValue);
226 }
227 break;
228 case lreal_:
229 {
230 std::list<Real> lRealValue;
231 DManager::readList(str, lRealValue);
232 set(lRealValue);
233 }
234 break;
235 case linteger_:
236 {
237 std::list<int> lintValue;
238 DManager::readList(str, lintValue);
239 set(lintValue);
240 }
241 break;
242 case lrange_:
243 {
244 std::list<Range> lRangeValue;
245 DManager::readList(str, lRangeValue);
246 set(lRangeValue);
247 }
248 break;
249 case page_:
250 STKRUNTIME_ERROR_1ARG(Option::setValue,str,page option not allowed.);
251 break;
252 case unknown_:
253 STKRUNTIME_ERROR_1ARG(Option::setValue,str, unknown option.);
254 break; // avoid warning
255 };
256 // error if an error occur in readList ?
257 return true;
258}
#define STKRUNTIME_ERROR_1ARG(Where, Arg, Error)
Definition STK_Macros.h:129
bool setValue(String const &str)
Convert a string in a value.
bool stringToType(Type &t, String const &s, std::ios_base &(*f)(std::ios_base &)=std::dec)
convert a String to Type
Definition STK_String.h:195
void readList(String const &strBuffer, std::list< TYPE > &lst, Char sep=CHAR_SEP)
Read a list of value of type TYPE stored in a line.
int Integer
STK fundamental type of integer values.

References integer_, linteger_, lrange_, lreal_, lstring_, page_, range_, STK::DManager::readList(), real_, set(), setValue(), STKRUNTIME_ERROR_1ARG, string_, STK::stringToType(), type_, and unknown_.

Referenced by setValue().

◆ type()

TypeOption STK::Option::type ( ) const
inline

type of the option.

Returns
the type of the option

Definition at line 120 of file STK_Option.h.

120{ return type_;}

References type_.

Referenced by operator=(), and Option().

◆ write()

void STK::Option::write ( ostream os) const

write out the options in the output stream

Parameters
osoutput stream

Definition at line 275 of file STK_Option.cpp.

276{
277 // write option name if it's not a page
278 if (type_ != page_)
279 { // write name and " = "
280 os << name_ << _T(" ") << CHAR_EQUAL << _T(" ");
281 }
282 // write option value
283 switch (type_)
284 {
285 case string_:
286 if (p_String_)
287 os << *p_String_;
288 break;
289 case real_:
290 if (p_Real_)
291 os << *p_Real_;
292 break;
293 case integer_:
294 if (p_int_)
295 os << *p_int_;
296 break;
297 case range_:
298 if (p_Range_)
299 os << *p_Range_;
300 break;
301 case lstring_:
302 if (p_lString_)
304 break;
305 case lreal_:
306 if (p_lReal_)
308 break;
309 case linteger_:
310 if (p_lint_)
312 break;
313 case lrange_:
314 if (p_lRange_)
316 break;
317 case page_:
318 if (p_Page_)
319 p_Page_->write(os);
320 break;
321 case unknown_:
322 STKRUNTIME_ERROR_NO_ARG(Option::write,Unknown option.);
323 break; // avoid warning
324 };
325}
#define _T(x)
Let x unmodified.
void write(ostream &os) const
write out options in a stream
void write(ostream &os) const
write out the options in the output stream
void writeList(ostream &os, std::list< TYPE > const &lst, Char sep=CHAR_SEP)
Write a list of value of type TYPE stored in a line.

References _T, integer_, linteger_, lrange_, lreal_, lstring_, name_, p_int_, p_lint_, p_lRange_, p_lReal_, p_lString_, p_Page_, p_Range_, p_Real_, p_String_, page_, range_, real_, sep_, STKRUNTIME_ERROR_NO_ARG, string_, type_, unknown_, STK::IPage::write(), write(), and STK::DManager::writeList().

Referenced by write().

Member Data Documentation

◆ [union]

union { ... } STK::Option

value of the option.

An other choice would be void*.

◆ isOptional_

bool STK::Option::isOptional_
private

true if the option is optional, false otherwise

Definition at line 245 of file STK_Option.h.

Referenced by isOptional(), and operator=().

◆ isValued_

bool STK::Option::isValued_
private

true if the option is valued, false otherwise.

A default value is settled when the Option is created as the type is fixed.

Definition at line 248 of file STK_Option.h.

Referenced by deleteValue(), operator=(), set(), set(), set(), set(), set(), set(), set(), set(), and setPage().

◆ name_

String STK::Option::name_
private

name of the option

Definition at line 239 of file STK_Option.h.

Referenced by name(), operator=(), Option(), Option(), and write().

◆ p_int_

int* STK::Option::p_int_

Definition at line 254 of file STK_Option.h.

Referenced by deleteValue(), get(), operator=(), Option(), set(), setDefaultValue(), and write().

◆ p_lint_

std::list<int>* STK::Option::p_lint_

Definition at line 258 of file STK_Option.h.

Referenced by deleteValue(), get(), operator=(), Option(), set(), setDefaultValue(), and write().

◆ p_lRange_

std::list<Range>* STK::Option::p_lRange_

Definition at line 259 of file STK_Option.h.

Referenced by deleteValue(), get(), operator=(), Option(), set(), setDefaultValue(), and write().

◆ p_lReal_

std::list<Real>* STK::Option::p_lReal_

Definition at line 257 of file STK_Option.h.

Referenced by deleteValue(), get(), operator=(), Option(), set(), setDefaultValue(), and write().

◆ p_lString_

std::list<String>* STK::Option::p_lString_

Definition at line 256 of file STK_Option.h.

Referenced by deleteValue(), get(), operator=(), Option(), set(), setDefaultValue(), and write().

◆ p_Page_

IPage* STK::Option::p_Page_

Definition at line 260 of file STK_Option.h.

Referenced by deleteValue(), get(), operator=(), Option(), read(), setDefaultValue(), setPage(), and write().

◆ p_Range_

Range* STK::Option::p_Range_

Definition at line 255 of file STK_Option.h.

Referenced by deleteValue(), get(), operator=(), Option(), set(), setDefaultValue(), and write().

◆ p_Real_

Real* STK::Option::p_Real_

Definition at line 253 of file STK_Option.h.

Referenced by deleteValue(), get(), operator=(), Option(), set(), setDefaultValue(), and write().

◆ p_String_

String* STK::Option::p_String_

Definition at line 252 of file STK_Option.h.

Referenced by deleteValue(), get(), operator=(), Option(), set(), setDefaultValue(), and write().

◆ sep_

Char STK::Option::sep_
private

Char used for the option list.

Definition at line 241 of file STK_Option.h.

Referenced by operator=(), setListSeparator(), and write().

◆ type_

TypeOption STK::Option::type_
private

type of the option

Definition at line 243 of file STK_Option.h.

Referenced by deleteValue(), operator=(), Option(), read(), setDefaultValue(), setPage(), setValue(), type(), and write().


The documentation for this class was generated from the following files: