| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
#ifndef _SGFPARSER_H_ |
|---|
| 25 |
#define _SGFPARSER_H_ |
|---|
| 26 |
|
|---|
| 27 |
#include <string> |
|---|
| 28 |
#include <vector> |
|---|
| 29 |
#include <utility> |
|---|
| 30 |
#include <stack> |
|---|
| 31 |
#include <map> |
|---|
| 32 |
|
|---|
| 33 |
typedef std::pair<char,char> p_cc; |
|---|
| 34 |
|
|---|
| 35 |
class SGFError { |
|---|
| 36 |
public: |
|---|
| 37 |
SGFError(); |
|---|
| 38 |
}; |
|---|
| 39 |
|
|---|
| 40 |
class ExtendedMoveNumber { |
|---|
| 41 |
public: |
|---|
| 42 |
int length; |
|---|
| 43 |
int* data; |
|---|
| 44 |
|
|---|
| 45 |
ExtendedMoveNumber(); |
|---|
| 46 |
ExtendedMoveNumber(int LENGTH, int* DATA); |
|---|
| 47 |
ExtendedMoveNumber(int D); |
|---|
| 48 |
ExtendedMoveNumber(const ExtendedMoveNumber& emn); |
|---|
| 49 |
~ExtendedMoveNumber(); |
|---|
| 50 |
|
|---|
| 51 |
ExtendedMoveNumber& operator=(const ExtendedMoveNumber& emn); |
|---|
| 52 |
void next(); |
|---|
| 53 |
void down() throw(SGFError); |
|---|
| 54 |
int total_move_num(); |
|---|
| 55 |
|
|---|
| 56 |
}; |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
char* SGFescape(const char* s); |
|---|
| 60 |
|
|---|
| 61 |
class PropValue { |
|---|
| 62 |
public: |
|---|
| 63 |
PropValue(std::string IDC, std::vector<std::string>* PV); |
|---|
| 64 |
~PropValue(); |
|---|
| 65 |
std::string IDcomplete; |
|---|
| 66 |
std::vector<std::string>* pv; |
|---|
| 67 |
}; |
|---|
| 68 |
|
|---|
| 69 |
class Node { |
|---|
| 70 |
public: |
|---|
| 71 |
Node* previous; |
|---|
| 72 |
Node* next; |
|---|
| 73 |
Node* up; |
|---|
| 74 |
Node* down; |
|---|
| 75 |
int numChildren; |
|---|
| 76 |
int level; |
|---|
| 77 |
std::string SGFstring; |
|---|
| 78 |
int parsed; |
|---|
| 79 |
std::vector<std::string> gpv(const std::string& prop); |
|---|
| 80 |
std::vector<std::string>* get_property_value(const std::string& prop); |
|---|
| 81 |
void set_property_value(std::string& IDcomplete, std::vector<std::string>* propValue) throw(SGFError); |
|---|
| 82 |
|
|---|
| 83 |
int posyD; |
|---|
| 84 |
|
|---|
| 85 |
Node(Node* prev, char* SGFst, int lvl) throw(SGFError); |
|---|
| 86 |
~Node(); |
|---|
| 87 |
ExtendedMoveNumber get_move_number(); |
|---|
| 88 |
void parseNode() throw(SGFError); |
|---|
| 89 |
static int sloppy; |
|---|
| 90 |
private: |
|---|
| 91 |
std::map<std::string, PropValue> data; |
|---|
| 92 |
}; |
|---|
| 93 |
|
|---|
| 94 |
typedef char* char_p; |
|---|
| 95 |
|
|---|
| 96 |
std::vector<std::string>* parseRootNode(Node* n, std::vector<std::string>* tags) throw(SGFError); |
|---|
| 97 |
|
|---|
| 98 |
class Cursor { |
|---|
| 99 |
public: |
|---|
| 100 |
Cursor(const char* sgf, int sloppy) throw(SGFError); |
|---|
| 101 |
~Cursor(); |
|---|
| 102 |
|
|---|
| 103 |
int atStart; |
|---|
| 104 |
int atEnd; |
|---|
| 105 |
int height; |
|---|
| 106 |
int width; |
|---|
| 107 |
Node* root; |
|---|
| 108 |
Node* currentN; |
|---|
| 109 |
int posx; |
|---|
| 110 |
int posy; |
|---|
| 111 |
|
|---|
| 112 |
void parse(const char* s) throw(SGFError); |
|---|
| 113 |
void game(int n) throw(SGFError); |
|---|
| 114 |
void next(int n=0) throw(SGFError); |
|---|
| 115 |
void previous() throw(SGFError); |
|---|
| 116 |
Node* getRootNode(int n) throw(SGFError); |
|---|
| 117 |
|
|---|
| 118 |
char* outputVar(Node* node); |
|---|
| 119 |
char* output(); |
|---|
| 120 |
void add(char* st); |
|---|
| 121 |
void delVariation(Node* node); |
|---|
| 122 |
void setFlags(); |
|---|
| 123 |
|
|---|
| 124 |
protected: |
|---|
| 125 |
void delVar(Node* node); |
|---|
| 126 |
void deltree(Node* node); |
|---|
| 127 |
|
|---|
| 128 |
}; |
|---|
| 129 |
|
|---|
| 130 |
std::string nodeToString(std::map<std::string, PropValue >& data) throw(SGFError); |
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
#endif |
|---|
| 134 |
|
|---|