#include <SimpleProperties.hpp>
Public Types | |
| Uint32Value = 0 | |
| StringValue = 1 | |
| BinaryValue = 2 | |
| InvalidValue = 3 | |
| Eof = 0 | |
| Break = 1 | |
| TypeMismatch = 2 | |
| ValueTooLow = 3 | |
| ValueTooHigh = 4 | |
| UnknownKey = 5 | |
| OutOfMemory = 6 | |
| enum | ValueType { Uint32Value = 0, StringValue = 1, BinaryValue = 2, InvalidValue = 3 } |
| enum | UnpackStatus { Eof = 0, Break = 1, TypeMismatch = 2, ValueTooLow = 3, ValueTooHigh = 4, UnknownKey = 5, OutOfMemory = 6 } |
Static Public Member Functions | |
| static UnpackStatus | unpack (class Reader &it, void *dst, const SP2StructMapping[], Uint32 mapSz, bool ignoreMinMax, bool ignoreUnknownKeys) |
| static UnpackStatus | pack (class Writer &, const void *src, const SP2StructMapping[], Uint32 mapSz, bool ignoreMinMax) |
Classes | |
| class | Reader |
| struct | SP2StructMapping |
| class | Writer |
Definition at line 36 of file SimpleProperties.hpp.
UnpackStatus - Value returned from unpack
Definition at line 64 of file SimpleProperties.hpp.
00064 { 00065 Eof = 0, // Success, end of SimpleProperties object reached 00066 Break = 1, // Success 00067 TypeMismatch = 2, 00068 ValueTooLow = 3, 00069 ValueTooHigh = 4, 00070 UnknownKey = 5, 00071 OutOfMemory = 6 // Only used when packing 00072 };
Value types
Definition at line 41 of file SimpleProperties.hpp.
00041 { 00042 Uint32Value = 0, 00043 StringValue = 1, 00044 BinaryValue = 2, 00045 InvalidValue = 3 00046 };
| SimpleProperties::UnpackStatus SimpleProperties::pack | ( | class Writer & | , | |
| const void * | src, | |||
| const | SP2StructMapping[], | |||
| Uint32 | mapSz, | |||
| bool | ignoreMinMax | |||
| ) | [static] |
Definition at line 242 of file SimpleProperties.cpp.
References SimpleProperties::Writer::add(), BinaryValue, Eof, InvalidValue, SimpleProperties::SP2StructMapping::Length_Offset, SimpleProperties::SP2StructMapping::Offset, ok(), OutOfMemory, StringValue, strlen(), Uint32Value, ValueTooHigh, and ValueTooLow.
Referenced by NdbDictInterface::create_file(), NdbDictInterface::create_filegroup(), Dbdict::packFilegroupIntoPages(), and Dbdict::packFileIntoPages().
00244 { 00245 00246 const char * _src = (const char *)__src; 00247 00248 for(Uint32 i = 0; i<mapSz; i++){ 00249 bool ok = false; 00250 const char * src = _src + _map[i].Offset; 00251 switch(_map[i].Type){ 00252 case SimpleProperties::InvalidValue: 00253 ok = true; 00254 break; 00255 case SimpleProperties::Uint32Value:{ 00256 Uint32 val = * ((Uint32*)src); 00257 if(!ignoreMinMax){ 00258 if(val < _map[i].minValue) 00259 return ValueTooLow; 00260 if(val > _map[i].maxValue) 00261 return ValueTooHigh; 00262 } 00263 ok = it.add(_map[i].Key, val); 00264 } 00265 break; 00266 case SimpleProperties::BinaryValue:{ 00267 const char * src_len = _src + _map[i].Length_Offset; 00268 Uint32 len = *((Uint32*)src_len); 00269 if(!ignoreMinMax){ 00270 if(len == _map[i].maxValue) 00271 return ValueTooHigh; 00272 } 00273 ok = it.add(_map[i].Key, src, len); 00274 break; 00275 } 00276 case SimpleProperties::StringValue: 00277 if(!ignoreMinMax){ 00278 size_t len = strlen(src); 00279 if(len == _map[i].maxValue) 00280 return ValueTooHigh; 00281 } 00282 ok = it.add(_map[i].Key, src); 00283 break; 00284 } 00285 if(!ok) 00286 return OutOfMemory; 00287 } 00288 00289 return Eof; 00290 }
Here is the call graph for this function:

Here is the caller graph for this function:

| SimpleProperties::UnpackStatus SimpleProperties::unpack | ( | class Reader & | it, | |
| void * | dst, | |||
| const | SP2StructMapping[], | |||
| Uint32 | mapSz, | |||
| bool | ignoreMinMax, | |||
| bool | ignoreUnknownKeys | |||
| ) | [static] |
Definition at line 185 of file SimpleProperties.cpp.
References abort(), BinaryValue, Break, Eof, SimpleProperties::Reader::getKey(), SimpleProperties::Reader::getString(), SimpleProperties::Reader::getUint32(), SimpleProperties::Reader::getValueLen(), SimpleProperties::Reader::getValueType(), InvalidValue, key, SimpleProperties::Reader::next(), SimpleProperties::SP2StructMapping::Offset, StringValue, TypeMismatch, Uint32Value, UnknownKey, SimpleProperties::Reader::valid(), ValueTooHigh, and ValueTooLow.
Referenced by Dbdict::create_fg_prepare_start(), Dbdict::create_file_prepare_start(), Dbdict::execCREATE_INDX_REQ(), Dbdict::handleTabInfo(), Dbdict::handleTabInfoInit(), Restore::parse_table_description(), NdbDictInterface::parseFilegroupInfo(), NdbDictInterface::parseFileInfo(), Suma::Table::parseTable(), Backup::parseTableDescription(), NdbDictInterface::parseTableInfo(), DbUtil::prepareOperation(), and unpack().
00188 { 00189 do { 00190 if(!it.valid()) 00191 break; 00192 00193 bool found = false; 00194 Uint16 key = it.getKey(); 00195 for(Uint32 i = 0; i<mapSz; i++){ 00196 if(key == _map[i].Key){ 00197 found = true; 00198 if(_map[i].Type == InvalidValue) 00199 return Break; 00200 if(_map[i].Type != it.getValueType()) 00201 return TypeMismatch; 00202 00203 char * _dst = (char *)dst; 00204 _dst += _map[i].Offset; 00205 00206 switch(it.getValueType()){ 00207 case Uint32Value:{ 00208 const Uint32 val = it.getUint32(); 00209 if(!ignoreMinMax){ 00210 if(val < _map[i].minValue) 00211 return ValueTooLow; 00212 if(val > _map[i].maxValue) 00213 return ValueTooHigh; 00214 } 00215 * ((Uint32 *)_dst) = val; 00216 break; 00217 } 00218 case BinaryValue: 00219 case StringValue:{ 00220 unsigned len = it.getValueLen(); 00221 if(len < _map[i].minValue) 00222 return ValueTooLow; 00223 if(len > _map[i].maxValue) 00224 return ValueTooHigh; 00225 it.getString(_dst); 00226 break; 00227 } 00228 default: 00229 abort(); 00230 } 00231 break; 00232 } 00233 } 00234 if(!found && !ignoreUnknownKeys) 00235 return UnknownKey; 00236 } while(it.next()); 00237 00238 return Eof; 00239 }
Here is the call graph for this function:

Here is the caller graph for this function:

1.4.7

