Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

fastformat/internal/shim_macros.h

Go to the documentation of this file.
00001 /* /////////////////////////////////////////////////////////////////////////
00002  * File:        fastformat/internal/shim_macros.h
00003  *
00004  * Purpose:     Definitions of macros used internally in the library
00005  *              components
00006  *
00007  * Created:     19th September 2006
00008  * Updated:     7th March 2010
00009  *
00010  * Home:        http://www.fastformat.org/
00011  *
00012  * Copyright (c) 2006-2010, Matthew Wilson and Synesis Software
00013  * All rights reserved.
00014  *
00015  * Redistribution and use in source and binary forms, with or without
00016  * modification, are permitted provided that the following conditions are
00017  * met:
00018  *
00019  * - Redistributions of source code must retain the above copyright notice,
00020  *   this list of conditions and the following disclaimer.
00021  * - Redistributions in binary form must reproduce the above copyright
00022  *   notice, this list of conditions and the following disclaimer in the
00023  *   documentation and/or other materials provided with the distribution.
00024  * - Neither the names of Matthew Wilson and Synesis Software nor the names
00025  *   of any contributors may be used to endorse or promote products derived
00026  *   from this software without specific prior written permission.
00027  *
00028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00029  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00030  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00031  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00032  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00033  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00034  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00035  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00036  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00037  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00038  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  *
00040  * ////////////////////////////////////////////////////////////////////// */
00041 
00042 
00048 #ifndef FASTFORMAT_INCL_FASTFORMAT_INTERNAL_H_SHIM_MACROS
00049 #define FASTFORMAT_INCL_FASTFORMAT_INTERNAL_H_SHIM_MACROS
00050 
00051 /* /////////////////////////////////////////////////////////////////////////
00052  * Includes
00053  */
00054 
00055 #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
00056 # include <fastformat/fastformat.h>
00057 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
00058 
00059 /* /////////////////////////////////////////////////////////////////////////
00060  * Macros
00061  */
00062 
00063 /* /////////////////////////////////////////////////////////////////////////
00064  * Compiler compatibility
00065  */
00066 
00067 /* The Digital Mars and GCC compilers both exhibit strange behaviour (bugs?)
00068  * with respect to the invocation of shims.
00069  *
00070  * - DMC++ requires explicit qualification, even in the presence of a
00071  *    (local) using declaration
00072  * - GCC requires a local using declaration and *must not* have explicit
00073  *    qualification.
00074  *
00075  * - all other compilers work fine without any using declaration and with
00076  *    explicit qualification.
00077  *
00078  * As currently defined, we follow the GCC way (which works for all other
00079  * compilers, except DMC++), and explicitly qualify for DMC++.
00080  *
00081  */
00082 
00083 #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
00084 
00085 /* 1. String access shims
00086  * ----------------------
00087  */
00088 
00089 # ifdef FASTFORMAT_INVOKE_c_str_data_
00090 #  undef FASTFORMAT_INVOKE_c_str_data_
00091 # endif /* FASTFORMAT_INVOKE_c_str_data_ */
00092 # ifdef FASTFORMAT_INVOKE_c_str_len_
00093 #  undef FASTFORMAT_INVOKE_c_str_len_
00094 # endif /* FASTFORMAT_INVOKE_c_str_len_ */
00095 # ifdef FASTFORMAT_INVOKE_c_str_ptr_
00096 #  undef FASTFORMAT_INVOKE_c_str_ptr_
00097 # endif /* FASTFORMAT_INVOKE_c_str_ptr_ */
00098 # ifdef FASTFORMAT_INVOKE_SHIM_PAIR_
00099 #  undef FASTFORMAT_INVOKE_SHIM_PAIR_
00100 # endif /* FASTFORMAT_INVOKE_SHIM_PAIR_ */
00101 # ifdef FASTFORMAT_c_str_data_name_
00102 #  undef FASTFORMAT_c_str_data_name_
00103 # endif /* FASTFORMAT_c_str_data_name_ */
00104 
00105 # ifdef FASTFORMAT_USE_WIDE_STRINGS
00106 #  define FASTFORMAT_c_str_data_name_                   c_str_data_w
00107 #  define FASTFORMAT_c_str_len_name_                    c_str_len_w
00108 #  define FASTFORMAT_c_str_ptr_name_                    c_str_ptr_w
00109 # else /* ? FASTFORMAT_USE_WIDE_STRINGS */
00110 #  define FASTFORMAT_c_str_data_name_                   c_str_data_a
00111 #  define FASTFORMAT_c_str_len_name_                    c_str_len_a
00112 #  define FASTFORMAT_c_str_ptr_name_                    c_str_ptr_a
00113 # endif /* FASTFORMAT_USE_WIDE_STRINGS */
00114 
00115 # if defined(STLSOFT_COMPILER_IS_DMC)
00116 #  define FASTFORMAT_INVOKE_c_str_data_(x)              stlsoft::FASTFORMAT_c_str_data_name_(x)
00117 #  define FASTFORMAT_INVOKE_c_str_len_(x)               stlsoft::FASTFORMAT_c_str_len_name_(x)
00118 #  define FASTFORMAT_INVOKE_c_str_ptr_(x)               stlsoft::FASTFORMAT_c_str_ptr_name_(x)
00119 #  define FASTFORMAT_DECLARE_c_str_ptr_()               stlsoft_static_cast(void, 0)
00120 #  define FASTFORMAT_DECLARE_c_str_datalen_PAIR_()      stlsoft_static_cast(void, 0)
00121 # elif defined(STLSOFT_COMPILER_IS_GCC)
00122 #  define FASTFORMAT_INVOKE_c_str_data_(x)              FASTFORMAT_c_str_data_name_(x)
00123 #  define FASTFORMAT_INVOKE_c_str_len_(x)               FASTFORMAT_c_str_len_name_(x)
00124 #  define FASTFORMAT_INVOKE_c_str_ptr_(x)               FASTFORMAT_c_str_ptr_name_(x)
00125 #  define FASTFORMAT_DECLARE_c_str_ptr_()               using ::stlsoft::FASTFORMAT_c_str_ptr_name_
00126 #  define FASTFORMAT_DECLARE_c_str_datalen_PAIR_()      using ::stlsoft::FASTFORMAT_c_str_data_name_; using ::stlsoft::FASTFORMAT_c_str_len_name_
00127 # else /* ? compiler */
00128 #  define FASTFORMAT_INVOKE_c_str_data_(x)              FASTFORMAT_c_str_data_name_(x)
00129 #  define FASTFORMAT_INVOKE_c_str_len_(x)               FASTFORMAT_c_str_len_name_(x)
00130 #  define FASTFORMAT_INVOKE_c_str_ptr_(x)               FASTFORMAT_c_str_ptr_name_(x)
00131 #  define FASTFORMAT_DECLARE_c_str_ptr_()               using ::stlsoft::FASTFORMAT_c_str_ptr_name_
00132 #  define FASTFORMAT_DECLARE_c_str_datalen_PAIR_()      using ::stlsoft::FASTFORMAT_c_str_data_name_; using ::stlsoft::FASTFORMAT_c_str_len_name_
00133 # endif /* compiler */
00134 # define FASTFORMAT_INVOKE_SHIM_PAIR_(x)                FASTFORMAT_INVOKE_c_str_data_(x), FASTFORMAT_INVOKE_c_str_len_(x)
00135 
00136 
00137 /* 2. Conversion shims
00138  * -------------------
00139  */
00140 
00141 # ifdef FASTFORMAT_NO_FILTER_TYPE_CONVERSION_SHIM_SUPPORT
00142 #  define FASTFORMAT_DECLARE_filter_type_()             stlsoft_static_cast(void, 0)
00143 #  define FASTFORMAT_INVOKE_filter_type_(x, y, z)       (x)
00144 # else /* ? FASTFORMAT_NO_FILTER_TYPE_CONVERSION_SHIM_SUPPORT */
00145 #  ifdef FASTFORMAT_NO_NAMESPACE
00146 #   define FASTFORMAT_DECLARE_filter_type_()            stlsoft_static_cast(void, 0)
00147 #  else /* ? FASTFORMAT_NO_NAMESPACE */
00148 #   define FASTFORMAT_DECLARE_filter_type_()            using ::fastformat::filters::filter_type
00149 #  endif /* FASTFORMAT_NO_NAMESPACE */
00150 #  define FASTFORMAT_INVOKE_filter_type_(x, y, z)       filter_type(x, y, z)
00151 # endif /* FASTFORMAT_NO_FILTER_TYPE_CONVERSION_SHIM_SUPPORT */
00152 
00153 
00154 /* 3. Action shims
00155  * ---------------
00156  */
00157 
00158 # if defined(FASTFORMAT_NO_NAMESPACE)
00159 #  define FASTFORMAT_DECLARE_fmt_slices_()
00160 #  define FASTFORMAT_INVOKE_fmt_slices_(s, f, t, e, r)  fmt_slices(s, f, t, e, r)
00161 # else /* FASTFORMAT_NO_NAMESPACE */
00162 #  if defined(STLSOFT_COMPILER_IS_DMC)
00163 #   define FASTFORMAT_DECLARE_fmt_slices_()             stlsoft_static_cast(void, 0)
00164 #   define FASTFORMAT_INVOKE_fmt_slices_(s, f, t, e, r) ::fastformat::sinks::fmt_slices(s, f, t, e, r)
00165 #  elif defined(STLSOFT_COMPILER_IS_GCC)
00166 #   define FASTFORMAT_DECLARE_fmt_slices_()             using ::fastformat::sinks::fmt_slices
00167 #   define FASTFORMAT_INVOKE_fmt_slices_(s, f, t, e, r) fmt_slices(s, f, t, e, r)
00168 #  else /* ? compiler */
00169 #   define FASTFORMAT_DECLARE_fmt_slices_()             using ::fastformat::sinks::fmt_slices
00170 #   define FASTFORMAT_INVOKE_fmt_slices_(s, f, t, e, r) fmt_slices(s, f, t, e, r)
00171 #  endif /* compiler */
00172 
00173 # endif /* FASTFORMAT_NO_NAMESPACE */
00174 
00175 
00176 /* 4. Internal helpers
00177  * -------------------
00178  */
00179 
00180 # if !defined(FASTFORMAT_NO_NAMESPACE)
00181 #  define FASTFORMAT_QUALIFY_HELPER_(x)                 ::fastformat::internal::helpers::x
00182 # else /* !FASTFORMAT_NO_NAMESPACE */
00183 #  define FASTFORMAT_QUALIFY_HELPER_(x)                 x
00184 # endif /* !FASTFORMAT_NO_NAMESPACE */
00185 
00186 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
00187 
00188 /* /////////////////////////////////////////////////////////////////////////
00189  * Inclusion
00190  */
00191 
00192 #ifdef STLSOFT_PPF_pragma_once_SUPPORT
00193 # pragma once
00194 #endif /* STLSOFT_PPF_pragma_once_SUPPORT */
00195 
00196 /* ////////////////////////////////////////////////////////////////////// */
00197 
00198 #endif /* FASTFORMAT_INCL_FASTFORMAT_INTERNAL_H_SHIM_MACROS */
00199 
00200 /* ///////////////////////////// end of file //////////////////////////// */

FastFormat Library documentation © Matthew Wilson, 2006-2009 SourceForge.net Logo