00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: pantheios/inserters/character.hpp 00003 * 00004 * Purpose: String inserters for fundamental types 00005 * 00006 * Created: 21st June 2005 00007 * Updated: 1st September 2006 00008 * 00009 * Author: Matthew Wilson 00010 * 00011 * Home: http://www.pantheios.org/ 00012 * 00013 * Copyright: Matthew Wilson and Synesis Software Pty Ltd, 1999-2005. 00014 * Matthew Wilson, 2005-2006. 00015 * 00016 * Redistribution and use in source and binary forms, with or without 00017 * modification, are permitted provided that the following conditions are met: 00018 * 00019 * - Redistributions of source code must retain the above copyright notice, this 00020 * list of conditions and the following disclaimer. 00021 * - Redistributions in binary form must reproduce the above copyright notice, 00022 * this list of conditions and the following disclaimer in the documentation 00023 * and/or other materials provided with the distribution. 00024 * - Neither the names of Matthew Wilson and Synesis Software nor the names of 00025 * any contributors may be used to endorse or promote products derived from 00026 * this software without specific prior written permission. 00027 * 00028 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00029 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00030 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00031 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00032 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00033 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00034 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00035 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00036 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00037 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00038 * POSSIBILITY OF SUCH DAMAGE. 00039 * 00040 * ////////////////////////////////////////////////////////////////////// */ 00041 00042 00049 #ifndef PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_CHARACTER 00050 #define PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_CHARACTER 00051 00052 /* ///////////////////////////////////////////////////////////////////////// 00053 * Version information 00054 */ 00055 00056 #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION 00057 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_CHARACTER_MAJOR 1 00058 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_CHARACTER_MINOR 0 00059 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_CHARACTER_REVISION 1 00060 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_CHARACTER_EDIT 1 00061 #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */ 00062 00063 /* ///////////////////////////////////////////////////////////////////////// 00064 * Includes 00065 */ 00066 00067 #include <pantheios/pantheios.hpp> 00068 #include <pantheios/inserters/fmt.hpp> 00069 00070 #include <stlsoft/shims/access/string/fwd.h> 00071 00072 /* ///////////////////////////////////////////////////////////////////////// 00073 * Namespace 00074 */ 00075 00076 #if !defined(PANTHEIOS_NO_NAMESPACE) 00077 namespace pantheios 00078 { 00079 00080 #endif /* !PANTHEIOS_NO_NAMESPACE */ 00081 00082 /* ///////////////////////////////////////////////////////////////////////// 00083 * Inserter classes 00084 */ 00085 00114 class character 00115 { 00116 public: 00117 typedef character class_type; 00118 00119 public: 00121 explicit character(char value); 00122 00123 private: 00124 explicit character(int); // Prevents implicit conversion from an integer 00125 00126 public: 00128 char const *data() const; 00130 char const *c_str() const; 00132 size_t length() const; 00133 00134 private: 00135 char m_value[2]; 00136 00137 private: 00138 #if !defined(STLSOFT_COMPILER_IS_GCC) 00139 character(class_type const &); 00140 #endif /* compiler */ 00141 class_type &operator =(class_type const &); 00142 }; 00143 00144 /* ///////////////////////////////////////////////////////////////////////// 00145 * String Access Shims 00146 */ 00147 00148 inline char const *c_str_data_a(character const &r) 00149 { 00150 return r.data(); 00151 } 00152 inline char const *c_str_data(character const &r) 00153 { 00154 return r.data(); 00155 } 00156 00157 inline size_t c_str_len_a(character const &r) 00158 { 00159 return r.length(); 00160 } 00161 inline size_t c_str_len(character const &r) 00162 { 00163 return r.length(); 00164 } 00165 00166 inline char const *c_str_ptr_a(character const &r) 00167 { 00168 return r.c_str(); 00169 } 00170 inline char const *c_str_ptr(character const &r) 00171 { 00172 return r.c_str(); 00173 } 00174 00175 /* ///////////////////////////////////////////////////////////////////////// 00176 * Implementation 00177 */ 00178 00179 inline /* explicit */ character::character(char value) 00180 { 00181 m_value[0] = value; 00182 m_value[1] = '\0'; 00183 } 00184 00185 inline char const *character::data() const 00186 { 00187 return m_value; 00188 } 00189 00190 inline char const *character::c_str() const 00191 { 00192 return m_value; 00193 } 00194 00195 inline size_t character::length() const 00196 { 00197 return 1; 00198 } 00199 00200 /* ///////////////////////////////////////////////////////////////////////// 00201 * Namespace 00202 */ 00203 00204 #if !defined(PANTHEIOS_NO_NAMESPACE) 00205 } /* namespace pantheios */ 00206 00207 namespace stlsoft 00208 { 00209 // 'Export' the string access shims into the STLSoft namespace 00210 // 00211 // c_str_ptr(_a) is not necessary for version 1.0 of Pantheios, but it's 00212 // defined and exported in order to allow for the case where someone 00213 // may find a legitimate use for the conversion classes additional to 00214 // the type-tunnelling of the Panthieos API. 00215 00216 using ::pantheios::c_str_data_a; 00217 using ::pantheios::c_str_data; 00218 00219 using ::pantheios::c_str_len; 00220 using ::pantheios::c_str_len_a; 00221 00222 using ::pantheios::c_str_ptr_a; 00223 using ::pantheios::c_str_ptr; 00224 } 00225 00226 #endif /* !PANTHEIOS_NO_NAMESPACE */ 00227 00228 /* ///////////////////////////////////////////////////////////////////////// 00229 * Inclusion 00230 */ 00231 00232 #ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT 00233 # pragma once 00234 #endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */ 00235 00236 /* ////////////////////////////////////////////////////////////////////// */ 00237 00238 #endif /* !PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_CHARACTER */ 00239 00240 /* ////////////////////////////////////////////////////////////////////// */
|
|
pantheios Library documentation © Matthew Wilson, 2006 |
|