Improve NAG parsing

This commit is contained in:
Loic Guegan 2023-01-18 18:42:13 +01:00
parent 2ac42558f2
commit da88575493
5 changed files with 30 additions and 27 deletions

View file

@ -2,7 +2,7 @@
namespace pgnp {
HalfMove::HalfMove() : count(-1), isBlack(false), MainLine(NULL) {}
HalfMove::HalfMove() : count(-1), isBlack(false), MainLine(NULL), NAG(0) {}
HalfMove::~HalfMove() {
delete MainLine;

View file

@ -24,7 +24,7 @@ public:
std::string move;
/// @brief Comment associated to the move
std::string comment;
std::string NAG;
std::uint8_t NAG;
/// @brief Next HalfMove link to this line
HalfMove *MainLine;
/// @brief Next HalfMove links to variation of this line

View file

@ -260,16 +260,19 @@ loctype PGN::ParseHalfMove(loctype loc, HalfMove *hm) {
EOF_CHECK(loc);
c = pgn_content[loc];
if (c == '$') {
hm->NAG += c;
//hm->NAG += c;
std::string NAG;
loc++;
EOF_CHECK(loc);
c = pgn_content[loc];
while (IS_DIGIT(c)) {
hm->NAG += c;
NAG += c;
loc++;
EOF_CHECK(loc);
c = pgn_content[loc];
}
if(NAG.size()>0)
hm->NAG=std::stoi(NAG);
}
} else if (c == '(') {
// Check for variations