中国象棋控件 v2.0.13
载入中...
搜索中...
未找到
Pgn.h
1// 作者:康林 <kl222@126.com>
2
3#ifndef CPGN_H_KL_2020_06_11_
4#define CPGN_H_KL_2020_06_11_
5
6#pragma once
7
8#include <string>
9#include <map>
10#include <time.h>
11#include <memory>
12
13#include "ChessStepsChinese.h"
14
22class CPGN
23{
24public:
25 CPGN();
26
27 std::string GetTag(const std::string &szTag);
28 int SetTag(const std::string &szTag, const std::string& szValue);
29
34 std::string toString() const;
40 int ParseString(const std::string szPgn);
41
46 const std::string& GetEvent() const;
47 int SetEvent(const char* pEvent);
48
53 const std::string& GetSite() const;
54 int SetSite(const char* pSite);
55
60 const time_t& GetDate() const;
61 int SetDate(const time_t &t);
62
63 int parseDate(const std::string& dateText);
64 std::string dateToString(const time_t &t) const;
65
70 const std::string& GetRound() const;
71 int SetRound(const char* pRound);
72
77 const std::string& GetRed() const;
78 int SetRed(const char* pRed);
79
84 const std::string& GetBlack() const;
85 int SetBlack(const char* pBlack);
86
91 const std::string& GetResult() const;
92 int SetResult(const char* pResult);
93
94 const std::string& GetFen() const;
95 int SetFen(const char* pFen);
96
97 const std::string& GetFormat() const;
98 int SetFormat(const char* pFormat);
99
100 int SetSteps(std::shared_ptr<CChessSteps> steps);
101
102private:
103 std::string m_Game; //游戏类型,国际象棋没有这个标签,中国象棋的PGN文件中这个标签必须放在第一位,其值必须为“Chinese Chess”
104 std::string m_Event; //比赛名
105 std::string m_Site; //比赛地点
106 time_t m_Date; //比赛日期,格式统一为“yyyy.mm.dd”
107 std::string m_Round; //比赛轮次
108 std::string m_Red; //红方棋手,不同与国际象棋的White
109 std::string m_Black; //黑方棋手
110 std::string m_Result; //比赛结果,“红先胜”用“1-0”表示,“黑先胜”用“0-1”表示,和棋用“1/2-1/2”表示,未知用“*”表示。
111 std::string m_szFEN; //开始局面,中局、残局和排局等摆出来的局面,作棋谱记录时通常要规定这个选项
112 std::string m_Format; //表示记谱方法,可以是Chinese(中文纵线格式)、WXF(WXF纵线格式)和ICCS(ICCS坐标格式),默认为Chinese。
113 std::map<std::string, std::string> m_Tags;
114
115 std::shared_ptr<CChessSteps> m_pSteps;
116};
117
118#endif // CPGN_H_KL_2020_06_11_
Class to hold all information for the Portable Game Notation (PGN) of a single game.
Definition Pgn.h:23
std::string toString() const
Gets the game as PGN string.
Definition Pgn.cpp:75
const std::string & GetRed() const
Get the player(s) of the white pieces.
Definition Pgn.cpp:175
const std::string & GetRound() const
Get the playing round ordinal of the game.
Definition Pgn.cpp:164
const std::string & GetBlack() const
Get the player(s) of the black pieces.
Definition Pgn.cpp:189
const time_t & GetDate() const
Gets the date of the event.
Definition Pgn.cpp:130
int ParseString(const std::string szPgn)
解析 PGN
Definition Pgn.cpp:103
const std::string & GetResult() const
Gets the result of the game, if any.
Definition Pgn.cpp:203
const std::string & GetSite() const
Gets the location of the event.
Definition Pgn.cpp:119
const std::string & GetEvent() const
Gets the name of the tournament or match event.
Definition Pgn.cpp:108