|
My Project
|
for generating raw NPL output message. More...
#include <NPLMsgOut.h>
Public Member Functions | |
| CNPLMsgOut_gen (NPLMsgOut &msg, int nReservedSize=-1) | |
| the internal buffer reserved size. More... | |
| void | AddFirstLine (const char *method, const char *uri) |
| void | AddFirstLine (const NPLFileName &file_name, int file_id=-1) |
| void | AddHeaderPair (const char *name, const char *value) |
| add a header name value pair to the message. More... | |
| void | AddBody (const char *pData, int nSize=-1, int nCompressionlevel=0) |
| add binary data to the message body. More... | |
| void | AddMsgBody (const char *pMsg, int nSize=-1, int nCompressionlevel=0) |
| Add a message string to the message body. More... | |
Static Public Attributes | |
| static bool | g_enable_ansi_mode = true |
| whether the first line of the NPL protocol is in ansi code page. More... | |
for generating raw NPL output message.
It generates the messages like below. <verbatim> A (g1)script/hello.lua NPL/1.0 rts:r1 User-Agent:NPL
14:"hello world!" </verbatim> CNPLMsgOut_gen writer; writer.AddFirstLine(filename); writer.AddHeaderPair("rts", "r1"); writer.AddHeaderPair("User-Agent", "NPL"); writer.AddMsgBody("msg={\"hello world!"}"); writer.AddBody(""hello world!""); const string& msg_str = writer.ToString();
|
inline |
the internal buffer reserved size.
| void NPL::CNPLMsgOut_gen::AddBody | ( | const char * | pData, |
| int | nSize = -1, |
||
| int | nCompressionlevel = 0 |
||
| ) |
add binary data to the message body.
| pData | the binary data |
| nSize | number of bytes in data. if -1, pData is considered as a string,and strlen() is used. |
| nCompressionlevel | compression level, which is an integer in the range of -1 to 9. default to 0, which means no compression. We usually choose to compress using -1, when data is larger than a given threshold value. Lower compression levels result in faster execution, but less compression. Higher levels result in greater compression, but slower execution. The zlib constant Z_DEFAULT_COMPRESSION, equal to -1, provides a good compromise between compression and speed and is equivalent to level 6. Level 0 actually does no compression at all, and in fact expands the data slightly to produce the zlib format (it is not a byte-for-byte copy of the input). |
| void NPL::CNPLMsgOut_gen::AddFirstLine | ( | const NPLFileName & | file_name, |
| int | file_id = -1 |
||
| ) |
| file_id | if not -1, the filename will be sent as id |
| void NPL::CNPLMsgOut_gen::AddHeaderPair | ( | const char * | name, |
| const char * | value | ||
| ) |
add a header name value pair to the message.
| void NPL::CNPLMsgOut_gen::AddMsgBody | ( | const char * | pMsg, |
| int | nSize = -1, |
||
| int | nCompressionlevel = 0 |
||
| ) |
Add a message string to the message body.
| pMsg | if should be in the format "msg={some_data_here}" when transmitted, only "some_data_here" is added to the message body. |
| nSize | number of bytes in msg. if -1, msg is considered as a string,and strlen() is used. |
| nCompressionlevel | compression level, which is an integer in the range of -1 to 9. default to 0, which means no compression. We usually choose to compress using -1, when data is larger than a given threshold value. Lower compression levels result in faster execution, but less compression. Higher levels result in greater compression, but slower execution. The zlib constant Z_DEFAULT_COMPRESSION, equal to -1, provides a good compromise between compression and speed and is equivalent to level 6. Level 0 actually does no compression at all, and in fact expands the data slightly to produce the zlib format (it is not a byte-for-byte copy of the input). |
|
static |
1.8.12