C/C++ User's Journal STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ... ATLSTL - where the Standard Template Library meets the Active Template Library COMSTL - where the Standard Template Library meets the Component Object Model
Synesis Software InetSTL - where the Standard Template Library meets the Internet UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

/include/recls/cpp/recls.hpp

Go to the documentation of this file.
00001 /* 
00002  * File:        recls/cpp/recls.hpp
00003  *
00004  * Purpose:     recls C++ mapping.
00005  *
00006  * Created:     18th August 2003
00007  * Updated:     24th December 2005
00008  *
00009  * Home:        http://recls.org/
00010  *
00011  * Copyright (c) 2003-2005, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without 
00015  * modification, are permitted provided that the following conditions are met:
00016  *
00017  * - Redistributions of source code must retain the above copyright notice, this
00018  *   list of conditions and the following disclaimer. 
00019  * - Redistributions in binary form must reproduce the above copyright notice,
00020  *   this list of conditions and the following disclaimer in the documentation
00021  *   and/or other materials provided with the distribution.
00022  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
00023  *   any contributors may be used to endorse or promote products derived from
00024  *   this software without specific prior written permission.
00025  *
00026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036  * POSSIBILITY OF SUCH DAMAGE.
00037  *
00038  * 
00039 
00040 
00041 #ifndef RECLS_INCL_RECLS_CPP_HPP_RECLSHPP
00042 #define RECLS_INCL_RECLS_CPP_HPP_RECLSHPP
00043 
00044 /* File version */
00045 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00046 # define RECLS_VER_RECLS_CPP_HPP_RECLSHPP_MAJOR     3
00047 # define RECLS_VER_RECLS_CPP_HPP_RECLSHPP_MINOR     0
00048 # define RECLS_VER_RECLS_CPP_HPP_RECLSHPP_REVISION  2
00049 # define RECLS_VER_RECLS_CPP_HPP_RECLSHPP_EDIT      21
00050 #endif /* !RECLS_DOCUMENTATION_SKIP_SECTION */
00051 
00056 /* 
00057  * Includes
00058  */
00059 
00060 #include <recls/recls.h>
00061 
00062 #if RECLS_VER < RECLS_VER_1_9_1
00063 # error The recls C++ mapping now requires version 1.9.1 or later of the recls C API
00064 #endif /* RECLS_VER < 1.9.1 */
00065 
00066 #include <stlsoft/stlsoft.h>    /* If the compiler cannot find this, you are not using STLSoft 1.9.1 or later, as required. */
00067 #if !defined(_STLSOFT_VER_1_9_1)
00068 # error STLSoft version 1.9.1 or greater required. (www.stlsoft.org/downloads.html)
00069 #endif /* STLSoft version */
00070 
00071 #ifdef RECLS_CPP_STRING_HEADER
00072 # include RECLS_CPP_STRING_HEADER
00073 #else
00074 # include <string>
00075 #endif /* RECLS_STRING_HEADER */
00076 
00077 #if defined(RECLS_COMPILER_IS_DMC)
00078 # include <stlsoft/iterator.hpp>  // For library detection
00079 #endif /* RECLS_COMPILER_IS_DMC */
00080 
00081 #ifdef RECLS_CPP_METHOD_PROPERTY_SUPPORT
00082 # undef RECLS_CPP_METHOD_PROPERTY_SUPPORT
00083 #endif /* RECLS_CPP_METHOD_PROPERTY_SUPPORT */
00084 
00085 #if defined(RECLS_CPP_FORCE_METHOD_PROPERTY_SUPPORT)
00086 # define RECLS_CPP_METHOD_PROPERTY_SUPPORT
00087 #elif defined(RECLS_CPP_NO_METHOD_PROPERTY_SUPPORT)
00088  /* Do not define RECLS_CPP_METHOD_PROPERTY_SUPPORT */
00089 #else /* ? RECLS_CPP_???_METHOD_PROPERTY_SUPPORT */
00090 # if defined(STLSOFT_COMPILER_IS_BORLAND)
00091  /* Do not define RECLS_CPP_METHOD_PROPERTY_SUPPORT */
00092 # elif defined(STLSOFT_COMPILER_IS_DMC)
00093  /* Do not define RECLS_CPP_METHOD_PROPERTY_SUPPORT for the current version, as
00094   * it causes an ICE, even though DMC++ does support properties in general
00095   */
00096 /* #  define RECLS_CPP_METHOD_PROPERTY_SUPPORT */
00097 # elif defined(STLSOFT_COMPILER_IS_GCC) && \
00098        (   __GNUC__ >= 4 || \
00099            (   __GNUC__ == 3 && \
00100                __GNUC_MINOR__ >= 3))
00101 #  define RECLS_CPP_METHOD_PROPERTY_SUPPORT
00102 # elif defined(STLSOFT_COMPILER_IS_INTEL)
00103 #  define RECLS_CPP_METHOD_PROPERTY_SUPPORT
00104 # elif defined(STLSOFT_COMPILER_IS_MSVC)
00105 #  if _MSC_VER >= 1310
00106 #   define RECLS_CPP_METHOD_PROPERTY_SUPPORT
00107 #  endif /* _MSC_VER */
00108 # elif defined(STLSOFT_COMPILER_IS_MWERKS)
00109 #  define RECLS_CPP_METHOD_PROPERTY_SUPPORT
00110 # endif /* compiler */
00111 #endif /* RECLS_CPP_???_METHOD_PROPERTY_SUPPORT */
00112 
00113 #ifdef RECLS_CPP_METHOD_PROPERTY_SUPPORT
00114 # include <stlsoft/method_properties.hpp>
00115 #endif /* RECLS_CPP_METHOD_PROPERTY_SUPPORT */
00116 
00117 /* 
00118  * Property Macros - borrowed from STLSoft's XMLSTL sub-project
00119  */
00120 
00121 #ifdef RECLS_CPP_METHOD_PROPERTY_SUPPORT
00122 # define RECLS_CPP_OPT_METHOD_PROPERTY_GET(V, R, C, GM, P)                  STLSOFT_METHOD_PROPERTY_GET(V, R, C, GM, P)
00123 # define RECLS_CPP_OPT_METHOD_PROPERTY_GET_PROP(R, C, GM, P)                STLSOFT_METHOD_PROPERTY_GET_EXTERNAL_PROP(R, C, GM, P)
00124 # define RECLS_CPP_OPT_METHOD_PROPERTY_GETSET(V, RG, RS, C, GM, SM, P)      STLSOFT_METHOD_PROPERTY_GETSET_EXTERNAL(RG, RS, C, GM, SM, P)
00125 # define RECLS_CPP_OPT_METHOD_PROPERTY_DEFINE_OFFSET(C, P)                  STLSOFT_METHOD_PROPERTY_DEFINE_OFFSET(C, P)
00126 # define RECLS_CPP_OPT_METHOD_PROPERTY_GETSET_PROP(RG, RS, C, GM, SM, P)    STLSOFT_METHOD_PROPERTY_GETSET_EXTERNAL_PROP(RG, RS, C, GM, SM, P)
00127 #else /* ? RECLS_CPP_METHOD_PROPERTY_SUPPORT */
00128 # define RECLS_CPP_OPT_METHOD_PROPERTY_GET(V, R, C, GM, P)
00129 # define RECLS_CPP_OPT_METHOD_PROPERTY_GET_PROP(R, C, GM, P)
00130 # define RECLS_CPP_OPT_METHOD_PROPERTY_GETSET(V, RG, RS, C, GM, SM, P)
00131 # define RECLS_CPP_OPT_METHOD_PROPERTY_DEFINE_OFFSET(C, P)
00132 # define RECLS_CPP_OPT_METHOD_PROPERTY_GETSET_PROP(RG, RS, C, GM, SM, P)
00133 #endif /* RECLS_CPP_METHOD_PROPERTY_SUPPORT */
00134 
00135 /* 
00136  * Namespace
00137  */
00138 
00139 #if !defined(RECLS_NO_NAMESPACE)
00140 namespace recls
00141 {
00142 
00143 namespace cpp
00144 {
00145 #endif /* !RECLS_NO_NAMESPACE */
00146 
00147 /* 
00148  * Typedefs
00149  */
00150 
00151 #ifdef RECLS_DOCUMENTATION_SKIP_SECTION
00152 
00161 typedef std::string             string_t;
00162 
00163 #else /* ? RECLS_DOCUMENTATION_SKIP_SECTION */
00164 
00165 # ifdef RECLS_CPP_STRING_HEADER
00166 #  ifndef RECLS_CPP_STRING_T
00167 #   error RECLS_CPP_STRING_T must be defined when RECLS_CPP_STRING_HEADER is defined
00168 #  endif /* !RECLS_STRING_T */
00169 typedef RECLS_CPP_STRING_T      string_t;
00170 # else
00171 #  if defined(RECLS_COMPILER_IS_DMC) && \
00172       !defined(STLSOFT_CF_STD_LIBRARY_IS_STLPORT)
00173 typedef string                  string_t;
00174 #  else
00175 typedef std::string             string_t;
00176 #  endif /* RECLS_COMPILER_IS_DMC */
00177 # endif /* RECLS_STRING_HEADER */
00178 #endif /* RECLS_DOCUMENTATION_SKIP_SECTION */
00179 
00180 /* 
00181  * Classes
00182  */
00183 
00185 class ReclsException
00186     : public std::exception
00187 {
00190 public:
00191     typedef std::exception  parent_class_type;
00192     typedef ReclsException  class_type;
00194 
00197 public:
00199     explicit ReclsException(recls_rc_t rc)
00200         : m_rc(rc)
00201         , m_message(create_message_(rc))
00202     {}
00203 #ifdef STLSOFT_COMPILER_IS_GCC
00204     virtual ~ReclsException() throw()
00205     {}
00206 #endif /* STLSOFT_COMPILER_IS_GCC */
00207 
00208 
00211 public:
00213     recls_rc_t rc() const
00214     {
00215         return m_rc;
00216     }
00217 
00219     virtual char const *what() const throw()
00220     {
00221         return m_message.c_str();
00222     }
00224 
00227 private:
00228     static string_t create_message_(recls_rc_t rc)
00229     {
00230         string_t    msg(recls::Recls_GetErrorString(rc, NULL, 0), '~');
00231 
00232         recls::Recls_GetErrorString(rc, &msg[0], msg.size());
00233 
00234         return msg;
00235     }
00237 
00240 private:
00241     const recls_rc_t    m_rc;
00242     const string_t      m_message;
00244 
00245 // Not to be implemented
00246 private:
00247     class_type &operator =(class_type const &);
00248 };
00249 
00250 /* 
00251  * Namespace
00252  */
00253 
00254 #if !defined(RECLS_NO_NAMESPACE)
00255 } /* namespace cpp */
00256 } /* namespace recls */
00257 namespace reclspp = ::recls::cpp;
00258 #endif /* !RECLS_NO_NAMESPACE */
00259 
00260 /* 
00261 
00262 #endif /* !RECLS_INCL_RECLS_CPP_HPP_RECLSHPP */
00263 
00264 /* 

recls Library documentation © Synesis Software Pty Ltd, 2001-2005