00001
00002
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
00016 class SgGameWriter
00017 {
00018 public:
00019 SgGameWriter(std::ostream& out);
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 void WriteGame(SgNode& root, bool allProps, int fileFormat,
00035 const std::string& application, int gameNumber,
00036 int defaultSize);
00037
00038 private:
00039 std::ostream& m_out;
00040
00041 int m_fileFormat;
00042
00043
00044 int m_numPropsOnLine;
00045
00046 void ConvertFormat(SgNode& root);
00047
00048 void HandleProps(const SgNode* node, int& boardSize) const;
00049
00050
00051 bool ShouldWriteProperty(const SgProp& prop);
00052
00053 void StartNewLine();
00054
00055 void WriteNode(const SgNode& node, bool allProps, int boardSize,
00056 SgPropPointFmt fmt);
00057
00058 void WriteSubtree(const SgNode& node, bool allProps, int boardSize,
00059 SgPropPointFmt fmt);
00060
00061
00062 SgGameWriter(const SgGameWriter&);
00063
00064
00065 SgGameWriter& operator=(const SgGameWriter&);
00066 };
00067
00068
00069
00070 #endif // SG_GAMEWRITER_H