mirror of
https://gitlab.com/manzerbredes/chess-move-interface.git
synced 2025-06-07 14:57:39 +00:00
Debug PGN parsing from a string. Add the ParseSANMoves() function. Add a new tests set
This commit is contained in:
parent
ef75681956
commit
52c2fd4521
5 changed files with 71 additions and 1 deletions
|
@ -37,8 +37,9 @@ char LargeFileStream::operator[](loctype loc) {
|
|||
if (use_string) {
|
||||
if (loc >= content.size()) {
|
||||
eof = true;
|
||||
return ('?');
|
||||
}
|
||||
return ('?');
|
||||
return (content[loc]);
|
||||
}
|
||||
|
||||
// Goto the right memory chuck
|
||||
|
|
|
@ -410,4 +410,13 @@ loctype PGN::GotoEOL(loctype loc) {
|
|||
}
|
||||
}
|
||||
|
||||
void ParseSANMoves(const std::string &sequence,HalfMove *moves) {
|
||||
PGN parser;
|
||||
// Note that PGN need a results (* at the end)
|
||||
// Otherwise an InvalidGameResult exception is raised
|
||||
parser.FromString(sequence+" *");
|
||||
parser.ParseNextGame();
|
||||
parser.GetMoves(moves);
|
||||
}
|
||||
|
||||
} // namespace pgnp
|
|
@ -102,4 +102,12 @@ struct STRCheckFailed : public std::exception {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Parse a simple sequence of SAN moves
|
||||
*
|
||||
* @param sequence e.g: 1.e4 e5 2.Nf3
|
||||
* @param moves Returned moves sequence
|
||||
*/
|
||||
void ParseSANMoves(const std::string &sequence,HalfMove *moves);
|
||||
|
||||
} // namespace pgnp
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue