OpenWalnut
1.3.1
|
A base class for all parts of OpenWalnut which can be serialized to a project file. More...
#include <WProjectFileIO.h>
Public Member Functions | |
WProjectFileIO () | |
Default constructor. More... | |
virtual | ~WProjectFileIO () |
Destructor. More... | |
virtual bool | parse (std::string line, unsigned int lineNumber)=0 |
This method parses the specified line and interprets it. More... | |
virtual void | done () |
Called whenever the end of the project file has been reached. More... | |
virtual void | save (std::ostream &output)=0 |
Saves the state to the specified stream. More... | |
bool | hadErrors () const |
Checks whether there where errors during load or save. More... | |
const std::vector< std::string > & | getErrors () const |
Get error list. More... | |
Protected Member Functions | |
void | addError (std::string description) |
Add an error. More... | |
Private Attributes | |
std::vector< std::string > | m_errors |
List of errors if any. More... | |
A base class for all parts of OpenWalnut which can be serialized to a project file.
It is used by WProjectFile to actually parse the file line by line. Derive from this class if you write your own parser and use it to fill your internal data structures. But write it in a very error-tolerant way. We want to avoid that small problems in the project file cause the whole file to be useless.
Definition at line 37 of file WProjectFileIO.h.
WProjectFileIO::WProjectFileIO | ( | ) |
Default constructor.
Definition at line 32 of file WProjectFileIO.cpp.
|
virtual |
Destructor.
Definition at line 38 of file WProjectFileIO.cpp.
|
protected |
Add an error.
Use this when you encounter some difficulties during parsing or applying settings. Provide useful errors. They will be presented to the user.
description | the error description |
Definition at line 58 of file WProjectFileIO.cpp.
References wlog::error(), and m_errors.
Referenced by WModuleProjectFileCombiner::apply(), and WModuleProjectFileCombiner::parse().
|
virtual |
Called whenever the end of the project file has been reached.
Use this to actually apply your loaded settings. Do this in a error-tolerant way and apply as most settings as possible even if some other settings are erroneous. Add errors with addError. Try avoiding exceptions if possible.
Reimplemented in WModuleProjectFileCombiner, WGEProjectFileIO, and WRoiProjectFileIO.
Definition at line 43 of file WProjectFileIO.cpp.
const std::vector< std::string > & WProjectFileIO::getErrors | ( | ) | const |
Get error list.
Definition at line 53 of file WProjectFileIO.cpp.
References m_errors.
bool WProjectFileIO::hadErrors | ( | ) | const |
Checks whether there where errors during load or save.
Definition at line 48 of file WProjectFileIO.cpp.
References m_errors.
|
pure virtual |
This method parses the specified line and interprets it.
It gets called line by line by WProjectFile. You should avoid applying anything of the loaded information here. You should use done for this.
line | the current line as string |
lineNumber | the current line number. Useful for error/warning/debugging output. |
Implemented in WModuleProjectFileCombiner, WGEProjectFileIO, and WRoiProjectFileIO.
|
pure virtual |
Saves the state to the specified stream.
output | the stream to print the state to. |
Implemented in WModuleProjectFileCombiner, WGEProjectFileIO, and WRoiProjectFileIO.
|
private |
List of errors if any.
Definition at line 102 of file WProjectFileIO.h.
Referenced by addError(), getErrors(), and hadErrors().