STK++ 0.9.13
|
A IPage is an interface base class for reading and/or writing a page of option in a file. More...
#include <STK_IPage.h>
Public Types | |
typedef std::vector< Option > | ContOption |
Container for the options. | |
Public Member Functions | |
IPage (String const &name, int const &level, bool isOptional) | |
Constructor. | |
IPage (IPage const &page) | |
Copy constructor. | |
virtual | ~IPage () |
Destructor. | |
String const & | name () const |
name of the IPage. | |
bool | isOptional () const |
is this Option optional ?. | |
ContOption const & | options () const |
get the options of the IPage | |
String const & | msg_error () const |
name of the IPage. | |
Option & | option (String const &name) |
bookkeeping function. | |
Option const & | option (String const &name) const |
bookkeeping function. | |
Option const & | option (int const &pos) const |
get the ith constant option of the IPage | |
Option & | option (int const &pos) |
get the ith option of the IPage | |
Option const & | operator[] (int const &pos) const |
get the ith constant option of the IPage | |
Option & | operator[] (int const &pos) |
get the ith option of the IPage | |
void | addOption (Option const &opt) |
add an option to the page | |
void | addPage (IPage const &page) |
add a sub-page as an option to the page | |
void | read (istream &is) |
read in options from an input steam stream | |
void | write (ostream &os) const |
write out options in a stream | |
virtual bool | validate () |
validate the page. | |
virtual IPage * | clone () const |
Protected Attributes | |
bool | isOptional_ |
true if the Page is optinal, false otherwise | |
ContOption | options_ |
array of the options | |
String | msg_error_ |
Contain the last error message. | |
Private Member Functions | |
bool | findKeyword (istream &is) const |
process the input stream until the keyword is encountered. | |
bool | processLine (String const &line) |
process the input line and set the value of the option. | |
Private Attributes | |
String | name_ |
name of the page of options | |
int | level_ |
level of the Page. | |
String | keyword_ |
keyword of the page of options. | |
A IPage is an interface base class for reading and/or writing a page of option in a file.
A page of option have the form
The 'Favorites' page has a 'softwares' subpage. Pages are indicated using the page name in square brackets. Subpage are made by increasing the number of matching square brackets around the page name.
Note that the whitespace are not significants in this example, but as with code indentation visually shows the structure of the information.
Comments can be added using the symbol '#'. All remaining character on the same line are ignored.
Every Page of options of a STK program should derive from the IPage class as in the following example:
Definition at line 93 of file STK_IPage.h.
typedef std::vector<Option> STK::IPage::ContOption |
Container for the options.
Definition at line 97 of file STK_IPage.h.
Constructor.
The constructor will initialize the name of the page (in upper case), and the keyword usign the form [...[NAME]...] where the number of open/closing bracket are given by the level.
name | name of the page |
level | level of the page |
isOptional | true if the page is optional, false otherwise |
Definition at line 72 of file STK_IPage.cpp.
References keyword_, name_, and STK::toUpperString().
Copy constructor.
page | the page to copy |
Definition at line 89 of file STK_IPage.cpp.
References isOptional_, keyword_, level_, name_, and options_.
|
virtual |
add an option to the page
opt | the option to add |
Definition at line 177 of file STK_IPage.h.
References options_.
Referenced by addPage().
add a sub-page as an option to the page
page | the option to add |
Definition at line 101 of file STK_IPage.cpp.
References addOption(), and level_.
Reimplemented in STK::AdditiveBSplineRegressionPage, and STK::LocalVariancePage.
Definition at line 195 of file STK_IPage.h.
Referenced by STK::Option::setPage().
process the input stream until the keyword is encountered.
is | input stream to process |
true
if the keyword have been found, false
otherwise Definition at line 228 of file STK_IPage.cpp.
References keyword_, STK::DManager::removeCharBeforeAndAfter(), and STK::toUpperString().
Referenced by read().
|
inline |
is this Option optional ?.
true
if the Option is optional, false
otherwise Definition at line 124 of file STK_IPage.h.
References isOptional_.
name of the IPage.
Definition at line 132 of file STK_IPage.h.
References msg_error_.
Referenced by STK::Option::read().
bookkeeping function.
Find an Option given its name
name | name of the Option to find |
Definition at line 211 of file STK_IPage.cpp.
References _T, msg_error_, name(), options_, STKRUNTIME_ERROR_NO_ARG, and STK::toUpperString().
bookkeeping function.
Find an Option given its name
name | name of the Option to find |
Definition at line 192 of file STK_IPage.cpp.
References _T, msg_error_, name(), options_, STKRUNTIME_ERROR_NO_ARG, and STK::toUpperString().
|
inline |
get the options of the IPage
Definition at line 128 of file STK_IPage.h.
References options_.
process the input line and set the value of the option.
line | input string to process |
true
if the keyword have been found, false
otherwise Definition at line 251 of file STK_IPage.cpp.
References msg_error_, name_, options_, STK::DManager::removeCharBeforeAndAfter(), and STK::toUpperString().
Referenced by read().
read in options from an input steam stream
is | input stream |
Definition at line 113 of file STK_IPage.cpp.
References _T, findKeyword(), isOptional_, keyword_, msg_error_, name_, options_, STK::Option::page_, processLine(), read(), STK::DManager::removeCharBeforeAndAfter(), STKRUNTIME_ERROR_NO_ARG, and validate().
Referenced by read(), and STK::Option::read().
validate the page.
Check if the options are coherent.
Reimplemented in STK::AdditiveBSplineRegressionPage, and STK::LocalVariancePage.
Definition at line 193 of file STK_IPage.h.
Referenced by read(), and STK::Option::read().
write out options in a stream
os | output stream |
Definition at line 172 of file STK_IPage.cpp.
References _T, keyword_, level_, options_, and STK::Option::page_.
Referenced by STK::Option::write().
|
protected |
true
if the Page is optinal, false
otherwise
Definition at line 199 of file STK_IPage.h.
Referenced by IPage(), isOptional(), and read().
|
mutableprivate |
keyword of the page of options.
The keyword is constructed using the level_ and the name_. It is of the form [...[name_]...] where the number of open/closing bracket is given by level_.
Definition at line 218 of file STK_IPage.h.
Referenced by findKeyword(), IPage(), IPage(), read(), and write().
|
mutableprivate |
|
mutableprotected |
Contain the last error message.
Definition at line 204 of file STK_IPage.h.
Referenced by msg_error(), option(), option(), processLine(), read(), STK::AdditiveBSplineRegressionPage::validate(), and STK::LocalVariancePage::validate().
|
private |
name of the page of options
Definition at line 208 of file STK_IPage.h.
Referenced by IPage(), IPage(), name(), processLine(), and read().
|
protected |
array of the options
Definition at line 201 of file STK_IPage.h.
Referenced by STK::AdditiveBSplineRegressionPage::AdditiveBSplineRegressionPage(), addOption(), IPage(), STK::LocalVariancePage::LocalVariancePage(), STK::LocalVariancePage::LocalVariancePage(), operator[](), operator[](), option(), option(), option(), option(), options(), processLine(), read(), STK::AdditiveBSplineRegressionPage::validate(), STK::LocalVariancePage::validate(), and write().