説明を見る。00001 #ifndef OSL_CSA_H
00002 #define OSL_CSA_H
00003
00004 #include "osl/numEffectState.h"
00005 #include <vector>
00006 #include <string>
00007 #include <iosfwd>
00008 #include <stdexcept>
00009 namespace osl
00010 {
00015 namespace csa
00016 {
00017 struct CsaIOError : public std::runtime_error
00018 {
00019 CsaIOError(const std::string& w) : std::runtime_error(w) {
00020 }
00021 };
00022
00023 const Move strToMove(const std::string& s,const SimpleState& st);
00024 Player charToPlayer(char c);
00025 const Square strToPos(const std::string& s);
00026 Ptype strToPtype(const std::string& s);
00027
00028 const std::string show(Move);
00029 const std::string fancyShow(Move);
00030 const std::string show(Square);
00031 const std::string show(Ptype);
00032 const std::string show(Piece);
00033 const std::string show(Player);
00034 const std::string show(const Move *first, const Move *last);
00035
00036 const std::string show(Move, std::string& buf);
00037 const std::string show(Square, std::string& buf, size_t offset=0);
00038 const std::string show(Ptype, std::string& buf, size_t offset=0);
00039 const std::string show(Player, std::string& buf, size_t offset=0);
00040 }
00041
00042 struct RecordMinimal
00043 {
00044 NumEffectState initial_state;
00045 std::vector<Move> moves;
00046 const NumEffectState& initialState() const { return initial_state; }
00047 };
00048
00049 namespace csa
00050 {
00051 class CsaFileMinimal
00052 {
00053 RecordMinimal record;
00054 public:
00055 CsaFileMinimal(const std::string& filename);
00056 CsaFileMinimal(std::istream& is);
00057 virtual ~CsaFileMinimal();
00058 RecordMinimal load() const { return record; }
00059 std::vector<Move> moves() const { return load().moves; }
00060 const NumEffectState& initialState() const { return load().initialState(); }
00061 protected:
00062 CsaFileMinimal() {}
00063 void load(std::istream&);
00064 public:
00065 static bool parseLine(SimpleState&, RecordMinimal&, std::string element,
00066 CArray<bool,9>&);
00067 };
00068
00069 class CsaString : public CsaFileMinimal
00070 {
00071 public:
00072 CsaString(const std::string&);
00073 NumEffectState initialState() const { return load().initial_state; }
00074 };
00075 }
00076 using csa::CsaIOError;
00077 using csa::CsaFileMinimal;
00078 using csa::CsaString;
00079 }
00080 #endif
00081
00082
00083
00084