19 #ifndef PROPERTIES_HPP
20 #define PROPERTIES_HPP
22 #include <ndb_global.h>
23 #include <BaseString.hpp>
24 #include <UtilBuffer.hpp>
27 PropertiesType_Uint32 = 0,
28 PropertiesType_char = 1,
29 PropertiesType_Properties = 2,
30 PropertiesType_Uint64 = 3
42 Property(
const char* name, Uint64 val);
43 Property(
const char* name,
const char * value);
57 static const char delimiter;
74 bool getCaseInsensitiveNames()
const;
82 bool put64(
const char *
name, Uint64 value,
bool replace =
false);
83 bool put(
const char *
name,
const char * value,
bool replace =
false);
91 bool put(
const char *, Uint32 no, Uint32,
bool replace =
false);
92 bool put64(
const char *, Uint32 no, Uint64,
bool replace =
false);
93 bool put(
const char *, Uint32 no,
const char *,
bool replace =
false);
97 bool getTypeOf(
const char *
name, PropertiesType *
type)
const;
102 bool get(
const char *
name, Uint32 * value)
const;
103 bool get(
const char *
name, Uint64 * value)
const;
104 bool get(
const char *
name,
const char ** value)
const;
108 bool getCopy(
const char *
name,
char ** value)
const;
115 bool getTypeOf(
const char *
name, Uint32 no, PropertiesType *
type)
const;
118 bool get(
const char *
name, Uint32 no, Uint32 * value)
const;
119 bool get(
const char *
name, Uint32 no, Uint64 * value)
const;
120 bool get(
const char *
name, Uint32 no,
const char ** value)
const;
121 bool get(
const char *
name, Uint32 no,
const Properties ** value)
const;
123 bool getCopy(
const char *
name, Uint32 no,
char ** value)
const;
124 bool getCopy(
const char *
name, Uint32 no,
Properties ** value)
const;
128 void remove(
const char *
name);
130 void print(FILE *
file = stdout,
const char * prefix = 0)
const;
146 Uint32 getPackedSize()
const;
147 bool pack(Uint32 *
buf)
const;
149 bool unpack(
const Uint32 *
buf, Uint32 bufLen);
152 Uint32 getPropertiesErrno()
const {
return propErrno; }
153 Uint32 getOSErrno()
const {
return osErrno; }
162 void setErrno(Uint32 pErr, Uint32 osErr = 0)
const ;
172 extern const Uint32 E_PROPERTIES_OK;
177 extern const Uint32 E_PROPERTIES_INVALID_NAME;
182 extern const Uint32 E_PROPERTIES_NO_SUCH_ELEMENT;
187 extern const Uint32 E_PROPERTIES_INVALID_TYPE;
192 extern const Uint32 E_PROPERTIES_ELEMENT_ALREADY_EXISTS;
197 extern const Uint32 E_PROPERTIES_INVALID_VERSION_WHILE_UNPACKING;
205 extern const Uint32 E_PROPERTIES_INVALID_BUFFER_TO_SHORT;
212 extern const Uint32 E_PROPERTIES_ERROR_MALLOC_WHILE_PACKING;
219 extern const Uint32 E_PROPERTIES_ERROR_MALLOC_WHILE_UNPACKING;
225 extern const Uint32 E_PROPERTIES_INVALID_CHECKSUM;
231 extern const Uint32 E_PROPERTIES_BUFFER_TO_SMALL_WHILE_UNPACKING;
235 return unpack((
const Uint32 *)buf.get_data(), buf.length());
240 Uint32
size = getPackedSize();
241 void *tmp_buf = buf.append(size);
244 bool ret = pack((Uint32 *)tmp_buf);