00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00048 #ifndef ACESTL_INCL_ACESTL_SHIMS_ACCESS_STRING_HPP_INET_ADDR
00049 #define ACESTL_INCL_ACESTL_SHIMS_ACCESS_STRING_HPP_INET_ADDR
00050
00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00052 # define ACESTL_VER_ACESTL_SHIMS_ACCESS_STRING_HPP_INET_ADDR_MAJOR 2
00053 # define ACESTL_VER_ACESTL_SHIMS_ACCESS_STRING_HPP_INET_ADDR_MINOR 0
00054 # define ACESTL_VER_ACESTL_SHIMS_ACCESS_STRING_HPP_INET_ADDR_REVISION 6
00055 # define ACESTL_VER_ACESTL_SHIMS_ACCESS_STRING_HPP_INET_ADDR_EDIT 43
00056 #endif
00057
00058
00059
00060
00061
00062 #ifndef ACESTL_INCL_ACESTL_HPP_ACESTL
00063 # include <acestl/acestl.hpp>
00064 #endif
00065 #ifndef STLSOFT_INCL_STLSOFT_MEMORY_HPP_AUTO_BUFFER
00066 # include <stlsoft/memory/auto_buffer.hpp>
00067 #endif
00068 #ifndef STLSOFT_INCL_STLSOFT_MEMORY_HPP_ALLOCATOR_SELECTOR
00069 # include <stlsoft/memory/allocator_selector.hpp>
00070 #endif
00071 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_STRING_HPP_STD_BASIC_STRING
00072 # include <stlsoft/shims/access/string/std/basic_string.hpp>
00073 #endif
00074 #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_SHIM_STRING
00075 # include <stlsoft/string/shim_string.hpp>
00076 #endif
00077
00078 #ifndef STLSOFT_INCL_ACE_H_INET_ADDR
00079 # define STLSOFT_INCL_ACE_H_INET_ADDR
00080 # include <ace/INET_Addr.h>
00081 #endif
00082 #ifndef STLSOFT_INCL_ACE_H_ACE_WCHAR
00083 # define STLSOFT_INCL_ACE_H_ACE_WCHAR
00084 # include <ace/ace_wchar.h>
00085 #endif
00086
00087
00088
00089
00090
00091 #ifndef _ACESTL_NO_NAMESPACE
00092 # if defined(_STLSOFT_NO_NAMESPACE) || \
00093 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00094
00095 namespace acestl
00096 {
00097 # else
00098
00099
00100 namespace stlsoft
00101 {
00102
00103 namespace acestl_project
00104 {
00105
00106 # endif
00107 #endif
00108
00109
00110
00111
00112
00113 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00114 namespace acestl_inet_addr_access_string_util
00115 {
00116 template <ss_typename_param_k S>
00117 void stream_insert(S& s, ACE_INET_Addr const& addr)
00118 {
00119 typedef ::stlsoft::auto_buffer_old< ACE_TCHAR
00120 , ::stlsoft::allocator_selector<ACE_TCHAR>::allocator_type
00121 > buffer_t;
00122
00123 buffer_t buffer(buffer_t::internal_size());
00124
00125 for(; 0 != addr.addr_to_string(&buffer[0], buffer.size()); buffer.resize(2 * buffer.size()))
00126 {}
00127
00128 buffer.resize(buffer.size() + 1);
00129 buffer[buffer.size() - 1] = '\0';
00130
00131 s << buffer.data();
00132 }
00133
00134 inline int invoke_addr_to_string(ACE_TCHAR const*, ACE_INET_Addr const& addr, ACE_TCHAR buffer[], as_size_t size, int fmt)
00135 {
00136 return addr.addr_to_string(buffer, size, fmt);
00137 }
00138
00139 # ifdef ACE_USES_WCHAR
00140 inline int invoke_addr_to_string(as_char_w_t const*, ACE_INET_Addr const& addr, as_char_a_t buffer[], as_size_t size, int fmt)
00141 # else
00142 inline int invoke_addr_to_string(as_char_a_t const*, ACE_INET_Addr const& addr, as_char_w_t buffer[], as_size_t size, int fmt)
00143 # endif
00144 {
00145 # ifdef ACE_USES_WCHAR
00146 stlsoft::auto_buffer<as_char_w_t> buff(1 + size);
00147 # else
00148 stlsoft::auto_buffer<as_char_a_t> buff(1 + size);
00149 # endif
00150 int res = addr.addr_to_string(&buff[0], buff.size(), fmt);
00151
00152 if(0 == res)
00153 {
00154 ACESTL_ASSERT(static_cast<ss_size_t>(res) < buff.size());
00155
00156 buff[size] = '\0';
00157
00158 # ifdef ACE_USES_WCHAR
00159 ::strncpy(&buffer[0], ACE_TEXT_ALWAYS_CHAR(buff.data()), size);
00160 # else
00161 ::wcsncpy(&buffer[0], ACE_TEXT_ALWAYS_WCHAR(buff.data()), size);
00162 # endif
00163 }
00164
00165 return res;
00166 }
00167
00168 inline int invoke_addr_to_string(ACE_INET_Addr const& addr, as_char_a_t buffer[], as_size_t size, int fmt = 1)
00169 {
00170 return invoke_addr_to_string(static_cast<ACE_TCHAR const*>(0), addr, buffer, size, fmt);
00171 }
00172 inline int invoke_addr_to_string(ACE_INET_Addr const& addr, as_char_w_t buffer[], as_size_t size, int fmt = 1)
00173 {
00174 return invoke_addr_to_string(static_cast<ACE_TCHAR const*>(0), addr, buffer, size, fmt);
00175 }
00176
00177 template <typename C>
00178 inline ::stlsoft::basic_shim_string<C> c_str_ptr_(ACE_INET_Addr const& addr)
00179 {
00180 typedef C char_t;
00181 typedef ::stlsoft::basic_shim_string<char_t>::buffer_type buffer_t;
00182
00183 ::stlsoft::basic_shim_string<char_t> retVal(buffer_t::internal_size());
00184 buffer_t &buffer = retVal.get_buffer();
00185
00186 for(;0 != invoke_addr_to_string(addr, &buffer[0], buffer.size()); buffer.resize((3 * buffer.size()) / 2))
00187 {}
00188
00189 buffer.resize(buffer.size() + 1);
00190 buffer[buffer.size() - 1] = '\0';
00191
00192 return retVal;
00193 }
00194
00195 }
00196 #endif
00197
00198
00199
00200
00201
00202
00203
00204 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00205
00206 inline ::stlsoft::basic_shim_string<as_char_a_t> c_str_data_a(ACE_INET_Addr const& addr)
00207 {
00208 return acestl_inet_addr_access_string_util::c_str_ptr_<as_char_a_t>(addr);
00209 }
00210 inline ::stlsoft::basic_shim_string<as_char_w_t> c_str_data_w(ACE_INET_Addr const& addr)
00211 {
00212 return acestl_inet_addr_access_string_util::c_str_ptr_<as_char_w_t>(addr);
00213 }
00214
00215 #endif
00216
00222 inline ::stlsoft::basic_shim_string<ACE_TCHAR> c_str_data(ACE_INET_Addr const& addr)
00223 {
00224 return acestl_inet_addr_access_string_util::c_str_ptr_<ACE_TCHAR>(addr);
00225 }
00226
00227
00228
00229 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00230
00231 inline as_size_t c_str_len_a(ACE_INET_Addr const& addr)
00232 {
00233 return c_str_data_a(addr).size();
00234 }
00235 inline as_size_t c_str_len_w(ACE_INET_Addr const& addr)
00236 {
00237 return c_str_data_w(addr).size();
00238 }
00239
00240 #endif
00241
00247 inline as_size_t c_str_len(ACE_INET_Addr const& addr)
00248 {
00249 return c_str_data(addr).size();
00250 }
00251
00252
00253
00254 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00255
00256 inline ::stlsoft::basic_shim_string<as_char_a_t> c_str_ptr_a(ACE_INET_Addr const& addr)
00257 {
00258 return acestl_inet_addr_access_string_util::c_str_ptr_<as_char_a_t>(addr);
00259 }
00260 inline ::stlsoft::basic_shim_string<as_char_w_t> c_str_ptr_w(ACE_INET_Addr const& addr)
00261 {
00262 return acestl_inet_addr_access_string_util::c_str_ptr_<as_char_w_t>(addr);
00263 }
00264
00265 #endif
00266
00272 inline ::stlsoft::basic_shim_string<ACE_TCHAR> c_str_ptr(ACE_INET_Addr const& addr)
00273 {
00274 return acestl_inet_addr_access_string_util::c_str_ptr_<ACE_TCHAR>(addr);
00275 }
00276
00277
00278
00279 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00280
00281 inline ::stlsoft::basic_shim_string<as_char_a_t> c_str_ptr_null_a(ACE_INET_Addr const& addr)
00282 {
00283 return acestl_inet_addr_access_string_util::c_str_ptr_<as_char_a_t>(addr);
00284 }
00285 inline ::stlsoft::basic_shim_string<as_char_w_t> c_str_ptr_null_w(ACE_INET_Addr const& addr)
00286 {
00287 return acestl_inet_addr_access_string_util::c_str_ptr_<as_char_w_t>(addr);
00288 }
00289
00290 #endif
00291
00297 inline ::stlsoft::basic_shim_string<ACE_TCHAR> c_str_ptr_null(ACE_INET_Addr const& addr)
00298 {
00299 return acestl_inet_addr_access_string_util::c_str_ptr_<ACE_TCHAR>(addr);
00300 }
00301
00302
00303
00304
00305
00306
00312 template <ss_typename_param_k S>
00313 inline S& operator <<(S& s, ACE_INET_Addr const& addr)
00314 {
00315 acestl_inet_addr_access_string_util::stream_insert(s, addr);
00316
00317 return s;
00318 }
00319
00321
00322
00323 #ifdef STLSOFT_UNITTEST
00324 # include "./unittest/inet_addr_unittest_.h"
00325 #endif
00326
00327
00328
00329 #ifndef _ACESTL_NO_NAMESPACE
00330 # if defined(_STLSOFT_NO_NAMESPACE) || \
00331 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00332 }
00333 # else
00334 }
00335 }
00336 # endif
00337
00343 template <ss_typename_param_k S>
00344 inline S& operator <<(S& s, ACE_INET_Addr const& addr)
00345 {
00346 ::acestl::acestl_inet_addr_access_string_util::stream_insert(s, addr);
00347
00348 return s;
00349 }
00350
00351
00352 namespace stlsoft
00353 {
00354
00355 using ::acestl::c_str_data;
00356 using ::acestl::c_str_data_a;
00357 using ::acestl::c_str_data_w;
00358
00359 using ::acestl::c_str_len;
00360 using ::acestl::c_str_len_a;
00361 using ::acestl::c_str_len_w;
00362
00363 using ::acestl::c_str_ptr;
00364 using ::acestl::c_str_ptr_a;
00365 using ::acestl::c_str_ptr_w;
00366
00367 using ::acestl::c_str_ptr_null;
00368 using ::acestl::c_str_ptr_null_a;
00369 using ::acestl::c_str_ptr_null_w;
00370
00371 }
00372
00373 #endif
00374
00375
00376
00377 #endif
00378
00379