// -*-c++-*- //------------------------------------------------------------------------------ // xword - (http://xword.sourceforge.net) // Copyright 2002 Patrick Crosby //------------------------------------------------------------------------------ // Puzzle.h // // $Id: Puzzle.h,v 1.8 2002/01/23 19:43:03 pcrosby Exp $ //------------------------------------------------------------------------------ // 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 __Puzzle__ #define __Puzzle__ #include #include #include #include #include "Clue.h" #include "Square.h" #include "Namespace.h" NAMESPACE_OPEN //------------------------------------------------------------------------------ class Puzzle { // Constants // Types private: typedef std::vector StringVec; // typedef std::map ClueMap; typedef std::map ClueMap; public: typedef std::vector SquareVec; typedef std::vector SquareGrid; // Variables private: std::string m_strFilename; int m_nSizeX, m_nSizeY; // char* m_pAnswerGrid[]; StringVec m_vecAnswers; StringVec m_vecGrid; StringVec m_vecClueStrings; std::string m_strTitle; std::string m_strAuthor; std::string m_strCopyright; ClueMap m_mapCluesAcross; ClueMap m_mapCluesDown; SquareGrid m_SquareGrid; StringVec m_vecLetters; int m_nMaxClueNum; // Methods public: Puzzle(const std::string& strFilename); ~Puzzle(); const SquareGrid& GetGrid() const { return m_SquareGrid; } void GetClue(int nX, int nY, bool bAcross, std::string& strClue, int& nClue) const; std::string GetTitle() const { return m_strTitle; } std::string GetAuthor() const { return m_strAuthor; } std::string GetCopyright() const { return m_strCopyright; } void SetLetter(int nRow, int nCol, char c); char GetLetter(int nRow, int nCol) const; std::string GetLetterRow(int nRow) const; bool IsEmpty(int nRow, int nCol) const; bool IsSolid(int nRow, int nCol) const; bool IsFull(int nRow, int nCol, bool bCountLetters) const; int GetClueRow(int nClue, bool bAcross) const; int GetClueCol(int nClue, bool bAcross) const; int GetMaxClueNum() const { return m_nMaxClueNum; } void Save() const; void Load(); void Dump() const; private: void ParseFile(); int GetLine(FILE* pFile, std::string& s); std::string EncodeFilename(const std::string& strIn) const; }; //------------------------------------------------------------------------------ NAMESPACE_CLOSE #endif //------------------------------------------------------------------------------