quickfast 编解码_quickfast解析中国的fastfix包

#include //注,解析未完善,仅解析上海深圳所需!!!,喜欢大而全的可以去用xerces来解析。

namespace QuickFAST

{

namespace Codecs

{

//具体的解析函数

bool parse(SegmentBodyPtr body,pugi::xml_node &node_item);

bool parseOp(FieldInstructionPtr field,pugi::xml_node &node_item)

{

pugi::xml_node nodeop=node_item.first_child();

if(nodeop.empty())

return true;

FieldOpPtr op;

std::string opname=nodeop.name();

if(opname=="increment")

op.reset(new FieldOpIncrement());

else if(opname=="default")

op.reset(new FieldOpDefault());

else if(opname=="copy")

op.reset(new FieldOpCopy());

else if(opname=="delta")

op.reset(new FieldOpDelta());

else if(opname=="constant")

{

op.reset(new FieldOpConstant());

}

else

{

return true;

}

std::string dictionary=nodeop.attribute("dictionary").value();

if(!dictionary.empty())

{

op->setDictionaryName(dictionary);

}

std::string key=nodeop.attribute("key").value();;

if(!key.empty())

{

op->setKey(key);

std::string nsKey=nodeop.attribute("nskey").value();

if(!nsKey.empty())

{

op->setKeyNamespace(nsKey);

}

}

std::string value=nodeop.attribute("value").value();

if(!value.empty())

{

op->setValue(value);

}

std::string pmapBitStr=nodeop.attribute("pmap").value();

if(!pmapBitStr.empty())

{

size_t pmapBit = atoi(pmapBitStr.c_str());

op->setPMapBit(pmapBit);

}

field->setFieldOp(op);

return true;

}

bool parseLength(std::string &tag,SegmentBodyPtr body,pugi::xml_node &node_item)

{

std::string name=node_item.attribute("name").value();

std::string ns=node_item.attribute("ns").value();

FieldInstructionPtr field(new FieldInstructionUInt32(name, ns));

std::string id=node_item.attribute("id").value();

if (!id.empty())

{

field->setId(atoi(id.c_str()));

}

std::string presence=node_item.attribute("presence").value();

if(!presence.empty())

{

field->setPresence(presence == "mandatory");

}

parseOp(field,node_item);

body->allowLengthField();

body->addLengthInstruction(field);

return true;

}

bool parseInt8(std::string &tag,SegmentBodyPtr body,pugi::xml_node &node_item)

{

std::string name=node_item.attribute("name").value();

std::string ns=node_item.attribute("ns").value();

FieldInstructionPtr field(new FieldInstructionInt8(name, ns));

std::string id=node_item.attribute("id").value();

if (!id.empty())

{

field->setId(atoi(id.c_str()));

}

std::string presence=node_item.attribute("presence").value();

if(!presence.empty())

{

field->setPresence(presence == "mandatory");

}

parseOp(field,node_item);

body->addInstruction(field);

return true;</

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值