aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/LargeFileStream.cpp3
-rw-r--r--src/PGN.cpp9
-rw-r--r--src/PGN.hpp8
3 files changed, 19 insertions, 1 deletions
diff --git a/src/LargeFileStream.cpp b/src/LargeFileStream.cpp
index 3ae1ce2..099c013 100644
--- a/src/LargeFileStream.cpp
+++ b/src/LargeFileStream.cpp
@@ -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
diff --git a/src/PGN.cpp b/src/PGN.cpp
index 96346e8..c0c80e3 100644
--- a/src/PGN.cpp
+++ b/src/PGN.cpp
@@ -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 \ No newline at end of file
diff --git a/src/PGN.hpp b/src/PGN.hpp
index d313f91..d7bc429 100644
--- a/src/PGN.hpp
+++ b/src/PGN.hpp
@@ -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