My Project
NPLMsgOut.h
1 #pragma once
2 
3 #include "NPLWriter.h"
4 #include "NPLMsgHeader.h"
5 #include "util/PoolBase.h"
6 #include "util/StringBuilder.h"
7 
8 #include <boost/asio.hpp>
9 #include <boost/noncopyable.hpp>
10 #include <boost/enable_shared_from_this.hpp>
11 
12 
13 namespace NPL
14 {
24  class NPLMsgOut :
25  public ParaEngine::PoolBase<NPLMsgOut>,
27  private boost::noncopyable
28  {
29  public:
30  virtual ~NPLMsgOut(){};
31 
34 
36  bool empty() {return m_msg.empty();}
37 
40  };
41 
60  {
61  public:
65  static bool g_enable_ansi_mode;
66 
68  CNPLMsgOut_gen(NPLMsgOut& msg, int nReservedSize=-1):CNPLBufWriter(msg.GetBuffer(), nReservedSize){}
69 
70  void AddFirstLine(const char* method, const char* uri);
72  void AddFirstLine(const NPLFileName& file_name, int file_id=-1);
73 
75  void AddHeaderPair(const char* name, const char* value);
86  void AddBody(const char* pData, int nSize=-1, int nCompressionlevel = 0);
87 
88 
100  void AddMsgBody( const char* pMsg, int nSize=-1, int nCompressionlevel = 0);
101  };
102 }
103 
104 
105 
static bool g_enable_ansi_mode
whether the first line of the NPL protocol is in ansi code page.
Definition: NPLMsgOut.h:65
An outgoing message to be sent by a socket.
Definition: NPLMsgOut.h:24
bool empty()
if message is empty
Definition: NPLMsgOut.h:36
define this to enable debugging of NPL code in visual studio
Definition: INPL.h:9
a globally unique name of a NPL file name instance.
Definition: NPLCommon.h:26
CNPLWriterT< ParaEngine::StringBuilder > CNPLBufWriter
using StringBuilder for buffering.
Definition: NPLWriter.h:6
CNPLMsgOut_gen(NPLMsgOut &msg, int nReservedSize=-1)
the internal buffer reserved size.
Definition: NPLMsgOut.h:68
if one wants to create and delete many objects of the same type per frame, derive your class from Poo...
Definition: PoolBase.h:60
ParaEngine::StringBuilder & GetBuffer()
get the internal string buffer
Definition: NPLMsgOut.h:39
Definition: enum_maker.hpp:46
ParaEngine::StringBuilder m_msg
The content to be sent in the reply.
Definition: NPLMsgOut.h:30
single-threaded reference counted base class for boost::intrusive_ptr all boost::intrusive_ptr<T>, should derive from this class.
Definition: intrusive_ptr.h:75
A NON-thread-safe, mutable sequence of characters(Binary is also possible).
Definition: StringBuilder.h:9
for generating raw NPL output message.
Definition: NPLMsgOut.h:59
bool empty() const
Retrieves whether the builder is empty.
Definition: StringBuilder.h:86