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
00022 #ifndef __BARRY_SYNC_VBASE_H__
00023 #define __BARRY_SYNC_VBASE_H__
00024
00025 #include "dll.h"
00026 #include "vsmartptr.h"
00027 #include "vformat.h"
00028 #include "error.h"
00029 #include <vector>
00030
00031 namespace Barry {
00032 class CategoryList;
00033 }
00034
00035 namespace Barry { namespace Sync {
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 class BXEXPORT vTimeConverter
00049 {
00050 public:
00051 virtual ~vTimeConverter() {}
00052
00053
00054
00055
00056 virtual std::string unix2vtime(const time_t *timestamp);
00057
00058
00059
00060
00061 virtual time_t vtime2unix(const char *vtime);
00062
00063
00064
00065
00066
00067 virtual int alarmduration2sec(const char *alarm);
00068 };
00069
00070
00071 typedef Barry::vSmartPtr<b_VFormatAttribute, b_VFormatAttribute, &b_vformat_attribute_free> vAttrPtr;
00072 typedef Barry::vSmartPtr<b_VFormatParam, b_VFormatParam, &b_vformat_attribute_param_free> vParamPtr;
00073 typedef Barry::vSmartPtr<char, void, &g_free> gStringPtr;
00074
00075
00076
00077
00078
00079
00080
00081
00082 class BXEXPORT vAttr
00083 {
00084 b_VFormatAttribute *m_attr;
00085
00086 public:
00087 vAttr()
00088 : m_attr(0)
00089 {
00090 }
00091
00092 vAttr(b_VFormatAttribute *attr)
00093 : m_attr(attr)
00094 {
00095 }
00096
00097 vAttr& operator=(b_VFormatAttribute *attr)
00098 {
00099 m_attr = attr;
00100 return *this;
00101 }
00102
00103 b_VFormatAttribute* Get() { return m_attr; }
00104
00105
00106
00107
00108 std::string GetName();
00109 std::string GetValue(int nth = 0);
00110 std::string GetDecodedValue();
00111 std::string GetParam(const char *name, int nth = 0);
00112 std::string GetAllParams(const char *name);
00113 };
00114
00115
00116
00117
00118
00119
00120
00121 class BXEXPORT vBase
00122 {
00123
00124 b_VFormat *m_format;
00125
00126 public:
00127 protected:
00128 vBase();
00129 explicit vBase(b_VFormat *format);
00130 virtual ~vBase();
00131
00132 b_VFormat* Format() { return m_format; }
00133 const b_VFormat* Format() const { return m_format; }
00134 void SetFormat(b_VFormat *format);
00135
00136 void Clear();
00137
00138 vAttrPtr NewAttr(const char *name);
00139 vAttrPtr NewAttr(const char *name, const char *value);
00140 void AddAttr(vAttrPtr attr);
00141 void AddValue(vAttrPtr &attr, const char *value);
00142 void AddEncodedValue(vAttrPtr &attr, b_VFormatEncoding encoding, const char *value, int len);
00143 void AddParam(vAttrPtr &attr, const char *name, const char *value);
00144
00145 void AddCategories(const Barry::CategoryList &categories);
00146
00147 std::string GetAttr(const char *attrname, const char *block = 0);
00148 std::vector<std::string> GetValueVector(const char *attrname, const char *block = 0);
00149 vAttr GetAttrObj(const char *attrname, int nth = 0, const char *block = 0);
00150
00151 std::vector<std::string> Tokenize(const std::string &str, const char delim = ',');
00152 std::string ToStringList(const std::vector<std::string> &list, const char delim = ',');
00153 };
00154
00155 }}
00156
00157 #endif
00158