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.
11 #ifndef ALGEBRAICNOTATION_H
12 #define ALGEBRAICNOTATION_H
21 class AlgebraicNotation
{
22 friend std::ostream
& operator<<(std::ostream
& os
, const AlgebraicNotation
& move
);
24 static QRegExp pattern
;
25 static QRegExp kingCastlingPattern
;
26 static QRegExp queenCastlingPattern
;
27 static QRegExp nonePattern
;
35 AlgebraicNotation(const QString
&, int& offset
, int ysize
);
36 explicit AlgebraicNotation(const QString
&, int ysize
);
39 void init(const QString
&, int& offset
, int ysize
);
44 CastlingType castling
;
47 inline bool invalid() const { return (to
== Point::invalid()) && (castling
== NoCastling
); }
48 inline bool valid() const { return !invalid(); }
51 class VerboseNotation
{
52 static QRegExp pattern
;
53 static QRegExp kingCastlingPattern
;
54 static QRegExp queenCastlingPattern
;
55 static QRegExp nonePattern
;
58 explicit VerboseNotation(const QString
&, int ysize
);
61 AlgebraicNotation::CastlingType castling
;
62 inline bool invalid() const { return (from
== Point::invalid() && to
== Point::invalid()); }
63 inline bool valid() const { return !invalid(); }
69 #define TRY(x) ref.getMove(x, ok); if (ok) return;
70 template <typename Pos
>
71 void minimalNotation(AlgebraicNotation
& san
, const Pos
& ref
) {
72 Point from
= san
.from
;
73 san
.castling
= AlgebraicNotation::NoCastling
;
76 // try notation without starting point
77 san
.from
= Point::invalid();
80 // add column indication
81 san
.from
= Point(from
.x
, -1);
85 san
.from
= Point(-1, from
.y
);
88 // add complete starting point
94 #endif // ALGEBRAICNOTATION_H