Update Turkish translation
[dasher.git] / Src / DasherCore / Alphabet / AlphIO.h
blob4e4ee00bb2cbab0bae1a520b74c60749ebeb2dab
1 // AlphIO.h
2 //
3 // Copyright (c) 2007 The Dasher Team
4 //
5 // This file is part of Dasher.
6 //
7 // Dasher is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
12 // Dasher is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with Dasher; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef __AlphIO_h__
22 #define __AlphIO_h__
24 #include "../../Common/Common.h"
25 #ifdef HAVE_CONFIG_H
26 #include <config.h>
27 #endif
29 #include "../AbstractXMLParser.h"
31 #include "../DasherTypes.h"
32 #include "AlphInfo.h"
34 #include <map>
35 #include <vector>
36 #include <utility> // for std::pair
38 namespace Dasher {
39 class CAlphIO;
42 /// \ingroup Alphabet
43 /// @{
45 /// This class is used to read in alphabet definitions from all files
46 /// alphabet.*.xml at startup (realization) time; it creates one CAlphInfo
47 /// object per alphabet at this time, and stores them in a map from AlphID
48 /// string until shutdown/destruction. (CAlphIO is a friend of CAlphInfo,
49 /// so can create/manipulate instances.)
50 class Dasher::CAlphIO : public AbstractXMLParser {
51 public:
53 ///Create a new AlphIO. Initially, it will have only a 'default' alphabet
54 /// definition (English); further alphabets may be loaded in by calling the
55 /// Parse... methods inherited from Abstract[XML]Parser
56 CAlphIO(CMessageDisplay *pMsgs);
58 virtual ~CAlphIO();
59 void GetAlphabets(std::vector < std::string > *AlphabetList) const;
60 std::string GetDefault();
61 const CAlphInfo *GetInfo(const std::string & AlphID) const;
62 private:
63 CAlphInfo::character *SpaceCharacter, *ParagraphCharacter;
64 std::vector<SGroupInfo *> m_vGroups;
65 std::map < std::string, const CAlphInfo* > Alphabets; // map AlphabetID to AlphabetInfo.
66 CAlphInfo *CreateDefault(); // Give the user an English alphabet rather than nothing if anything goes horribly wrong.
68 // XML handling:
69 /////////////////////////
71 void ReadCharAtts(const XML_Char **atts, CAlphInfo::character &ch);
72 // Alphabet types:
73 std::map < std::string, Opts::AlphabetTypes > StoT;
74 std::map < Opts::AlphabetTypes, std::string > TtoS;
76 // Data gathered
77 std::string CData; // Text gathered from when an elemnt starts to when it ends
78 CAlphInfo *InputInfo;
79 int iGroupIdx;
80 std::string LanguageCode;
82 void XmlStartHandler(const XML_Char * name, const XML_Char ** atts);
83 void XmlEndHandler(const XML_Char * name);
84 void XmlCData(const XML_Char * s, int len);
86 /// @}
88 #endif /* #ifndef __AlphIO_h__ */