ui-gxmlcpp  1.4.5
Buffer.hpp
Go to the documentation of this file.
1 
10 #ifndef UI_GXML_BUFFER_HPP
11 #define UI_GXML_BUFFER_HPP
12 
13 // STDC++
14 #include <string>
15 
16 // C libraries
17 #include <libxml/tree.h>
18 
19 // C++ libraries
20 #include <ui-gxmlcpp/Exception.hpp>
21 #include <ui-gxmlcpp/Util.hpp>
22 
23 namespace UI {
24 namespace GXML {
25 
27 class Buffer: private UI::Util::auto_base<xmlBuffer>
28 {
29 public:
31  enum ErrorCode
32  {
33  Mem_
34  };
37 
38  Buffer();
39  ~Buffer();
40 
42  void concat(std::string const & text);
44  char const * getBuf() const;
46  int getSize() const;
47 
48  using UI::Util::auto_base<xmlBuffer>::get;
49 };
50 
52 class OutputBuffer: private Buffer
53 {
54 public:
55  OutputBuffer();
56 
57  using Buffer::ErrorCode;
58  using Buffer::Exception;
59  using Buffer::concat;
60 #ifdef LIBXML2_NEW_BUFFER
61  ~OutputBuffer();
63  char const * getBuf() const;
65  int getSize() const;
66 #else
67  using Buffer::getBuf;
68  using Buffer::getSize;
69 #endif
70 
72  xmlOutputBuffer * get() const;
74  xmlOutputBuffer * operator->() const;
75 
76 private:
77 #ifdef LIBXML2_NEW_BUFFER
78  xmlOutputBuffer * outbuf_;
79 #else
80  xmlOutputBuffer outbuf_;
81 #endif
82 };
83 
84 }}
85 #endif
UI::GXML::Buffer::concat
void concat(std::string const &text)
Append text.
Definition: Buffer.cpp:48
UI::GXML::OutputBuffer::get
xmlOutputBuffer * get() const
Get underlying pointer.
Definition: Buffer.cpp:106
UI::GXML::OutputBuffer::operator->
xmlOutputBuffer * operator->() const
Smart dereferencing.
Definition: Buffer.cpp:111
UI::GXML::Buffer
Abstraction for libxml2's xmlBuffer.
Definition: Buffer.hpp:28
UI
Namespace for all Schlund+Partner Code.
Definition: Buffer.cpp:30
UI::GXML::CodeException
Adding code facility to Exception.
Definition: Exception.hpp:35
UI::GXML::OutputBuffer
OutputBuffer holder class.
Definition: Buffer.hpp:53
UI::GXML::Buffer::getSize
int getSize() const
Get buffer content size.
Definition: Buffer.cpp:61
UI::GXML::OutputBuffer::getSize
int getSize() const
Get buffer content size.
Definition: Buffer.cpp:61
UI::GXML::Buffer::getBuf
char const * getBuf() const
Get buffer content address.
Definition: Buffer.cpp:56
UI::GXML::Buffer::Exception
CodeException< ErrorCode > Exception
Exceptions for this class.
Definition: Buffer.hpp:36
UI::GXML::Buffer::ErrorCode
ErrorCode
Error codes for exceptions.
Definition: Buffer.hpp:32
Util.hpp
Exception.hpp
UI::GXML::OutputBuffer::getBuf
char const * getBuf() const
Get buffer content address.
Definition: Buffer.cpp:56
Buffer.hpp