kisen.h
Go to the documentation of this file.
#ifndef OSL_KISEN_H
#define OSL_KISEN_H
#include "osl/record/record.h"
#include "osl/numEffectState.h"
#include <boost/date_time/gregorian/gregorian_types.hpp>
#include <string>
#include <iosfwd>
#include <fstream>
namespace osl
{
namespace record
{
class KisenUtils{
public:
static Square convertSquare( int pos );
static Move convertMove(SimpleState const& state,int c0,int c1 );
static int convertSquare(Square pos);
};
class KisenFile{
private:
NumEffectState initial_state;
std::ifstream ifs;
size_t number_of_games;
const std::string filename;
public:
static const size_t MaxMoves=256;
explicit KisenFile(const std::string& filename);
~KisenFile();
size_t size() const{ return number_of_games; }
NumEffectState initialState() const{ return initial_state; }
std::vector<Move> moves(size_t index);
std::string fileName() const { return filename; }
std::string ipxFileName() const { return ipxFileName(filename); }
static std::string ipxFileName(const std::string&);
};
class KisenIpxFile{
std::ifstream ifs;
size_t number_of_games;
const std::string file_name;
public:
enum{
BY_PARITY=0,
BLACK_WIN=1,
WHITE_WIN=2,
SENNNICHITE=3,
JISHOGI=4,
BLACK_WIN_256=5,
WHITE_WIN_256=6,
SENNNICHITE_256=7,
JISHOGI_256=8,
};
explicit KisenIpxFile(std::string const& filename);
~KisenIpxFile();
size_t size() const{ return number_of_games; }
std::string player(size_t index,Player pl);
std::string title(size_t index,Player pl);
unsigned int rating(size_t index,Player pl);
unsigned int result(size_t index);
const std::string& fileName() const { return file_name; }
boost::gregorian::date startDate(size_t index);
};
class KisenPlusFile{
private:
NumEffectState initial_state;
std::ifstream ifs;
size_t number_of_games;
public:
static const size_t maxMoves=256;
explicit KisenPlusFile(const std::string& fileName);
size_t size() const{ return number_of_games; }
NumEffectState initialState() const{ return initial_state; }
std::vector<Move> moves(size_t index);
void load(size_t index, std::vector<Move>&, std::vector<int>&);
};
class KisenWriter
{
public:
KisenWriter(std::ostream &ostream) : os(ostream) { }
void save(const RecordMinimal&);
private:
std::ostream &os;
};
class KisenIpxWriter
{
public:
KisenIpxWriter(std::ostream &ostream) : os(ostream) { }
void save(const Record &,
int black_rating, int white_rating,
const std::string &black_title,
const std::string &white_title);
private:
void writeString(const std::string &name, size_t length);
void writeRating(int rating);
void writeStartDate(int year, int month, int day, int hour, int min);
std::ostream &os;
};
} // namespace record
using record::KisenFile;
using record::KisenIpxFile;
using record::KisenWriter;
using record::KisenIpxWriter;
} // namespace osl
#endif // OSL_KISEN_H
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; End:
osl::KisenFile::KisenFile
KisenFile(const std::string &filename)
Definition kisen.cc:84
osl::KisenIpxFile::KisenIpxFile
KisenIpxFile(std::string const &filename)
Definition kisen.cc:130
osl::KisenIpxWriter::KisenIpxWriter
KisenIpxWriter(std::ostream &ostream)
Definition kisen.h:133
osl::KisenWriter::KisenWriter
KisenWriter(std::ostream &ostream)
Definition kisen.h:118
osl::Move
圧縮していない moveの表現 .
Definition basic_type.h:1052
osl::NumEffectState
利きを持つ局面
Definition numEffectState.h:34
osl::SimpleState
Definition simpleState.h:35
osl::Square
Definition basic_type.h:532
osl::record::KisenFile
「.kif」という拡張子を持つ棋泉形式ファイル.
Definition kisen.h:24
osl::record::KisenFile::fileName
std::string fileName() const
Definition kisen.h:38
osl::record::KisenFile::MaxMoves
static const size_t MaxMoves
Definition kisen.h:31
osl::record::KisenFile::number_of_games
size_t number_of_games
Definition kisen.h:28
osl::record::KisenFile::initial_state
NumEffectState initial_state
Definition kisen.h:26
osl::record::KisenFile::size
size_t size() const
Definition kisen.h:35
osl::record::KisenFile::moves
std::vector< Move > moves(size_t index)
Definition kisen.cc:94
osl::record::KisenFile::filename
const std::string filename
Definition kisen.h:29
osl::record::KisenFile::~KisenFile
~KisenFile()
Definition kisen.cc:273
osl::record::KisenFile::KisenFile
KisenFile(const std::string &filename)
Definition kisen.cc:84
osl::record::KisenFile::ipxFileName
std::string ipxFileName() const
Definition kisen.h:39
osl::record::KisenFile::initialState
NumEffectState initialState() const
Definition kisen.h:36
osl::record::KisenFile::ifs
std::ifstream ifs
Definition kisen.h:27
osl::record::KisenIpxFile
「.ipx」という拡張子を持つ棋泉形式ファイル.
Definition kisen.h:67
osl::record::KisenIpxFile::startDate
boost::gregorian::date startDate(size_t index)
開始日の年月日を返す
Definition kisen.cc:183
osl::record::KisenIpxFile::fileName
const std::string & fileName() const
Definition kisen.h:91
osl::record::KisenIpxFile::ifs
std::ifstream ifs
Definition kisen.h:68
osl::record::KisenIpxFile::size
size_t size() const
Definition kisen.h:86
osl::record::KisenIpxFile::player
std::string player(size_t index, Player pl)
Definition kisen.cc:139
osl::record::KisenIpxFile::title
std::string title(size_t index, Player pl)
Definition kisen.cc:170
osl::record::KisenIpxFile::number_of_games
size_t number_of_games
Definition kisen.h:69
osl::record::KisenIpxFile::KisenIpxFile
KisenIpxFile(std::string const &filename)
Definition kisen.cc:130
osl::record::KisenIpxFile::JISHOGI_256
@ JISHOGI_256
Definition kisen.h:81
osl::record::KisenIpxFile::BLACK_WIN
@ BLACK_WIN
Definition kisen.h:74
osl::record::KisenIpxFile::BY_PARITY
@ BY_PARITY
Definition kisen.h:73
osl::record::KisenIpxFile::SENNNICHITE
@ SENNNICHITE
Definition kisen.h:76
osl::record::KisenIpxFile::SENNNICHITE_256
@ SENNNICHITE_256
Definition kisen.h:80
osl::record::KisenIpxFile::WHITE_WIN_256
@ WHITE_WIN_256
Definition kisen.h:79
osl::record::KisenIpxFile::WHITE_WIN
@ WHITE_WIN
Definition kisen.h:75
osl::record::KisenIpxFile::BLACK_WIN_256
@ BLACK_WIN_256
Definition kisen.h:78
osl::record::KisenIpxFile::JISHOGI
@ JISHOGI
Definition kisen.h:77
osl::record::KisenIpxFile::~KisenIpxFile
~KisenIpxFile()
Definition kisen.cc:278
osl::record::KisenIpxFile::result
unsigned int result(size_t index)
Definition kisen.cc:162
osl::record::KisenIpxFile::file_name
const std::string file_name
Definition kisen.h:70
osl::record::KisenIpxWriter
「.ipx」という拡張子を持つ棋泉形式ファイル.
Definition kisen.h:131
osl::record::KisenIpxWriter::save
void save(const Record &, int black_rating, int white_rating, const std::string &black_title, const std::string &white_title)
Definition kisen.cc:365
osl::record::KisenIpxWriter::writeStartDate
void writeStartDate(int year, int month, int day, int hour, int min)
Definition kisen.cc:352
osl::record::KisenIpxWriter::os
std::ostream & os
Definition kisen.h:142
osl::record::KisenIpxWriter::writeRating
void writeRating(int rating)
Definition kisen.cc:344
osl::record::KisenIpxWriter::writeString
void writeString(const std::string &name, size_t length)
Definition kisen.cc:328
osl::record::KisenIpxWriter::KisenIpxWriter
KisenIpxWriter(std::ostream &ostream)
Definition kisen.h:133
osl::record::KisenPlusFile::initialState
NumEffectState initialState() const
Definition kisen.h:110
osl::record::KisenPlusFile::maxMoves
static const size_t maxMoves
Definition kisen.h:107
osl::record::KisenPlusFile::initial_state
NumEffectState initial_state
Definition kisen.h:103
osl::record::KisenPlusFile::load
void load(size_t index, std::vector< Move > &, std::vector< int > &)
Definition kisen.cc:221
osl::record::KisenPlusFile::ifs
std::ifstream ifs
Definition kisen.h:104
osl::record::KisenPlusFile::moves
std::vector< Move > moves(size_t index)
Definition kisen.cc:213
osl::record::KisenPlusFile::KisenPlusFile
KisenPlusFile(const std::string &fileName)
Definition kisen.cc:203
osl::record::KisenPlusFile::size
size_t size() const
Definition kisen.h:109
osl::record::KisenPlusFile::number_of_games
size_t number_of_games
Definition kisen.h:105
osl::record::KisenUtils
Definition kisen.h:14
osl::record::KisenUtils::convertMove
static Move convertMove(SimpleState const &state, int c0, int c1)
Definition kisen.cc:18
osl::record::KisenUtils::convertSquare
static Square convertSquare(int pos)
Definition kisen.cc:8
osl::record::KisenWriter
Definition kisen.h:116
osl::record::KisenWriter::os
std::ostream & os
Definition kisen.h:121
osl::record::KisenWriter::save
void save(const RecordMinimal &)
Definition kisen.cc:283
osl::record::KisenWriter::KisenWriter
KisenWriter(std::ostream &ostream)
Definition kisen.h:118
osl::rating
Definition construct.h:18
osl::record
棋譜関係
Definition checkDuplicate.h:15
osl
Definition additionalEffect.h:6
osl::Player
Player
Definition basic_type.h:8
numEffectState.h
record.h
osl::RecordMinimal
Definition csa.h:43
osl::record::Record
Definition record.h:15