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_TIME_VALUE
00049 #define ACESTL_INCL_ACESTL_SHIMS_ACCESS_STRING_HPP_TIME_VALUE
00050
00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00052 # define ACESTL_VER_ACESTL_SHIMS_ACCESS_STRING_HPP_TIME_VALUE_MAJOR 2
00053 # define ACESTL_VER_ACESTL_SHIMS_ACCESS_STRING_HPP_TIME_VALUE_MINOR 0
00054 # define ACESTL_VER_ACESTL_SHIMS_ACCESS_STRING_HPP_TIME_VALUE_REVISION 5
00055 # define ACESTL_VER_ACESTL_SHIMS_ACCESS_STRING_HPP_TIME_VALUE_EDIT 40
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_SHIMS_ACCESS_HPP_STRING
00066 # include <stlsoft/shims/access/string.hpp>
00067 #endif
00068 #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_SHIM_STRING
00069 # include <stlsoft/string/shim_string.hpp>
00070 #endif
00071 #ifndef STLSOFT_INCL_STLSOFT_MEMORY_HPP_AUTO_BUFFER
00072 # include <stlsoft/memory/auto_buffer.hpp>
00073 #endif
00074
00075 #ifndef STLSOFT_INCL_ACE_H_TIME_VALUE
00076 # define STLSOFT_INCL_ACE_H_TIME_VALUE
00077 # include <ace/Time_Value.h>
00078 #endif
00079 #ifndef STLSOFT_INCL_ACE_H_ACE_WCHAR
00080 # define STLSOFT_INCL_ACE_H_ACE_WCHAR
00081 # include <ace/ace_wchar.h>
00082 #endif
00083 #if ACESTL_ACE_VERSION >= 0x00050004
00084 #ifndef STLSOFT_INCL_ACE_H_OS_NS_STDIO
00085 # define STLSOFT_INCL_ACE_H_OS_NS_STDIO
00086 # include <ace/OS_NS_stdio.h>
00087 #endif
00088 #ifndef STLSOFT_INCL_ACE_H_OS_NS_TIME
00089 # define STLSOFT_INCL_ACE_H_OS_NS_TIME
00090 # include <ace/OS_NS_time.h>
00091 #endif
00092 #endif
00093
00094
00095
00096
00097
00098 #ifndef _ACESTL_NO_NAMESPACE
00099 # if defined(_STLSOFT_NO_NAMESPACE) || \
00100 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00101
00102 namespace acestl
00103 {
00104 # else
00105
00106
00107 namespace stlsoft
00108 {
00109
00110 namespace acestl_project
00111 {
00112
00113 # endif
00114 #endif
00115
00116
00117
00118
00119
00120 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00121 namespace acestl_time_access_string_util
00122 {
00123 template <ss_typename_param_k S>
00124 void stream_insert(S& s, ACE_Time_Value const& t)
00125 {
00126 char s1[20];
00127 ACE_TCHAR s2[24];
00128
00129 const long s = t.sec();
00130 const long us = t.usec();
00131 struct tm *const tm = ACE_OS::localtime(&static_cast<time_t const&>(s));
00132 as_size_t len = ACE_OS::strftime(s1, STLSOFT_NUM_ELEMENTS(s1), "%Y-%m-%d %H:%M:%S", tm);
00133
00134 ACESTL_ASSERT(len == 1 + STLSOFT_NUM_ELEMENTS(s1));
00135
00136 len = ACE_OS::snprintf(s2, STLSOFT_NUM_ELEMENTS(s2), ACE_TEXT("%s.%03ld"), ACE_TEXT_CHAR_TO_TCHAR(s1), us / 1000);
00137
00138 ACESTL_ASSERT(len == 1 + STLSOFT_NUM_ELEMENTS(s2));
00139
00140 s.write(&s2[0], len);
00141 }
00142
00143 inline int invoke_ACE_OS_snprintf(ACE_TCHAR s2[], as_size_t size, ACE_TCHAR const* fmt, as_char_a_t const* s1, long ms)
00144 {
00145 return ACE_OS::snprintf(s2, size, fmt, ACE_TEXT_CHAR_TO_TCHAR(s1), ms);
00146 }
00147
00148 # ifdef ACE_USES_WCHAR
00149 inline int invoke_ACE_OS_snprintf(as_char_a_t s2[], as_size_t size, as_char_w_t const* fmt, as_char_a_t const* s1, long ms)
00150 {
00151 return ACE_OS::snprintf(s2, size, ACE_TEXT_ALWAYS_CHAR(fmt), s1, ms);
00152 }
00153 # else
00154 inline int invoke_ACE_OS_snprintf(as_char_w_t s2[], as_size_t size, as_char_a_t const* fmt, as_char_a_t const* s1, long ms)
00155 {
00156 stlsoft::auto_buffer<as_char_a_t> buff(1 + size);
00157 int res;
00158
00159 s2[0] = '\0';
00160
00161 res = ACE_OS::snprintf(&buff[0], buff.size(), ACE_TEXT_ALWAYS_CHAR(fmt), s1, ms);
00162
00163 if(0 < res)
00164 {
00165 ACESTL_ASSERT(static_cast<ss_size_t>(res) < buff.size());
00166
00167 ::mbstowcs(&s2[2], buff.data(), res);
00168 s2[res] = '\0';
00169 }
00170
00171 return res;
00172 }
00173 # endif
00174
00175 template <ss_typename_param_k C>
00176 inline ::stlsoft::basic_shim_string<C> c_str_ptr_(ACE_Time_Value const& t)
00177 {
00178 typedef C char_t;
00179
00180 as_char_a_t s1[20];
00181 char_t s2[24];
00182 const long s = t.sec();
00183 const long us = t.usec();
00184 struct tm *const tm = ACE_OS::localtime(&static_cast<time_t const&>(s));
00185 as_size_t len = ACE_OS::strftime(s1, STLSOFT_NUM_ELEMENTS(s1), "%Y-%m-%d %H:%M:%S", tm);
00186
00187 ACESTL_ASSERT(1 + len == STLSOFT_NUM_ELEMENTS(s1));
00188
00189 len = invoke_ACE_OS_snprintf(s2, STLSOFT_NUM_ELEMENTS(s2), ACE_TEXT("%s.%03ld"), s1, us / 1000);
00190
00191 ACESTL_ASSERT(1 + len == STLSOFT_NUM_ELEMENTS(s2));
00192
00193 return ::stlsoft::basic_shim_string<char_t>(&s2[0], len);
00194 }
00195
00196 }
00197 #endif
00198
00199
00200
00201
00202
00203
00204
00205 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00206
00207 inline ::stlsoft::basic_shim_string<as_char_a_t> c_str_data_a(ACE_Time_Value const& t)
00208 {
00209 return acestl_time_access_string_util::c_str_ptr_<as_char_a_t>(t);
00210 }
00211 inline ::stlsoft::basic_shim_string<as_char_w_t> c_str_data_w(ACE_Time_Value const& t)
00212 {
00213 return acestl_time_access_string_util::c_str_ptr_<as_char_w_t>(t);
00214 }
00215 #endif
00216
00222 inline ::stlsoft::basic_shim_string<ACE_TCHAR> c_str_data(ACE_Time_Value const& t)
00223 {
00224 return acestl_time_access_string_util::c_str_ptr_<ACE_TCHAR>(t);
00225 }
00226
00227
00228
00229 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00230
00231 inline as_size_t c_str_len_a(ACE_Time_Value const& )
00232 {
00233 return 23;
00234 }
00235 inline as_size_t c_str_len_w(ACE_Time_Value const& )
00236 {
00237 return 23;
00238 }
00239
00240 #endif
00241
00247 inline as_size_t c_str_len(ACE_Time_Value const& )
00248 {
00249 return 23;
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_Time_Value const& t)
00257 {
00258 return acestl_time_access_string_util::c_str_ptr_<as_char_a_t>(t);
00259 }
00260 inline ::stlsoft::basic_shim_string<as_char_w_t> c_str_ptr_w(ACE_Time_Value const& t)
00261 {
00262 return acestl_time_access_string_util::c_str_ptr_<as_char_w_t>(t);
00263 }
00264
00265 #endif
00266
00272 inline ::stlsoft::basic_shim_string<ACE_TCHAR> c_str_ptr(ACE_Time_Value const& t)
00273 {
00274 return acestl_time_access_string_util::c_str_ptr_<ACE_TCHAR>(t);
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_Time_Value const& t)
00282 {
00283 return acestl_time_access_string_util::c_str_ptr_<as_char_a_t>(t);
00284 }
00285 inline ::stlsoft::basic_shim_string<as_char_w_t> c_str_ptr_null_w(ACE_Time_Value const& t)
00286 {
00287 return acestl_time_access_string_util::c_str_ptr_<as_char_w_t>(t);
00288 }
00289
00290 #endif
00291
00297 inline ::stlsoft::basic_shim_string<ACE_TCHAR> c_str_ptr_null(ACE_Time_Value const& t)
00298 {
00299 return acestl_time_access_string_util::c_str_ptr_<ACE_TCHAR>(t);
00300 }
00301
00302
00303
00304
00305
00306
00311 template <ss_typename_param_k S>
00312 inline S& operator <<(S& s, ACE_Time_Value const& t)
00313 {
00314 acestl_time_access_string_util::stream_insert(s, t);
00315
00316 return s;
00317 }
00318
00320
00321
00322 #ifdef STLSOFT_UNITTEST
00323 # include "./unittest/time_value_unittest_.h"
00324 #endif
00325
00326
00327
00328 #ifndef _ACESTL_NO_NAMESPACE
00329 # if defined(_STLSOFT_NO_NAMESPACE) || \
00330 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00331 }
00332 # else
00333 }
00334 }
00335 # endif
00336
00341 template <ss_typename_param_k S>
00342 inline S& operator <<(S& s, ACE_Time_Value const& t)
00343 {
00344 ::acestl::acestl_time_access_string_util::stream_insert(s, t);
00345
00346 return s;
00347 }
00348
00349 namespace stlsoft
00350 {
00351
00352 using ::acestl::c_str_data;
00353 using ::acestl::c_str_data_a;
00354 using ::acestl::c_str_data_w;
00355
00356 using ::acestl::c_str_len;
00357 using ::acestl::c_str_len_a;
00358 using ::acestl::c_str_len_w;
00359
00360 using ::acestl::c_str_ptr;
00361 using ::acestl::c_str_ptr_a;
00362 using ::acestl::c_str_ptr_w;
00363
00364 using ::acestl::c_str_ptr_null;
00365 using ::acestl::c_str_ptr_null_a;
00366 using ::acestl::c_str_ptr_null_w;
00367
00368 }
00369
00370 #endif
00371
00372
00373
00374 #endif
00375
00376