3 // Copyright (c) 2007 The Dasher Team
5 // This file is part of Dasher.
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
24 #include "../../Common/Common.h"
29 #include "../AbstractXMLParser.h"
31 #include "../DasherTypes.h"
36 #include <utility> // for std::pair
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
{
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
);
59 void GetAlphabets(std::vector
< std::string
> *AlphabetList
) const;
60 std::string
GetDefault();
61 const CAlphInfo
*GetInfo(const std::string
& AlphID
) const;
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.
69 /////////////////////////
71 void ReadCharAtts(const XML_Char
**atts
, CAlphInfo::character
&ch
);
73 std::map
< std::string
, Opts::AlphabetTypes
> StoT
;
74 std::map
< Opts::AlphabetTypes
, std::string
> TtoS
;
77 std::string CData
; // Text gathered from when an elemnt starts to when it ends
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
);
88 #endif /* #ifndef __AlphIO_h__ */