Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgGameWriter Class Reference

#include <SgGameWriter.h>

List of all members.


Detailed Description

Write file with SGF data.

Definition at line 16 of file SgGameWriter.h.

Public Member Functions

 SgGameWriter (std::ostream &out)
void WriteGame (SgNode &root, bool allProps, int fileFormat, const std::string &application, 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.
SgGameWriteroperator= (const SgGameWriter &)
 Not implemented.

Private Attributes

std::ostream & m_out
int m_fileFormat
int m_numPropsOnLine
 Number of properties on this line.


Constructor & Destructor Documentation

SgGameWriter::SgGameWriter ( std::ostream &  out  ) 

Definition at line 19 of file SgGameWriter.cpp.

SgGameWriter::SgGameWriter ( const SgGameWriter  )  [private]

Not implemented.


Member Function Documentation

void SgGameWriter::ConvertFormat ( SgNode root  )  [private]

void SgGameWriter::HandleProps ( const SgNode node,
int &  boardSize 
) const [private]

Definition at line 106 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 158 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 148 of file SgGameWriter.cpp.

References m_numPropsOnLine, and m_out.

Referenced by WriteNode(), and WriteSubtree().

void SgGameWriter::WriteGame ( SgNode root,
bool  allProps,
int  fileFormat,
const std::string &  application,
int  gameNumber,
int  defaultSize 
)

Write the game tree at 'root' to the given archive.

Add file format and application properties to the root node.

Parameters:
root Root node of the game.
allProps Write all properties.
fileFormat if zero, write it out with the default file format.
application Application name (will add AP property if not empty)
gameNumber Game number (will add GM property)
defaultSize The (game-dependent) default board size, if file contains no SZ property.
Exceptions:
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 26 of file SgGameWriter.cpp.

References SgNode::Add(), SgNode::GetIntProp(), SgPropUtil::GetPointFmt(), SgNode::HasProp(), m_fileFormat, m_out, SgPropList::MoveToFront(), SgNode::Props(), SG_PROP_ADD_BLACK, SG_PROP_ADD_EMPTY, SG_PROP_ADD_WHITE, SG_PROP_APPLIC, SG_PROP_DATE, SG_PROP_EVENT, SG_PROP_FORMAT, SG_PROP_GAME, SG_PROP_GAME_NAME, SG_PROP_PLACE, SG_PROP_PLAYER, SG_PROP_PLAYER_BLACK, SG_PROP_PLAYER_WHITE, SG_PROP_RANK_BLACK, SG_PROP_RANK_WHITE, SG_PROP_RESULT, SG_PROP_ROUND, SG_PROP_SIZE, SG_PROP_SOURCE, SG_PROP_TEAM_BLACK, SG_PROP_TEAM_WHITE, SG_PROP_USER, and WriteSubtree().

void SgGameWriter::WriteNode ( const SgNode node,
bool  allProps,
int  boardSize,
SgPropPointFmt  fmt 
) [private]

Definition at line 119 of file SgGameWriter.cpp.

References SgNode::HasProp(), m_fileFormat, m_numPropsOnLine, m_out, SgNode::Props(), SG_PROP_GAME, SG_PROPCLASS_NEWLINE, ShouldWriteProperty(), and StartNewLine().

Referenced by WriteSubtree().

void SgGameWriter::WriteSubtree ( const SgNode node,
bool  allProps,
int  boardSize,
SgPropPointFmt  fmt 
) [private]

Definition at line 74 of file SgGameWriter.cpp.

References HandleProps(), SgNode::HasRightBrother(), SgNode::LeftMostSon(), m_out, StartNewLine(), and WriteNode().

Referenced by WriteGame().


Member Data Documentation

int SgGameWriter::m_fileFormat [private]

Definition at line 41 of file SgGameWriter.h.

Referenced by ShouldWriteProperty(), WriteGame(), and WriteNode().

int SgGameWriter::m_numPropsOnLine [private]

Number of properties on this line.

Definition at line 44 of file SgGameWriter.h.

Referenced by StartNewLine(), and WriteNode().

std::ostream& SgGameWriter::m_out [private]

Definition at line 39 of file SgGameWriter.h.

Referenced by StartNewLine(), WriteGame(), WriteNode(), and WriteSubtree().


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


17 Jun 2010 Doxygen 1.4.7