My Project
std
osl
record
usiRecord.cc
Go to the documentation of this file.
1
/* usiRecord.cc
2
*/
3
#include "
osl/record/usiRecord.h
"
4
#include "
osl/usi.h
"
5
#include <boost/algorithm/string/replace.hpp>
6
#include <iostream>
7
#include <fstream>
8
#include <sstream>
9
#include <cctype>
10
11
void
osl::usi::
12
escape
(std::string& str)
13
{
14
boost::algorithm::replace_all(str,
"/"
,
"_"
);
15
boost::algorithm::replace_all(str,
"+"
,
"@"
);
16
boost::algorithm::replace_all(str,
" "
,
"."
);
17
}
18
19
void
osl::usi::
20
unescape
(std::string& str)
21
{
22
boost::algorithm::replace_all(str,
"_"
,
"/"
);
23
boost::algorithm::replace_all(str,
"@"
,
"+"
);
24
boost::algorithm::replace_all(str,
"."
,
" "
);
25
}
26
27
␌
28
osl::usi::
29
UsiFile::UsiFile
(
const
std::string& filename)
30
{
31
std::ifstream is(filename.c_str());
32
std::string line;
33
if
(! std::getline(is, line))
34
{
35
const
std::string msg =
"UsiFile::UsiFile file cannot read "
;
36
std::cerr << msg << filename <<
"\n"
;
37
throw
usi::ParseError
(msg + filename);
38
}
39
::osl::usi::parse
(line, record.record.initial_state, record.record.moves);
40
assert(record.record.initial_state.isConsistent());
41
}
42
43
osl::usi::
44
UsiFile::~UsiFile
()
45
{
46
}
47
48
/* ------------------------------------------------------------------------- */
49
// ;;; Local Variables:
50
// ;;; mode:c++
51
// ;;; c-basic-offset:2
52
// ;;; End:
osl::usi::ParseError
Definition
usi.h:24
osl::usi::UsiFile::UsiFile
UsiFile(const std::string &filename)
Definition
usiRecord.cc:29
osl::usi::UsiFile::~UsiFile
~UsiFile()
Definition
usiRecord.cc:44
osl::usi::unescape
void unescape(std::string &str)
escapeされた文字を元に戻す.
Definition
usiRecord.cc:20
osl::usi::parse
void parse(const std::string &line, NumEffectState &)
[sfen <sfenstring> | startpos ] moves <move1> ... <movei>
Definition
usi.cc:301
osl::usi::escape
void escape(std::string &str)
URIやFile systemとして使えるように、文字をescape.
Definition
usiRecord.cc:12
usiRecord.h
usi.h
Generated by
1.9.8