00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef INCL_WINITEM
00037 #define INCL_WINITEM
00038
00044 #include "base/fscapi.h"
00045 #include "base/Log.h"
00046 #include "vocl/VObject.h"
00047 #include <string>
00048 #include <list>
00049 #include <map>
00050 #include <vector>
00051
00052 using namespace std;
00053
00054
00055
00056 #define VCARD_VERSION TEXT("2.1")
00057 #define VCALENDAR_VERSION TEXT("1.0")
00058 #define VNOTE_VERSION TEXT("1.1")
00059 #define SIF_VERSION TEXT("1.1")
00060
00061
00062
00063 #define ERR_ITEM_VOBJ_PARSE "VConverter: error occurred parsing the item data."
00064 #define ERR_ITEM_VOBJ_WRONG_TYPE "Error: wrong vobject type \"%ls\" (\"%ls\" expected)"
00065 #define ERR_ITEM_VOBJ_TYPE_NOTFOUND "Error: vobject type not specified (\"%ls\" expected)"
00066 #define ERR_SIFFIELDS_NULL "Parsing error: sifFields must be initialized before parsing data."
00067 #define INFO_ITEM_VOBJ_WRONG_VERSION "Warning! Wrong vobject version \"%ls\" (\"%ls\" expected)"
00068 #define INFO_ITEM_VOBJ_VERSION_NOTFOUND "Warning! VObject version not specified (\"%ls\" expected)"
00069 #include "base/globalsdef.h"
00070
00071 BEGIN_NAMESPACE
00072
00073
00074 typedef map<wstring,wstring>::iterator mapIterator;
00075
00076
00084 class WinItem {
00085
00086 private:
00087
00090 static wstring badString;
00091
00092 static bool (*defaultValidateExtraProperty) (const std::wstring &);
00093
00094 bool (*validateExtraProperty) (const std::wstring &);
00095
00096 protected:
00097
00099 static unsigned long crc32Table[256];
00100
00101
00102 public:
00103
00112 map<wstring,wstring> propertyMap;
00113
00114 map<wstring,wstring> extraPropertyMap;
00115
00117 WinItem();
00118
00120 virtual ~WinItem();
00121
00123 int getPropertyMapSize();
00124
00126 map<wstring,wstring>& getPropertyMap();
00127
00128
00136 void setProperty(const wstring propertyName, const wstring propertyValue);
00137
00145 void setIntProperty(const wstring propertyName, const int intValue);
00146
00147
00157 bool getProperty(const wstring propertyName, wstring& propertyValue);
00158
00170 wstring& getPropertyRef(const wstring propertyName, bool* found);
00171
00180 bool getIntProperty(const wstring propertyName, int* intValue);
00181
00182
00183 void removeElement(wstring key);
00184
00186 void resetPropertyMap();
00187
00189 void resetAllValues();
00190
00191
00198 virtual wstring toString() = 0;
00199
00207 virtual int parse(const wstring & dataString) = 0;
00208
00209
00216 virtual long getCRC();
00217
00224 WCHAR* getVObjectPropertyValue(VObject* vo, const WCHAR* propertyName);
00225
00226
00232 virtual wstring& getName();
00233
00234 void setExtraProperty(const wstring propertyName, const wstring propertyValue);
00235 bool getExtraProperty(const wstring propertyName, wstring& propertyValue);
00236 vector<wstring> getExtraPropertyNames();
00237 void addExtraProperties(VObject * vo);
00238
00239 bool validExtraProperty(const std::wstring & name);
00240
00241 void setValidateFunction(bool (*validate)(const std::wstring &));
00242 static void setDefaultValidateFunction(bool (*default) (const std::wstring &));
00243 };
00244
00245
00246 END_NAMESPACE
00247
00250 #endif