OpenWalnut  1.3.1
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
WProjectFileIO Class Referenceabstract

A base class for all parts of OpenWalnut which can be serialized to a project file. More...

#include <WProjectFileIO.h>

+ Inheritance diagram for WProjectFileIO:

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

WProjectFileIO::WProjectFileIO ( )

Default constructor.

Definition at line 32 of file WProjectFileIO.cpp.

WProjectFileIO::~WProjectFileIO ( )
virtual

Destructor.

Definition at line 38 of file WProjectFileIO.cpp.

Member Function Documentation

void WProjectFileIO::addError ( std::string  description)
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.

Parameters
descriptionthe error description

Definition at line 58 of file WProjectFileIO.cpp.

References wlog::error(), and m_errors.

Referenced by WModuleProjectFileCombiner::apply(), and WModuleProjectFileCombiner::parse().

void WProjectFileIO::done ( )
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.

Returns
the 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.

Returns
true if there where.

Definition at line 48 of file WProjectFileIO.cpp.

References m_errors.

virtual bool WProjectFileIO::parse ( std::string  line,
unsigned int  lineNumber 
)
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.

Parameters
linethe current line as string
lineNumberthe current line number. Useful for error/warning/debugging output.
Returns
true if the line could be parsed.

Implemented in WModuleProjectFileCombiner, WGEProjectFileIO, and WRoiProjectFileIO.

virtual void WProjectFileIO::save ( std::ostream &  output)
pure virtual

Saves the state to the specified stream.

Parameters
outputthe stream to print the state to.

Implemented in WModuleProjectFileCombiner, WGEProjectFileIO, and WRoiProjectFileIO.

Member Data Documentation

std::vector< std::string > WProjectFileIO::m_errors
private

List of errors if any.

Definition at line 102 of file WProjectFileIO.h.

Referenced by addError(), getErrors(), and hadErrors().


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