- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages
- Examples

# fastformat/shims/conversion/filter_type/void_pointers.hpp

Go to the documentation of this file.

    00001 /* /////////////////////////////////////////////////////////////////////////
    00002  * File:        fastformat/shims/conversion/filter_type/void_pointers.hpp
    00003  *
    00004  * Purpose:     FastFormat argument conversion shim for floating-point
    00005  *              types.
    00006  *
    00007  * Created:     30th November 2008
    00008  * Updated:     7th March 2010
    00009  *
    00010  * Home:        http://www.fastformat.org/
    00011  *
    00012  * Copyright (c) 2008-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_SHIMS_CONVERSION_FILTER_TYPE_HPP_VOID_POINTERS
    00049 #define FASTFORMAT_INCL_FASTFORMAT_SHIMS_CONVERSION_FILTER_TYPE_HPP_VOID_POINTERS
    00050
    00051 /* /////////////////////////////////////////////////////////////////////////
    00052  * Version information
    00053  */
    00054
    00055 #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
    00056 # define FASTFORMAT_VER_FASTFORMAT_SHIMS_CONVERSION_FILTER_TYPE_HPP_VOID_POINTERS_MAJOR     1
    00057 # define FASTFORMAT_VER_FASTFORMAT_SHIMS_CONVERSION_FILTER_TYPE_HPP_VOID_POINTERS_MINOR     1
    00058 # define FASTFORMAT_VER_FASTFORMAT_SHIMS_CONVERSION_FILTER_TYPE_HPP_VOID_POINTERS_REVISION  2
    00059 # define FASTFORMAT_VER_FASTFORMAT_SHIMS_CONVERSION_FILTER_TYPE_HPP_VOID_POINTERS_EDIT      6
    00060 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
    00061
    00062 /* /////////////////////////////////////////////////////////////////////////
    00063  * Language
    00064  */
    00065
    00066 #ifndef __cplusplus
    00067 # error This file can only be included in C++ compilation units
    00068 #endif /* !__cplusplus */
    00069
    00070 /* /////////////////////////////////////////////////////////////////////////
    00071  * Includes
    00072  */
    00073
    00074 #include <fastformat/fastformat.h>
    00075 #include <fastformat/internal/stlsoft.h>
    00076 #include <fastformat/quality/contract.h>
    00077 #include <fastformat/util/string/snprintf.h>
    00078
    00079 #include <stlsoft/string/shim_string.hpp>
    00080
    00081 /* /////////////////////////////////////////////////////////////////////////
    00082  * Namespace
    00083  */
    00084
    00085 #if !defined(FASTFORMAT_NO_NAMESPACE)
    00086 namespace fastformat
    00087 {
    00088 namespace filters
    00089 {
    00090 #endif /* !FASTFORMAT_NO_NAMESPACE */
    00091
    00092 /* /////////////////////////////////////////////////////////////////////////
    00093  * Overloadable conversion shim functions:
    00094  *
    00095  * float
    00096  * double
    00097  */
    00098
    00102 inline stlsoft::basic_shim_string<ff_char_t, 32> filter_type(void const volatile* value, void const volatile* const*, ff_char_t const volatile*)
    00103 {
    00104     static const ff_char_t  fmt[] = { '%', 'p', '\0' };
    00105
    00106     stlsoft::basic_shim_string<ff_char_t, 32>   r(32);
    00107
    00108     int n = fastformat_util_snprintf(r.data(), r.size(), fmt, value);
    00109
    00110     if(n < 0)
    00111     {
    00112         n = 0;
    00113     }
    00114
    00115     r.truncate(static_cast<size_t>(n));
    00116
    00117     return r;
    00118 }
    00119
    00123 inline stlsoft::basic_shim_string<ff_char_t, 32> filter_type(void const* value, void const* const*, ff_char_t const volatile*)
    00124 {
    00125     void const volatile* value2 = value;
    00126
    00127     return filter_type(value2, &value2, static_cast<ff_char_t const volatile*>(0));
    00128 }
    00129
    00133 inline stlsoft::basic_shim_string<ff_char_t, 32> filter_type(void volatile* value, void volatile* const*, ff_char_t const volatile*)
    00134 {
    00135     void const volatile* value2 = value;
    00136
    00137     return filter_type(value2, &value2, static_cast<ff_char_t const volatile*>(0));
    00138 }
    00139
    00143 inline stlsoft::basic_shim_string<ff_char_t, 32> filter_type(void* value, void* const*, ff_char_t const volatile*)
    00144 {
    00145     void const volatile* value2 = value;
    00146
    00147     return filter_type(value2, &value2, static_cast<ff_char_t const volatile*>(0));
    00148 }
    00149
    00150 /* /////////////////////////////////////////////////////////////////////////
    00151  * Namespace
    00152  */
    00153
    00154 #if !defined(FASTFORMAT_NO_NAMESPACE)
    00155 } /* namespace filters */
    00156 } /* namespace fastformat */
    00157 #endif /* !FASTFORMAT_NO_NAMESPACE */
    00158
    00159 /* /////////////////////////////////////////////////////////////////////////
    00160  * Inclusion
    00161  */
    00162
    00163 #ifdef STLSOFT_PPF_pragma_once_SUPPORT
    00164 # pragma once
    00165 #endif /* STLSOFT_PPF_pragma_once_SUPPORT */
    00166
    00167 /* ////////////////////////////////////////////////////////////////////// */
    00168
    00169 #endif /* FASTFORMAT_INCL_FASTFORMAT_SHIMS_CONVERSION_FILTER_TYPE_HPP_VOID_POINTERS */
    00170
    00171 /* ///////////////////////////// end of file //////////////////////////// */

FastFormat Library documentation © Matthew Wilson, 2006-2009 |