From 18ef14486e46064f4317ab407c5fe0afa3209d4b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 4 Aug 2011 13:29:43 +0200 Subject: Add support for value wrappers Wrapper is a class that wraps another type. Examples of wrappers are various smart pointers, holders, etc. A wrapper can be transparent or it can handle the NULL semantics. The new odb::nullable class template is a NULL wrapper that helps to add the NULL semantics to a value type. New test: common/wrapper. --- common/wrapper/test.hxx | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 common/wrapper/test.hxx (limited to 'common/wrapper/test.hxx') diff --git a/common/wrapper/test.hxx b/common/wrapper/test.hxx new file mode 100644 index 0000000..68a8750 --- /dev/null +++ b/common/wrapper/test.hxx @@ -0,0 +1,53 @@ +// file : common/wrapper/test.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include // HAVE_TR1_MEMORY + +#include +#include // std::auto_ptr +#include + +#include +#include + +#ifdef HAVE_TR1_MEMORY +# include +#endif + +using odb::nullable; + +typedef nullable nullable_string; + +#ifdef HAVE_TR1_MEMORY +typedef std::tr1::shared_ptr tr1_nullable_string; +#endif + +#pragma db object +struct object +{ + #pragma db id auto + unsigned long id_; + + std::auto_ptr num; + + #pragma db null + std::auto_ptr str; + + nullable_string nstr; + std::vector nstrs; + +#ifdef HAVE_TR1_MEMORY + #pragma db null + tr1_nullable_string tr1_str; + + #pragma db value_null + std::vector tr1_strs; +#endif +}; + +#endif // TEST_HXX -- cgit v1.1