#include <SgGameReader.h>
Definition at line 27 of file SgGameReader.h.
Public Types | |
typedef std::bitset< NU_WARNING_FLAGS > | Warnings |
Warnings that occurred during reading. | |
INVALID_BOARDSIZE | |
Invalid board size. | |
PROPERTY_WITHOUT_VALUE | |
NU_WARNING_FLAGS | |
Number of WarningFlags. | |
enum | WarningFlags { INVALID_BOARDSIZE, PROPERTY_WITHOUT_VALUE, NU_WARNING_FLAGS } |
Warning conditions that occurred during reading. More... | |
Public Member Functions | |
SgGameReader (std::istream &in, int defaultSize=19) | |
Create reader from an input stream. | |
Warnings | GetWarnings () const |
Get warnings of last ReadGame or ReadGames. | |
void | PrintWarnings (std::ostream &out) const |
Print warnings of last ReadGame or ReadGames to stream. | |
SgNode * | ReadGame () |
Read next game tree from file. | |
void | ReadGames (SgVectorOf< SgNode > *rootList) |
Read all game trees from this file. | |
Private Types | |
typedef std::map< std::string, std::vector< std::string > > | RawProperties |
Map label to values (unparsed). | |
Private Member Functions | |
SgGameReader (const SgGameReader &) | |
Not implemented. | |
SgGameReader & | operator= (const SgGameReader &) |
Not implemented. | |
void | HandleProperties (SgNode *node, const RawProperties &properties, int &boardSize, SgPropPointFmt &fmt) |
Create SgProp instances and add them to node. | |
SgNode * | ReadGame (bool resetWarnings) |
std::string | ReadLabel (int c) |
SgNode * | ReadSubtree (SgNode *node, int boardSize, SgPropPointFmt fmt) |
bool | ReadValue (std::string &value) |
Static Private Member Functions | |
static bool | GetIntProp (const RawProperties &properties, const std::string &label, int &value) |
Private Attributes | |
std::istream & | m_in |
const int | m_defaultSize |
int | m_fileFormat |
The file format read in. | |
Warnings | m_warnings |
typedef std::map<std::string, std::vector<std::string> > SgGameReader::RawProperties [private] |
typedef std::bitset<NU_WARNING_FLAGS> SgGameReader::Warnings |
Warning conditions that occurred during reading.
INVALID_BOARDSIZE |
Invalid board size.
The file contained a size property with a value not in [SG_MIN_SIZE..SG_MAX_SIZE]. |
PROPERTY_WITHOUT_VALUE | |
NU_WARNING_FLAGS | Number of WarningFlags. |
Definition at line 33 of file SgGameReader.h.
SgGameReader::SgGameReader | ( | std::istream & | in, | |
int | defaultSize = 19 | |||
) |
Create reader from an input stream.
in | The input stream. | |
defaultSize | The (game-dependent) default board size, if file contains no SZ property. no SZ property. |
Definition at line 36 of file SgGameReader.cpp.
SgGameReader::SgGameReader | ( | const SgGameReader & | ) | [private] |
Not implemented.
bool SgGameReader::GetIntProp | ( | const RawProperties & | properties, | |
const std::string & | label, | |||
int & | value | |||
) | [static, private] |
SgGameReader::Warnings SgGameReader::GetWarnings | ( | ) | const |
Get warnings of last ReadGame or ReadGames.
Definition at line 109 of file SgGameReader.h.
References m_warnings.
void SgGameReader::HandleProperties | ( | SgNode * | node, | |
const RawProperties & | properties, | |||
int & | boardSize, | |||
SgPropPointFmt & | fmt | |||
) | [private] |
Create SgProp instances and add them to node.
The only properties that are interpreted by the reader are SZ (board size) and GM (point format, because they must be handled before all other root node properties to parse points correctly.
Definition at line 59 of file SgGameReader.cpp.
References SgNode::Add(), SgProp::CreateProperty(), SgProp::FromString(), SgProp::GetIDOfLabel(), GetIntProp(), SgPropUtil::GetPointFmt(), INVALID_BOARDSIZE, m_warnings, PROPERTY_WITHOUT_VALUE, SG_MAX_SIZE, SG_PROP_NONE, and SG_PROP_UNKNOWN.
Referenced by ReadSubtree().
SgGameReader& SgGameReader::operator= | ( | const SgGameReader & | ) | [private] |
Not implemented.
void SgGameReader::PrintWarnings | ( | std::ostream & | out | ) | const |
Print warnings of last ReadGame or ReadGames to stream.
Prints the warnings as human readable text.
Definition at line 92 of file SgGameReader.cpp.
References INVALID_BOARDSIZE, m_warnings, PrintWarning(), PROPERTY_WITHOUT_VALUE, and SG_ASSERT.
SgNode * SgGameReader::ReadGame | ( | bool | resetWarnings | ) | [private] |
Definition at line 102 of file SgGameReader.cpp.
References m_defaultSize, m_in, m_warnings, ReadSubtree(), SgNode::Root(), and SG_PROPPOINTFMT_GO.
SgNode * SgGameReader::ReadGame | ( | ) |
Read next game tree from file.
Definition at line 114 of file SgGameReader.h.
Referenced by ReadGames().
void SgGameReader::ReadGames | ( | SgVectorOf< SgNode > * | rootList | ) |
Read all game trees from this file.
Return a list with the root of each game tree.
Definition at line 123 of file SgGameReader.cpp.
References SgVector< void * >::Clear(), m_warnings, SgVectorOf< T >::PushBack(), ReadGame(), and SG_ASSERT.
string SgGameReader::ReadLabel | ( | int | c | ) | [private] |
SgNode * SgGameReader::ReadSubtree | ( | SgNode * | node, | |
int | boardSize, | |||
SgPropPointFmt | fmt | |||
) | [private] |
Definition at line 155 of file SgGameReader.cpp.
References HandleProperties(), m_in, ReadLabel(), and ReadValue().
Referenced by ReadGame().
bool SgGameReader::ReadValue | ( | std::string & | value | ) | [private] |
const int SgGameReader::m_defaultSize [private] |
int SgGameReader::m_fileFormat [private] |
std::istream& SgGameReader::m_in [private] |
Definition at line 79 of file SgGameReader.h.
Referenced by ReadGame(), ReadLabel(), ReadSubtree(), and ReadValue().
Warnings SgGameReader::m_warnings [private] |
Definition at line 86 of file SgGameReader.h.
Referenced by GetWarnings(), HandleProperties(), PrintWarnings(), ReadGame(), and ReadGames().