00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: pantheios/inserters/pointer.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_POINTER 00050 #define PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_POINTER 00051 00052 /* ///////////////////////////////////////////////////////////////////////// 00053 * Version information 00054 */ 00055 00056 #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION 00057 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_POINTER_MAJOR 2 00058 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_POINTER_MINOR 0 00059 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_POINTER_REVISION 8 00060 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_POINTER_EDIT 8 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 00105 class pointer 00106 { 00107 public: 00108 typedef pointer class_type; 00109 00110 public: 00112 explicit pointer(void const *pv, int widthAndFormat); 00113 00114 public: 00116 char const *data() const; 00118 char const *c_str() const; 00120 size_t length() const; 00121 00122 private: 00123 void construct_() const; 00124 void construct_(); 00125 00126 private: 00127 void const *m_value; 00128 size_t m_len; 00129 char m_sz[21]; 00130 const int m_widthAndFormat; 00131 00132 private: 00133 #if !defined(STLSOFT_COMPILER_IS_GCC) 00134 pointer(class_type const &); 00135 #endif /* compiler */ 00136 class_type &operator =(class_type const &); 00137 }; 00138 00139 /* ///////////////////////////////////////////////////////////////////////// 00140 * String Access Shims 00141 */ 00142 00143 inline char const *c_str_data_a(pointer const &p) 00144 { 00145 return p.data(); 00146 } 00147 inline char const *c_str_data(pointer const &p) 00148 { 00149 return p.data(); 00150 } 00151 00152 inline size_t c_str_len_a(pointer const &p) 00153 { 00154 return p.length(); 00155 } 00156 inline size_t c_str_len(pointer const &p) 00157 { 00158 return p.length(); 00159 } 00160 00161 inline char const *c_str_ptr_a(pointer const &p) 00162 { 00163 return p.c_str(); 00164 } 00165 inline char const *c_str_ptr(pointer const &p) 00166 { 00167 return p.c_str(); 00168 } 00169 00170 /* ///////////////////////////////////////////////////////////////////////// 00171 * Namespace 00172 */ 00173 00174 #if !defined(PANTHEIOS_NO_NAMESPACE) 00175 } /* namespace pantheios */ 00176 00177 namespace stlsoft 00178 { 00179 // 'Export' the string access shims into the STLSoft namespace 00180 // 00181 // c_str_ptr(_a) is not necessary for version 1.0 of Pantheios, but it's 00182 // defined and exported in order to allow for the case where someone 00183 // may find a legitimate use for the conversion classes additional to 00184 // the type-tunnelling of the Panthieos API. 00185 00186 using ::pantheios::c_str_data_a; 00187 using ::pantheios::c_str_data; 00188 00189 using ::pantheios::c_str_len; 00190 using ::pantheios::c_str_len_a; 00191 00192 using ::pantheios::c_str_ptr_a; 00193 using ::pantheios::c_str_ptr; 00194 } 00195 00196 #endif /* !PANTHEIOS_NO_NAMESPACE */ 00197 00198 /* ///////////////////////////////////////////////////////////////////////// 00199 * Inclusion 00200 */ 00201 00202 #ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT 00203 # pragma once 00204 #endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */ 00205 00206 /* ////////////////////////////////////////////////////////////////////// */ 00207 00208 #endif /* !PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_POINTER */ 00209 00210 /* ////////////////////////////////////////////////////////////////////// */
|
|
pantheios Library documentation © Matthew Wilson, 2006 |
|