/*************************************************************************** * Copyright (C) 2002-2003 Andi Peredri * * andi@ukr.net * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef PDN_H #define PDN_H #include #define ENOTATION "1 2 3 4 5 6 7 8 9 1011121314151617181920212223242526272829303132" #define RNOTATION "b8d8f8h8a7c7e7g7b6d6f6h6a5c5e5g5b4d4f4h4a3c3e3g3b2d2f2h2a1c1e1g1" #define ENGLISH 21 #define RUSSIAN 25 // Portable Draughts Notation Format File parser class Pdn { public: Pdn() { clear(); } int item(int i) const { return board[i]; } int count() const { return database.count(); } enum Tag { Date,Site,Type,Event,Round,White,Black,Result }; bool open(const QString& filename); bool save(const QString& filename, int game); bool parse(int game); bool isWhite() const { return white; } void set(Tag tag, const QString& string); void setItem(int i, int set) { board[i]=set; } void setWhite(bool set) { white=set; } QString get(Tag tag) const; private: void clear(); bool parse(const QString& string, bool side); bool white; int board[32]; QString pdnDate; QString pdnSite; QString pdnType; QString pdnEvent; QString pdnRound; QString pdnWhite; QString pdnBlack; QString pdnResult; QStringList database; }; #endif