Removed AlgebraicNotation from the variant API.
[tagua/yd.git] / src / decoratedmove.cpp
blob0fc2663129ae252ac6dff9c3edb709d7b706a917
1 /*
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.
9 */
11 #include "decoratedmove.h"
13 #include <iostream>
14 #include <QRegExp>
16 #include "common.h"
18 DecoratedMove::DecoratedMove() { }
20 DecoratedMove::DecoratedMove(const QString& str) {
21 load(str);
24 void DecoratedMove::load(const QString& str) {
25 static QRegExp figurine("\\{[^}]*\\}");
26 int offset = 0;
27 int begin;
28 std::cout << "DecoratedMove load" << std::endl;
29 while ((begin = figurine.indexIn(str, offset)) != -1) {
30 std::cout << "begin = " << begin << std::endl;
31 if (begin > offset) {
32 m_elements.push_back(str.mid(offset, begin - offset));
33 std::cout << "found text: " << str.mid(offset, begin - offset) << std::endl;
35 m_elements.push_back(MovePart(str.mid(begin + 1, figurine.matchedLength() - 2), MovePart::Figurine));
36 std::cout << "found figurine: " << str.mid(begin + 1, figurine.matchedLength() - 2) << std::endl;
37 offset = begin + figurine.matchedLength();
40 if (offset < str.length())
41 m_elements.push_back(str.mid(offset));
44 void DecoratedMove::push_back(const MovePart& part) {
45 m_elements.push_back(part);
48 MovePart DecoratedMove::operator[](int index) const {
49 return m_elements[index];
52 unsigned int DecoratedMove::size() const {
53 return m_elements.size();