diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-08-18 18:26:33 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-08-18 18:26:33 +0200 |
commit | dce5d0658e67ced4d5fa64f98f598b86917927a7 (patch) | |
tree | e910d86848a672ef4d0e3977d351e21d3f633227 /odb/details/buffer.hxx | |
parent | 854af2dbb1ee01f6e1c8d4f8f513ff2bad7da4f0 (diff) |
Move buffer to the details namespace
Diffstat (limited to 'odb/details/buffer.hxx')
-rw-r--r-- | odb/details/buffer.hxx | 59 |
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 |