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

fastformat/fastformat.hpp

Go to the documentation of this file.
00001 /* /////////////////////////////////////////////////////////////////////////
00002  * File:        fastformat/fastformat.hpp
00003  *
00004  * Purpose:     FastFormat C++ primary include.
00005  *
00006  * Created:     19th September 2006
00007  * Updated:     23rd June 2010
00008  *
00009  * Home:        http://www.fastformat.org/
00010  *
00011  * Copyright (c) 2006-2010, 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
00016  * met:
00017  *
00018  * - Redistributions of source code must retain the above copyright notice,
00019  *   this list of conditions and the following disclaimer.
00020  * - Redistributions in binary form must reproduce the above copyright
00021  *   notice, this list of conditions and the following disclaimer in the
00022  *   documentation and/or other materials provided with the distribution.
00023  * - Neither the names of Matthew Wilson and Synesis Software nor the names
00024  *   of any contributors may be used to endorse or promote products derived
00025  *   from this software without specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00028  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00029  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00030  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00031  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00032  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00033  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00034  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00035  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00036  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00037  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038  *
00039  * ////////////////////////////////////////////////////////////////////// */
00040 
00041 
00047 #ifndef FASTFORMAT_INCL_FASTFORMAT_HPP_FASTFORMAT
00048 #define FASTFORMAT_INCL_FASTFORMAT_HPP_FASTFORMAT
00049 
00050 /* /////////////////////////////////////////////////////////////////////////
00051  * Version information
00052  */
00053 
00054 #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
00055 # define FASTFORMAT_VER_FASTFORMAT_HPP_FASTFORMAT_MAJOR     2
00056 # define FASTFORMAT_VER_FASTFORMAT_HPP_FASTFORMAT_MINOR     1
00057 # define FASTFORMAT_VER_FASTFORMAT_HPP_FASTFORMAT_REVISION  4
00058 # define FASTFORMAT_VER_FASTFORMAT_HPP_FASTFORMAT_EDIT      38
00059 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
00060 
00061 /* /////////////////////////////////////////////////////////////////////////
00062  * Language
00063  */
00064 
00065 #ifndef __cplusplus
00066 # error This file can only be included in C++ compilation units
00067 #endif /* !__cplusplus */
00068 
00069 /* /////////////////////////////////////////////////////////////////////////
00070  * Includes - 1
00071  */
00072 
00073 #include <fastformat/fastformat.h>
00074 #include <fastformat/exceptions.hpp>
00075 #include <fastformat/format/standard_flags.hpp>
00076 #ifdef FASTFORMAT_NO_USE_JIT_CACHE
00077 # include <fastformat/internal/format_element.h>
00078 #endif /* FASTFORMAT_NO_USE_JIT_CACHE */
00079 #include <fastformat/internal/stlsoft.h>
00080 #include <fastformat/quality/contract.h>
00081 
00082 /* /////////////////////////////////////////////////////////////////////////
00083  * Compatibility
00084  */
00085 
00086 /* FASTFORMAT_NO_FILTER_TYPE_CONVERSION_SHIM_SUPPORT
00087  *
00088  * Some compilers can't handle the filter_type mechanism, so we must allow
00089  * for it to be disabled
00090  */
00091 
00092 #if (   defined(STLSOFT_COMPILER_IS_BORLAND) && \
00093         __BORLANDC__ < 0x0600) /* This is a guess, since I cannot verify whether 5.9.x supports filter_type; 5.8 does not, 6.1 does */ || \
00094     defined(STLSOFT_COMPILER_IS_DMC) || \
00095     defined(STLSOFT_COMPILER_IS_WATCOM)
00096 # define FASTFORMAT_NO_FILTER_TYPE_CONVERSION_SHIM_SUPPORT
00097 #endif /* compiler */
00098 
00099 /* FASTFORMAT_SUPPORT_IMPLICIT_SHIM_STRING_ACTION_SHIM
00100  *
00101  * Determines whether support for using a shim string as a sink is
00102  * available
00103  */
00104 
00105 #ifndef FASTFORMAT_NO_FILTER_TYPE_CONVERSION_SHIM_SUPPORT
00106 # if defined(STLSOFT_COMPILER_IS_MWERKS) || \
00107      (  defined(STLSOFT_COMPILER_IS_GCC) && \
00108         (   __GNUC__ >= 4 || \
00109             (   __GNUC__ == 3 && \
00110                 __GNUC_MINOR__ >= 4))) || \
00111     (   defined(STLSOFT_COMPILER_IS_MSVC) && \
00112         _MSC_VER >= 1310)
00113   /* allow shim string action shim for these compilers ...
00114    *
00115    * ... unless STLSoft main line is not 1.10 and 1.10 alpha is not
00116    * present
00117    */
00118 #  include <stlsoft/string/shim_string.hpp>
00119 #  if _STLSOFT_VER >= 0x010a0000 || \
00120       (   defined(_STLSOFT_1_10_VER) && \
00121           _STLSOFT_1_10_VER >= 0x010a0105)
00122 #   define FASTFORMAT_SUPPORT_IMPLICIT_SHIM_STRING_ACTION_SHIM
00123 #  else /* ? shim string version */
00124 #   ifndef FASTFORMAT_NO_VERSION_NAG
00125 #    ifdef STLSOFT_PPF_pragma_message_SUPPORT
00126 #     pragma message(__FILE__ "(" STLSOFT_STRINGIZE(__LINE__) "): " "NOTE: Implicit support for shim_string sinks is not enabled. To enable this, download STLSoft 1.10 alpha 5+ and add -I$STLSOFT_1_10/include to your command-line/project include directories _before_ -$STLSOFT/include")
00127 #    endif /* STLSOFT_PPF_pragma_message_SUPPORT */
00128 #   endif /* !FASTFORMAT_NO_VERSION_NAG */
00129 #  endif /* shim string version */
00130 # endif /* compiler */
00131 #endif /* !FASTFORMAT_NO_FILTER_TYPE_CONVERSION_SHIM_SUPPORT */
00132 
00133 /* /////////////////////////////////////////////////////////////////////////
00134  * Includes - 2
00135  */
00136 
00137 #include <stlsoft/memory/auto_buffer.hpp>
00138 #include <stlsoft/shims/access/string.hpp>
00139 #ifdef FASTFORMAT_SUPPORT_IMPLICIT_SHIM_STRING_ACTION_SHIM
00140 # include <stlsoft/string/shim_string.hpp>
00141 #endif /* FASTFORMAT_SUPPORT_IMPLICIT_SHIM_STRING_ACTION_SHIM */
00142 #include <stlsoft/string/string_traits.hpp>
00143 #include <stlsoft/string/string_view.hpp>
00144 
00145  /* /////////////////////////////////////////////////////////////////////////
00146  * Namespace
00147  */
00148 
00149 #if !defined(FASTFORMAT_NO_NAMESPACE)
00150 namespace fastformat
00151 {
00152 #endif /* !FASTFORMAT_NO_NAMESPACE */
00153 
00154 /* /////////////////////////////////////////////////////////////////////////
00155  * Typedefs
00156  */
00157 
00158 #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
00159 
00162 struct defs
00163 {
00164 #ifdef FASTFORMAT_NO_USE_JIT_CACHE
00165     typedef stlsoft::auto_buffer<ff_format_element_t>   format_elements_t;
00166 #endif /* FASTFORMAT_NO_USE_JIT_CACHE */
00167     typedef stlsoft::auto_buffer<ff_string_slice_t>     slices_buffer_t;
00168 };
00169 
00170 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
00171 
00172 /* /////////////////////////////////////////////////////////////////////////
00173  * Stock sinks
00174  *
00175  * This section includes all the implicit action shims that are available
00176  * for sinks, without the need to explicitly include sinks files (e.g.
00177  * fastformat/sinks/ostream.hpp)
00178  */
00179 
00180 #if !defined(FASTFORMAT_NO_NAMESPACE)
00181 } /* namespace fastformat */
00182 #endif /* !FASTFORMAT_NO_NAMESPACE */
00183 
00184 #if !defined(FASTFORMAT_NO_IMPLICIT_ACTION_SHIMS)
00185 
00186 # if !defined(FASTFORMAT_NO_IMPLICIT_GENERIC_STRING_ACTION_SHIM)
00187 #  include <fastformat/shims/action/fmt_slices/generic_string.hpp>
00188 # endif /* !FASTFORMAT_NO_IMPLICIT_GENERIC_STRING_ACTION_SHIM */
00189 
00190 # if !defined(FASTFORMAT_NO_IMPLICIT_SHIM_STRING_ACTION_SHIM)
00191 #  if defined(FASTFORMAT_SUPPORT_IMPLICIT_SHIM_STRING_ACTION_SHIM)
00192 #   include <fastformat/sinks/shim_string.hpp>
00193 #  endif /* FASTFORMAT_SUPPORT_IMPLICIT_SHIM_STRING_ACTION_SHIM */
00194 # endif /* !FASTFORMAT_NO_IMPLICIT_SHIM_STRING_ACTION_SHIM */
00195 
00196 #endif /* !FASTFORMAT_NO_IMPLICIT_ACTION_SHIMS */
00197 
00198 #if !defined(FASTFORMAT_NO_NAMESPACE)
00199 namespace fastformat
00200 {
00201 #endif /* !FASTFORMAT_NO_NAMESPACE */
00202 
00203 /* /////////////////////////////////////////////////////////////////////////
00204  * Conversion shims for implicit filtering
00205  */
00206 
00207 #if !defined(FASTFORMAT_NO_NAMESPACE)
00208 namespace filters
00209 {
00210 #endif /* !FASTFORMAT_NO_NAMESPACE */
00211 
00213 template<   typename T /* The type to be converted */
00214         ,   typename C /* The character type */
00215         >
00216 inline T const& filter_type(T const& t, T const*, C const volatile*)
00217 {
00218     return t;
00219 }
00220 
00221 #if !defined(FASTFORMAT_NO_NAMESPACE)
00222 } /* namespace filters */
00223 #endif /* !FASTFORMAT_NO_NAMESPACE */
00224 
00225 
00226 /* /////////////////////////////////////////////////////////////////////////
00227  * Stock filtering
00228  */
00229 
00230 #if !defined(FASTFORMAT_NO_NAMESPACE)
00231 } /* namespace fastformat */
00232 #endif /* !FASTFORMAT_NO_NAMESPACE */
00233 
00234 #if !defined(FASTFORMAT_NO_DEFAULT_CONVERSION_SHIMS)
00235 
00236   /* By default uses the fast non-l7d conversions. Can request l7d ones
00237    * by FASTFORMAT_USE_L7D_INTEGER_CONVERSION_SHIMS.
00238    */
00239 # if defined(FASTFORMAT_USE_L7D_INTEGER_CONVERSION_SHIMS)
00240 #  error Feature not yet implemented. Please complain via sourceforge.net/forum/forum.php?forum_id=612781 and your wish will be granted
00241 /* #  include <fastformat/shims/conversion/filter_type/l7d_integers.hpp> */
00242 # elif !defined(FASTFORMAT_NO_DEFAULT_INTEGER_CONVERSION_SHIMS)
00243 #  include <fastformat/shims/conversion/filter_type/fast_integers.hpp>
00244 # endif /* !FASTFORMAT_NO_DEFAULT_INTEGER_CONVERSION_SHIMS */
00245 
00246 # if defined(FASTFORMAT_USE_L7D_REAL_CONVERSION_SHIMS)
00247 #  error Feature not yet implemented. Please complain via sourceforge.net/forum/forum.php?forum_id=612781 and your wish will be granted
00248 /* #  include <fastformat/shims/conversion/filter_type/l7d_reals.hpp> */
00249 # endif /* FASTFORMAT_USE_L7D_REAL_CONVERSION_SHIMS */
00250 
00251 # if defined(FASTFORMAT_USE_VOID_POINTERS_CONVERSION_SHIMS)
00252 #  include <fastformat/shims/conversion/filter_type/void_pointers.hpp>
00253 # endif /* FASTFORMAT_USE_VOID_POINTERS_CONVERSION_SHIMS */
00254 
00255 # if defined(FASTFORMAT_USE_CHAR_CONVERSION_SHIMS)
00256 #  error Feature not yet implemented. Please complain via sourceforge.net/forum/forum.php?forum_id=612781 and your wish will be granted
00257 /* #  include <fastformat/shims/conversion/filter_type/characters.hpp> */
00258 # endif /* FASTFORMAT_USE_CHAR_CONVERSION_SHIMS */
00259 
00260 # if defined(FASTFORMAT_USE_BOOLEAN_CONVERSION_SHIMS)
00261 #  error Feature not yet implemented. Please complain via sourceforge.net/forum/forum.php?forum_id=612781 and your wish will be granted
00262 /* #  include <fastformat/shims/conversion/filter_type/boolean.hpp> */
00263 # endif /* FASTFORMAT_USE_BOOLEAN_CONVERSION_SHIMS */
00264 
00265 #endif /* !FASTFORMAT_NO_DEFAULT_CONVERSION_SHIMS */
00266 
00267 #if !defined(FASTFORMAT_NO_NAMESPACE)
00268 namespace fastformat
00269 {
00270 #endif /* !FASTFORMAT_NO_NAMESPACE */
00271 
00272 /* /////////////////////////////////////////////////////////////////////////
00273  * Helper functions
00274  */
00275 
00276 #if !defined(FASTFORMAT_NO_NAMESPACE)
00277 namespace internal
00278 {
00279 namespace helpers
00280 {
00281 #endif /* !FASTFORMAT_NO_NAMESPACE */
00282 
00283 #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
00284 # define FASTFORMAT_INCLUDING_HELPER_FUNCTIONS
00285 # include <fastformat/internal/generated/helper_functions.hpp>
00286 # undef FASTFORMAT_INCLUDING_HELPER_FUNCTIONS
00287 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
00288 
00289 #if !defined(FASTFORMAT_NO_NAMESPACE)
00290 } /* namespace helpers */
00291 } /* namespace internal */
00292 #endif /* !FASTFORMAT_NO_NAMESPACE */
00293 
00294 /* /////////////////////////////////////////////////////////////////////////
00295  * API functions
00296  */
00297 
00374 #ifdef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
00375 # include "./internal/generated/api_functions.hpp"
00376 #else /* ? FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
00377 # define FASTFORMAT_INCLUDING_API_FUNCTIONS
00378 # include <fastformat/internal/generated/api_functions.hpp>
00379 # undef FASTFORMAT_INCLUDING_API_FUNCTIONS
00380 #endif /* FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
00381 
00382 /* /////////////////////////////////////////////////////////////////////////
00383  * Auto-initialisation
00384  *
00385  * Except when making a DLL, this is automatic, unless FASTFORMAT_NO_AUTO_INIT
00386  * is defined.
00387  *
00388  * To force it for a DLL, define FASTFORMAT_FORCE_AUTO_INIT
00389  */
00390 
00391 #if defined(__DLL__) /* Borland, with -WD */ || \
00392     defined(_WINDLL) /* VC++, defined by user/wizard */ || \
00393     defined(_USRDLL) /* VC++, defined by user/wizard */
00394 # define FASTFORMAT_NO_AUTO_INIT
00395 #endif /* dynamic library */
00396 
00397 #ifdef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
00398 # include "./internal/initialiser.hpp"
00399 #else /* ? FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
00400 # if defined(FASTFORMAT_FORCE_AUTO_INIT) || \
00401      !defined(FASTFORMAT_NO_AUTO_INIT)
00402 #  include <fastformat/internal/initialiser.hpp> /* Schwarz counter initialisation */
00403 # endif /* FASTFORMAT_FORCE_AUTO_INIT || !FASTFORMAT_NO_AUTO_INIT */
00404 #endif /* FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
00405 
00406 /* /////////////////////////////////////////////////////////////////////////
00407  * Namespace
00408  */
00409 
00410 #if !defined(FASTFORMAT_NO_NAMESPACE)
00411 } /* namespace fastformat */
00412 #endif /* !FASTFORMAT_NO_NAMESPACE */
00413 
00414 /* /////////////////////////////////////////////////////////////////////////
00415  * Inclusion
00416  */
00417 
00418 #ifdef STLSOFT_PPF_pragma_once_SUPPORT
00419 # pragma once
00420 #endif /* STLSOFT_PPF_pragma_once_SUPPORT */
00421 
00422 /* ////////////////////////////////////////////////////////////////////// */
00423 
00424 #endif /* FASTFORMAT_INCL_FASTFORMAT_HPP_FASTFORMAT */
00425 
00426 /* ///////////////////////////// end of file //////////////////////////// */

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