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
00038 class XAP_App;
00039
00041
00043
00044 #define dcl(id,s) XAP_STRING_ID_##id,
00045
00046 typedef enum _XAP_String_Id_Enum
00047 {
00048 XAP_STRING_ID__FIRST__ = 0,
00049 #include "xap_String_Id.h"
00050 XAP_STRING_ID__LAST__
00051 } XAP_String_Id_Enum;
00052
00053 #undef dcl
00054
00056
00058
00059 typedef UT_uint32 XAP_String_Id;
00060
00062
00064
00065 class ABI_EXPORT XAP_StringSet
00066 {
00067 public:
00068 XAP_StringSet(XAP_App * pApp, const gchar * szLanguageName);
00069 virtual ~XAP_StringSet(void);
00070
00071 const gchar * getLanguageName(void) const;
00072
00073 virtual const gchar * getValue(XAP_String_Id id) const = 0;
00074
00075 bool getValue(XAP_String_Id id, const char * inEncoding, std::string &s) const;
00076 bool getValueUTF8(XAP_String_Id id, std::string &s) const;
00077
00078 void setEncoding(const char * inEndcoding);
00079 const char * getEncoding() const;
00080
00081 protected:
00082 XAP_App * m_pApp;
00083 const gchar * m_szLanguageName;
00084
00085 private:
00086 std::string m_encoding ;
00087 };
00088
00090
00092
00093 class ABI_EXPORT XAP_BuiltinStringSet : public XAP_StringSet
00094 {
00095 public:
00096 XAP_BuiltinStringSet(XAP_App * pApp, const gchar * szLanguageName);
00097 virtual ~XAP_BuiltinStringSet(void);
00098
00099 virtual const gchar * getValue(XAP_String_Id id) const;
00100
00101 private:
00102 const gchar ** m_arrayXAP;
00103 };
00104
00106
00108
00109 class ABI_EXPORT XAP_DiskStringSet : public XAP_StringSet, public UT_XML::Listener
00110 {
00111 public:
00112 XAP_DiskStringSet(XAP_App * pApp);
00113 virtual ~XAP_DiskStringSet(void);
00114
00115 virtual bool setValue(XAP_String_Id id, const gchar * szString);
00116 virtual bool setValue(const gchar * szId, const gchar * szString);
00117 virtual const gchar * getValue(XAP_String_Id id) const;
00118 virtual bool loadStringsFromDisk(const char * szFilename);
00119
00120 bool setLanguage(const gchar * szLanguageName);
00121 void setFallbackStringSet(XAP_StringSet * pFallback);
00122
00123 public:
00124
00125
00126 void startElement(const gchar *name, const gchar **atts);
00127 void endElement(const gchar *name);
00128 void charData(const gchar *s, int len);
00129
00130 protected:
00131 XAP_StringSet * m_pFallbackStringSet;
00132
00133 private:
00134 UT_GenericVector<gchar*> m_vecStringsXAP;
00135 std::map<std::string, UT_uint32> m_hash;
00136
00137 struct
00138 {
00139 bool m_parserStatus;
00140 } m_parserState;
00141 };
00142
00143 #endif