3 /////////////////////////////////////////////////////////////////////////////
5 // Copyright (c) 2002 Iain Murray
7 /////////////////////////////////////////////////////////////////////////////
10 #define __ColourIO_h__
12 #include "DasherTypes.h"
17 #include <utility> // for std::pair
18 #include <stdio.h> // for C style file IO
21 #include "../Common/Expat/lib/expat.h"
26 class Dasher::CColourIO
{
28 // This structure completely describes the characters used in alphabet
32 bool Mutable
; // If from user we may play. If from system defaults this is immutable. User should take a copy.
34 // Complete description of the alphabet:
35 std::vector
< int >Reds
;
36 std::vector
< int >Greens
;
37 std::vector
< int >Blues
;
40 CColourIO(std::string SystemLocation
, std::string UserLocation
, std::vector
< std::string
> Filenames
);
41 void GetColours(std::vector
< std::string
> *ColourList
) const;
42 const ColourInfo
& GetInfo(const std::string
& ColourID
);
43 void SetInfo(const ColourInfo
& NewInfo
);
44 void Delete(const std::string
& ColourID
);
47 std::string SystemLocation
;
48 std::string UserLocation
;
49 std::map
< std::string
, ColourInfo
> Colours
; // map short names (file names) to descriptions
50 std::vector
< std::string
> Filenames
;
52 void Save(const std::string
& ColourID
);
53 void CreateDefault(); // Give the user a default colour scheme rather than nothing if anything goes horribly wrong.
56 /////////////////////////
59 void ParseFile(std::string Filename
);
61 // & to & < to < and > to > and if (Attribute) ' to ' and " to "
62 void XML_Escape(std::string
* Text
, bool Attribute
);
65 std::string CData
; // Text gathered from when an elemnt starts to when it ends
68 // Callback functions. These involve the normal dodgy casting to a pointer
69 // to an instance to get a C++ class to work with a plain C library.
70 static void XML_StartElement(void *userData
, const expat::XML_Char
* name
, const expat::XML_Char
** atts
);
71 static void XML_EndElement(void *userData
, const expat::XML_Char
* name
);
72 static void XML_CharacterData(void *userData
, const expat::XML_Char
* s
, int len
);
75 #endif /* #ifndef __ColourIO_h__ */