libcamgm
ByteBuffer.hpp
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | |
3 | _ _ _ _ __ _ |
4 | | | | | | \_/ | / \ | | |
5 | | | | | | |_| | / /\ \ | | |
6 | | |__ | | | | | | / ____ \ | |__ |
7 | |____||_| |_| |_|/ / \ \|____| |
8 | |
9 | core library |
10 | |
11 | (C) SUSE Linux Products GmbH |
12 \----------------------------------------------------------------------/
13 
14  File: ByteBuffer.hpp
15 
16  Maintainer: Michael Calmer
17 
18 /-*/
26 #ifndef CA_MGM_BYTEBUFFER_HPP
27 #define CA_MGM_BYTEBUFFER_HPP
28 
29 #include <ca-mgm/config.h>
30 #include <ca-mgm/PtrTypes.hpp>
31 #include <iostream>
32 extern "C"
33 {
34 #include <sys/types.h>
35 }
36 
37 namespace CA_MGM_NAMESPACE
38 {
39 
40  /*
41  * Forward declaration.
42  */
43  class ByteBufferImpl;
44 
45 
55  class ByteBuffer
56  {
57  public:
58 
62  ByteBuffer();
63 
72  ByteBuffer(const char *str);
73 
82  ByteBuffer(const char *ptr, size_t len);
83 
94  ByteBuffer(const ByteBuffer &buf);
95 
99  ~ByteBuffer();
100 
108  void clear();
109 
113  bool empty() const;
114 
120  size_t size() const;
121 
127  const char* data() const;
128 
136  char at(size_t pos) const;
137 
145  void append(const char *ptr, size_t len);
146 
153  void append(char c);
154 
155 #ifndef SWIG
156 
167  ByteBuffer& operator=(const ByteBuffer& buf);
168 
178  const char& operator[](size_t pos) const;
179 
189  char& operator[](size_t pos);
190 
202  ByteBuffer& operator+=(const ByteBuffer& buf);
203 
204 
205  // friends
206 
210  friend std::ostream& operator<<(std::ostream &out,
211  const ByteBuffer &buf);
212 
217  friend bool operator==(const ByteBuffer &l, const ByteBuffer &r);
218 
223  friend bool operator!=(const ByteBuffer &l, const ByteBuffer &r);
224 
229  friend bool operator<(const ByteBuffer &l, const ByteBuffer &r);
230 
235  friend bool operator>(const ByteBuffer &l, const ByteBuffer &r);
236 
241  friend bool operator<=(const ByteBuffer &l, const ByteBuffer &r);
242 
247  friend bool operator>=(const ByteBuffer &l, const ByteBuffer &r);
248 
255  friend ByteBuffer operator+(const ByteBuffer& b1, const ByteBuffer& b2);
256 
257 #endif
258 
259  private:
261  };
262 
263 } // End Of CA_MGM_NAMESPACE
264 #endif // CA_MGM_BYTEBUFFER_HPP
PathName operator+(const PathName &lname, const PathName &rname)
Definition: PathName.hpp:451
bool operator!=(const PathName &lname, const PathName &rname)
Definition: PathName.hpp:443
ca_mgm::RWCOW_pointer< ByteBufferImpl > m_impl
Definition: ByteBuffer.hpp:260
std::ostream & operator<<(std::ostream &ostr, const PathName &path)
Buffer for storing binary data.
Definition: ByteBuffer.hpp:55
bool operator==(const PathName &lname, const PathName &rname)
Definition: PathName.hpp:435