Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

pantheios/inserters/hostid.hpp

Go to the documentation of this file.
00001 /* /////////////////////////////////////////////////////////////////////////
00002  * File:        pantheios/inserters/hostid.hpp
00003  *
00004  * Purpose:     String inserter for host identity.
00005  *
00006  * Created:     14th March 2008
00007  * Updated:     23rd March 2010
00008  *
00009  * Home:        http://www.pantheios.org/
00010  *
00011  * Copyright (c) 2008-2010, Matthew Wilson and Synesis Software
00012  * All rights reserved.
00013  *
00014  * Redistribution and use in source and binary forms, with or without
00015  * modification, are permitted provided that the following conditions are
00016  * met:
00017  *
00018  * - Redistributions of source code must retain the above copyright notice,
00019  *   this list of conditions and the following disclaimer.
00020  * - Redistributions in binary form must reproduce the above copyright
00021  *   notice, this list of conditions and the following disclaimer in the
00022  *   documentation and/or other materials provided with the distribution.
00023  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
00024  *   names of any contributors may be used to endorse or promote products
00025  *   derived from this software without specific prior written permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00028  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00029  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00030  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00031  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00032  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00033  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00034  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00035  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00036  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00037  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038  *
00039  * ////////////////////////////////////////////////////////////////////// */
00040 
00041 
00047 #ifndef PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_HOSTID
00048 #define PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_HOSTID
00049 
00050 /* /////////////////////////////////////////////////////////////////////////
00051  * Version information
00052  */
00053 
00054 #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
00055 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_HOSTID_MAJOR     1
00056 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_HOSTID_MINOR     3
00057 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_HOSTID_REVISION  1
00058 # define PANTHEIOS_VER_PANTHEIOS_INSERTERS_HPP_HOSTID_EDIT      10
00059 #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
00060 
00061 /* /////////////////////////////////////////////////////////////////////////
00062  * Includes
00063  */
00064 
00065 #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS
00066 # include <pantheios/pantheios.h>
00067 #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */
00068 #ifndef PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_FMT
00069 # include <pantheios/inserters/fmt.hpp>
00070 #endif /* !PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_FMT */
00071 
00072 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_H_FWD
00073 # include <stlsoft/shims/access/string/fwd.h>
00074 #endif /* !STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_H_FWD */
00075 
00076 /* /////////////////////////////////////////////////////////////////////////
00077  * Namespace
00078  */
00079 
00080 #if !defined(PANTHEIOS_NO_NAMESPACE)
00081 namespace pantheios
00082 {
00083 #endif /* !PANTHEIOS_NO_NAMESPACE */
00084 
00085 /* /////////////////////////////////////////////////////////////////////////
00086  * Typedefs
00087  */
00088 
00089 #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
00090 struct hostId_t;
00091 #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
00092 
00108 extern struct hostId_t const* hostId;
00109 
00110 /* /////////////////////////////////////////////////////////////////////////
00111  * Namespace
00112  */
00113 
00114 #ifndef PANTHEIOS_DOCUMENTATION_SKIP_SECTION
00115 
00116 # if !defined(PANTHEIOS_NO_NAMESPACE) && \
00117      !defined(STLSOFT_COMPILER_IS_BORLAND) /* NOTE: BC++ 5.6 experiences crashes when the sub-namespace is used */
00118 namespace inserters
00119 {
00120 # endif /* !PANTHEIOS_NO_NAMESPACE) && !STLSOFT_COMPILER_IS_BORLAND */
00121 
00122 /* /////////////////////////////////////////////////////////////////////////
00123  * Inserter classes and String Access Shims
00124  */
00125 
00126 class host_id_t
00127 {
00128 public:
00129     typedef host_id_t               class_type;
00130 # if !defined(PANTHEIOS_NO_NAMESPACE)
00131     typedef ::pantheios::hostId_t   id_type;
00132 # else /* ? !PANTHEIOS_NO_NAMESPACE */
00133     typedef struct hostId_t         id_type;
00134 # endif /* !PANTHEIOS_NO_NAMESPACE */
00135 
00136 public:
00137     host_id_t();
00138     ~host_id_t() stlsoft_throw_0();
00139 private:
00140 #if !defined(STLSOFT_COMPILER_IS_BORLAND) && \
00141     !defined(STLSOFT_COMPILER_IS_GCC) && \
00142     !defined(STLSOFT_COMPILER_IS_MSVC)
00143     host_id_t(class_type const&);
00144 #endif /* compiler */
00145     class_type& operator =(class_type const&);
00146 
00147 public:
00148     operator size_t () const;
00149     operator pan_char_t const* () const;
00150 
00151 private:
00152     void construct_();
00153     void construct_() const;
00154 
00155 private:
00156     pan_char_t const*   m_value;
00157     size_t              m_len;
00158 };
00159 
00160 # if !defined(PANTHEIOS_NO_NAMESPACE) && \
00161      !defined(STLSOFT_COMPILER_IS_BORLAND)
00162 } /* namespace inserters */
00163 #  define PANTHEIOS_INSERTERS_DECLARE_host_id_t     ::pantheios::inserters::host_id_t
00164 # else /* ? !PANTHEIOS_NO_NAMESPACE && !STLSOFT_COMPILER_IS_BORLAND */
00165 #  define PANTHEIOS_INSERTERS_DECLARE_host_id_t     host_id_t
00166 # endif /* !PANTHEIOS_NO_NAMESPACE && !STLSOFT_COMPILER_IS_BORLAND */
00167 
00168 # if !defined(PANTHEIOS_NO_NAMESPACE)
00169 namespace shims
00170 {
00171 # endif /* !PANTHEIOS_NO_NAMESPACE */
00172 
00173 #  ifdef PANTHEIOS_USE_WIDE_STRINGS
00174 inline PANTHEIOS_INSERTERS_DECLARE_host_id_t c_str_data_w(PANTHEIOS_INSERTERS_DECLARE_host_id_t::id_type const*)
00175 #  else /* ? PANTHEIOS_USE_WIDE_STRINGS */
00176 inline PANTHEIOS_INSERTERS_DECLARE_host_id_t c_str_data_a(PANTHEIOS_INSERTERS_DECLARE_host_id_t::id_type const*)
00177 #  endif /* PANTHEIOS_USE_WIDE_STRINGS */
00178 {
00179     return PANTHEIOS_INSERTERS_DECLARE_host_id_t();
00180 }
00181 inline PANTHEIOS_INSERTERS_DECLARE_host_id_t c_str_data(PANTHEIOS_INSERTERS_DECLARE_host_id_t::id_type const*)
00182 {
00183     return PANTHEIOS_INSERTERS_DECLARE_host_id_t();
00184 }
00185 
00186 #  ifdef PANTHEIOS_USE_WIDE_STRINGS
00187 inline PANTHEIOS_INSERTERS_DECLARE_host_id_t c_str_len_w(PANTHEIOS_INSERTERS_DECLARE_host_id_t::id_type const*)
00188 #  else /* ? PANTHEIOS_USE_WIDE_STRINGS */
00189 inline PANTHEIOS_INSERTERS_DECLARE_host_id_t c_str_len_a(PANTHEIOS_INSERTERS_DECLARE_host_id_t::id_type const*)
00190 #  endif /* PANTHEIOS_USE_WIDE_STRINGS */
00191 {
00192     return PANTHEIOS_INSERTERS_DECLARE_host_id_t();
00193 }
00194 inline PANTHEIOS_INSERTERS_DECLARE_host_id_t c_str_len(PANTHEIOS_INSERTERS_DECLARE_host_id_t::id_type const*)
00195 {
00196     return PANTHEIOS_INSERTERS_DECLARE_host_id_t();
00197 }
00198 
00199 #  ifdef PANTHEIOS_USE_WIDE_STRINGS
00200 inline PANTHEIOS_INSERTERS_DECLARE_host_id_t c_str_ptr_w(PANTHEIOS_INSERTERS_DECLARE_host_id_t::id_type const*)
00201 #  else /* ? PANTHEIOS_USE_WIDE_STRINGS */
00202 inline PANTHEIOS_INSERTERS_DECLARE_host_id_t c_str_ptr_a(PANTHEIOS_INSERTERS_DECLARE_host_id_t::id_type const*)
00203 #  endif /* PANTHEIOS_USE_WIDE_STRINGS */
00204 {
00205     return PANTHEIOS_INSERTERS_DECLARE_host_id_t();
00206 }
00207 inline PANTHEIOS_INSERTERS_DECLARE_host_id_t c_str_ptr(PANTHEIOS_INSERTERS_DECLARE_host_id_t::id_type const*)
00208 {
00209     return PANTHEIOS_INSERTERS_DECLARE_host_id_t();
00210 }
00211 
00212 # if !defined(PANTHEIOS_NO_NAMESPACE)
00213 } /* namespace shims */
00214 
00215 #  if defined(STLSOFT_COMPILER_IS_GCC)
00216     /* GCC does not seem to correctly handle the phases of
00217      * processing of C++ templates, so we need to 'use' the
00218      * shims into the same namespace as the inserter class
00219      * in order that ADL can suffice instead.
00220      */
00221 #   ifdef PANTHEIOS_USE_WIDE_STRINGS
00222     using ::pantheios::shims::c_str_data_w;
00223     using ::pantheios::shims::c_str_len_w;
00224     using ::pantheios::shims::c_str_ptr_w;
00225 #   else /* ? PANTHEIOS_USE_WIDE_STRINGS */
00226     using ::pantheios::shims::c_str_data_a;
00227     using ::pantheios::shims::c_str_len_a;
00228     using ::pantheios::shims::c_str_ptr_a;
00229 #   endif /* PANTHEIOS_USE_WIDE_STRINGS */
00230     using ::pantheios::shims::c_str_data;
00231     using ::pantheios::shims::c_str_len;
00232     using ::pantheios::shims::c_str_ptr;
00233 #  endif /* compiler */
00234 
00235 # endif /* !PANTHEIOS_NO_NAMESPACE */
00236 
00237 #endif /* !PANTHEIOS_DOCUMENTATION_SKIP_SECTION */
00238 
00239 /* /////////////////////////////////////////////////////////////////////////
00240  * Namespace
00241  */
00242 
00243 #if !defined(PANTHEIOS_NO_NAMESPACE)
00244 
00245 } /* namespace pantheios */
00246 
00247 namespace stlsoft
00248 {
00249     // 'Export' the string access shims into the STLSoft namespace
00250     //
00251     // c_str_ptr(_a) is not necessary for version 1.0 of Pantheios, but it's
00252     // defined and exported in order to allow for the case where someone
00253     // may find a legitimate use for the conversion classes additional to
00254     // the type-tunneling of the Pantheios API.
00255 
00256 #ifdef PANTHEIOS_USE_WIDE_STRINGS
00257     using ::pantheios::shims::c_str_data_w;
00258     using ::pantheios::shims::c_str_len_w;
00259     using ::pantheios::shims::c_str_ptr_w;
00260 #else /* ? PANTHEIOS_USE_WIDE_STRINGS */
00261     using ::pantheios::shims::c_str_data_a;
00262     using ::pantheios::shims::c_str_len_a;
00263     using ::pantheios::shims::c_str_ptr_a;
00264 #endif /* PANTHEIOS_USE_WIDE_STRINGS */
00265     using ::pantheios::shims::c_str_data;
00266     using ::pantheios::shims::c_str_len;
00267     using ::pantheios::shims::c_str_ptr;
00268 
00269 }
00270 
00271 #endif /* !PANTHEIOS_NO_NAMESPACE */
00272 
00273 /* /////////////////////////////////////////////////////////////////////////
00274  * Inclusion
00275  */
00276 
00277 #ifdef STLSOFT_PPF_pragma_once_SUPPORT
00278 # pragma once
00279 #endif /* STLSOFT_PPF_pragma_once_SUPPORT */
00280 
00281 /* ////////////////////////////////////////////////////////////////////// */
00282 
00283 #endif /* !PANTHEIOS_INCL_PANTHEIOS_INSERTERS_HPP_HOSTID */
00284 
00285 /* ///////////////////////////// end of file //////////////////////////// */

pantheios Library documentation © Matthew Wilson & Synesis Software, 2006-2011 SourceForge.net Logo