Index   Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

SgGameWriter.h

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file SgGameWriter.h */
00003 //----------------------------------------------------------------------------
00004 
00005 #ifndef SG_GAMEWRITER_H
00006 #define SG_GAMEWRITER_H
00007 
00008 #include <iosfwd>
00009 #include "SgProp.h"
00010 
00011 class SgNode;
00012 
00013 //----------------------------------------------------------------------------
00014 
00015 /** Write file with SGF data */
00016 class SgGameWriter
00017 {
00018 public:
00019     SgGameWriter(std::ostream& out);
00020 
00021     /** Write the game tree at 'root' to the given archive.
00022         @param root Root node of the game.
00023         @param allProps Write all properties.
00024         @param fileFormat if zero, write it out with the default file format.
00025         @param gameNumber Game number (will add GM property)
00026         @param defaultSize The (game-dependent) default board size, if file
00027         contains no SZ property.
00028         @throws SgException If saving fails (presently it does only check if
00029         the file is ok at the beginning, not if all writes succeed) */
00030     void WriteGame(const SgNode& root, bool allProps, int fileFormat,
00031                    int gameNumber, int defaultSize);
00032 
00033 private:
00034     std::ostream& m_out;
00035 
00036     int m_fileFormat;
00037 
00038     /** Number of properties on this line. */
00039     int m_numPropsOnLine;
00040 
00041     void ConvertFormat(SgNode& root);
00042 
00043     void HandleProps(const SgNode* node, int& boardSize) const;
00044 
00045     /** Should property be written to file? May depend on options. */
00046     bool ShouldWriteProperty(const SgProp& prop);
00047 
00048     void StartNewLine();
00049 
00050     void WriteNode(const SgNode& node, bool allProps, int boardSize,
00051                    SgPropPointFmt fmt);
00052 
00053     void WriteSubtree(const SgNode& node, bool allProps, int boardSize,
00054                       SgPropPointFmt fmt);
00055 
00056     /** Not implemented. */
00057     SgGameWriter(const SgGameWriter&);
00058 
00059     /** Not implemented. */
00060     SgGameWriter& operator=(const SgGameWriter&);
00061 };
00062 
00063 //----------------------------------------------------------------------------
00064 
00065 #endif // SG_GAMEWRITER_H


Sun Mar 13 2011 Doxygen 1.7.1