| QxOrm 1.4.6 C++ Object Relational Mapping library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

cont_ptr_utils.h
Go to the documentation of this file.

    00001 // -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
    00002 // vim:tabstop=4:shiftwidth=4:expandtab:
    00003
    00004 /*
    00005  * Copyright (C) 2004-2008 Wu Yongwei <adah at users dot sourceforge dot net>
    00006  *
    00007  * This software is provided 'as-is', without any express or implied
    00008  * warranty.  In no event will the authors be held liable for any
    00009  * damages arising from the use of this software.
    00010  *
    00011  * Permission is granted to anyone to use this software for any purpose,
    00012  * including commercial applications, and to alter it and redistribute
    00013  * it freely, subject to the following restrictions:
    00014  *
    00015  * 1. The origin of this software must not be misrepresented; you must
    00016  *    not claim that you wrote the original software.  If you use this
    00017  *    software in a product, an acknowledgement in the product
    00018  *    documentation would be appreciated but is not required.
    00019  * 2. Altered source versions must be plainly marked as such, and must
    00020  *    not be misrepresented as being the original software.
    00021  * 3. This notice may not be removed or altered from any source
    00022  *    distribution.
    00023  *
    00024  * This file is part of Stones of Nvwa:
    00025  *      http://sourceforge.net/projects/nvwa
    00026  *
    00027  */
    00028
    00041 #ifndef QT_NO_DEBUG
    00042 #ifndef _QX_MODE_RELEASE
    00043 #if _QX_USE_MEM_LEAK_DETECTION
    00044
    00045 #ifndef _CONT_PTR_UTILS_H
    00046 #define _CONT_PTR_UTILS_H
    00047
    00048 #ifdef _MSC_VER
    00049 #pragma once
    00050 #endif
    00051
    00052 namespace qx {
    00053 namespace memory {
    00054
    00067 struct QX_DLL_EXPORT dereference
    00068 {
    00069     template <typename _Tp>
    00070     const _Tp& operator()(const _Tp* __ptr) const
    00071     {
    00072         return *__ptr;
    00073     }
    00074 };
    00075
    00089 struct QX_DLL_EXPORT dereference_less
    00090 {
    00091     template <typename _Pointer>
    00092     bool operator()(_Pointer __ptr1, _Pointer __ptr2) const
    00093     {
    00094         return *__ptr1 < *__ptr2;
    00095     }
    00096 };
    00097
    00108 struct QX_DLL_EXPORT delete_object
    00109 {
    00110     template <typename _Pointer>
    00111     void operator()(_Pointer __ptr) const
    00112     {
    00113         delete __ptr;
    00114     }
    00115 };
    00116
    00127 template <typename _OutputStrm, typename _StringType = const char*>
    00128 struct output_object
    00129 {
    00130     output_object(_OutputStrm& __outs, const _StringType& __sep)
    00131         : _M_outs(__outs), _M_sep(__sep)
    00132     {}
    00133
    00134     template <typename _Tp>
    00135     void operator()(const _Tp* __ptr) const
    00136     {
    00137         _M_outs << *__ptr << _M_sep;
    00138     }
    00139
    00140 private:
    00141     _OutputStrm& _M_outs;
    00142     _StringType  _M_sep;
    00143 };
    00144
    00145 } // namespace memory
    00146 } // namespace qx
    00147
    00148 #endif // _CONT_PTR_UTILS_H
    00149 #endif // _QX_USE_MEM_LEAK_DETECTION
    00150 #endif // _QX_MODE_RELEASE
    00151 #endif // QT_NO_DEBUG