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
00041
00042
00049 #ifndef FASTFORMAT_INCL_FASTFORMAT_SHIMS_CONVERSION_FILTER_TYPE_HPP_FAST_INTEGERS
00050 #define FASTFORMAT_INCL_FASTFORMAT_SHIMS_CONVERSION_FILTER_TYPE_HPP_FAST_INTEGERS
00051
00052
00053
00054
00055
00056 #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION
00057 # define FASTFORMAT_VER_FASTFORMAT_SHIMS_CONVERSION_FILTER_TYPE_HPP_FAST_INTEGERS_MAJOR 2
00058 # define FASTFORMAT_VER_FASTFORMAT_SHIMS_CONVERSION_FILTER_TYPE_HPP_FAST_INTEGERS_MINOR 1
00059 # define FASTFORMAT_VER_FASTFORMAT_SHIMS_CONVERSION_FILTER_TYPE_HPP_FAST_INTEGERS_REVISION 1
00060 # define FASTFORMAT_VER_FASTFORMAT_SHIMS_CONVERSION_FILTER_TYPE_HPP_FAST_INTEGERS_EDIT 11
00061 #endif
00062
00063
00064
00065
00066
00067 #ifndef __cplusplus
00068 # error This file can only be included in C++ compilation units
00069 #endif
00070
00071
00072
00073
00074
00075 #include <fastformat/fastformat.h>
00076 #include <fastformat/internal/stlsoft.h>
00077 #include <fastformat/quality/contract.h>
00078
00079 #include <stlsoft/conversion/integer_to_string.hpp>
00080 #include <stlsoft/string/shim_string.hpp>
00081
00082
00083
00084
00085
00086 #if !defined(FASTFORMAT_NO_NAMESPACE)
00087 namespace fastformat
00088 {
00089 namespace filters
00090 {
00091 #endif
00092
00093
00094
00095
00096
00097 namespace ximpl_fastformat_filters_fast_integers
00098 {
00099 #if 1
00100 template <size_t N>
00101 struct integer_shim
00102 {
00103 public:
00104 ff_char_t const* ptr;
00105 ff_char_t buff[N];
00106 size_t len;
00107
00108 public:
00109 integer_shim()
00110 {}
00111
00112 integer_shim(integer_shim const& rhs)
00113 : ptr(&buff[0] + (rhs.ptr - &rhs.buff[0]))
00114 , len(rhs.len)
00115 {
00116 ::memcpy(const_cast<ff_char_t*>(ptr), rhs.ptr, sizeof(ff_char_t) * len);
00117 }
00118
00119 public:
00120 void assign(ff_char_t const* p)
00121 {
00122 this->ptr = p;
00123 }
00124
00125 public:
00126 ff_char_t const* data() const
00127 {
00128 return ptr;
00129 }
00130 size_t size() const
00131 {
00132 return len;
00133 }
00134 };
00135 #else
00136 template <size_t N>
00137 struct integer_shim
00138 {
00139 public:
00140 ptrdiff_t offset;
00141 ff_char_t buff[N];
00142 size_t len;
00143
00144 public:
00145 void assign(ff_char_t const* p)
00146 {
00147 this->offset = p - &buff[0];
00148 }
00149
00150 public:
00151 ff_char_t const* data() const
00152 {
00153 return &buff[0] + offset;
00154 }
00155 size_t size() const
00156 {
00157 return len;
00158 }
00159 };
00160 #endif
00161
00162 }
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 #if defined(STLSOFT_CF_BUILTIN_long_long_SUPPORT) || \
00179 defined(STLSOFT_CF_64BIT_INT_SUPPORT)
00180
00185 inline ximpl_fastformat_filters_fast_integers::integer_shim<21> filter_type(
00186 # if defined(STLSOFT_CF_BUILTIN_long_long_SUPPORT)
00187 signed long long value
00188 , signed long long const*
00189 # elif defined(STLSOFT_CF_64BIT_INT_SUPPORT)
00190 ::stlsoft::sint64_t value
00191 , ::stlsoft::sint64_t const*
00192 # else
00193 # error Bad discrimination
00194 # endif
00195 , ff_char_t const volatile*
00196 )
00197 {
00198 ximpl_fastformat_filters_fast_integers::integer_shim<21> r;
00199
00200 r.assign(stlsoft::integer_to_string(r.buff, STLSOFT_NUM_ELEMENTS(r.buff), value, r.len));
00201
00202 return r;
00203 }
00204
00209 inline ximpl_fastformat_filters_fast_integers::integer_shim<21> filter_type(
00210 # if defined(STLSOFT_CF_BUILTIN_long_long_SUPPORT)
00211 unsigned long long value
00212 , unsigned long long const*
00213 # elif defined(STLSOFT_CF_64BIT_INT_SUPPORT)
00214 ::stlsoft::uint64_t value
00215 , ::stlsoft::uint64_t const*
00216 # else
00217 # error Bad discrimination
00218 # endif
00219 , ff_char_t const volatile*
00220 )
00221 {
00222 ximpl_fastformat_filters_fast_integers::integer_shim<21> r;
00223
00224 r.assign(stlsoft::integer_to_string(r.buff, STLSOFT_NUM_ELEMENTS(r.buff), value, r.len));
00225
00226 return r;
00227 }
00228
00229 #endif
00230
00234 inline ximpl_fastformat_filters_fast_integers::integer_shim<12> filter_type(
00235 signed long value
00236 , signed long const*
00237 , ff_char_t const volatile*
00238 )
00239 {
00240 ximpl_fastformat_filters_fast_integers::integer_shim<12> r;
00241
00242 r.assign(stlsoft::integer_to_string(r.buff, STLSOFT_NUM_ELEMENTS(r.buff), value, r.len));
00243
00244 return r;
00245 }
00246
00250 inline ximpl_fastformat_filters_fast_integers::integer_shim<12> filter_type(
00251 unsigned long value
00252 , unsigned long const*
00253 , ff_char_t const volatile*
00254 )
00255 {
00256 ximpl_fastformat_filters_fast_integers::integer_shim<12> r;
00257
00258 r.assign(stlsoft::integer_to_string(r.buff, STLSOFT_NUM_ELEMENTS(r.buff), value, r.len));
00259
00260 return r;
00261 }
00262
00266 inline ximpl_fastformat_filters_fast_integers::integer_shim<12> filter_type(
00267 signed int value
00268 , signed int const*
00269 , ff_char_t const volatile*
00270 )
00271 {
00272 signed long value2 = value;
00273
00274 return filter_type(value2, &value2, static_cast<ff_char_t const volatile*>(0));
00275 }
00276
00280 inline ximpl_fastformat_filters_fast_integers::integer_shim<12> filter_type(
00281 unsigned int value
00282 , unsigned int const*
00283 , ff_char_t const volatile*
00284 )
00285 {
00286 unsigned long value2 = value;
00287
00288 return filter_type(value2, &value2, static_cast<ff_char_t const volatile*>(0));
00289 }
00290
00294 inline ximpl_fastformat_filters_fast_integers::integer_shim<12> filter_type(
00295 signed short value
00296 , signed short const*
00297 , ff_char_t const volatile*
00298 )
00299 {
00300 signed long value2 = value;
00301
00302 return filter_type(value2, &value2, static_cast<ff_char_t const volatile*>(0));
00303 }
00304
00308 inline ximpl_fastformat_filters_fast_integers::integer_shim<12> filter_type(
00309 unsigned short value
00310 , unsigned short const*
00311 , ff_char_t const volatile*
00312 )
00313 {
00314 unsigned long value2 = value;
00315
00316 return filter_type(value2, &value2, static_cast<ff_char_t const volatile*>(0));
00317 }
00318
00319
00320
00321 #ifdef STLSOFT_CF_INT_DISTINCT_INT_TYPE
00322 inline ximpl_fastformat_filters_fast_integers::integer_shim<12> filter_type(
00323 ::stlsoft::sint32_t value
00324 , ::stlsoft::sint32_t const*
00325 , ff_char_t const volatile*
00326 )
00327 {
00328 signed long value2 = value;
00329
00330 return filter_type(value2, &value2, static_cast<ff_char_t const volatile*>(0));
00331 }
00332
00333 inline ximpl_fastformat_filters_fast_integers::integer_shim<12> filter_type(
00334 ::stlsoft::uint32_t value
00335 , ::stlsoft::uint32_t const*
00336 , ff_char_t const volatile*
00337 )
00338 {
00339 unsigned long value2 = value;
00340
00341 return filter_type(value2, &value2, static_cast<ff_char_t const volatile*>(0));
00342 }
00343 #endif
00344
00345
00346
00347
00348
00350 template <size_t N>
00351 #ifdef FASTFORMAT_USE_WIDE_STRINGS
00352 inline wchar_t const* c_str_data_w(
00353 #else
00354 inline char const* c_str_data_a(
00355 #endif
00356 #if !defined(FASTFORMAT_NO_NAMESPACE)
00357 ::fastformat::filters::
00358 #endif
00359 ximpl_fastformat_filters_fast_integers::integer_shim<N> const& s
00360 )
00361 {
00362 #if 1
00363 return s.data();
00364 #else
00365 return s.ptr;
00366 #endif
00367 }
00368
00370 template <size_t N>
00371 inline ff_char_t const* c_str_data(
00372 #if !defined(FASTFORMAT_NO_NAMESPACE)
00373 ::fastformat::filters::
00374 #endif
00375 ximpl_fastformat_filters_fast_integers::integer_shim<N> const& s
00376 )
00377 {
00378 #ifdef FASTFORMAT_USE_WIDE_STRINGS
00379 return c_str_data_w(s);
00380 #else
00381 return c_str_data_a(s);
00382 #endif
00383 }
00384
00386 template <size_t N>
00387 #ifdef FASTFORMAT_USE_WIDE_STRINGS
00388 inline size_t c_str_len_w(
00389 #else
00390 inline size_t c_str_len_a(
00391 #endif
00392 #if !defined(FASTFORMAT_NO_NAMESPACE)
00393 ::fastformat::filters::
00394 #endif
00395 ximpl_fastformat_filters_fast_integers::integer_shim<N> const& s
00396 )
00397 {
00398 #if 0
00399 return s.size();
00400 #else
00401 return s.len;
00402 #endif
00403 }
00404
00406 template <size_t N>
00407 inline size_t c_str_len(
00408 #if !defined(FASTFORMAT_NO_NAMESPACE)
00409 ::fastformat::filters::
00410 #endif
00411 ximpl_fastformat_filters_fast_integers::integer_shim<N> const& s
00412 )
00413 {
00414 #ifdef FASTFORMAT_USE_WIDE_STRINGS
00415 return c_str_len_w(s);
00416 #else
00417 return c_str_len_a(s);
00418 #endif
00419 }
00420
00421
00422
00423
00424
00425 #if !defined(FASTFORMAT_NO_NAMESPACE)
00426 }
00427 }
00428
00429 # ifndef _STLSOFT_NO_NAMESPACE
00430 namespace stlsoft
00431 {
00432 # endif
00433
00434 # ifdef FASTFORMAT_USE_WIDE_STRINGS
00435 using ::fastformat::filters::c_str_data_w;
00436 using ::fastformat::filters::c_str_len_w;
00437 # else
00438 using ::fastformat::filters::c_str_data_a;
00439 using ::fastformat::filters::c_str_len_a;
00440 # endif
00441 using ::fastformat::filters::c_str_data;
00442 using ::fastformat::filters::c_str_len;
00443
00444 # ifndef _STLSOFT_NO_NAMESPACE
00445 }
00446 # endif
00447
00448 #else
00449
00450 # ifndef _STLSOFT_NO_NAMESPACE
00451 namespace stlsoft
00452 {
00453
00455 template <size_t N>
00456 # ifdef FASTFORMAT_USE_WIDE_STRINGS
00457 inline wchar_t const* c_str_data_w(
00458 # else
00459 inline char const* c_str_data_a(
00460 # endif
00461 #if !defined(FASTFORMAT_NO_NAMESPACE)
00462 ::fastformat::filters::
00463 #endif
00464 ximpl_fastformat_filters_fast_integers::integer_shim<N> const& s
00465 )
00466 {
00467 #if 1
00468 return s.data();
00469 #else
00470 return s.ptr;
00471 #endif
00472 }
00473
00475 template <size_t N>
00476 inline ff_char_t const* c_str_data(
00477 #if !defined(FASTFORMAT_NO_NAMESPACE)
00478 ::fastformat::filters::
00479 #endif
00480 ximpl_fastformat_filters_fast_integers::integer_shim<N> const& s
00481 )
00482 {
00483 #ifdef FASTFORMAT_USE_WIDE_STRINGS
00484 return c_str_data_w(s);
00485 #else
00486 return c_str_data_a(s);
00487 #endif
00488 }
00489
00491 template <size_t N>
00492 # ifdef FASTFORMAT_USE_WIDE_STRINGS
00493 inline size_t c_str_len_w(
00494 # else
00495 inline size_t c_str_len_a(
00496 # endif
00497 #if !defined(FASTFORMAT_NO_NAMESPACE)
00498 ::fastformat::filters::
00499 #endif
00500 ximpl_fastformat_filters_fast_integers::integer_shim<N> const& s
00501 )
00502 {
00503 #if 0
00504 return s.size();
00505 #else
00506 return s.len;
00507 #endif
00508 }
00509
00511 template <size_t N>
00512 inline size_t c_str_len(
00513 #if !defined(FASTFORMAT_NO_NAMESPACE)
00514 ::fastformat::filters::
00515 #endif
00516 ximpl_fastformat_filters_fast_integers::integer_shim<N> const& s
00517 )
00518 {
00519 #ifdef FASTFORMAT_USE_WIDE_STRINGS
00520 return c_str_len_w(s);
00521 #else
00522 return c_str_len_a(s);
00523 #endif
00524 }
00525
00526 }
00527 # endif
00528
00529 #endif
00530
00531
00532
00533
00534
00535 #ifdef STLSOFT_PPF_pragma_once_SUPPORT
00536 # pragma once
00537 #endif
00538
00539
00540
00541 #endif
00542
00543