编码就是将需要格式化的内容转换成对应类型写入缓冲区。
template < typename Arg >
void encode(Arg arg);
template < typename Arg >
void encode(Arg arg, uint8_t type_id);
void encode(char * arg);
void encode(char const * arg);
void encode(string_literal_t arg);
void encode_c_string(char const * arg, size_t length);
void resize_buffer_if_needed(size_t additional_bytes);
以下为具体代码
template < typename Arg >
void NanoLogLine::encode(Arg arg)
{
*reinterpret_cast<Arg*>(buffer()) = arg; 转换成参数类型写入缓冲区
m_bytes_used += sizeof(Arg); 对应的使用记录要增加对应类型的字节
}
针对