diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2009-03-11 09:30:41 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2009-03-11 09:30:41 +0200 |
commit | 9db750f407ceeb5c1fab99414b074d289bfda179 (patch) | |
tree | eb1a5e52ebf84d79d378d5ab2ae56372028776e0 /libxsde/xsde/cxx/stack.hxx | |
parent | bc628cff98a1d90d4ee293f22979db56b4ed0695 (diff) |
Add support for parsing/serialization of recursive types
tests/cxx/hybrid/recursive/: new test
Diffstat (limited to 'libxsde/xsde/cxx/stack.hxx')
-rw-r--r-- | libxsde/xsde/cxx/stack.hxx | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/libxsde/xsde/cxx/stack.hxx b/libxsde/xsde/cxx/stack.hxx new file mode 100644 index 0000000..f58b1c7 --- /dev/null +++ b/libxsde/xsde/cxx/stack.hxx @@ -0,0 +1,83 @@ +// file : xsde/cxx/stack.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef XSDE_CXX_STACK_HXX +#define XSDE_CXX_STACK_HXX + +#include <stddef.h> // size_t + +#include <xsde/cxx/config.hxx> + +namespace xsde +{ + namespace cxx + { + // POD stack with pre-allocated first element. You may + // need to pad your elements to get the proper alignment. + // + struct stack + { +#ifndef XSDE_EXCEPTIONS + enum error + { + error_none, + error_no_memory + }; +#endif + + ~stack (); + stack (size_t element_size, void* first_element); + + private: + stack (stack&); + stack& operator= (stack&); + + public: + void + pop (); + +#ifdef XSDE_EXCEPTIONS + void +#else + error +#endif + push (); + + void* + top (); + + void + clear (); + + bool + empty () const; + + size_t + size () const; + + size_t + element_size () const; + + private: +#ifdef XSDE_EXCEPTIONS + void +#else + error +#endif + grow (); + + private: + size_t el_size_; + void* first_; + char* data_; + size_t size_; + size_t capacity_; + }; + } +} + +#include <xsde/cxx/stack.ixx> + +#endif // XSDE_CXX_STACK_HXX |