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; */
32 #include "../../Common/Expat/lib/expat.h"
45 class Dasher::CAlphIO
{
47 // This structure completely describes the characters used in alphabet
52 bool Mutable
; // If from user we may play. If from system defaults this is immutable. User should take a copy.
54 // Complete description of the alphabet:
55 std::string TrainingFile
;
56 std::string GameModeFile
;
57 std::string PreferredColours
;
58 Opts::AlphabetTypes Encoding
;
59 Opts::AlphabetTypes Type
;
60 Opts::ScreenOrientations Orientation
;
66 std::string Foreground
;
69 /* // Obsolete groups stuff */
71 /* std::string Description; */
72 /* std::vector < character > Characters; */
74 /* std::string Label; */
76 /* std::vector < group > Groups; */
80 std::vector
<SGroupInfo
*> m_vGroups
;
81 SGroupInfo
*m_pBaseGroup
;
83 std::vector
<character
> m_vCharacters
;
85 character ParagraphCharacter
; // display and edit text of paragraph character. Use ("", "") if no paragraph character.
86 character SpaceCharacter
; // display and edit text of Space character. Typically (" ", "_"). Use ("", "") if no space character.
87 character ControlCharacter
; // display and edit text of Control character. Typically ("", "Control"). Use ("", "") if no control character.
88 character StartConvertCharacter
;
89 character EndConvertCharacter
;
91 std::string m_strDefaultContext
;
94 CAlphIO(std::string SystemLocation
, std::string UserLocation
, std::vector
< std::string
> Filenames
);
95 void GetAlphabets(std::vector
< std::string
> *AlphabetList
) const;
96 std::string
GetDefault();
97 const AlphInfo
& GetInfo(const std::string
& AlphID
);
98 void SetInfo(const AlphInfo
& NewInfo
);
99 void Delete(const std::string
& AlphID
);
102 std::string SystemLocation
;
103 std::string UserLocation
;
104 std::map
< std::string
, AlphInfo
> Alphabets
; // map short names (file names) to descriptions
105 std::vector
< std::string
> Filenames
;
107 void Save(const std::string
& AlphID
);
108 void CreateDefault(); // Give the user an English alphabet rather than nothing if anything goes horribly wrong.
111 /////////////////////////
114 void ParseFile(std::string Filename
);
117 std::map
< std::string
, Opts::AlphabetTypes
> StoT
;
118 std::map
< Opts::AlphabetTypes
, std::string
> TtoS
;
120 // & to & < to < and > to > and if (Attribute) ' to ' and " to "
121 void XML_Escape(std::string
* Text
, bool Attribute
);
124 std::string CData
; // Text gathered from when an elemnt starts to when it ends
129 // Callback functions. These involve the normal dodgy casting to a pointer
130 // to an instance to get a C++ class to work with a plain C library.
131 static void XML_StartElement(void *userData
, const expat::XML_Char
* name
, const expat::XML_Char
** atts
);
132 static void XML_EndElement(void *userData
, const expat::XML_Char
* name
);
133 static void XML_CharacterData(void *userData
, const expat::XML_Char
* s
, int len
);
138 #endif /* #ifndef __AlphIO_h__ */