From 9db750f407ceeb5c1fab99414b074d289bfda179 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 11 Mar 2009 09:30:41 +0200 Subject: Add support for parsing/serialization of recursive types tests/cxx/hybrid/recursive/: new test --- libxsde/xsde/cxx/stack.hxx | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 libxsde/xsde/cxx/stack.hxx (limited to 'libxsde/xsde/cxx/stack.hxx') 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 +// 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 // size_t + +#include + +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 + +#endif // XSDE_CXX_STACK_HXX -- cgit v1.1