Example #1
0
bool BinarySerialize::isValidClassNamespace(void* _1, string className, string namespc, bool iscontainer)
{
	StringUtil::replaceAll(namespc, "::", "_");
	StringUtil::replaceAll(className, "std::", "");
	StringUtil::replaceAll(className, "::", "_");
	StringUtil::replaceAll(className, "<", "-");
	StringUtil::replaceAll(className, ">", "-");
	if(className.at(className.length()-1)=='-')
		className = className.substr(0, className.length()-1);
	if(className.find('-')!=string::npos)
	{
		string pre = className.substr(0, className.find_last_of("-")+1);
		className = className.substr(className.find_last_of("-")+1);
		className = pre + namespc + className;
	}
	else
		className = namespc + className;
	AMEFObject* element = (AMEFObject*)_1;
	if(element->getNameStr()!=className || (iscontainer &&  element->getPackets().size()==0))
		return false;
	return true;
}
Example #2
0
void* BinarySerialize::getObjectPrimitiveValue(void* _1, string className, string propName)
{
	AMEFObject* root = (AMEFObject*)_1;
	if((className=="signed" || className=="int" || className=="signed int") && root->getNameStr()==propName)
	{
		int *vt = new int;
		*vt = root->getIntValue();
		return vt;
	}
	else if((className=="unsigned" || className=="unsigned int") && root->getNameStr()==propName)
	{
		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") && root->getNameStr()==propName)
	{
		short *vt = new short;
		*vt = root->getShortValue();
		return vt;
	}
	else if((className=="unsigned short" || className=="unsigned short int") && root->getNameStr()==propName)
	{
		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") && root->getNameStr()==propName)
	{
		long *vt = new long;
		*vt = root->getLongLongValue();
		return vt;
	}
	else if((className=="unsigned long" || className=="unsigned long int") && root->getNameStr()==propName)
	{
		long *vt = new long;
		*vt = root->getLongLongValue();
		return vt;
	}
	else if((className=="long long" || className=="long long int" || className=="signed long long int") && root->getNameStr()==propName)
	{
		long long *vt = new long long;
		*vt = root->getULongLongValue();
		return vt;
	}
	else if((className=="unsigned long long" || className=="unsigned long long int") && root->getNameStr()==propName)
	{
		unsigned long long *vt = new unsigned long long;
		*vt = root->getULongLongValue();
		return vt;
	}
	else if((className=="char" || className=="signed char") && root->getNameStr()==propName)
	{
		char *vt = new char;
		*vt = root->getCharValue();
		return vt;
	}
	else if(className=="unsigned char" && root->getNameStr()==propName)
	{
		unsigned char *vt = new unsigned char;
		*vt = root->getUCharValue();
		return vt;
	}
	else if(className=="Date" && root->getNameStr()==propName)
	{
		DateFormat formt("yyyy-mm-dd hh:mi:ss");
		return formt.parse(root->getValueStr());
	}
	else if(className=="BinaryData" && root->getNameStr()==propName)
	{
		return BinaryData::unSerilaize(root->getValueStr());
	}
	else if(className=="float" && root->getNameStr()==propName)
	{
		float *vt = new float;
		*vt = root->getFloatValue();
		return vt;
	}
	else if(className=="double" && root->getNameStr()==propName)
	{
		double *vt = new double;
		*vt = root->getDoubleValue();
		return vt;
	}
	else if(className=="long double" && root->getNameStr()==propName)
	{
		long double *vt = new long double;
		*vt = root->getLongDoubleValue();
		return vt;
	}
	else if(className=="bool" && root->getNameStr()==propName)
	{
		bool *vt = new bool;
		*vt = root->getBoolValue();
		return vt;
	}
	else if((className=="std::string" || className=="string") && root->getNameStr()==propName)
	{
		string *vt = new string;
		*vt = root->getValueStr();
		return vt;
	}
	return NULL;
}
Example #3
0
void* Serialize::_handleAllUnSerialization(string objXml,string className)
{
	AMEFDecoder dec;
	AMEFObject* root = dec.decodeB(objXml, true, false);
	if(root==NULL)
		return NULL;
	if(className=="std::string" || className=="string" || className=="int" || className=="short" ||
					className=="bool" || className=="long" || className=="float" || className=="double")
	{
		root = root->getPackets().at(0);
		if(className=="int" && className==root->getNameStr())
		{
			int *vt = new int;
			*vt = root->getIntValue();
			return vt;
		}
		else if(className=="short" && className==root->getNameStr())
		{
			short *vt = new short;
			*vt = root->getShortValue();
			return vt;
		}
		else if(className=="long" && className==root->getNameStr())
		{
			long *vt = new long;
			*vt = root->getLongValue();
			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=="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;
		}
	}
	else if(root->getNameStr()!="")
	{
		if(root->getNameStr().find("vector<")==0)
		{
			return unserializevec(root, objXml);
		}
		else if(root->getNameStr().find("set<")==0)
		{
			return unserializeset(root, objXml);
		}
		else if(root->getNameStr().find("multiset<")==0)
		{
			return unserializemultiset(root, objXml);
		}
		else if(root->getNameStr().find("list<")==0)
		{
			return unserializelist(root, objXml);
		}
		else if(root->getNameStr().find("std::queue<")==0 || root->getNameStr().find("queue<")==0)
		{
			return unserializeq(root, objXml);
		}
		else if(root->getNameStr().find("deque<")==0)
		{
			return unserializedq(root, objXml);
		}
	}
	return _unser(objXml,className);
}
Example #4
0
string BinarySerialize::getUnserializableClassName(void* _1, string className)
{
	AMEFObject* root = (AMEFObject*)_1;
	return root->getNameStr();
}
Example #5
0
string BinarySerialize::getUnserializableClassName(void* _1, const string& className)
{
	AMEFObject* root = static_cast<AMEFObject*>(_1);
	return root->getNameStr();
}