Write file with SGF data. More...
#include <SgGameWriter.h>
Public Member Functions | |
SgGameWriter (std::ostream &out) | |
void | WriteGame (const SgNode &root, bool allProps, int fileFormat, int gameNumber, int defaultSize) |
Write the game tree at 'root' to the given archive. | |
Private Member Functions | |
void | ConvertFormat (SgNode &root) |
void | HandleProps (const SgNode *node, int &boardSize) const |
bool | ShouldWriteProperty (const SgProp &prop) |
Should property be written to file? May depend on options. | |
void | StartNewLine () |
void | WriteNode (const SgNode &node, bool allProps, int boardSize, SgPropPointFmt fmt) |
void | WriteSubtree (const SgNode &node, bool allProps, int boardSize, SgPropPointFmt fmt) |
SgGameWriter (const SgGameWriter &) | |
Not implemented. | |
SgGameWriter & | operator= (const SgGameWriter &) |
Not implemented. | |
Private Attributes | |
std::ostream & | m_out |
int | m_fileFormat |
int | m_numPropsOnLine |
Number of properties on this line. |
Write file with SGF data.
Definition at line 16 of file SgGameWriter.h.
SgGameWriter::SgGameWriter | ( | std::ostream & | out | ) |
Definition at line 18 of file SgGameWriter.cpp.
SgGameWriter::SgGameWriter | ( | const SgGameWriter & | ) | [private] |
Not implemented.
void SgGameWriter::ConvertFormat | ( | SgNode & | root | ) | [private] |
void SgGameWriter::HandleProps | ( | const SgNode * | node, | |
int & | boardSize | |||
) | const [private] |
Definition at line 73 of file SgGameWriter.cpp.
References SgNode::GetIntProp(), SG_MAX_SIZE, SG_MIN_SIZE, SG_PROP_SIZE, and SgWarning().
Referenced by WriteSubtree().
SgGameWriter& SgGameWriter::operator= | ( | const SgGameWriter & | ) | [private] |
Not implemented.
bool SgGameWriter::ShouldWriteProperty | ( | const SgProp & | prop | ) | [private] |
Should property be written to file? May depend on options.
Definition at line 125 of file SgGameWriter.cpp.
References SgProp::Flag(), SgProp::ID(), SgProp::Label(), m_fileFormat, SG_PROP_TIME_BLACK, SG_PROP_TIME_WHITE, and SG_PROPCLASS_NOTCLEAN.
Referenced by WriteNode().
void SgGameWriter::StartNewLine | ( | ) | [private] |
Definition at line 115 of file SgGameWriter.cpp.
References m_numPropsOnLine, and m_out.
Referenced by WriteNode(), and WriteSubtree().
void SgGameWriter::WriteGame | ( | const SgNode & | root, | |
bool | allProps, | |||
int | fileFormat, | |||
int | gameNumber, | |||
int | defaultSize | |||
) |
Write the game tree at 'root' to the given archive.
root | Root node of the game. | |
allProps | Write all properties. | |
fileFormat | if zero, write it out with the default file format. | |
gameNumber | Game number (will add GM property) | |
defaultSize | The (game-dependent) default board size, if file contains no SZ property. |
SgException | If saving fails (presently it does only check if the file is ok at the beginning, not if all writes succeed) |
Definition at line 25 of file SgGameWriter.cpp.
References SgNode::GetIntProp(), SgPropUtil::GetPointFmt(), SgNode::HasProp(), m_fileFormat, m_out, SG_PROP_FORMAT, and WriteSubtree().
void SgGameWriter::WriteNode | ( | const SgNode & | node, | |
bool | allProps, | |||
int | boardSize, | |||
SgPropPointFmt | fmt | |||
) | [private] |
Definition at line 86 of file SgGameWriter.cpp.
References SgProp::Flag(), SgNode::HasProp(), SgProp::Label(), m_fileFormat, m_numPropsOnLine, m_out, SgNode::Props(), SG_PROP_GAME, SG_PROPCLASS_NEWLINE, ShouldWriteProperty(), StartNewLine(), and SgProp::ToString().
Referenced by WriteSubtree().
void SgGameWriter::WriteSubtree | ( | const SgNode & | node, | |
bool | allProps, | |||
int | boardSize, | |||
SgPropPointFmt | fmt | |||
) | [private] |
Definition at line 41 of file SgGameWriter.cpp.
References HandleProps(), SgNode::HasRightBrother(), SgNode::LeftMostSon(), m_out, SgNode::RightBrother(), StartNewLine(), and WriteNode().
Referenced by WriteGame().
int SgGameWriter::m_fileFormat [private] |
Definition at line 36 of file SgGameWriter.h.
Referenced by ShouldWriteProperty(), WriteGame(), and WriteNode().
int SgGameWriter::m_numPropsOnLine [private] |
Number of properties on this line.
Definition at line 39 of file SgGameWriter.h.
Referenced by StartNewLine(), and WriteNode().
std::ostream& SgGameWriter::m_out [private] |
Definition at line 34 of file SgGameWriter.h.
Referenced by StartNewLine(), WriteGame(), WriteNode(), and WriteSubtree().