aboutsummaryrefslogtreecommitdiff
path: root/odb/details/buffer.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'odb/details/buffer.hxx')
-rw-r--r--odb/details/buffer.hxx59
1 files changed, 59 insertions, 0 deletions
diff --git a/odb/details/buffer.hxx b/odb/details/buffer.hxx
new file mode 100644
index 0000000..4393114
--- /dev/null
+++ b/odb/details/buffer.hxx
@@ -0,0 +1,59 @@
+// file : odb/details/buffer.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_BUFFER_DETAILS_HXX
+#define ODB_BUFFER_DETAILS_HXX
+
+#include <new>
+#include <cstddef> // std::size_t
+
+namespace odb
+{
+ namespace details
+ {
+ class buffer
+ {
+ public:
+ ~buffer ()
+ {
+ if (data_)
+ operator delete (data_);
+ }
+
+ buffer ()
+ : capacity_ (512)
+ {
+ data_ = static_cast<char*> (operator new (capacity_));
+ }
+
+ char*
+ data ()
+ {
+ return data_;
+ }
+
+ const char*
+ data () const
+ {
+ return data_;
+ }
+
+ std::size_t
+ capacity () const
+ {
+ return capacity_;
+ }
+
+ void
+ capacity (std::size_t, std::size_t data_size = 0);
+
+ private:
+ char* data_;
+ std::size_t capacity_;
+ };
+ }
+}
+
+#endif // ODB_BUFFER_DETAILS_HXX