My Project
NPLWriter.h
1 #pragma once
2 #include "util/StringBuilder.h"
3 namespace NPL
4 {
5  template <typename StringBufferType = std::string>
6  class CNPLWriterT;
7 
9  typedef CNPLWriterT< ParaEngine::StringBuilder > CNPLBufWriter;
10 
12  typedef CNPLWriterT< std::string > CNPLWriter;
13 
14  using namespace std;
15 
39  template <typename StringBufferType>
40  class CNPLWriterT
41  {
42  public:
43  typedef StringBufferType Buffer_Type;
44 
46  CNPLWriterT(int nReservedSize = -1);
48  CNPLWriterT(Buffer_Type& buff_, int nReservedSize = -1);
49  ~CNPLWriterT();
50 
52  void Reset(int nReservedSize = -1);
53 
55  void BeginTable();
58  void WriteName(const char* name, bool bUseBrackets = false);
59 
61  void WriteValue(const char* value, bool bInQuotation=true);
63  void WriteValue(const char* buffer, int nSize, bool bInQuotation=true);
64  void WriteValue(const string& sStr, bool bInQuotation=true);
66  void WriteValue(double value);
68  void WriteNil();
69 
71  void EndTable();
72 
74  void Append(const char* text);
75  void Append(const char* pData, int nSize);
76  void Append(const string& sText);
81  char* AddMemBlock(int nSize);
82 
84  void WriteParamDelimiter(){ Append(";"); };
85 
87  const Buffer_Type& ToString() {return m_sCode;};
88  public:
89  // static strings.
90 
92  static const Buffer_Type& GetNilMessage();
93 
95  static const Buffer_Type& GetEmptyMessage();
96  private:
97  Buffer_Type& m_sCode;
98  Buffer_Type m_buf;
99  bool m_bBeginAssignment;
100  int m_nTableLevel;
101  };
102 }
103 
104 
const Buffer_Type & ToString()
get the current NPL code.
Definition: NPLWriter.h:87
define this to enable debugging of NPL code in visual studio
Definition: INPL.h:9
CNPLWriterT< std::string > CNPLWriter
using std::string for buffering
Definition: NPLWriter.h:12
void WriteParamDelimiter()
write ";"
Definition: NPLWriter.h:84
CNPLWriterT< ParaEngine::StringBuilder > CNPLBufWriter
using StringBuilder for buffering.
Definition: NPLWriter.h:6