26 #include <forward_list> 125 #define GAME_DECODE_NONE 0 126 #define GAME_DECODE_TAGS 1 127 #define GAME_DECODE_COMMENTS 2 128 #define GAME_DECODE_ALL 3 144 #define PGN_STYLE_TAGS 1 145 #define PGN_STYLE_COMMENTS 2 146 #define PGN_STYLE_VARS 4 147 #define PGN_STYLE_INDENT_COMMENTS 8 148 #define PGN_STYLE_INDENT_VARS 16 149 #define PGN_STYLE_SYMBOLS 32 // e.g. "! +-" instead of "$2 $14" 150 #define PGN_STYLE_SHORT_HEADER 64 151 #define PGN_STYLE_MOVENUM_SPACE 128 // Space after move numbers. 152 #define PGN_STYLE_COLUMN 256 // Column style: one move per line. 153 #define PGN_STYLE_SCIDFLAGS 512 154 #define PGN_STYLE_STRIP_MARKS 1024 // Strip [%mark] and [%arrow] codes. 155 #define PGN_STYLE_NO_NULL_MOVES 2048 // Convert null moves to comments. 156 #define PGN_STYLE_UNICODE 4096 // Use U+2654..U+2659 for figurine 169 std::vector<std::pair<std::string, std::string> > extraTags_;
170 std::string WhiteStr;
171 std::string BlackStr;
172 std::string EventStr;
174 std::string RoundStr;
180 byte WhiteRatingType;
181 byte BlackRatingType;
187 std::forward_list<std::unique_ptr<moveT[]> > moveChunks_;
188 std::unique_ptr<Position> StartPos;
189 std::unique_ptr<Position> CurrentPos{
new Position};
197 bool KeepDecodedMoves;
199 eloT WhiteEstimateElo;
200 eloT BlackEstimateElo;
202 uint NumMovesPrinted;
212 bool MakeHomePawnList(
byte* pbPawnList);
220 struct GameSavedPos {
229 void strip(
bool variations,
bool comments,
bool NAGs);
241 errorT SetStartFen(
const char* fenStr);
244 constexpr
size_t size =
sizeof(ScidFlags) /
sizeof(*ScidFlags);
245 std::fill_n(ScidFlags, size, 0);
246 std::copy_n(s, std::min(size - 1, len), ScidFlags);
261 void TruncateStart();
270 errorT MoveExitVariation();
271 errorT MoveForwardInPGN();
272 errorT MoveToLocationInPGN(
unsigned stopLocation);
276 for (
int i = 0; i < hmNumber; ++i)
280 return GameSavedPos{*CurrentPos, CurrentMove, VarDepth};
283 *CurrentPos = savedPos.pos;
284 CurrentMove = savedPos.move;
285 VarDepth = savedPos.varDepth;
293 return CurrentPos.get();
299 auto ply = CurrentPos->GetPlyCounter();
300 return StartPos ? ply - StartPos->GetPlyCounter() : ply;
315 for (
auto parent = moves.first; parent; varNumber++) {
316 parent = parent->varChild;
317 if (parent == moves.second)
324 unsigned GetLocationInPGN()
const;
325 unsigned GetPgnOffset()
const;
329 bool AtStart()
const {
return (VarDepth == 0 && AtVarStart()); }
330 bool AtEnd()
const {
return (VarDepth == 0 && AtVarEnd()); }
338 errorT RemoveNag(
bool isMoveNag);
355 return (move) ? move->
comment.c_str() :
"";
361 void SetMoveComment(
const char* comment);
363 const char* GetNextSAN();
364 void GetSAN(
char* str);
365 void GetPrevSAN(
char* str);
366 void GetPrevMoveUCI(
char* str)
const;
367 void GetNextMoveUCI(
char* str);
372 void AddPgnTag(
const char* tag,
const char* value);
373 bool RemoveExtraTag(
const char* tag);
374 const char* FindExtraTag(
const char* tag)
const;
375 std::string& accessTagValue(
const char* tag,
size_t tagLen);
376 const decltype(extraTags_) &
GetExtraTags()
const {
return extraTags_; }
393 int setRating(
colorT col,
const char* ratingType,
size_t ratingTypeLen,
394 std::pair<const char*, const char*> rating);
411 eloT GetAverageElo ();
414 bool CommentEmpty (
const char * comment);
415 void WriteComment (
TextBuffer * tb,
const char * preStr,
416 const char * comment,
const char * postStr);
418 bool printMoveNum,
bool inComment);
419 std::pair<const char*, unsigned> WriteToPGN (
uint lineWidth = 0,
420 bool NewLineAtEnd =
false,
421 bool newLineToSpaces =
true);
428 if (setting) { AddPgnStyle (mask); }
else { RemovePgnStyle (mask); }
434 bool SetPgnFormatFromString (
const char * str);
435 static bool PgnFormatFromString (
const char * str,
gameFormatT * fmt);
447 patternT * pattern,
int minPly,
int maxPly,
449 bool oppBishops,
bool sameBishops,
450 int minDiff,
int maxDiff);
461 {
return ExactMatch (pos, buf, sm, searchType, NULL); }
479 visitor(
"Date", dateBuf);
489 std::string rType =
"White";
491 visitor(rType.c_str(), std::to_string(elo).c_str());
494 std::string rType =
"Black";
496 visitor(rType.c_str(), std::to_string(elo).c_str());
500 visitor(
"ECO", strBuf);
504 visitor(
"EventDate", strBuf);
511 visitor(e.first.c_str(), e.second.c_str());
514 visitor(
"FEN", strBuf);
549 template <
typename TCont>
579 std::vector<GamePos> res;
587 #endif // #ifndef SCID_GAME_H
bool ExactMatch(Position *pos, ByteBuffer *buf, simpleMoveT *sm, bool *neverMatch)
void transPieces(char *s)
void SetEventStr(const char *str)
std::string & accessMoveComment()
void tags_extra(const Game &game, TFunc visitor)
const byte NAG_WithBlackAttack
const byte NAG_BlackCounterPlay
const byte NAG_OppositeBishops
const byte NAG_SlightCounterPlay
const char * langPieces[]
void SetBlackRatingType(byte b)
void restoreLocation(const GameSavedPos &savedPos)
WritePGNpath name rating xml
bool ExactMatch(Position *pos, ByteBuffer *buf, simpleMoveT *sm)
const byte NAG_Compensation
const byte NAG_ExcellentMove
void SetWhiteElo(eloT elo)
const char * ratingTypeNames[17]
const char * GetMoveComment() const
const byte NAG_SeparatedPawns
const byte NAG_BishopPair
void SetEventDate(dateT date)
const byte MAX_NAGS_ARRAY
const moveT * getPrevMove() const
const byte NAG_WhiteSlight
dateT GetEventDate() const
uint GetVarNumber() const
A tree graph of moves representing a game.
void SetResult(resultT res)
void date_DecodeToString(dateT date, char *str)
const byte NAG_ModerateKingSide
byte GetWhiteRatingType() const
const byte NAG_VariousMoves
void SetWhiteStr(const char *str)
const byte NAG_UnitedPawns
const char * GetPreviousMoveComment() const
Return the comment on the move previously played by CurrentPos->ToMove If there are no previous moves...
const byte NAG_BlackClear
ushort GetCurrentPly() const
byte GetBlackRatingType() const
errorT MoveForwardInPGN()
const byte NAG_InterestingMove
const byte NAG_SameBishops
const byte NAG_BlackDecisive
uint strGetRatingType(const char *name)
This class stores the database's names (players, events, sites and rounds).
void SetSiteStr(const char *str)
const byte NAG_DubiousMove
resultT GetResult() const
void SetRoundStr(const char *str)
void PrintFEN(char *str, uint flags) const
const byte NAG_BlackSlightCounterPlay
void SetBlackStr(const char *str)
UI_res_t Result(UI_handle_t ti, errorT res)
const char * GetBlackStr() const
const byte NAG_WhiteDecisive
void ResetPgnStyle(uint flag)
uint GetNumVariations() const
Position * GetCurrentPos()
const char * GetWhiteStr() const
simpleMoveT * GetCurrentMove()
const byte NAG_WithInitiative
void AddPgnStyle(uint mask)
void SetPgnFormat(gameFormatT gf)
decltype(extraTags_) const & GetExtraTags() const
void eco_ToExtendedString(ecoT ecoCode, char *ecoStr)
const byte NAG_BlackSlight
byte game_parseNag(std::pair< const char *, const char *> strview)
const byte NAG_SlightKingSide
const byte NAG_WhiteClear
GameSavedPos currentLocation() const
byte * GetNextNags() const
void SetHtmlStyle(uint style)
void MoveToPly(int hmNumber)
void SetWhiteRatingType(byte b)
const byte NAG_BlackDecisiveCounterPlay
const byte NAG_DoublePawns
const char RESULT_LONGSTR[4][8]
const Position * currentPos() const
const char * GetSiteStr() const
const byte NAG_WithAttack
eloT GetBlackEstimateElo() const
const byte NAG_SlightQueenSide
void SetScidFlags(const char *s)
const byte NAG_SlightCentre
void RemovePgnStyle(uint mask)
void tags_STR(const Game &game, TFunc visitor)
bool ExactMatch(Position *pos, ByteBuffer *buf, simpleMoveT *sm, gameExactMatchT searchType)
const byte NAG_CounterPlay
const byte NAG_WhiteCrushing
const byte NAG_DevelopmentAdvantage
bool HasNonStandardStart(char *outFEN=nullptr) const
void game_printNag(byte nag, char *str, bool asSymbol, gameFormatT format)
eloT GetWhiteEstimateElo() const
const char * GetEventStr() const
std::vector< GamePos > collectPositions(Game &game)
Returns all the positions of a game.
std::pair< const moveT *, const moveT * > getParent() const
const byte NAG_BlackZugZwang
void SetBlackElo(eloT elo)
const byte NAG_ModerateQueenSide
void GetPrevSAN(char *str)
const byte NAG_DecisiveCounterPlay
const byte NAG_PassedPawn
const char * GetRoundStr() const
void SetScidFlags(const char *s, size_t len)
const byte NAG_BlackCrushing
void SetPgnStyle(uint mask, bool setting)
char transPiecesChar(char c)
const uint FEN_ALL_FIELDS