00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: pantheios/inserters/blob.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_BLOB 00050 #define PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_BLOB 00051 00052 /* ///////////////////////////////////////////////////////////////////////// 00053 * Version information 00054 */ 00055 00056 #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION 00057 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_BLOB_MAJOR 2 00058 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_BLOB_MINOR 0 00059 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_BLOB_REVISION 8 00060 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_BLOB_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 #include <stdio.h> 00073 00074 /* ///////////////////////////////////////////////////////////////////////// 00075 * Namespace 00076 */ 00077 00078 #if !defined(PANTHEIOS_NO_NAMESPACE) 00079 namespace pantheios 00080 { 00081 00082 #endif /* !PANTHEIOS_NO_NAMESPACE */ 00083 00084 /* ///////////////////////////////////////////////////////////////////////// 00085 * Inserter classes 00086 */ 00087 00144 class blob 00145 { 00148 public: 00149 typedef blob class_type; 00151 00154 public: 00160 blob( void const *pv 00161 , size_t cb); 00162 00172 blob( void const *pv 00173 , size_t cb 00174 , unsigned bytesPerGroup 00175 , char const *groupSeparator); 00176 00189 blob( void const *pv 00190 , size_t cb 00191 , unsigned bytesPerGroup 00192 , char const *groupSeparator 00193 , int groupsPerLine 00194 , char const *lineSeparator = "\n"); 00195 00197 ~blob() stlsoft_throw_0(); 00199 00202 public: 00204 char const *data() const; 00206 char const *c_str() const; 00208 size_t length() const; 00210 00213 private: 00214 void construct_() const; 00215 void construct_(); 00217 00220 private: 00221 char const *m_value; 00222 size_t m_len; 00223 void const *m_pv; 00224 size_t m_cb; 00225 unsigned m_byteGrouping; 00226 char const *m_groupSeparator; 00227 int m_groupsPerLine; 00228 char const *m_lineSeparator; 00230 00233 private: 00234 #if !defined(STLSOFT_COMPILER_IS_GCC) 00235 blob(class_type const &); 00236 #endif /* compiler */ 00237 class_type &operator =(class_type const &); 00239 }; 00240 00241 /* ///////////////////////////////////////////////////////////////////////// 00242 * String Access Shims 00243 */ 00244 00245 inline char const *c_str_data_a(blob const &i) 00246 { 00247 return i.data(); 00248 } 00249 inline char const *c_str_data(blob const &i) 00250 { 00251 return i.data(); 00252 } 00253 00254 inline size_t c_str_len_a(blob const &i) 00255 { 00256 return i.length(); 00257 } 00258 inline size_t c_str_len(blob const &i) 00259 { 00260 return i.length(); 00261 } 00262 00263 inline char const *c_str_ptr_a(blob const &i) 00264 { 00265 return i.c_str(); 00266 } 00267 inline char const *c_str_ptr(blob const &i) 00268 { 00269 return i.c_str(); 00270 } 00271 00272 /* ///////////////////////////////////////////////////////////////////////// 00273 * Namespace 00274 */ 00275 00276 #if !defined(PANTHEIOS_NO_NAMESPACE) 00277 } /* namespace pantheios */ 00278 00279 namespace stlsoft 00280 { 00281 // 'Export' the string access shims into the STLSoft namespace 00282 // 00283 // c_str_ptr(_a) is not necessary for version 1.0 of Pantheios, but it's 00284 // defined and exported in order to allow for the case where someone 00285 // may find a legitimate use for the conversion classes additional to 00286 // the type-tunnelling of the Panthieos API. 00287 00288 using ::pantheios::c_str_data_a; 00289 using ::pantheios::c_str_data; 00290 00291 using ::pantheios::c_str_len; 00292 using ::pantheios::c_str_len_a; 00293 00294 using ::pantheios::c_str_ptr_a; 00295 using ::pantheios::c_str_ptr; 00296 } 00297 00298 #endif /* !PANTHEIOS_NO_NAMESPACE */ 00299 00300 /* ///////////////////////////////////////////////////////////////////////// 00301 * Inclusion 00302 */ 00303 00304 #ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT 00305 # pragma once 00306 #endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */ 00307 00308 /* ////////////////////////////////////////////////////////////////////// */ 00309 00310 #endif /* !PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_BLOB */ 00311 00312 /* ////////////////////////////////////////////////////////////////////// */
|
|
pantheios Library documentation © Matthew Wilson, 2006 |
|