Beispiel #1
0
int ShzdApi::shzdSendInfoToTrade(dict data)
{
	CShZdMessage msg = CShZdMessage();

	//插入信息类型
	if (data.has_key("msgtype"))
	{
		object msgtype = data["msgtype"];
		extract<string> x(msgtype);
		if (x.check())
		{
			string typestr = x();
			msg.SetMsgType(typestr.c_str());
		}
	}
	
	//插入字段
	boost::python::list keyList = data.keys();
	boost::python::list valueList = data.values();

	for (int n = 0; n < len(keyList); n++)		
	{
		//声明
		int keyint = 0;
		string valuestr = "";
		
		//获取整数型的key
		object key = keyList[n];
		extract<string> x1(key);
		if (x1.check())
		{
			string keystr = x1();
			stringstream ss;
			ss << keystr;
			ss >> keyint;
		}

		//获取字符串的value
		object value = valueList[n];
		extract<string> x2(value);
		if (x2.check())
		{
			valuestr = x2();
		}

		//添加到msg中
		msg.SetTag(keyint, valuestr.c_str());
	}
object dict_values(dict data)
{
    return data.values();
}