FIX 4.0 Demo 1.0
Loading...
Searching...
No Matches
fix40::FixCodec Class Reference

FIX 消息编解码器 More...

#include <fix_codec.hpp>

Collaboration diagram for fix40::FixCodec:
Collaboration graph

Public Member Functions

std::string encode (FixMessage &msg) const
 FixMessage 编码为 FIX 协议字符串
 
FixMessage decode (const std::string &raw) const
 将 FIX 协议字符串解码为 FixMessage 对象
 

Detailed Description

FIX 消息编解码器

负责 FIX 消息的序列化(编码)和反序列化(解码)。

编码流程
  1. 自动添加 SendingTime (52)
  2. 按标准顺序构造消息头
  3. 计算并设置 BodyLength (9)
  4. 计算并附加 CheckSum (10)
解码流程
  1. 校验 CheckSum
  2. 解析所有字段
  3. 校验 BodyLength
FIX 消息格式
8=FIX.4.0|9=BodyLength|35=MsgType|49=Sender|56=Target|34=SeqNum|52=Time|...|10=Checksum|
其中 | 代表 SOH 分隔符

Member Function Documentation

◆ decode()

FixMessage fix40::FixCodec::decode ( const std::string &  raw) const
inline

将 FIX 协议字符串解码为 FixMessage 对象

Parameters
raw原始 FIX 消息字符串
Returns
FixMessage 解码后的消息对象
Exceptions
std::runtime_errorCheckSum 校验失败、BodyLength 不匹配或格式错误时抛出
Here is the call graph for this function:

◆ encode()

std::string fix40::FixCodec::encode ( FixMessage msg) const
inline

FixMessage 编码为 FIX 协议字符串

Parameters
msg要编码的消息对象(会被修改以添加时间戳等字段)
Returns
std::string 编码后的 FIX 消息字符串
Note
自动计算并设置 BodyLength 和 CheckSum
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: