STK++ 0.9.13
|
The ReadWritePages class allow to handle a file of option containing pages. More...
#include <STK_ReadWritePages.h>
Public Member Functions | |
ReadWritePages (std::string const &file_name=std::string()) | |
default constructor. | |
virtual | ~ReadWritePages () |
Destructor. | |
IPage const * | p_page (int const &pos) const |
get a constant page of option. | |
IPage * | p_page (int const &pos) |
get a page of option. | |
IPage const * | p_page (String const &name) const |
constant bookkeeping function. | |
IPage * | p_page (String const &name) |
bookkeeping function. | |
IPage const * | operator[] (int const &pos) const |
get a constant page of option. | |
IPage * | operator[] (int const &pos) |
get a page of option. | |
void | addPage (IPage const &page) |
Add a page of option to read and/or write. | |
bool | write (std::string const &file_name=std::string()) const |
Attempts to write the ReadWritePage to the location specified by file_name. | |
bool | write (ostream &os) const |
Attempts to write the ReadWritePage to the specified output stream. | |
bool | read (std::string const &file_name=std::string()) |
Attempts to read the specified file. | |
bool | read (istream &is) |
Attempts to read the pages from an input stream. | |
bool | validate () |
validate all the pages. | |
String const & | error () const |
give the last error message encountered | |
Protected Attributes | |
ContPage | pages_ |
The list of page to read and/or write. | |
stringstream | buffer_ |
the string buffer containing the file with all the options. | |
std::string | file_name_ |
Name of the Current file to read/write. | |
String | msg_error_ |
The last error message. | |
Private Types | |
typedef std::vector< IPage * > | ContPage |
type of the container for the pages. | |
The ReadWritePages class allow to handle a file of option containing pages.
A file of pages 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.
Definition at line 77 of file STK_ReadWritePages.h.
|
private |
type of the container for the pages.
Definition at line 81 of file STK_ReadWritePages.h.
STK::ReadWritePages::ReadWritePages | ( | std::string const & | file_name = std::string() | ) |
default constructor.
Instantiates an instance of ReadWritePage and reads the specified file.
file_name | name of the file to read/write |
Definition at line 42 of file STK_ReadWritePages.cpp.
|
virtual |
Destructor.
Definition at line 47 of file STK_ReadWritePages.cpp.
References pages_.
Add a page of option to read and/or write.
page | the page of option to add |
Definition at line 59 of file STK_ReadWritePages.cpp.
References pages_.
give the last error message encountered
Definition at line 171 of file STK_ReadWritePages.h.
References msg_error_.
get a page of option.
pos | the position of the page of option |
Definition at line 130 of file STK_ReadWritePages.h.
References pages_.
get a constant page of option.
pos | the position of the page of option |
Definition at line 123 of file STK_ReadWritePages.h.
References pages_.
get a page of option.
pos | the position of the page of option |
Definition at line 104 of file STK_ReadWritePages.h.
References pages_.
get a constant page of option.
pos | the position of the page of option |
Definition at line 97 of file STK_ReadWritePages.h.
References pages_.
bookkeeping function.
Find a page given its name
name | name of the Page to find |
Definition at line 194 of file STK_ReadWritePages.cpp.
References pages_, and STK::toUpperString().
constant bookkeeping function.
name | name of the Page to find |
Definition at line 177 of file STK_ReadWritePages.cpp.
References pages_, and STK::toUpperString().
Attempts to read the pages from an input stream.
is | name of the input stream to read |
true
if successful, false
if an error is encountered. Definition at line 141 of file STK_ReadWritePages.cpp.
References STK::IRunnerBase::error(), msg_error_, pages_, and validate().
Attempts to read the specified file.
file_name | name of the file to read |
true
if successful, false
if an error is encountered. Definition at line 110 of file STK_ReadWritePages.cpp.
References buffer_, STK::IRunnerBase::error(), file_name_, msg_error_, and read().
Referenced by read().
bool STK::ReadWritePages::validate | ( | ) |
validate all the pages.
return
true if all the page are validated, false
otherwise.
Definition at line 162 of file STK_ReadWritePages.cpp.
References pages_.
Referenced by read().
Attempts to write the ReadWritePage to the specified output stream.
os | name of output stream to write |
true
if successful, false
if an error is encountered. Definition at line 92 of file STK_ReadWritePages.cpp.
References STK::IRunnerBase::error(), msg_error_, and pages_.
Attempts to write the ReadWritePage to the location specified by file_name.
file_name | name of the file to write |
true
if successful, false
if an error is encountered. Definition at line 67 of file STK_ReadWritePages.cpp.
References STK::IRunnerBase::error(), file_name_, msg_error_, and write().
Referenced by write().
|
protected |
the string buffer containing the file with all the options.
Definition at line 177 of file STK_ReadWritePages.h.
Referenced by read().
|
mutableprotected |
Name of the Current file to read/write.
Definition at line 179 of file STK_ReadWritePages.h.
|
mutableprotected |
|
protected |
The list of page to read and/or write.
Definition at line 175 of file STK_ReadWritePages.h.
Referenced by addPage(), operator[](), operator[](), p_page(), p_page(), p_page(), p_page(), read(), validate(), write(), and ~ReadWritePages().