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

# fastformat/shims/action/fmt_slices/generic_string.hpp

Go to the documentation of this file.

    00001 /* /////////////////////////////////////////////////////////////////////////
    00002  * File:        fastformat/shims/action/fmt_slices/generic_string.hpp
    00003  *
    00004  * Purpose:     FastFormat formatting action shim for generic string types.
    00005  *
    00006  * Created:     19th September 2006
    00007  * Updated:     7th March 2010
    00008  *
    00009  * Thanks:      To Ric Parkin for pointing out the ramifications of
    00010  *              21.3.5.2/6 and 21.3.1/6 before I change the definition of
    00011  *              c_str_data[_a|_w] to allow NULL to be returned.
    00012  *
    00013  * Home:        http://www.fastformat.org/
    00014  *
    00015  * Copyright (c) 2006-2010, Matthew Wilson and Synesis Software
    00016  * All rights reserved.
    00017  *
    00018  * Redistribution and use in source and binary forms, with or without
    00019  * modification, are permitted provided that the following conditions are
    00020  * met:
    00021  *
    00022  * - Redistributions of source code must retain the above copyright notice,
    00023  *   this list of conditions and the following disclaimer.
    00024  * - Redistributions in binary form must reproduce the above copyright
    00025  *   notice, this list of conditions and the following disclaimer in the
    00026  *   documentation and/or other materials provided with the distribution.
    00027  * - Neither the names of Matthew Wilson and Synesis Software nor the names
    00028  *   of any contributors may be used to endorse or promote products derived
    00029  *   from this software without specific prior written permission.
    00030  *
    00031  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    00032  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    00033  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    00034  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    00035  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    00036  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    00037  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    00038  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    00039  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    00040  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    00041  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00042  *
    00043  * ////////////////////////////////////////////////////////////////////// */
    00044
    00045
    00051 #ifndef FASTFORMAT_INCL_FASTFORMAT_SHIMS_ACTION_FMT_SLICES_HPP_GENERIC_STRING
    00052 #define FASTFORMAT_INCL_FASTFORMAT_SHIMS_ACTION_FMT_SLICES_HPP_GENERIC_STRING
    00053
    00054 /* /////////////////////////////////////////////////////////////////////////
    00055  * Version information
    00056  */
    00057
    00058 #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
    00059 # define FASTFORMAT_VER_FASTFORMAT_SHIMS_ACTION_FMT_SLICES_HPP_GENERIC_STRING_MAJOR     3
    00060 # define FASTFORMAT_VER_FASTFORMAT_SHIMS_ACTION_FMT_SLICES_HPP_GENERIC_STRING_MINOR     2
    00061 # define FASTFORMAT_VER_FASTFORMAT_SHIMS_ACTION_FMT_SLICES_HPP_GENERIC_STRING_REVISION  3
    00062 # define FASTFORMAT_VER_FASTFORMAT_SHIMS_ACTION_FMT_SLICES_HPP_GENERIC_STRING_EDIT      21
    00063 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
    00064
    00065 /* /////////////////////////////////////////////////////////////////////////
    00066  * Language
    00067  */
    00068
    00069 #ifndef __cplusplus
    00070 # error This file can only be included in C++ compilation units
    00071 #endif /* !__cplusplus */
    00072
    00073 /* /////////////////////////////////////////////////////////////////////////
    00074  * Includes
    00075  */
    00076
    00077 #include <fastformat/fastformat.h>
    00078 #include <fastformat/internal/stlsoft.h>
    00079 #include <fastformat/quality/contract.h>
    00080 #include <fastformat/format/standard_flags.hpp>
    00081
    00082 /* /////////////////////////////////////////////////////////////////////////
    00083  * Namespace
    00084  */
    00085
    00086 #if !defined(FASTFORMAT_NO_NAMESPACE)
    00087 namespace fastformat
    00088 {
    00089 namespace sinks
    00090 {
    00091 #endif /* !FASTFORMAT_NO_NAMESPACE */
    00092
    00093 /* /////////////////////////////////////////////////////////////////////////
    00094  * Overloadable functions
    00095  */
    00096
    00109 template <typename S>
    00110 inline S& fmt_slices(
    00111     S&                          sink
    00112 ,   int                         flags
    00113 ,   size_t                      cchTotal
    00114 ,   size_t                      numResults
    00115 ,   ff_string_slice_t const*    results
    00116 )
    00117 {
    00118     sink.reserve(sink.size() + cchTotal + 2);  // Ask for two more, in case need CR (&LF)
    00119
    00120     { for(size_t i = 0; i != numResults; ++i)
    00121     {
    00122         ff_string_slice_t const& slice = results[i];
    00123
    00124         if(0u != slice.len) // This test required by 21.3.5.2/6 => 21.3.1/6
    00125         {
    00126             sink.append(slice.ptr, slice.len);
    00127         }
    00128     }}
    00129
    00130     if(flags::ff_newLine & flags)
    00131     {
    00132         const ff_string_slice_t crlf = fastformat_getNewlineForPlatform();
    00133
    00134         sink.append(crlf.ptr, crlf.len);
    00135     }
    00136
    00137     return sink;
    00138 }
    00139
    00140 /* /////////////////////////////////////////////////////////////////////////
    00141  * Namespace
    00142  */
    00143
    00144 #if !defined(FASTFORMAT_NO_NAMESPACE)
    00145 } /* namespace sinks */
    00146 } /* namespace fastformat */
    00147 #endif /* !FASTFORMAT_NO_NAMESPACE */
    00148
    00149 /* /////////////////////////////////////////////////////////////////////////
    00150  * Inclusion
    00151  */
    00152
    00153 #ifdef STLSOFT_PPF_pragma_once_SUPPORT
    00154 # pragma once
    00155 #endif /* STLSOFT_PPF_pragma_once_SUPPORT */
    00156
    00157 /* ////////////////////////////////////////////////////////////////////// */
    00158
    00159 #endif /* FASTFORMAT_INCL_FASTFORMAT_SHIMS_ACTION_FMT_SLICES_HPP_GENERIC_STRING */
    00160
    00161 /* ///////////////////////////// end of file //////////////////////////// */

FastFormat Library documentation © Matthew Wilson, 2006-2009 |