3 /////////////////////////////////////////////////////////////////////////////
5 // Copyright (c) 2002 Iain Murray
7 /////////////////////////////////////////////////////////////////////////////
12 #include "../DasherTypes.h"
13 //#include "Alphabet.h"
14 #include "GroupInfo.h"
19 #include <utility> // for std::pair
20 #include <stdio.h> // for C style file IO
22 /* namespace Dasher { */
23 /* class CAlphabet { */
25 /* struct SGroupInfo; */
30 #include "../../Common/Expat/lib/expat.h"
37 class Dasher::CAlphIO
{
39 // This structure completely describes the characters used in alphabet
44 bool Mutable
; // If from user we may play. If from system defaults this is immutable. User should take a copy.
46 // Complete description of the alphabet:
47 std::string TrainingFile
;
48 std::string GameModeFile
;
49 std::string PreferredColours
;
50 Opts::AlphabetTypes Encoding
;
51 Opts::AlphabetTypes Type
;
52 Opts::ScreenOrientations Orientation
;
58 std::string Foreground
;
61 /* // Obsolete groups stuff */
63 /* std::string Description; */
64 /* std::vector < character > Characters; */
66 /* std::string Label; */
68 /* std::vector < group > Groups; */
72 std::vector
<SGroupInfo
*> m_vGroups
;
73 SGroupInfo
*m_pBaseGroup
;
75 std::vector
<character
> m_vCharacters
;
77 character ParagraphCharacter
; // display and edit text of paragraph character. Use ("", "") if no paragraph character.
78 character SpaceCharacter
; // display and edit text of Space character. Typically (" ", "_"). Use ("", "") if no space character.
79 character ControlCharacter
; // display and edit text of Control character. Typically ("", "Control"). Use ("", "") if no control character.
81 // Added for Kanji Conversion by T.Kaburagi 15 July 2005
82 character StartConvertCharacter
;
83 character EndConvertCharacter
;
89 CAlphIO(std::string SystemLocation
, std::string UserLocation
, std::vector
< std::string
> Filenames
);
90 void GetAlphabets(std::vector
< std::string
> *AlphabetList
) const;
91 std::string
GetDefault();
92 const AlphInfo
& GetInfo(const std::string
& AlphID
);
93 void SetInfo(const AlphInfo
& NewInfo
);
94 void Delete(const std::string
& AlphID
);
97 std::string SystemLocation
;
98 std::string UserLocation
;
99 std::map
< std::string
, AlphInfo
> Alphabets
; // map short names (file names) to descriptions
100 std::vector
< std::string
> Filenames
;
102 void Save(const std::string
& AlphID
);
103 void CreateDefault(); // Give the user an English alphabet rather than nothing if anything goes horribly wrong.
106 /////////////////////////
109 void ParseFile(std::string Filename
);
112 std::map
< std::string
, Opts::AlphabetTypes
> StoT
;
113 std::map
< Opts::AlphabetTypes
, std::string
> TtoS
;
115 // & to & < to < and > to > and if (Attribute) ' to ' and " to "
116 void XML_Escape(std::string
* Text
, bool Attribute
);
119 std::string CData
; // Text gathered from when an elemnt starts to when it ends
124 // Callback functions. These involve the normal dodgy casting to a pointer
125 // to an instance to get a C++ class to work with a plain C library.
126 static void XML_StartElement(void *userData
, const expat::XML_Char
* name
, const expat::XML_Char
** atts
);
127 static void XML_EndElement(void *userData
, const expat::XML_Char
* name
);
128 static void XML_CharacterData(void *userData
, const expat::XML_Char
* s
, int len
);
131 #endif /* #ifndef __AlphIO_h__ */