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.
11 #include "decoratedmove.h"
18 DecoratedMove::DecoratedMove() { }
20 DecoratedMove::DecoratedMove(const QString
& str
) {
24 void DecoratedMove::load(const QString
& str
) {
25 static QRegExp
figurine("\\{[^}]*\\}");
28 while ((begin
= figurine
.indexIn(str
, offset
)) != -1) {
30 m_elements
.push_back(str
.mid(offset
, begin
- offset
));
32 m_elements
.push_back(MovePart(str
.mid(begin
+ 1, figurine
.matchedLength() - 2), MovePart::Figurine
));
33 offset
= begin
+ figurine
.matchedLength();
36 if (offset
< str
.length())
37 m_elements
.push_back(str
.mid(offset
));
40 void DecoratedMove::push_back(const MovePart
& part
) {
41 m_elements
.push_back(part
);
44 MovePart
DecoratedMove::operator[](int index
) const {
45 return m_elements
[index
];
48 unsigned int DecoratedMove::size() const {
49 return m_elements
.size();