#include <ConfigValues.hpp>
Public Types | |
| InvalidType = 0 | |
| IntType = 1 | |
| StringType = 2 | |
| SectionType = 3 | |
| Int64Type = 4 | |
| enum | ValueType { InvalidType = 0, IntType = 1, StringType = 2, SectionType = 3, Int64Type = 4 } |
Public Member Functions | |
| ~ConfigValues () | |
| Uint32 | getPackedSize () const |
| Uint32 | pack (UtilBuffer &) const |
| Uint32 | pack (void *dst, Uint32 len) const |
Private Member Functions | |
| ConfigValues (Uint32 sz, Uint32 data) | |
| bool | getByPos (Uint32 pos, Entry *) const |
| Uint64 * | get64 (Uint32 index) const |
| char ** | getString (Uint32 index) const |
Private Attributes | |
| Uint32 | m_size |
| Uint32 | m_dataSize |
| Uint32 | m_stringCount |
| Uint32 | m_int64Count |
| Uint32 | m_values [1] |
| void * | m_data [1] |
Friends | |
| class | ConfigValuesFactory |
| class | Iterator |
| class | ConstIterator |
Classes | |
| class | ConstIterator |
| struct | Entry |
| class | Iterator |
Definition at line 7 of file ConfigValues.hpp.
Definition at line 14 of file ConfigValues.hpp.
00014 { 00015 InvalidType = 0, 00016 IntType = 1, 00017 StringType = 2, 00018 SectionType = 3, 00019 Int64Type = 4 00020 };
Definition at line 48 of file ConfigValues.cpp.
References CFV_KEY_FREE, m_dataSize, m_int64Count, m_size, m_stringCount, and m_values.
00048 { 00049 m_size = sz; 00050 m_dataSize = dsz; 00051 m_stringCount = 0; 00052 m_int64Count = 0; 00053 for(Uint32 i = 0; i<m_size; i++){ 00054 m_values[i << 1] = CFV_KEY_FREE; 00055 } 00056 }
| ConfigValues::~ConfigValues | ( | ) |
Definition at line 58 of file ConfigValues.cpp.
References free, getString(), and m_stringCount.
Referenced by ConfigValuesFactory::expand(), main(), and ConfigValuesFactory::shrink().
00058 { 00059 for(Uint32 i = 0; i<m_stringCount; i++){ 00060 free(* getString(i)); 00061 } 00062 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 103 of file ConfigValues.cpp.
References assert, data, m_int64Count, m_size, and m_values.
Referenced by getByPos(), pack(), ConfigValuesFactory::put(), and ConfigValues::Iterator::set().
00103 { 00104 assert(index < m_int64Count); 00105 const Uint32 * data = m_values + (m_size << 1); 00106 Uint64 * ptr = (Uint64*)data; 00107 ptr += index; 00108 return ptr; 00109 }
Here is the caller graph for this function:

Definition at line 76 of file ConfigValues.cpp.
References assert, get64(), getString(), getTypeOf(), Int64Type, IntType, InvalidType, ConfigValues::Entry::m_int, ConfigValues::Entry::m_int64, m_size, ConfigValues::Entry::m_string, ConfigValues::Entry::m_type, m_values, SectionType, and StringType.
Referenced by ConfigValues::ConstIterator::get().
00076 { 00077 assert(pos < (2 * m_size)); 00078 Uint32 keypart = m_values[pos]; 00079 Uint32 val = m_values[pos+1]; 00080 00081 switch(::getTypeOf(keypart)){ 00082 case IntType: 00083 case SectionType: 00084 result->m_int = val; 00085 break; 00086 case StringType: 00087 result->m_string = * getString(val); 00088 break; 00089 case Int64Type: 00090 result->m_int64 = * get64(val); 00091 break; 00092 case InvalidType: 00093 default: 00094 return false; 00095 } 00096 00097 result->m_type = ::getTypeOf(keypart); 00098 00099 return true; 00100 }
Here is the call graph for this function:

Here is the caller graph for this function:

| Uint32 ConfigValues::getPackedSize | ( | ) | const |
Definition at line 556 of file ConfigValues.cpp.
References abort(), CFV_KEY_FREE, getString(), getTypeOf(), Int64Type, IntType, InvalidType, key, m_size, m_values, Magic, mod4(), SectionType, StringType, and strlen().
Referenced by main(), NDB_COMMAND(), and pack().
00556 { 00557 00558 Uint32 size = 0; 00559 for(Uint32 i = 0; i < 2 * m_size; i += 2){ 00560 Uint32 key = m_values[i]; 00561 if(key != CFV_KEY_FREE){ 00562 switch(::getTypeOf(key)){ 00563 case IntType: 00564 case SectionType: 00565 size += 8; 00566 break; 00567 case Int64Type: 00568 size += 12; 00569 break; 00570 case StringType: 00571 size += 8; // key + len 00572 size += mod4(strlen(* getString(m_values[i+1])) + 1); 00573 break; 00574 case InvalidType: 00575 default: 00576 abort(); 00577 } 00578 } 00579 } 00580 00581 return size + sizeof(Magic) + 4; // checksum also 00582 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char ** ConfigValues::getString | ( | Uint32 | index | ) | const [private] |
Definition at line 112 of file ConfigValues.cpp.
References assert, data, m_dataSize, m_size, m_stringCount, and m_values.
Referenced by getByPos(), getPackedSize(), pack(), ConfigValuesFactory::put(), ConfigValues::Iterator::set(), and ~ConfigValues().
00112 { 00113 assert(index < m_stringCount); 00114 const Uint32 * data = m_values + (m_size << 1); 00115 char * ptr = (char*)data; 00116 ptr += m_dataSize; 00117 ptr -= (index * sizeof(char *)); 00118 return (char**)ptr; 00119 }
Here is the caller graph for this function:

Definition at line 585 of file ConfigValues.cpp.
References abort(), CFV_KEY_FREE, get64(), getString(), getTypeOf(), Int64Type, IntType, InvalidType, key, m_size, m_values, Magic, memcpy, memset, mod4(), SectionType, StringType, and strlen().
00585 { 00586 Uint32 i; 00587 char * dst = (char*)_dst; 00588 memcpy(dst, Magic, sizeof(Magic)); dst += sizeof(Magic); 00589 00590 for(i = 0; i < 2 * m_size; i += 2){ 00591 Uint32 key = m_values[i]; 00592 Uint32 val = m_values[i+1]; 00593 if(key != CFV_KEY_FREE){ 00594 switch(::getTypeOf(key)){ 00595 case IntType: 00596 case SectionType: 00597 * (Uint32*)dst = htonl(key); dst += 4; 00598 * (Uint32*)dst = htonl(val); dst += 4; 00599 break; 00600 case Int64Type:{ 00601 Uint64 i64 = * get64(val); 00602 Uint32 hi = (i64 >> 32); 00603 Uint32 lo = (i64 & 0xFFFFFFFF); 00604 * (Uint32*)dst = htonl(key); dst += 4; 00605 * (Uint32*)dst = htonl(hi); dst += 4; 00606 * (Uint32*)dst = htonl(lo); dst += 4; 00607 } 00608 break; 00609 case StringType:{ 00610 const char * str = * getString(val); 00611 Uint32 len = strlen(str) + 1; 00612 * (Uint32*)dst = htonl(key); dst += 4; 00613 * (Uint32*)dst = htonl(len); dst += 4; 00614 memcpy(dst, str, len); 00615 memset(dst+len, 0, mod4(len) - len); 00616 dst += mod4(len); 00617 } 00618 break; 00619 case InvalidType: 00620 default: 00621 abort(); 00622 } 00623 } 00624 } 00625 00626 const Uint32 * sum = (Uint32*)_dst; 00627 const Uint32 len = ((Uint32*)dst) - sum; 00628 Uint32 chk = 0; 00629 for(i = 0; i<len; i++){ 00630 chk ^= htonl(sum[i]); 00631 } 00632 00633 * (Uint32*)dst = htonl(chk); dst += 4; 00634 return 4 * (len + 1); 00635 }
Here is the call graph for this function:

| Uint32 ConfigValues::pack | ( | UtilBuffer & | ) | const [inline] |
Definition at line 240 of file ConfigValues.hpp.
References buf, and getPackedSize().
Referenced by main(), and NDB_COMMAND().
00240 { 00241 Uint32 len = getPackedSize(); 00242 void * tmp = buf.append(len); 00243 if(tmp == 0){ 00244 return 0; 00245 } 00246 return pack(tmp, len); 00247 }
Here is the call graph for this function:

Here is the caller graph for this function:

friend class ConfigValuesFactory [friend] |
Definition at line 8 of file ConfigValues.hpp.
friend class ConstIterator [friend] |
Definition at line 74 of file ConfigValues.hpp.
friend class Iterator [friend] |
Definition at line 73 of file ConfigValues.hpp.
void* ConfigValues::m_data[1] [private] |
Definition at line 86 of file ConfigValues.hpp.
Uint32 ConfigValues::m_dataSize [private] |
Definition at line 81 of file ConfigValues.hpp.
Referenced by ConfigValues(), ConfigValuesFactory::ConfigValuesFactory(), ConfigValuesFactory::expand(), getString(), and ConfigValuesFactory::shrink().
Uint32 ConfigValues::m_int64Count [private] |
Definition at line 83 of file ConfigValues.hpp.
Referenced by ConfigValues(), get64(), and ConfigValuesFactory::put().
Uint32 ConfigValues::m_size [private] |
Definition at line 80 of file ConfigValues.hpp.
Referenced by ConfigValues(), ConfigValuesFactory::ConfigValuesFactory(), ConfigValuesFactory::expand(), ConfigValues::ConstIterator::get(), get64(), getByPos(), getPackedSize(), getString(), pack(), ConfigValuesFactory::put(), ConfigValues::Iterator::set(), and ConfigValuesFactory::shrink().
Uint32 ConfigValues::m_stringCount [private] |
Definition at line 82 of file ConfigValues.hpp.
Referenced by ConfigValues(), getString(), ConfigValuesFactory::put(), and ~ConfigValues().
Uint32 ConfigValues::m_values[1] [private] |
Definition at line 85 of file ConfigValues.hpp.
Referenced by ConfigValues(), ConfigValuesFactory::ConfigValuesFactory(), ConfigValues::ConstIterator::get(), get64(), getByPos(), getPackedSize(), getString(), pack(), ConfigValuesFactory::put(), and ConfigValues::Iterator::set().
1.4.7

