2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
18 #pragma warning( push )
19 #pragma warning( disable : 4100 )
20 #include <boost/variant.hpp>
21 #pragma warning( pop )
23 #include <boost/variant.hpp>
35 Move(int n
, const QString
& s
)
36 : m_number(n
), m_move(s
) { }
38 class BeginVariation
{};
39 class EndVariation
{};
40 typedef boost::variant
<Move
, QString
, BeginVariation
, EndVariation
> Entry
;
43 /* friend std::ostream& operator<<(std::ostream& os, const PGN& pgn);*/
47 static QRegExp number
, begin_var
, end_var
, comment
, comment2
,
48 wsPattern
, tag
, result
, time
, eol
, move_tag
, move
;
50 static bool tryRegExp(QRegExp
& re
, const QString
& str
, int& offset
);
51 bool parse(const QString
& pgn
);
53 std::vector
<Entry
> m_entries
;
54 std::map
<QString
, QString
> m_tags
;
55 explicit PGN(const QString
&);
56 inline bool valid() const { return m_valid
; }
57 inline uint
size() const { return m_entries
.size(); }
58 const Entry
* operator[](int index
) const { return &m_entries
[index
]; }