aboutsummaryrefslogtreecommitdiff
path: root/src/pgnp.hpp
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-01-25 10:53:10 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-01-25 10:53:10 +0100
commit4f1d7c524744861ee9cd3052c2ec9e42e83a32ca (patch)
treef2be23409388665dc0766be9ba89ee94db9c9379 /src/pgnp.hpp
parente817ac6bed46737839b592b4308c6d525d70aa2d (diff)
Refactoring
Diffstat (limited to 'src/pgnp.hpp')
-rw-r--r--src/pgnp.hpp99
1 files changed, 0 insertions, 99 deletions
diff --git a/src/pgnp.hpp b/src/pgnp.hpp
deleted file mode 100644
index 492dfc0..0000000
--- a/src/pgnp.hpp
+++ /dev/null
@@ -1,99 +0,0 @@
-#include <algorithm>
-#include <exception>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <streambuf>
-#include <string>
-#include <unordered_map>
-#include <vector>
-
-namespace pgnp {
-
-class HalfMove {
-private:
- /// @brief Recursive dump
- void NestedDump(HalfMove *, int);
-
-public:
- int count;
- bool isBlack;
- std::string move;
- std::string comment;
- HalfMove *MainLine;
- std::vector<HalfMove *> variations;
-
- HalfMove();
- ~HalfMove();
- /// @brief Get number of HalfMove in the MailLine
- int GetLength();
- /// @brief Dump move and all its variations
- void Dump();
- void Copy(HalfMove* copy);
-};
-
-class PGN {
-private:
- std::unordered_map<std::string, std::string> tags;
- std::vector<std::string> tagkeys;
- std::string result;
-
- HalfMove *moves;
- std::string pgn_content;
-
-public:
- ~PGN();
- void FromFile(std::string);
- void FromString(std::string);
- bool HasTag(std::string);
- /// @brief Perform a Seven Tag Roster compliance check
- void STRCheck();
- /// @brief Dump parsed PGN
- void Dump();
- std::vector<std::string> GetTagList();
- std::string GetTagValue(std::string);
- std::string GetResult();
- void GetMoves(HalfMove*);
-
-private:
- /// @brief Populate @a tags with by parsing the one starting at location in
- /// argument
- int ParseNextTag(int);
-
- /// @brief Get the next non-blank char location starting from location in
- /// argument
- int NextNonBlank(int);
-
- int ParseLine(int, HalfMove *);
-};
-
-struct UnexpectedEOF : public std::exception {
- const char *what() const throw() { return "Unexpected end of pgn file"; }
-};
-
-struct InvalidTagName : public std::exception {
- const char *what() const throw() { return "Invalid tag name"; }
-};
-
-struct InvalidGameResult : public std::exception {
- const char *what() const throw() { return "Invalid game result"; }
-};
-
-struct UnexpectedCharacter : public std::exception {
- std::string msg;
- UnexpectedCharacter(char actual, char required, int loc) {
- std::stringstream ss;
- ss << "Expected \'" << required << "\' at location " << loc
- << " but read \'" << actual << "\'";
- msg = ss.str();
- }
- const char *what() const throw() { return msg.c_str(); }
-};
-
-struct STRCheckFailed : public std::exception {
- const char *what() const throw() {
- return "Seven Tag Roster compliance check failed";
- }
-};
-
-} // namespace pgnp