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
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef WAVEPACKET_DATAHASH_UTIL_H__
00035 #define WAVEPACKET_DATAHASH_UTIL_H__
00036
00037
00038 #include "datahash.h"
00039
00040 #include <sstream>
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 enum eDatahash_Flag {
00058 eDatahash_Required = 1,
00059 eDatahash_Optional = 2,
00060
00061
00062 eDatahash_Invalid = 0
00063 };
00064
00065
00066 const char * getString(IN const Datahash * hash, IN const char * key,
00067 IN eDatahash_Flag flag = eDatahash_Required);
00068
00069 const char * getOptionalString(IN const Datahash * hash, IN const char * key,
00070 IN const char * default_value);
00071
00072 long getLong(IN const Datahash * hash, IN const char * key);
00073
00074 long getOptionalLong(IN const Datahash * hash, IN const char * key,
00075 IN long default_value);
00076
00077 double getDouble(IN const Datahash * hash, IN const char * key);
00078
00079 bool getBooleanValueFromString(IN const char * value);
00080
00081 bool getBoolean(IN const Datahash * hash, IN const char * key);
00082
00083 smart_ptr<Datahash> getSubhash(IN const Datahash * hash,
00084 IN const char * key_name,
00085 IN eDatahash_Flag flag = eDatahash_Required);
00086
00087
00088
00089 static inline short getShort(IN const Datahash * hash, IN const char * key)
00090 { return (short) getLong(hash, key); }
00091
00092 static inline int getInt(IN const Datahash * hash, IN const char * key)
00093 { return (int) getLong(hash, key); }
00094
00095 static inline byte_t getByte(IN const Datahash * hash, IN const char * key)
00096 { return (byte_t) getLong(hash, key); }
00097
00098 static inline float getFloat(IN const Datahash * hash, IN const char * key)
00099 { return (float) getDouble(hash, key); }
00100
00101
00102
00103 template <class T>
00104 void
00105 setValue
00106 (
00107 IN Datahash * hash,
00108 IN const char * key_name,
00109 IN const T& t
00110 )
00111 {
00112 std::ostringstream out;
00113 out << t;
00114
00115 hash->remove(key_name);
00116 hash->insert(key_name, out.str().c_str());
00117 }
00118
00119
00120 void setTimestampAsDateString(IN Datahash * hash,
00121 IN const char * key, long timestamp);
00122
00123 long getTimestampFromDateString(IN const Datahash * hash,
00124 IN const char * key);
00125
00126
00127 void getStringValues(IN const Datahash * hash,
00128 IN const char * key,
00129 OUT VecString& vec);
00130
00131
00132
00133 smart_ptr<Datahash> getHashFromColonString(IN const char * s);
00134
00135
00136 #endif // WAVEPACKET_DATAHASH_UTIL_H__
00137