1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#include <ndb_global.h>
18
#include <Properties.hpp>
24
char * f_strdup(const char * s){
30
* Note has to be a multiple of 4 bytes
32
const char Properties::version[] = { 2, 0, 0, 1, 1, 1, 1, 4 };
33
const char Properties::delimiter = ':';
39
PropertiesType valueType;
44
PropertyImpl(const char * name, Uint32 value);
45
PropertyImpl(const char * name, Uint64 value);
46
PropertyImpl(const char * name, const char * value);
47
PropertyImpl(const char * name, const Properties * value);
49
static PropertyImpl * copyPropertyImpl(const PropertyImpl &);
55
class PropertiesImpl {
56
PropertiesImpl(const PropertiesImpl &); // Not implemented
57
PropertiesImpl& operator=(const PropertiesImpl&); // Not implemented
59
PropertiesImpl(Properties *, bool case_insensitive);
60
PropertiesImpl(Properties *, const PropertiesImpl &);
63
Properties * properties;
67
PropertyImpl **content;
70
int (* compare)(const char *s1, const char *s2);
72
void setCaseInsensitiveNames(bool value);
73
void grow(int sizeToAdd);
75
PropertyImpl * get(const char * name) const;
76
PropertyImpl * put(PropertyImpl *);
77
void remove(const char * name);
79
Uint32 getPackedSize(Uint32 pLen) const;
80
bool pack(Uint32 *& buf, const char * prefix, Uint32 prefixLen) const;
81
bool unpack(const Uint32 * buf, Uint32 &bufLen, Properties * top, int items);
83
Uint32 getTotalItems() const;
85
void setErrno(Uint32 pErr, Uint32 osErr = 0){
86
properties->setErrno(pErr, osErr);
89
const char * getProps(const char * name, const PropertiesImpl ** impl) const;
90
const char * getPropsPut(const char * name, PropertiesImpl ** impl);
94
* Methods for Property
96
Property::Property(const char * name, Uint32 value){
97
impl = new PropertyImpl(name, value);
100
Property::Property(const char * name, const char * value){
101
impl = new PropertyImpl(name, value);
104
Property::Property(const char * name, const class Properties * value){
105
impl = new PropertyImpl(name, value);
107
((Properties*)impl->value)->setCaseInsensitiveNames(value->getCaseInsensitiveNames());
110
Property::~Property(){
115
* Methods for Properties
117
Properties::Properties(bool case_insensitive){
119
impl = new PropertiesImpl(this, case_insensitive);
122
Properties::Properties(const Properties & org){
124
impl = new PropertiesImpl(this, * org.impl);
127
Properties::Properties(const Property * anArray, int arrayLen){
128
impl = new PropertiesImpl(this, false);
130
put(anArray, arrayLen);
133
Properties::~Properties(){
139
Properties::put(const Property * anArray, int arrayLen){
142
for(int i = 0; i<arrayLen; i++)
143
impl->put(anArray[i].impl);
148
put(PropertiesImpl * impl, const char * name, T value, bool replace){
150
impl->setErrno(E_PROPERTIES_INVALID_NAME);
154
PropertiesImpl * tmp = 0;
155
const char * short_name = impl->getPropsPut(name, &tmp);
158
impl->setErrno(E_PROPERTIES_NO_SUCH_ELEMENT);
162
if(tmp->get(short_name) != 0){
164
tmp->remove(short_name);
166
impl->setErrno(E_PROPERTIES_ELEMENT_ALREADY_EXISTS);
170
return tmp->put(new PropertyImpl(short_name, value));
175
Properties::put(const char * name, Uint32 value, bool replace){
176
return ::put(impl, name, value, replace);
180
Properties::put64(const char * name, Uint64 value, bool replace){
181
return ::put(impl, name, value, replace);
185
Properties::put(const char * name, const char * value, bool replace){
186
return ::put(impl, name, value, replace);
190
Properties::put(const char * name, const Properties * value, bool replace){
191
return ::put(impl, name, value, replace);
195
Properties::getTypeOf(const char * name, PropertiesType * type) const {
196
PropertyImpl * nvp = impl->get(name);
198
setErrno(E_PROPERTIES_NO_SUCH_ELEMENT);
201
setErrno(E_PROPERTIES_OK);
202
* type = nvp->valueType;
207
Properties::contains(const char * name) const {
208
PropertyImpl * nvp = impl->get(name);
213
Properties::get(const char * name, Uint32 * value) const {
214
PropertyImpl * nvp = impl->get(name);
216
setErrno(E_PROPERTIES_NO_SUCH_ELEMENT);
220
if(nvp->valueType == PropertiesType_Uint32){
221
* value = * (Uint32 *)nvp->value;
222
setErrno(E_PROPERTIES_OK);
226
if(nvp->valueType == PropertiesType_Uint64){
227
Uint64 tmp = * (Uint64 *)nvp->value;
228
Uint64 max = 1; max <<= 32;
230
* value = (Uint32)tmp;
231
setErrno(E_PROPERTIES_OK);
235
setErrno(E_PROPERTIES_INVALID_TYPE);
240
Properties::get(const char * name, Uint64 * value) const {
241
PropertyImpl * nvp = impl->get(name);
243
setErrno(E_PROPERTIES_NO_SUCH_ELEMENT);
247
if(nvp->valueType == PropertiesType_Uint32){
248
Uint32 tmp = * (Uint32 *)nvp->value;
249
* value = (Uint64)tmp;
250
setErrno(E_PROPERTIES_OK);
254
if(nvp->valueType == PropertiesType_Uint64){
255
* value = * (Uint64 *)nvp->value;
256
setErrno(E_PROPERTIES_OK);
259
setErrno(E_PROPERTIES_INVALID_TYPE);
264
Properties::get(const char * name, const char ** value) const {
265
PropertyImpl * nvp = impl->get(name);
267
setErrno(E_PROPERTIES_NO_SUCH_ELEMENT);
271
if(nvp->valueType == PropertiesType_char){
272
* value = (const char *)nvp->value;
273
setErrno(E_PROPERTIES_OK);
276
setErrno(E_PROPERTIES_INVALID_TYPE);
281
Properties::get(const char * name, BaseString& value) const {
282
const char *tmp = "";
284
ret = get(name, &tmp);
290
Properties::get(const char * name, const Properties ** value) const {
291
PropertyImpl * nvp = impl->get(name);
293
setErrno(E_PROPERTIES_NO_SUCH_ELEMENT);
296
if(nvp->valueType == PropertiesType_Properties){
297
* value = (const Properties *)nvp->value;
298
setErrno(E_PROPERTIES_OK);
301
setErrno(E_PROPERTIES_INVALID_TYPE);
306
Properties::getCopy(const char * name, char ** value) const {
307
PropertyImpl * nvp = impl->get(name);
309
setErrno(E_PROPERTIES_NO_SUCH_ELEMENT);
313
if(nvp->valueType == PropertiesType_char){
314
* value = f_strdup((const char *)nvp->value);
315
setErrno(E_PROPERTIES_OK);
318
setErrno(E_PROPERTIES_INVALID_TYPE);
323
Properties::getCopy(const char * name, Properties ** value) const {
324
PropertyImpl * nvp = impl->get(name);
326
setErrno(E_PROPERTIES_NO_SUCH_ELEMENT);
330
if(nvp->valueType == PropertiesType_Properties){
331
* value = new Properties(* (const Properties *)nvp->value);
332
setErrno(E_PROPERTIES_OK);
335
setErrno(E_PROPERTIES_INVALID_TYPE);
341
while(impl->items > 0)
342
impl->remove(impl->content[0]->name);
346
Properties::remove(const char * name) {
351
Properties::print(FILE * out, const char * prefix) const{
356
strncpy(buf, prefix, 1024);
358
for(unsigned int i = 0; i<impl->items; i++){
359
switch(impl->content[i]->valueType){
360
case PropertiesType_Uint32:
361
fprintf(out, "%s%s = (Uint32) %d\n", buf, impl->content[i]->name,
362
*(Uint32 *)impl->content[i]->value);
364
case PropertiesType_Uint64:
365
fprintf(out, "%s%s = (Uint64) %lld\n", buf, impl->content[i]->name,
366
*(Uint64 *)impl->content[i]->value);
368
case PropertiesType_char:
369
fprintf(out, "%s%s = (char*) \"%s\"\n", buf, impl->content[i]->name,
370
(char *)impl->content[i]->value);
372
case PropertiesType_Properties:
374
BaseString::snprintf(buf2, sizeof(buf2), "%s%s%c",buf, impl->content[i]->name,
375
Properties::delimiter);
376
((Properties *)impl->content[i]->value)->print(out, buf2);
382
Properties::Iterator::Iterator(const Properties* prop) :
388
Properties::Iterator::first() {
394
Properties::Iterator::next() {
395
if (m_iterator < m_prop->impl->items)
396
return m_prop->impl->content[m_iterator++]->name;
402
Properties::getPackedSize() const {
405
sz += sizeof(version); // Version id of properties object
406
sz += 4; // No Of Items
409
return sz + impl->getPackedSize(0);
414
computeChecksum(const Uint32 * buf, Uint32 words){
416
for(unsigned int i = 0; i<words; i++)
417
sum ^= htonl(buf[i]);
423
Properties::pack(Uint32 * buf) const {
424
Uint32 * bufStart = buf;
426
memcpy(buf, version, sizeof(version));
428
// Note that version must be a multiple of 4
429
buf += (sizeof(version) / 4);
431
* buf = htonl(impl->getTotalItems());
433
bool res = impl->pack(buf, "", 0);
437
* buf = htonl(computeChecksum(bufStart, (buf - bufStart)));
443
Properties::unpack(const Uint32 * buf, Uint32 bufLen){
444
const Uint32 * bufStart = buf;
445
Uint32 bufLenOrg = bufLen;
447
if(bufLen < sizeof(version)){
448
setErrno(E_PROPERTIES_INVALID_BUFFER_TO_SHORT);
452
if(memcmp(buf, version, sizeof(version)) != 0){
453
setErrno(E_PROPERTIES_INVALID_VERSION_WHILE_UNPACKING);
456
bufLen -= sizeof(version);
458
// Note that version must be a multiple of 4
459
buf += (sizeof(version) / 4);
462
setErrno(E_PROPERTIES_INVALID_BUFFER_TO_SHORT);
466
Uint32 totalItems = ntohl(* buf);
468
bool res = impl->unpack(buf, bufLen, this, totalItems);
472
Uint32 sum = computeChecksum(bufStart, (bufLenOrg-bufLen)/4);
473
if(sum != ntohl(bufStart[(bufLenOrg-bufLen)/4])){
474
setErrno(E_PROPERTIES_INVALID_CHECKSUM);
481
* Methods for PropertiesImpl
483
PropertiesImpl::PropertiesImpl(Properties * p, bool case_insensitive){
484
this->properties = p;
487
content = new PropertyImpl * [size];
488
setCaseInsensitiveNames(case_insensitive);
491
PropertiesImpl::PropertiesImpl(Properties * p, const PropertiesImpl & org){
492
this->properties = p;
493
this->size = org.size;
494
this->items = org.items;
495
this->m_insensitive = org.m_insensitive;
496
this->compare = org.compare;
497
content = new PropertyImpl * [size];
498
for(unsigned int i = 0; i<items; i++){
499
content[i] = PropertyImpl::copyPropertyImpl(* org.content[i]);
503
PropertiesImpl::~PropertiesImpl(){
504
for(unsigned int i = 0; i<items; i++)
510
PropertiesImpl::setCaseInsensitiveNames(bool value){
511
m_insensitive = value;
513
compare = strcasecmp;
519
PropertiesImpl::grow(int sizeToAdd){
520
PropertyImpl ** newContent = new PropertyImpl * [size + sizeToAdd];
521
memcpy(newContent, content, items * sizeof(PropertyImpl *));
523
content = newContent;
528
PropertiesImpl::get(const char * name) const {
529
const PropertiesImpl * tmp = 0;
530
const char * short_name = getProps(name, &tmp);
535
for(unsigned int i = 0; i<tmp->items; i++) {
536
if((* compare)(tmp->content[i]->name, short_name) == 0)
537
return tmp->content[i];
544
PropertiesImpl::put(PropertyImpl * nvp){
547
content[items] = nvp;
551
if(nvp->valueType == PropertiesType_Properties){
552
((Properties*)nvp->value)->parent = properties;
558
PropertiesImpl::remove(const char * name){
559
for(unsigned int i = 0; i<items; i++){
560
if((* compare)(content[i]->name, name) == 0){
562
memmove(&content[i], &content[i+1], (items-i-1)*sizeof(PropertyImpl *));
570
PropertiesImpl::getTotalItems() const {
572
for(unsigned int i = 0; i<items; i++)
573
if(content[i]->valueType == PropertiesType_Properties){
574
ret += ((Properties*)content[i]->value)->impl->getTotalItems();
582
PropertiesImpl::getProps(const char * name,
583
const PropertiesImpl ** impl) const {
584
const char * ret = name;
585
const char * tmp = strchr(name, Properties::delimiter);
590
Uint32 sz = tmp - name;
591
char * tmp2 = (char*)malloc(sz + 1);
592
memcpy(tmp2, name, sz);
595
PropertyImpl * nvp = get(tmp2);
603
if(nvp->valueType != PropertiesType_Properties){
607
return ((Properties*)nvp->value)->impl->getProps(tmp+1, impl);
612
PropertiesImpl::getPropsPut(const char * name,
613
PropertiesImpl ** impl) {
614
const char * ret = name;
615
const char * tmp = strchr(name, Properties::delimiter);
620
Uint32 sz = tmp - name;
621
char * tmp2 = (char*)malloc(sz + 1);
622
memcpy(tmp2, name, sz);
625
PropertyImpl * nvp = get(tmp2);
628
Properties * tmpP = new Properties();
629
PropertyImpl * tmpPI = new PropertyImpl(tmp2, tmpP);
630
PropertyImpl * nvp2 = put(tmpPI);
634
return ((Properties*)nvp2->value)->impl->getPropsPut(tmp+1, impl);
637
if(nvp->valueType != PropertiesType_Properties){
641
return ((Properties*)nvp->value)->impl->getPropsPut(tmp+1, impl);
646
mod4(unsigned int i){
647
int res = i + (4 - (i % 4));
652
PropertiesImpl::getPackedSize(Uint32 pLen) const {
654
for(unsigned int i = 0; i<items; i++){
655
if(content[i]->valueType == PropertiesType_Properties){
656
Properties * p = (Properties*)content[i]->value;
657
sz += p->impl->getPackedSize(pLen+strlen(content[i]->name)+1);
661
sz += 4; // Value Len
662
sz += mod4(pLen + strlen(content[i]->name)); // Name
663
switch(content[i]->valueType){
664
case PropertiesType_char:
665
sz += mod4(strlen((char *)content[i]->value));
667
case PropertiesType_Uint32:
670
case PropertiesType_Uint64:
673
case PropertiesType_Properties:
697
void clear() { contentLen = 0;}
698
bool add(const char * str, Uint32 strLen){
699
if(!expand(contentLen + strLen + 1))
701
memcpy(&buffer[contentLen], str, strLen);
702
contentLen += strLen;
703
buffer[contentLen] = 0;
711
bool expand(Uint32 newSize){
712
if(newSize >= bufLen){
714
char * tmp = (char*)malloc(newSize + 1024);
715
memset(tmp, 0, newSize + 1024);
719
memcpy(tmp, buffer, contentLen);
723
bufLen = newSize + 1024;
730
PropertiesImpl::pack(Uint32 *& buf, const char * prefix, Uint32 pLen) const {
733
for(unsigned int i = 0; i<items; i++){
734
const int strLenName = strlen(content[i]->name);
736
if(content[i]->valueType == PropertiesType_Properties){
738
if(!charBuf.add(prefix, pLen)){
739
properties->setErrno(E_PROPERTIES_ERROR_MALLOC_WHILE_PACKING,
744
if(!charBuf.add(content[i]->name, strLenName)){
745
properties->setErrno(E_PROPERTIES_ERROR_MALLOC_WHILE_PACKING,
750
if(!charBuf.add(Properties::delimiter)){
751
properties->setErrno(E_PROPERTIES_ERROR_MALLOC_WHILE_PACKING,
756
if(!((Properties*)(content[i]->value))->impl->pack(buf,
758
charBuf.contentLen)){
765
Uint32 valLenData = 0;
766
Uint32 valLenWrite = 0;
767
Uint32 sz = 4 + 4 + 4 + mod4(pLen + strLenName);
768
switch(content[i]->valueType){
769
case PropertiesType_Uint32:
772
case PropertiesType_Uint64:
775
case PropertiesType_char:
776
valLenData = strlen((char *)content[i]->value);
778
case PropertiesType_Properties:
781
valLenWrite = mod4(valLenData);
784
* (buf + 0) = htonl(content[i]->valueType);
785
* (buf + 1) = htonl(pLen + strLenName);
786
* (buf + 2) = htonl(valLenData);
788
char * valBuf = (char*)(buf + 3);
789
char * nameBuf = (char*)(buf + 3 + (valLenWrite / 4));
791
memset(valBuf, 0, sz-12);
793
switch(content[i]->valueType){
794
case PropertiesType_Uint32:
795
* (Uint32 *)valBuf = htonl(* (Uint32 *)content[i]->value);
797
case PropertiesType_Uint64:{
798
Uint64 val = * (Uint64 *)content[i]->value;
799
Uint32 hi = (val >> 32);
800
Uint32 lo = (val & 0xFFFFFFFF);
801
* (Uint32 *)valBuf = htonl(hi);
802
* (Uint32 *)(valBuf + 4) = htonl(lo);
805
case PropertiesType_char:
806
memcpy(valBuf, content[i]->value, strlen((char*)content[i]->value));
808
case PropertiesType_Properties:
812
memcpy(nameBuf, prefix, pLen);
813
memcpy(nameBuf + pLen, content[i]->name, strLenName);
822
PropertiesImpl::unpack(const Uint32 * buf, Uint32 &bufLen, Properties * top,
829
top->setErrno(E_PROPERTIES_BUFFER_TO_SMALL_WHILE_UNPACKING);
833
tmp[0] = ntohl(buf[0]);
834
tmp[1] = ntohl(buf[1]);
835
tmp[2] = ntohl(buf[2]);
839
PropertiesType pt = (PropertiesType)tmp[0];
840
Uint32 nameLen = tmp[1];
841
Uint32 valueLen = tmp[2];
842
Uint32 nameLenRead = mod4(nameLen);
843
Uint32 valueLenRead = mod4(valueLen);
845
Uint32 sz = nameLenRead + valueLenRead;
847
top->setErrno(E_PROPERTIES_BUFFER_TO_SMALL_WHILE_UNPACKING);
851
if(!charBuf.expand(sz)){
852
top->setErrno(E_PROPERTIES_ERROR_MALLOC_WHILE_UNPACKING, errno);
856
memcpy(charBuf.buffer, buf, sz);
860
char * valBuf = charBuf.buffer;
861
char * nameBuf = charBuf.buffer + valueLenRead;
863
nameBuf[nameLen] = 0;
864
valBuf[valueLen] = 0;
868
case PropertiesType_Uint32:
869
res3 = top->put(nameBuf, ntohl(* (Uint32 *)valBuf), true);
871
case PropertiesType_Uint64:{
872
Uint64 hi = ntohl(* (Uint32 *)valBuf);
873
Uint64 lo = ntohl(* (Uint32 *)(valBuf + 4));
874
res3 = top->put64(nameBuf, (hi << 32) + lo, true);
877
case PropertiesType_char:
878
res3 = top->put(nameBuf, valBuf, true);
880
case PropertiesType_Properties:
891
PropertyImpl::~PropertyImpl(){
894
case PropertiesType_Uint32:
895
delete (Uint32 *)value;
897
case PropertiesType_Uint64:
898
delete (Uint64 *)value;
900
case PropertiesType_char:
903
case PropertiesType_Properties:
904
delete (Properties *)value;
910
PropertyImpl::copyPropertyImpl(const PropertyImpl & org){
911
switch(org.valueType){
912
case PropertiesType_Uint32:
913
return new PropertyImpl(org.name, * (Uint32 *)org.value);
914
case PropertiesType_Uint64:
915
return new PropertyImpl(org.name, * (Uint64 *)org.value);
917
case PropertiesType_char:
918
return new PropertyImpl(org.name, (char *)org.value);
920
case PropertiesType_Properties:
921
return new PropertyImpl(org.name, (Properties *)org.value);
929
PropertyImpl::PropertyImpl(const char * _name, Uint32 _value){
930
this->name = f_strdup(_name);
931
this->value = new Uint32;
932
* ((Uint32 *)this->value) = _value;
933
this->valueType = PropertiesType_Uint32;
936
PropertyImpl::PropertyImpl(const char * _name, Uint64 _value){
937
this->name = f_strdup(_name);
938
this->value = new Uint64;
939
* ((Uint64 *)this->value) = _value;
940
this->valueType = PropertiesType_Uint64;
943
PropertyImpl::PropertyImpl(const char * _name, const char * _value){
944
this->name = f_strdup(_name);
945
this->value = f_strdup(_value);
946
this->valueType = PropertiesType_char;
950
PropertyImpl::PropertyImpl(const char * _name, const Properties * _value){
951
this->name = f_strdup(_name);
952
this->value = new Properties(* _value);
953
this->valueType = PropertiesType_Properties;
956
const Uint32 E_PROPERTIES_OK = 0;
957
const Uint32 E_PROPERTIES_INVALID_NAME = 1;
958
const Uint32 E_PROPERTIES_NO_SUCH_ELEMENT = 2;
959
const Uint32 E_PROPERTIES_INVALID_TYPE = 3;
960
const Uint32 E_PROPERTIES_ELEMENT_ALREADY_EXISTS = 4;
962
const Uint32 E_PROPERTIES_ERROR_MALLOC_WHILE_PACKING = 5;
963
const Uint32 E_PROPERTIES_INVALID_VERSION_WHILE_UNPACKING = 6;
964
const Uint32 E_PROPERTIES_INVALID_BUFFER_TO_SHORT = 7;
965
const Uint32 E_PROPERTIES_ERROR_MALLOC_WHILE_UNPACKING = 8;
966
const Uint32 E_PROPERTIES_INVALID_CHECKSUM = 9;
967
const Uint32 E_PROPERTIES_BUFFER_TO_SMALL_WHILE_UNPACKING = 10;
970
* These are methods that used to be inline
972
* But Diab 4.1f could not compile -release with to many inlines
975
Properties::setErrno(Uint32 pErr, Uint32 osErr) const {
977
parent->setErrno(pErr, osErr);
982
* propErrno & osErrno used to be mutable,
983
* but diab didn't know what mutable meant.
985
*((Uint32*)&propErrno) = pErr;
986
*((Uint32*)&osErrno) = osErr;
990
* Inlined get/put(name, no, ...) - methods
994
Properties::put(const char * name, Uint32 no, Uint32 val, bool replace){
995
size_t tmp_len = strlen(name)+20;
996
char * tmp = (char*)malloc(tmp_len);
997
BaseString::snprintf(tmp, tmp_len, "%s_%d", name, no);
998
bool res = put(tmp, val, replace);
1004
Properties::put64(const char * name, Uint32 no, Uint64 val, bool replace){
1005
size_t tmp_len = strlen(name)+20;
1006
char * tmp = (char*)malloc(tmp_len);
1007
BaseString::snprintf(tmp, tmp_len, "%s_%d", name, no);
1008
bool res = put(tmp, val, replace);
1015
Properties::put(const char * name, Uint32 no, const char * val, bool replace){
1016
size_t tmp_len = strlen(name)+20;
1017
char * tmp = (char*)malloc(tmp_len);
1018
BaseString::snprintf(tmp, tmp_len, "%s_%d", name, no);
1019
bool res = put(tmp, val, replace);
1026
Properties::put(const char * name, Uint32 no, const Properties * val,
1028
size_t tmp_len = strlen(name)+20;
1029
char * tmp = (char*)malloc(tmp_len);
1030
BaseString::snprintf(tmp, tmp_len, "%s_%d", name, no);
1031
bool res = put(tmp, val, replace);
1038
Properties::getTypeOf(const char * name, Uint32 no,
1039
PropertiesType * type) const {
1040
size_t tmp_len = strlen(name)+20;
1041
char * tmp = (char*)malloc(tmp_len);
1042
BaseString::snprintf(tmp, tmp_len, "%s_%d", name, no);
1043
bool res = getTypeOf(tmp, type);
1049
Properties::contains(const char * name, Uint32 no) const {
1050
size_t tmp_len = strlen(name)+20;
1051
char * tmp = (char*)malloc(tmp_len);
1052
BaseString::snprintf(tmp, tmp_len, "%s_%d", name, no);
1053
bool res = contains(tmp);
1059
Properties::get(const char * name, Uint32 no, Uint32 * value) const{
1060
size_t tmp_len = strlen(name)+20;
1061
char * tmp = (char*)malloc(tmp_len);
1062
BaseString::snprintf(tmp, tmp_len, "%s_%d", name, no);
1063
bool res = get(tmp, value);
1069
Properties::get(const char * name, Uint32 no, Uint64 * value) const{
1070
size_t tmp_len = strlen(name)+20;
1071
char * tmp = (char*)malloc(tmp_len);
1072
BaseString::snprintf(tmp, tmp_len, "%s_%d", name, no);
1073
bool res = get(tmp, value);
1080
Properties::get(const char * name, Uint32 no, const char ** value) const {
1081
size_t tmp_len = strlen(name)+20;
1082
char * tmp = (char*)malloc(tmp_len);
1083
BaseString::snprintf(tmp, tmp_len, "%s_%d", name, no);
1084
bool res = get(tmp, value);
1091
Properties::get(const char * name, Uint32 no, const Properties ** value) const{
1092
size_t tmp_len = strlen(name)+20;
1093
char * tmp = (char*)malloc(tmp_len);
1094
BaseString::snprintf(tmp, tmp_len, "%s_%d", name, no);
1095
bool res = get(tmp, value);
1102
Properties::getCopy(const char * name, Uint32 no, char ** value) const {
1103
size_t tmp_len = strlen(name)+20;
1104
char * tmp = (char*)malloc(tmp_len);
1105
BaseString::snprintf(tmp, tmp_len, "%s_%d", name, no);
1106
bool res = getCopy(tmp, value);
1113
Properties::getCopy(const char * name, Uint32 no, Properties ** value) const {
1114
size_t tmp_len = strlen(name)+20;
1115
char * tmp = (char*)malloc(tmp_len);
1116
BaseString::snprintf(tmp, tmp_len, "%s_%d", name, no);
1117
bool res = getCopy(tmp, value);
1123
Properties::setCaseInsensitiveNames(bool value){
1124
impl->setCaseInsensitiveNames(value);
1128
Properties::getCaseInsensitiveNames() const {
1129
return impl->m_insensitive;
1132
template bool put(PropertiesImpl *, const char *, Uint32, bool);
1133
template bool put(PropertiesImpl *, const char *, Uint64, bool);
1134
template bool put(PropertiesImpl *, const char *, const char *, bool);
1135
template bool put(PropertiesImpl *, const char *, const Properties*, bool);