void BinarySerialize::startObjectSerialization(void* _1, const string& className) { AMEFEncoder enc; AMEFObject* object = static_cast<AMEFObject*>(_1); object->setName(className); }
void* BinarySerialize::getPrimitiveValue(void* _1, const string& className) { AMEFObject* root = static_cast<AMEFObject*>(_1); root = root->getPackets().at(0); if((className=="signed" || className=="int" || className=="signed int") && className==root->getNameStr()) { int *vt = new int; *vt = root->getIntValue(); return vt; } else if((className=="unsigned" || className=="unsigned int") && className==root->getNameStr()) { unsigned int *vt = new unsigned int; *vt = root->getUIntValue(); return vt; } else if((className=="short" || className=="short int" || className=="signed short" || className=="signed short int") && className==root->getNameStr()) { short *vt = new short; *vt = root->getShortValue(); return vt; } else if((className=="unsigned short" || className=="unsigned short int") && className==root->getNameStr()) { unsigned short *vt = new unsigned short; *vt = root->getUShortValue(); return vt; } else if((className=="long" || className=="long int" || className=="signed long" || className=="signed long int") && className==root->getNameStr()) { long *vt = new long; *vt = root->getLongLongValue(); return vt; } else if((className=="unsigned long" || className=="unsigned long int") && root->getNameStr()==className) { long *vt = new long; *vt = root->getLongLongValue(); return vt; } else if((className=="long long" || className=="long long int") && className==root->getNameStr()) { long long *vt = new long long; *vt = root->getULongLongValue(); return vt; } else if((className=="unsigned long long" || className=="unsigned long long int") && className==root->getNameStr()) { unsigned long long *vt = new unsigned long long; *vt = root->getULongLongValue(); return vt; } else if((className=="char" || className=="signed char") && className==root->getNameStr()) { char *vt = new char; *vt = root->getCharValue(); return vt; } else if(className=="unsigned char" && className==root->getNameStr()) { unsigned char *vt = new unsigned char; *vt = root->getUCharValue(); return vt; } else if(className=="Date" && className==root->getNameStr()) { DateFormat formt("yyyy-mm-dd hh:mi:ss"); return formt.parse(root->getValueStr()); } else if(className=="BinaryData" && className==root->getNameStr()) { return BinaryData::unSerilaize(root->getValueStr()); } else if(className=="float" && className==root->getNameStr()) { float *vt = new float; *vt = root->getFloatValue(); return vt; } else if(className=="double" && className==root->getNameStr()) { double *vt = new double; *vt = root->getDoubleValue(); return vt; } else if(className=="long double" && className==root->getNameStr()) { long double *vt = new long double; *vt = root->getLongDoubleValue(); return vt; } else if(className=="bool" && className==root->getNameStr()) { bool *vt = new bool; *vt = root->getBoolValue(); return vt; } else if((className=="std::string" || className=="string") && className==root->getNameStr()) { string *vt = new string; *vt = root->getValueStr(); return vt; } return NULL; }
void* BinarySerialize::getObjectProperty(void* _1, const int& counter) { AMEFObject* element = static_cast<AMEFObject*>(_1); return element->getPackets().at(counter); }
int BinarySerialize::getContainerSize(void* _1) { AMEFObject* root = static_cast<AMEFObject*>(_1); return root->getPackets().size(); }
string BinarySerialize::getUnserializableClassName(void* _1, const string& className) { AMEFObject* root = static_cast<AMEFObject*>(_1); return root->getNameStr(); }
void BinarySerialize::addPrimitiveElementToContainer(void* _1, const int& counter, const string& className, void* cont, const string& container) { AMEFDecoder dec; AMEFObject* root = static_cast<AMEFObject*>(_1); AMEFObject* root2 = dec.decodeB(root->getPackets().at(counter)->getValue(), true); if(className=="std::string" || className=="string") { string retVal = root2->getPackets().at(0)->getValueStr(); addValueToNestedContainer(container, retVal, cont); } else if(className=="int") { int retVal = root2->getPackets().at(0)->getIntValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="short") { short retVal = root2->getPackets().at(0)->getShortValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="long") { long retVal = root2->getPackets().at(0)->getLongValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="long long") { long long retVal = root2->getPackets().at(0)->getLongLongValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="long double") { long double retVal = root2->getPackets().at(0)->getLongDoubleValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="unsigned int") { unsigned int retVal = root2->getPackets().at(0)->getUIntValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="unsigned short") { unsigned short retVal = root2->getPackets().at(0)->getUShortValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="unsigned long") { unsigned long retVal = root2->getPackets().at(0)->getULongValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="unsigned long long") { unsigned long long retVal = root2->getPackets().at(0)->getULongLongValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="float") { float retVal = root2->getPackets().at(0)->getFloatValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="double") { double retVal = root2->getPackets().at(0)->getDoubleValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="bool") { bool retVal = root2->getPackets().at(0)->getBoolValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="char") { char retVal = root2->getPackets().at(0)->getCharValue(); addValueToNestedContainer(container, retVal, cont); } else if(className=="unsigned char") { unsigned char retVal = root2->getPackets().at(0)->getUCharValue(); addValueToNestedContainer(container, retVal, cont); } }
string BinarySerialize::elementToSerializedString(void* _1, const int& counter) { AMEFObject* object = static_cast<AMEFObject*>(_1); return object->getPackets().at(counter)->getValueStr(); }
void BinarySerialize::addContainerSerializableElement(void* _1, const string& tem) { AMEFEncoder enc; AMEFObject* object = static_cast<AMEFObject*>(_1); object->addPacket(tem); }
void BinarySerialize::startContainerSerialization(void* _1, const string& className, const string& container) { AMEFEncoder enc; AMEFObject* object = static_cast<AMEFObject*>(_1); object->setName(container+"-"+className); }
AMEFObject* AMEFDecoder::decodeSinglePacketB(string buffer,bool ignoreName) { char type = (char)buffer[position]; AMEFObject *jDBObject = NULL; int st, en; if(type==AMEFObject::NULL_STRING || type==AMEFObject::NULL_DATE || type==AMEFObject::NULL_NUMBER || type==AMEFObject::NULL_BOOL || type==AMEFObject::NULL_CHAR) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; } else if(type==AMEFObject::STRING_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; int lengthm = AMEFObject::charArrayToInt(buffer,position,4); position += 4; string value = buffer.substr(position,lengthm); jDBObject->setValue(value); position += lengthm; } else if(type==AMEFObject::STRING_65536_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; int lengthm = AMEFObject::charArrayToInt(buffer,position,2); position += 2; string value = buffer.substr(position,lengthm); jDBObject->setValue(value); position += lengthm; } else if(type==AMEFObject::STRING_16777216_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; int lengthm = AMEFObject::charArrayToInt(buffer,position,3); position += 3; string value = buffer.substr(position,lengthm); jDBObject->setValue(value); position += lengthm; } else if(type==AMEFObject::DATE_TYPE || type==AMEFObject::STRING_256_TYPE || type==AMEFObject::DOUBLE_FLOAT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; int lengthm = AMEFObject::charArrayToInt(buffer,position,1); position++; string value = buffer.substr(position,lengthm); jDBObject->setValue(value); position += lengthm; } else if(type==AMEFObject::VERY_SMALL_INT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; jDBObject->pushChar(buffer[position]); position += 1; } else if(type==AMEFObject::SMALL_INT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; jDBObject->pushChar(buffer[position]); jDBObject->pushChar(buffer[position+1]); position += 2; } else if(type==AMEFObject::BIG_INT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; jDBObject->pushChar(buffer[position]); jDBObject->pushChar(buffer[position+1]); jDBObject->pushChar(buffer[position+2]); position += 3; } else if(type==AMEFObject::INT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; jDBObject->pushChar(buffer[position]); jDBObject->pushChar(buffer[position+1]); jDBObject->pushChar(buffer[position+2]); jDBObject->pushChar(buffer[position+3]); position += 4; } else if(type==AMEFObject::VS_LONG_INT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; jDBObject->pushChar(buffer[position]); jDBObject->pushChar(buffer[position+1]); jDBObject->pushChar(buffer[position+2]); jDBObject->pushChar(buffer[position+3]); jDBObject->pushChar(buffer[position+4]); position += 5; } else if(type==AMEFObject::S_LONG_INT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; jDBObject->pushChar(buffer[position]); jDBObject->pushChar(buffer[position+1]); jDBObject->pushChar(buffer[position+2]); jDBObject->pushChar(buffer[position+3]); jDBObject->pushChar(buffer[position+4]); jDBObject->pushChar(buffer[position+5]); position += 6; } else if(type==AMEFObject::B_LONG_INT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; jDBObject->pushChar(buffer[position]); jDBObject->pushChar(buffer[position+1]); jDBObject->pushChar(buffer[position+2]); jDBObject->pushChar(buffer[position+3]); jDBObject->pushChar(buffer[position+4]); jDBObject->pushChar(buffer[position+5]); jDBObject->pushChar(buffer[position+6]); position += 7; } else if(type==AMEFObject::LONG_INT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; jDBObject->pushChar(buffer[position]); jDBObject->pushChar(buffer[position+1]); jDBObject->pushChar(buffer[position+2]); jDBObject->pushChar(buffer[position+3]); jDBObject->pushChar(buffer[position+4]); jDBObject->pushChar(buffer[position+5]); jDBObject->pushChar(buffer[position+6]); jDBObject->pushChar(buffer[position+7]); position += 8; } else if(type==AMEFObject::BOOLEAN_TYPE || type==AMEFObject::CHAR_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; jDBObject->pushChar(buffer[position]); position += 1; } else if(type==AMEFObject::VS_OBJECT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; position++; while(position<(int)buffer.length()) { AMEFObject *obj = decodeSinglePacketB(buffer,ignoreName); jDBObject->addPacket(obj); } } else if(type==AMEFObject::S_OBJECT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; position += 2; while(position<(int)buffer.length()) { AMEFObject* obj = decodeSinglePacketB(buffer,ignoreName); jDBObject->addPacket(obj); } } else if(type==AMEFObject::B_OBJECT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; position += 3; while(position<(int)buffer.length()) { AMEFObject* obj = decodeSinglePacketB(buffer,ignoreName); jDBObject->addPacket(obj); } } else if(type==AMEFObject::OBJECT_TYPE) { jDBObject = new AMEFObject(); jDBObject->setType(type); if(!ignoreName) { decodeObjectName(buffer, jDBObject); } else position++; position += 4; while(position<(int)buffer.length()) { AMEFObject* obj = decodeSinglePacketB(buffer,ignoreName); jDBObject->addPacket(obj); } } return jDBObject; }