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

# fastformat/internal/format_element.h

Go to the documentation of this file.

    00001 /* /////////////////////////////////////////////////////////////////////////
    00002  * File:        fastformat/internal/format_element.h
    00003  *
    00004  * Purpose:     Definition of the format element type and associated
    00005  *              constants
    00006  *
    00007  * Created:     6th November 2008
    00008  * Updated:     16th February 2009
    00009  *
    00010  * Home:        http://www.fastformat.org/
    00011  *
    00012  * Copyright (c) 2008-2009, 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
    00053 #ifndef FASTFORMAT_INCL_FASTFORMAT_INTERNAL_H_FORMAT_ELEMENT
    00054 #define FASTFORMAT_INCL_FASTFORMAT_INTERNAL_H_FORMAT_ELEMENT
    00055
    00056 /* /////////////////////////////////////////////////////////////////////////
    00057  * Includes
    00058  */
    00059
    00060 #include <fastformat/fastformat.h>
    00061
    00062 /* /////////////////////////////////////////////////////////////////////////
    00063  * Namespace
    00064  */
    00065
    00066 #if !defined(FASTFORMAT_NO_NAMESPACE)
    00067 namespace fastformat
    00068 {
    00069 #endif /* !FASTFORMAT_NO_NAMESPACE */
    00070
    00071 /* /////////////////////////////////////////////////////////////////////////
    00072  * Constants and definitions
    00073  */
    00074
    00075 #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
    00076
    00077 #define FASTFORMAT_INTERNAL_FORMAT_ELEMENT_INDEX_LITERAL_       (-1)
    00078 #define FASTFORMAT_INTERNAL_FORMAT_ELEMENT_INDEX_INVALID_       (-2)
    00079
    00080 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
    00081
    00082 /* /////////////////////////////////////////////////////////////////////////
    00083  * Typedefs
    00084  */
    00085
    00086 #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
    00087
    00088 typedef short   ff_format_element_width_t_;
    00089
    00090 enum ff_format_element_alignment_t_
    00091 {
    00092         FASTFORMAT_ALIGNMENT_NONE   =   0
    00093     ,   FASTFORMAT_ALIGNMENT_LEFT   =   1
    00094     ,   FASTFORMAT_ALIGNMENT_RIGHT  =   2
    00095     ,   FASTFORMAT_ALIGNMENT_CENTRE =   3
    00096 };
    00097
    00098 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
    00099
    00100 /* Three kinds of elements:
    00101  *
    00102  * 1. Literals
    00103  *  index       ==  FASTFORMAT_INTERNAL_FORMAT_ELEMENT_INDEX_LITERAL_
    00104  *  len         ->  length of the literal slice
    00105  *  ptr         ->  pointer to the slice
    00106  *  minWidth    ->  UNDEFINED
    00107  *  maxWidth    ->  UNDEFINED
    00108  *
    00109  * 2. Replacements
    00110  *  index       ->  the replacement index (>= 0)
    00111  *  len         ->  UNDEFINED
    00112  *  ptr         ->  UNDEFINED
    00113  *  minWidth    ->  UNDEFINED
    00114  *  maxWidth    ->  UNDEFINED
    00115  *
    00116  * 3. Spacers
    00117  *  index       ->  { FASTFORMAT_INTERNAL_FORMAT_ELEMENT_INDEX_PAD_LEFT_ | FASTFORMAT_INTERNAL_FORMAT_ELEMENT_INDEX_PAD_RIGHT_ }
    00118  *  len         ->  UNDEFINED
    00119  *  ptr         ->  UNDEFINED
    00120  *  minWidth    ->  minimum width of field
    00121  *  maxWidth    ->  maximum width of field
    00122  *
    00123  *   Spacers always precede Replacements
    00124  */
    00125
    00128 struct ff_format_element_t
    00129 {
    00130     size_t                          len;
    00131     ff_char_t const*                ptr;
    00132     int                             index;
    00133     ff_format_element_width_t_      minWidth;
    00134     ff_format_element_width_t_      maxWidth;
    00135     ff_format_element_alignment_t_  alignment;
    00136     int                             fill;
    00137 #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
    00138     int                             reserved1;
    00139     void*                           reserved2;
    00140 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */
    00141 };
    00142
    00143 /* /////////////////////////////////////////////////////////////////////////
    00144  * Namespace
    00145  */
    00146
    00147 #if !defined(FASTFORMAT_NO_NAMESPACE)
    00148 } /* namespace fastformat */
    00149 #endif /* !FASTFORMAT_NO_NAMESPACE */
    00150
    00151 /* ////////////////////////////////////////////////////////////////////// */
    00152
    00153 #endif /* FASTFORMAT_INCL_FASTFORMAT_INTERNAL_H_FORMAT_ELEMENT */
    00154
    00155 /* ///////////////////////////// end of file //////////////////////////// */

FastFormat Library documentation © Matthew Wilson, 2006-2009 |