kisen-to-csa.cc Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kisen-to-csa.cc
Go to the documentation of this file.
1 #include "osl/state/numEffectState.h"
2 #include "osl/record/kisen.h"
3 #include "osl/record/csaRecord.h"
4
5 #include <iostream>
6 #include <fstream>
7
8 void usage (const char *program_name)
9 {
10 std::cerr << "Usage: " << program_name << " KISENFILE INDEX CSAFILE"
11 << std::endl;
12 exit(1);
13 }
14
15 void convert(const char*kisen_filename, const char *csa_filename, size_t i)
16 {
17 osl::record::KisenFile kisen(kisen_filename);
18 std::ofstream ofs(csa_filename);
19
20 if (i < kisen.size())
21 {
22 osl::state::NumEffectState state = kisen.getInitialState();
23 ofs << state;
24 const osl::stl::vector<osl::Move> moves = kisen.getMoves(i);
25 for (size_t j = 0; j < moves.size(); ++j)
26 {
27 ofs << osl::record::csa::show(moves[j]) << std::endl;
28 }
29 }
30 else
31 {
32 std::cerr << "Index out of bounds: " << i << std::endl;
33 }
34 }
35
36 int main(int argc, char **argv)
37 {
38 if (argc != 4)
39 usage(argv[0]);
40
41 convert(argv[1], argv[3], atoi(argv[2]));
42
43 return 0;
44 }