説明を見る。00001 #ifndef OSL_KISEN_H
00002 #define OSL_KISEN_H
00003
00004 #include "osl/record/record.h"
00005 #include "osl/numEffectState.h"
00006 #include <boost/date_time/gregorian/gregorian_types.hpp>
00007 #include <string>
00008 #include <iosfwd>
00009 #include <fstream>
00010 namespace osl
00011 {
00012 namespace record
00013 {
00014 class KisenUtils{
00015 public:
00016 static Square convertSquare( int pos );
00017 static Move convertMove(SimpleState const& state,int c0,int c1 );
00018 static int convertSquare(Square pos);
00019 };
00024 class KisenFile{
00025 private:
00026 NumEffectState initial_state;
00027 std::ifstream ifs;
00028 size_t number_of_games;
00029 const std::string filename;
00030 public:
00031 static const size_t MaxMoves=256;
00032 explicit KisenFile(const std::string& filename);
00033 ~KisenFile();
00034
00035 size_t size() const{ return number_of_games; }
00036 NumEffectState initialState() const{ return initial_state; }
00037 std::vector<Move> moves(size_t index);
00038 std::string fileName() const { return filename; }
00039 std::string ipxFileName() const { return ipxFileName(filename); }
00040 static std::string ipxFileName(const std::string&);
00041 };
00067 class KisenIpxFile{
00068 std::ifstream ifs;
00069 size_t number_of_games;
00070 const std::string file_name;
00071 public:
00072 enum{
00073 BY_PARITY=0,
00074 BLACK_WIN=1,
00075 WHITE_WIN=2,
00076 SENNNICHITE=3,
00077 JISHOGI=4,
00078 BLACK_WIN_256=5,
00079 WHITE_WIN_256=6,
00080 SENNNICHITE_256=7,
00081 JISHOGI_256=8,
00082 };
00083 explicit KisenIpxFile(std::string const& filename);
00084 ~KisenIpxFile();
00085
00086 size_t size() const{ return number_of_games; }
00087 std::string player(size_t index,Player pl);
00088 std::string title(size_t index,Player pl);
00089 unsigned int rating(size_t index,Player pl);
00090 unsigned int result(size_t index);
00091 const std::string& fileName() const { return file_name; }
00095 boost::gregorian::date startDate(size_t index);
00096 };
00101 class KisenPlusFile{
00102 private:
00103 NumEffectState initial_state;
00104 std::ifstream ifs;
00105 size_t number_of_games;
00106 public:
00107 static const size_t maxMoves=256;
00108 explicit KisenPlusFile(const std::string& fileName);
00109 size_t size() const{ return number_of_games; }
00110 NumEffectState initialState() const{ return initial_state; }
00111 std::vector<Move> moves(size_t index);
00112 void load(size_t index, std::vector<Move>&, std::vector<int>&);
00113 };
00114
00115 class KisenWriter
00116 {
00117 public:
00118 KisenWriter(std::ostream &ostream) : os(ostream) { }
00119 void save(const RecordMinimal&);
00120 private:
00121 std::ostream &os;
00122 };
00123
00130 class KisenIpxWriter
00131 {
00132 public:
00133 KisenIpxWriter(std::ostream &ostream) : os(ostream) { }
00134 void save(const Record &,
00135 int black_rating, int white_rating,
00136 const std::string &black_title,
00137 const std::string &white_title);
00138 private:
00139 void writeString(const std::string &name, size_t length);
00140 void writeRating(int rating);
00141 void writeStartDate(int year, int month, int day, int hour, int min);
00142 std::ostream &os;
00143 };
00144 }
00145 using record::KisenFile;
00146 using record::KisenIpxFile;
00147 using record::KisenWriter;
00148 using record::KisenIpxWriter;
00149 }
00150 #endif // OSL_KISEN_H
00151
00152
00153
00154