Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef XAP_STRINGS_H
00022 #define XAP_STRINGS_H
00023
00024 #include <map>
00025 #include <string>
00026
00027
00028
00029
00030
00031 #ifndef UT_TYPES_H
00032 #include "ut_types.h"
00033 #endif
00034 #include "ut_xml.h"
00035 #include "ut_vector.h"
00036 #include "ut_string.h"
00037 #include "ut_string_class.h"
00038
00039 class XAP_App;
00040
00042
00044
00045 #define dcl(id,s) XAP_STRING_ID_##id,
00046
00047 typedef enum _XAP_String_Id_Enum
00048 {
00049 XAP_STRING_ID__FIRST__ = 0,
00050 #include "xap_String_Id.h"
00051 XAP_STRING_ID__LAST__
00052 } XAP_String_Id_Enum;
00053
00054 #undef dcl
00055
00057
00059
00060 typedef UT_uint32 XAP_String_Id;
00061
00063
00065
00066 class ABI_EXPORT XAP_StringSet
00067 {
00068 public:
00069 XAP_StringSet(XAP_App * pApp, const gchar * szLanguageName);
00070 virtual ~XAP_StringSet(void);
00071
00072 const gchar * getLanguageName(void) const;
00073
00074 virtual const gchar * getValue(XAP_String_Id id) const = 0;
00075
00076 bool getValue(XAP_String_Id id, const char * inEncoding, UT_String &s) const;
00077 bool getValueUTF8(XAP_String_Id id, std::string &s) const;
00078 bool getValueUTF8(XAP_String_Id id, UT_UTF8String &s) const;
00079
00080 void setEncoding(const char * inEndcoding);
00081 const char * getEncoding() const;
00082
00083 protected:
00084 XAP_App * m_pApp;
00085 const gchar * m_szLanguageName;
00086
00087 private:
00088 UT_String m_encoding ;
00089 };
00090
00092
00094
00095 class ABI_EXPORT XAP_BuiltinStringSet : public XAP_StringSet
00096 {
00097 public:
00098 XAP_BuiltinStringSet(XAP_App * pApp, const gchar * szLanguageName);
00099 virtual ~XAP_BuiltinStringSet(void);
00100
00101 virtual const gchar * getValue(XAP_String_Id id) const;
00102
00103 private:
00104 const gchar ** m_arrayXAP;
00105 };
00106
00108
00110
00111 class ABI_EXPORT XAP_DiskStringSet : public XAP_StringSet, public UT_XML::Listener
00112 {
00113 public:
00114 XAP_DiskStringSet(XAP_App * pApp);
00115 virtual ~XAP_DiskStringSet(void);
00116
00117 virtual bool setValue(XAP_String_Id id, const gchar * szString);
00118 virtual bool setValue(const gchar * szId, const gchar * szString);
00119 virtual const gchar * getValue(XAP_String_Id id) const;
00120 virtual bool loadStringsFromDisk(const char * szFilename);
00121
00122 bool setLanguage(const gchar * szLanguageName);
00123 void setFallbackStringSet(XAP_StringSet * pFallback);
00124
00125 public:
00126
00127
00128 void startElement(const gchar *name, const gchar **atts);
00129 void endElement(const gchar *name);
00130 void charData(const gchar *s, int len);
00131
00132 protected:
00133 XAP_StringSet * m_pFallbackStringSet;
00134
00135 private:
00136 UT_GenericVector<gchar*> m_vecStringsXAP;
00137 std::map<std::string, UT_uint32> m_hash;
00138
00139 struct
00140 {
00141 bool m_parserStatus;
00142 } m_parserState;
00143 };
00144
00145 #endif