void BinarySerialize::addContainerSerializableElementMulti(void* _1, string tem) { //tem = tem.substr(4); AMEFEncoder enc; AMEFObject* object = (AMEFObject*)_1; object->addPacket(tem); }
void BinarySerialize::addContainerSerializableElementMulti(void* _1, const string& tem) { //tem = tem.substr(4); AMEFEncoder enc; AMEFObject* object = static_cast<AMEFObject*>(_1); object->addPacket(tem); }
void BinarySerialize::addObjectProperty(void* _1, string propName, string className, string t) { AMEFObject* object = (AMEFObject*)_1; object->addPacket(t, propName); }
void BinarySerialize::addObjectPrimitiveProperty(void* _1, string propName, string className, void* t) { AMEFObject* object = (AMEFObject*)_1; if(className=="std::string" || className=="string") { string tem = *(string*)t; object->addPacket(tem, propName); } else if(className=="char") { char tem = *(char*)t; object->addPacket(tem, propName); } else if(className=="unsigned char") { unsigned char tem = *(unsigned char*)t; object->addPacket(tem, propName); } else if(className=="int") { int tem = *(int*)t; object->addPacket(tem, propName); } else if(className=="unsigned int") { unsigned int tem = *(unsigned int*)t; object->addPacket(tem, propName); } else if(className=="short") { short tem = *(short*)t; object->addPacket(tem, propName); } else if(className=="unsigned short") { unsigned short tem = *(unsigned short*)t; object->addPacket(tem, propName); } else if(className=="long") { long tem = *(long*)t; object->addPacket(tem, propName); } else if(className=="unsigned long") { unsigned long tem = *(unsigned long*)t; object->addPacket(tem, propName); } else if(className=="long long") { long long tem = *(long long*)t; object->addPacket(tem, propName); } else if(className=="unsigned long long") { unsigned long long tem = *(unsigned long long*)t; object->addPacket(tem, propName); } else if(className=="float") { float tem = *(float*)t; object->addPacket(tem, propName); } else if(className=="double") { double tem = *(double*)t; object->addPacket(tem, propName); } else if(className=="long double") { long double tem = *(long double*)t; object->addPacket(tem, propName); } else if(className=="bool") { bool tem = *(bool*)t; object->addPacket(tem, propName); } else if(className=="Date") { string tem = *(string*)t; object->addPacket(tem, propName); } else if(className=="BinaryData") { string tem = *(string*)t; object->addPacket(tem, propName); } }
string BinarySerialize::serializePrimitive(string className, void* t) { string objXml; AMEFEncoder enc; AMEFObject object; if(className=="std::string" || className=="string") { string tem = *(string*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="char") { char tem = *(char*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="unsigned char") { unsigned char tem = *(unsigned char*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="int") { int tem = *(int*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="unsigned int") { unsigned int tem = *(unsigned int*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="short") { short tem = *(short*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="unsigned short") { unsigned short tem = *(unsigned short*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="long") { long tem = *(long*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="unsigned long") { unsigned long tem = *(unsigned long*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="long long") { long long tem = *(long long*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="unsigned long long") { unsigned long long tem = *(unsigned long long*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="float") { float tem = *(float*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="double") { double tem = *(double*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="long double") { long double tem = *(long double*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="bool") { bool tem = *(bool*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="Date") { string tem = *(string*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } else if(className=="BinaryData") { string tem = *(string*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); } return enc.encodeB(&object, false); }
void BinarySerialize::addContainerSerializableElement(void* _1, string tem) { AMEFEncoder enc; AMEFObject* object = (AMEFObject*)_1; object->addPacket(tem); }
string Serialize::_handleAllSerialization(string className,void *t) { string objXml; AMEFEncoder enc; AMEFObject object; if(className=="std::string" || className=="string") { string tem = *(string*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); //objXml = CastUtil::lexical_cast<string>(tem); } else if(className=="int") { int tem = *(int*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); //objXml = CastUtil::lexical_cast<string>(tem); } else if(className=="short") { short tem = *(short*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); //objXml = CastUtil::lexical_cast<string>(tem); } else if(className=="long") { long tem = *(long*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); //objXml = CastUtil::lexical_cast<string>(tem); } else if(className=="float") { float tem = *(float*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); //objXml = CastUtil::lexical_cast<string>(tem); } else if(className=="double") { double tem = *(double*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); //objXml = CastUtil::lexical_cast<string>(tem); } else if(className=="bool") { bool tem = *(bool*)t; object.addPacket(tem, className); objXml = enc.encodeB(&object, false); //objXml = CastUtil::lexical_cast<string>(tem); } else if(className=="Date") { DateFormat formt("yyyy-mm-dd hh:mi:ss"); object.addPacket(formt.format(*(Date*)t), className); objXml = enc.encodeB(&object, false); //objXml = formt.format(*(Date*)t); } else if(className=="BinaryData") { object.addPacket(BinaryData::serilaize(*(BinaryData*)t), className); objXml = enc.encodeB(&object, false); //objXml = BinaryData::serilaize(*(BinaryData*)t); } else if(className.find("std::vector<std::string,")!=string::npos || className.find("std::vector<string,")!=string::npos) { vector<string> *tt = (vector<string>*)t; objXml = serializevec<string>(*tt); } else if(className.find("std::vector<int,")!=string::npos) { vector<int> *tt = (vector<int>*)t; objXml = serializevec<int>(*tt); } else if(className.find("std::vector<short,")!=string::npos) { vector<short> *tt = (vector<short>*)t; objXml = serializevec<short>(*tt); } else if(className.find("std::vector<long,")!=string::npos) { vector<long> *tt = (vector<long>*)t; objXml = serializevec<long>(*tt); } else if(className.find("std::vector<double,")!=string::npos) { vector<double> *tt = (vector<double>*)t; objXml = serializevec<double>(*tt); } else if(className.find("std::vector<float,")!=string::npos) { vector<float> *tt = (vector<float>*)t; objXml = serializevec<float>(*tt); } else if(className.find("std::vector<bool,")!=string::npos) { vector<bool> *tt = (vector<bool>*)t; objXml = serializevec<bool>(*tt); } else if(className.find("std::vector<")!=string::npos) { StringUtil::replaceFirst(className,"std::vector<",""); string vtyp = className.substr(0,className.find(",")); return _servec(t,vtyp); } else if(className.find("std::list<std::string,")!=string::npos || className.find("std::list<string,")!=string::npos) { list<string> *tt = (list<string>*)t; objXml = serializelist<string>(*tt); } else if(className.find("std::list<int,")!=string::npos) { list<int> *tt = (list<int>*)t; objXml = serializelist<int>(*tt); } else if(className.find("std::list<long,")!=string::npos) { list<long> *tt = (list<long>*)t; objXml = serializelist<long>(*tt); } else if(className.find("std::list<short,")!=string::npos) { list<short> *tt = (list<short>*)t; objXml = serializelist<short>(*tt); } else if(className.find("std::list<double,")!=string::npos) { list<double> *tt = (list<double>*)t; objXml = serializelist<double>(*tt); } else if(className.find("std::list<float,")!=string::npos) { list<float> *tt = (list<float>*)t; objXml = serializelist<float>(*tt); } else if(className.find("std::list<bool,")!=string::npos) { list<bool> *tt = (list<bool>*)t; objXml = serializelist<bool>(*tt); } else if(className.find("std::list<")!=string::npos) { StringUtil::replaceFirst(className,"std::list<",""); string vtyp = className.substr(0,className.find(",")); return _serlis(t,vtyp); } else if(className.find("std::set<std::string,")!=string::npos || className.find("std::set<string,")!=string::npos) { set<string> *tt = (set<string>*)t; objXml = serializeset<string>(*tt); } else if(className.find("std::set<int,")!=string::npos) { set<int> *tt = (set<int>*)t; objXml = serializeset<int>(*tt); } else if(className.find("std::set<short,")!=string::npos) { set<short> *tt = (set<short>*)t; objXml = serializeset<short>(*tt); } else if(className.find("std::set<long,")!=string::npos) { set<long> *tt = (set<long>*)t; objXml = serializeset<long>(*tt); } else if(className.find("std::set<double,")!=string::npos) { set<double> *tt = (set<double>*)t; objXml = serializeset<double>(*tt); } else if(className.find("std::set<float,")!=string::npos) { set<float> *tt = (set<float>*)&t; objXml = serializeset<float>(*tt); } else if(className.find("std::set<bool,")!=string::npos) { set<bool> *tt = (set<bool>*)&t; objXml = serializeset<bool>(*tt); } else if(className.find("std::set<")!=string::npos) { StringUtil::replaceFirst(className,"std::set<",""); string vtyp = className.substr(0,className.find(",")); return _serset(t,vtyp); } else if(className.find("std::multiset<std::string,")!=string::npos || className.find("std::multiset<string,")!=string::npos) { multiset<string> *tt = (multiset<string>*)t; objXml = serializemultiset<string>(*tt); } else if(className.find("std::multiset<int,")!=string::npos) { multiset<int> *tt = (multiset<int>*)t; objXml = serializemultiset<int>(*tt); } else if(className.find("std::multiset<long,")!=string::npos) { multiset<long> *tt = (multiset<long>*)t; objXml = serializemultiset<long>(*tt); } else if(className.find("std::multiset<short,")!=string::npos) { multiset<short> *tt = (multiset<short>*)t; objXml = serializemultiset<short>(*tt); } else if(className.find("std::multiset<double,")!=string::npos) { multiset<double> *tt = (multiset<double>*)t; objXml = serializemultiset<double>(*tt); } else if(className.find("std::multiset<float,")!=string::npos) { multiset<float> *tt = (multiset<float>*)t; objXml = serializemultiset<float>(*tt); } else if(className.find("std::multiset<bool,")!=string::npos) { multiset<bool> *tt = (multiset<bool>*)t; objXml = serializemultiset<bool>(*tt); } else if(className.find("std::multiset<")!=string::npos) { StringUtil::replaceFirst(className,"std::multiset<",""); string vtyp = className.substr(0,className.find(",")); return _sermultiset(t,vtyp); } else if(className.find("std::queue<std::string,")!=string::npos || className.find("std::queue<string,")!=string::npos) { std::queue<string> *tt = (std::queue<string>*)t; objXml = serializeq<string>(*tt); } else if(className.find("std::queue<int,")!=string::npos) { std::queue<int> *tt = (std::queue<int>*)t; objXml = serializeq<int>(*tt); } else if(className.find("std::queue<short,")!=string::npos) { std::queue<short> *tt = (std::queue<short>*)t; objXml = serializeq<short>(*tt); } else if(className.find("std::queue<long,")!=string::npos) { std::queue<long> *tt = (std::queue<long>*)t; objXml = serializeq<long>(*tt); } else if(className.find("std::queue<double,")!=string::npos) { std::queue<double> *tt = (std::queue<double>*)t; objXml = serializeq<double>(*tt); } else if(className.find("std::queue<float,")!=string::npos) { std::queue<float> *tt = (std::queue<float>*)t; objXml = serializeq<float>(*tt); } else if(className.find("std::queue<bool,")!=string::npos) { std::queue<bool> *tt = (std::queue<bool>*)t; objXml = serializeq<bool>(*tt); } else if(className.find("std::queue<")!=string::npos) { StringUtil::replaceFirst(className,"std::queue<",""); string vtyp = className.substr(0,className.find(",")); return _serq(t,vtyp); } else if(className.find("std::deque<std::string,")!=string::npos || className.find("std::deque<string,")!=string::npos) { deque<string> *tt = (deque<string>*)t; objXml = serializedq<string>(*tt); } else if(className.find("std::deque<int,")!=string::npos) { deque<int> *tt = (deque<int>*)t; objXml = serializedq<int>(*tt); } else if(className.find("std::deque<long,")!=string::npos) { deque<long> *tt = (deque<long>*)t; objXml = serializedq<long>(*tt); } else if(className.find("std::deque<short,")!=string::npos) { deque<short> *tt = (deque<short>*)t; objXml = serializedq<short>(*tt); } else if(className.find("std::deque<double,")!=string::npos) { deque<double> *tt = (deque<double>*)t; objXml = serializedq<double>(*tt); } else if(className.find("std::deque<float,")!=string::npos) { deque<float> *tt = (deque<float>*)t; objXml = serializedq<float>(*tt); } else if(className.find("std::deque<bool,")!=string::npos) { deque<bool> *tt = (deque<bool>*)t; objXml = serializedq<bool>(*tt); } else if(className.find("std::deque<")!=string::npos) { StringUtil::replaceFirst(className,"std::deque<",""); string vtyp = className.substr(0,className.find(",")); return _serdq(t,vtyp); } else { return _ser(t,className); } return objXml; }
void BinarySerialize::addObjectProperty(void* _1, const string& propName, string className, const string& t) { AMEFObject* object = static_cast<AMEFObject*>(_1); object->addPacket(t, propName); }
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; }