2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
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>
26 #include "algebraicnotation.h"
36 Move(int n
, const QString
& s
)
37 : m_number(n
), m_move(s
) { }
39 class BeginVariation
{};
40 class EndVariation
{};
41 typedef boost::variant
<Move
, QString
, BeginVariation
, EndVariation
> Entry
;
44 /* friend std::ostream& operator<<(std::ostream& os, const PGN& pgn);*/
48 static QRegExp number
, begin_var
, end_var
, comment
, comment2
,
49 wsPattern
, tag
, result
, time
, eol
, move_tag
, move
;
51 static bool tryRegExp(QRegExp
& re
, const QString
& str
, int& offset
);
52 bool parse(const QString
& pgn
);
54 std::vector
<Entry
> m_entries
;
55 std::map
<QString
, QString
> m_tags
;
56 explicit PGN(const QString
&);
57 inline bool valid() const { return m_valid
; }
58 inline uint
size() const { return m_entries
.size(); }
59 const Entry
* operator[](int index
) const { return &m_entries
[index
]; }