1 /* ///////////////////////////////////////////////////////////////////////
7 * Brief: integer ==> string
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_CONVERSION_ITOS_H
13 #define EXTL_CONVERSION_ITOS_H
16 * \brief integer ==> string
19 * - Automatic symbol identification
20 * - Automatic type identification
21 * - support 64-bit integer conversion
22 * - support static array size determination
23 * - Multi-band conversion ==> Default: 10
24 * - itos<10> or itos Decimal(Default)
25 * - itos<16> Hexadecimal
29 * - Automatic type identification
30 * - support 64-bit integer conversion
31 * - support static array size determination
32 * - Multi-band conversion ==> Default: 10
33 * - Note: needs provide conversion buffer
36 * - Note: It's rather dangerous because the life cycle of it's buffer is so short
38 * - e_char_t *p = i2s<e_char_t>(0);
39 * - printf(p); <== Undefined!
40 * - printf(i2s<e_char_t>(0)); <== Safe!
43 * - WATCOM: Only support uitos(),sitos()
44 * - VC6.0: Only support itos()
45 * - VECTORC: When compiling i2s<> in unicode character-set will link failure
49 # error itos.h need be supported by c++.
52 /* ///////////////////////////////////////////////////////////////////////
57 #include "../type/traits/limit_traits.h"
58 #include "../type/traits/is_signed.h"
59 #include "../type/traits/is_unsigned.h"
60 #include "../memory/stack_buffer.h"
62 #ifdef EXTL_CONVERSION_ITOS_TEST_ENABLE
63 # include "../counter/counter.h"
64 # ifdef EXTL_COMPILER_IS_GCC
65 # define ultoa_test _ultot
67 # define ultoa_test _ultot
69 # define ltoa_test _ltot
72 /* ///////////////////////////////////////////////////////////////////////
76 /* itos<N>() support */
77 #ifdef EXTL_CONVERSION_ITOS_WITH_PARAM_SUPPORT
78 # undef EXTL_CONVERSION_ITOS_WITH_PARAM_SUPPORT
81 #if !defined(EXTL_TEMPLATE_TYPE_REQUIRED_IN_ARGLIST) && \
82 defined(EXTL_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS_SUPPORT)
83 # define EXTL_CONVERSION_ITOS_WITH_PARAM_SUPPORT
86 /* The maximum number of the string buffer */
87 #define EXTL_ITOS_MAX_CHAR_NUM (64 + 1)
89 /* ///////////////////////////////////////////////////////////////////////
90 * ::extl::detail namespace
93 EXTL_DETAIL_BEGIN_NAMESPACE
96 template < typename_param_k C
>
97 #ifdef EXTL_TEMPLATE_TYPE_REQUIRED_IN_ARGLIST /* WATCOM */
98 inline C
const* get_digit_char(C
*)
100 inline C
const* get_digit_char()
103 static C
const s_char_table
[31] =
105 'F', 'E', 'D', 'C', 'B', 'A', '9', '8', '7', '6', '5', '4', '3', '2', '1' /* Negative integer */
107 , '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' /* Positive integer */
110 return s_char_table
+ 15;
113 /* ///////////////////////////////////////////////////////////////////////
114 * unsigned integer conversion implementaion
116 #ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
117 template < typename_param_k I
, typename_param_k C
, e_size_t N
= 10 >
119 template < typename_param_k I
, typename_param_k C
, e_size_t N
>
123 static inline C
const* convert(I num
, C
* buf
, e_size_t
const& n
)
125 EXTL_MUST_BE_UNSIGNED(I
);
127 EXTL_ASSERT(NULL
!= buf
);
128 if(NULL
== buf
) return NULL
;
133 buf
[0] = static_cast<C
>('\0');
137 /* convert from the tail */
143 I index
= static_cast<I
>(num
% static_cast<I
>(N
));
144 num
= static_cast<I
>(num
/ static_cast<I
>(N
));
148 #ifdef EXTL_COMPILER_IS_WATCOM
149 *p
= get_digit_char(static_cast<C
*>(NULL
))[index
];
151 # ifdef EXTL_TEMPLATE_TYPE_REQUIRED_IN_ARGLIST
152 *p
= get_digit_char
<C
>(static_cast<C
*>(NULL
))[index
];
154 *p
= get_digit_char
<C
>()[index
];
161 EXTL_ASSERT((p
>= buf
));
166 static inline C
const* convert(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
168 C
const* p
= convert(num
, buf
, n
);
169 result_count
= n
- (p
- buf
+ 1);
174 /* ///////////////////////////////////////////////////////////////////////
175 * signed integer conversion implementaion
177 #ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
178 template < typename_param_k I
, typename_param_k C
, e_size_t N
= 10 >
180 template < typename_param_k I
, typename_param_k C
, e_size_t N
>
184 static inline C
const* convert(I num
, C
* buf
, e_size_t
const& n
)
186 EXTL_MUST_BE_SIGNED(I
);
187 EXTL_ASSERT(NULL
!= buf
);
188 if(NULL
== buf
) return NULL
;
193 if((num
< 0) && (N
== 10)) /* Negative integer */
198 buf
[0] = static_cast<C
>('\0');
204 I index
= static_cast<I
>(num
% static_cast<I
>(N
));
205 num
= static_cast<I
>(num
/ static_cast<I
>(N
));
209 #ifdef EXTL_COMPILER_IS_WATCOM
210 *p
= get_digit_char(static_cast<C
*>(NULL
))[index
];
212 # ifdef EXTL_TEMPLATE_TYPE_REQUIRED_IN_ARGLIST
213 *p
= get_digit_char
<C
>(static_cast<C
*>(NULL
))[index
];
215 *p
= get_digit_char
<C
>()[index
];
225 else /* Positive integer */
230 buf
[0] = static_cast<C
>('\0');
236 I index
= static_cast<I
>(num
% static_cast<I
>(N
));
237 num
= static_cast<I
>(num
/ static_cast<I
>(N
));
241 #ifdef EXTL_COMPILER_IS_WATCOM
242 *p
= get_digit_char(static_cast<C
*>(NULL
))[index
];
244 # ifdef EXTL_TEMPLATE_TYPE_REQUIRED_IN_ARGLIST
245 *p
= get_digit_char
<C
>(static_cast<C
*>(NULL
))[index
];
247 *p
= get_digit_char
<C
>()[index
];
255 EXTL_ASSERT((p
>= buf
));
260 static inline C
const* convert(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
262 C
const* p
= convert(num
, buf
, n
);
263 result_count
= n
- (p
- buf
+ 1);
268 /* ///////////////////////////////////////////////////////////////////////
269 * itos<N>() implementation
270 * //////////////////////////////////////////////////////////////////// */
271 #ifndef EXTL_TEMPLATE_TYPE_REQUIRED_IN_ARGLIST
272 /* //////////////////////////////////////////////////////////////////// */
273 #ifdef EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT
274 # ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
275 template < e_bool_t is_unsigned
, e_bool_t is_signed
, typename_param_k I
, typename_param_k C
, e_size_t N
= 10 >
276 struct sign_selector
;
278 template < e_bool_t is_unsigned
, e_bool_t is_signed
, typename_param_k I
, typename_param_k C
, e_size_t N
>
279 struct sign_selector
;
282 template < e_bool_t is_unsigned
, e_bool_t is_signed
>
283 struct sign_selector
;
286 /* Select unsigned integer conversion */
287 #ifdef EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT
288 template < typename_param_k I
, typename_param_k C
, e_size_t N
>
289 struct sign_selector
< e_true_v
, e_false_v
, I
, C
, N
>
292 EXTL_TEMPLATE_SPECIALISATION
293 struct sign_selector
< e_true_v
, e_false_v
>
295 # ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
296 template < typename_param_k I
, typename_param_k C
, e_size_t N
= 10 >
300 template < typename_param_k I
, typename_param_k C
, e_size_t N
>
305 static inline C
const* convert(I num
, C
* buf
, e_size_t
const& n
)
307 return uitos_impl
<I
, C
, N
>::convert(num
, buf
, n
);
310 static inline C
const* convert(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
312 C
const* p
= convert(num
, buf
, n
);
313 result_count
= n
- (p
- buf
+ 1);
317 #ifndef EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT
322 /* Select signed integer conversion */
323 #ifdef EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT
324 template < typename_param_k I
, typename_param_k C
, e_size_t N
>
325 struct sign_selector
< e_false_v
, e_true_v
, I
, C
, N
>
328 EXTL_TEMPLATE_SPECIALISATION
329 struct sign_selector
< e_false_v
, e_true_v
>
331 # ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
332 template < typename_param_k I
, typename_param_k C
, e_size_t N
= 10 >
336 template < typename_param_k I
, typename_param_k C
, e_size_t N
>
341 static inline C
const* convert(I num
, C
* buf
, e_size_t
const& n
)
343 return sitos_impl
<I
, C
, N
>::convert(num
, buf
, n
);
346 static inline C
const* convert(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
348 C
const* p
= convert(num
, buf
, n
);
349 result_count
= n
- (p
- buf
+ 1);
353 #ifndef EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT
357 #endif /* EXTL_TEMPLATE_TYPE_REQUIRED_IN_ARGLIST */
358 /* //////////////////////////////////////////////////////////////////// */
359 EXTL_DETAIL_END_NAMESPACE
/* ::extl::detail namespace */
360 /* //////////////////////////////////////////////////////////////////// */
362 #if defined(EXTL_CONVERSION_ITOS_WITH_PARAM_SUPPORT)
365 template < e_size_t N
, typename_param_k I
, typename_param_k C
>
366 inline C
const* uitos(I num
, C
* buf
, e_size_t
const& n
)
368 return EXTL_NS_DETAIL(uitos_impl
)<I
, C
, N
>::convert(num
, buf
, n
);
371 template < e_size_t N
, typename_param_k I
, typename_param_k C
>
372 inline C
const* uitos(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
374 return EXTL_NS_DETAIL(uitos_impl
)<I
, C
, N
>::convert(num
, buf
, n
, result_count
);
377 template < e_size_t N
, typename_param_k I
, typename_param_k C
>
378 inline C
const* sitos(I num
, C
* buf
, e_size_t
const& n
)
380 return EXTL_NS_DETAIL(sitos_impl
)<I
, C
, N
>::convert(num
, buf
, n
);
383 template < e_size_t N
, typename_param_k I
, typename_param_k C
>
384 inline C
const* sitos(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
386 return EXTL_NS_DETAIL(sitos_impl
)<I
, C
, N
>::convert(num
, buf
, n
, result_count
);
390 template < e_size_t N
, typename_param_k I
, typename_param_k C
>
391 inline C
const* itos(I num
, C
* buf
, e_size_t
const& n
)
393 # ifdef EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT
394 return EXTL_NS_DETAIL(sign_selector
)
396 (is_unsigned
<I
>::value
),
397 (is_signed
<I
>::value
),
399 >::convert(num
, buf
, n
);
401 return EXTL_NS_DETAIL(sign_selector
)
403 (is_unsigned
<I
>::value
),
404 (is_signed
<I
>::value
)
405 >::template_qual_k itos_impl
<I
, C
, N
>::convert(num
, buf
, n
);
409 template < e_size_t N
, typename_param_k I
, typename_param_k C
>
410 inline C
const* itos(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
412 C
const* p
= itos
<N
, I
, C
>(num
, buf
, n
);
413 result_count
= n
- (p
- buf
+ 1);
416 /* ///////////////////////////////////////////////////////////////////////
417 * Default: Decimal integer conversion
421 template < typename_param_k I
, typename_param_k C
>
422 inline C
const* uitos(I num
, C
* buf
, e_size_t
const& n
)
424 return EXTL_NS_DETAIL(uitos_impl
)<I
, C
>::convert(num
, buf
, n
);
427 template < typename_param_k I
, typename_param_k C
>
428 inline C
const* uitos(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
430 return EXTL_NS_DETAIL(uitos_impl
)<I
, C
>::convert(num
, buf
, n
, result_count
);
434 template < typename_param_k I
, typename_param_k C
>
435 inline C
const* sitos(I num
, C
* buf
, e_size_t
const& n
)
437 return EXTL_NS_DETAIL(sitos_impl
)<I
, C
>::convert(num
, buf
, n
);
440 template < typename_param_k I
, typename_param_k C
>
441 inline C
const* sitos(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
443 return EXTL_NS_DETAIL(sitos_impl
)<I
, C
>::convert(num
, buf
, n
, result_count
);
447 template < typename_param_k I
, typename_param_k C
>
448 inline C
const* itos(I num
, C
* buf
, e_size_t
const& n
)
450 return itos
<10, I
, C
>(num
, buf
, n
);
453 template < typename_param_k I
, typename_param_k C
>
454 inline C
const* itos(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
456 return itos
<10, I
, C
>(num
, buf
, n
, result_count
);
458 /* ///////////////////////////////////////////////////////////////////////
459 * static array size determination
461 #ifdef EXTL_STATIC_ARRAY_SIZE_DETERMINATION_SUPPORT
464 template < e_size_t N
, typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
465 inline C
const* uitos(I num
, C (&buf
)[BUF_COUNT
])
467 return EXTL_NS_DETAIL(uitos_impl
)<I
, C
, N
>::convert(num
, buf
, BUF_COUNT
);
470 template < e_size_t N
, typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
471 inline C
const* uitos(I num
, C (&buf
)[BUF_COUNT
], e_size_t
& result_count
)
473 return EXTL_NS_DETAIL(uitos_impl
)<I
, C
, N
>::convert(num
, buf
, BUF_COUNT
, result_count
);
476 template < e_size_t N
, typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
477 inline C
const* sitos(I num
, C (&buf
)[BUF_COUNT
])
479 return EXTL_NS_DETAIL(sitos_impl
)<I
, C
, N
>::convert(num
, buf
, BUF_COUNT
);
482 template < e_size_t N
, typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
483 inline C
const* sitos(I num
, C (&buf
)[BUF_COUNT
], e_size_t
& result_count
)
485 return EXTL_NS_DETAIL(sitos_impl
)<I
, C
, N
>::convert(num
, buf
, BUF_COUNT
, result_count
);
488 template < e_size_t N
, typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
489 inline C
const* itos(I num
, C (&buf
)[BUF_COUNT
])
491 return itos
<N
, I
, C
>(num
, buf
, BUF_COUNT
);
494 template < e_size_t N
, typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
495 inline C
const* itos(I num
, C (&buf
)[BUF_COUNT
], e_size_t
& result_count
)
497 return itos
<N
, I
, C
>(num
, buf
, BUF_COUNT
, result_count
);
499 /* ///////////////////////////////////////////////////////////////////////
500 * Default: Decimal integer conversion
504 template < typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
505 inline C
const* uitos(I num
, C (&buf
)[BUF_COUNT
])
507 return EXTL_NS_DETAIL(uitos_impl
)<I
, C
>::convert(num
, buf
, BUF_COUNT
);
510 template < typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
511 inline C
const* uitos(I num
, C (&buf
)[BUF_COUNT
], e_size_t
& result_count
)
513 return EXTL_NS_DETAIL(uitos_impl
)<I
, C
>::convert(num
, buf
, BUF_COUNT
, result_count
);
516 template < typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
517 inline C
const* sitos(I num
, C (&buf
)[BUF_COUNT
])
519 return EXTL_NS_DETAIL(sitos_impl
)<I
, C
>::convert(num
, buf
, BUF_COUNT
);
522 template < typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
523 inline C
const* sitos(I num
, C (&buf
)[BUF_COUNT
], e_size_t
& result_count
)
525 return EXTL_NS_DETAIL(sitos_impl
)<I
, C
>::convert(num
, buf
, BUF_COUNT
, result_count
);
528 template < typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
529 inline C
const* itos(I num
, C (&buf
)[BUF_COUNT
])
531 return itos
<10, I
, C
>(num
, buf
, BUF_COUNT
);
534 template < typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
535 inline C
const* itos(I num
, C (&buf
)[BUF_COUNT
], e_size_t
& result_count
)
537 return itos
<10, I
, C
>(num
, buf
, BUF_COUNT
, result_count
);
541 #else /* !defined(EXTL_CONVERSION_ITOS_WITH_PARAM_SUPPORT) */
544 template < typename_param_k I
, typename_param_k C
>
545 inline C
const* uitos(I num
, C
* buf
, e_size_t
const& n
)
547 return EXTL_NS_DETAIL(uitos_impl
)<I
, C
, 10>::convert(num
, buf
, n
);
550 template < typename_param_k I
, typename_param_k C
>
551 inline C
const* uitos(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
553 return EXTL_NS_DETAIL(uitos_impl
)<I
, C
, 10>::convert(num
, buf
, n
, result_count
);
557 template < typename_param_k I
, typename_param_k C
>
558 inline C
const* sitos(I num
, C
* buf
, e_size_t
const& n
)
560 return EXTL_NS_DETAIL(sitos_impl
)<I
, C
, 10>::convert(num
, buf
, n
);
563 template < typename_param_k I
, typename_param_k C
>
564 inline C
const* sitos(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
566 return EXTL_NS_DETAIL(sitos_impl
)<I
, C
, 10>::convert(num
, buf
, n
, result_count
);
569 #if defined(EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT) || \
570 defined(EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT)
572 template < typename_param_k I
, typename_param_k C
>
573 inline C
const* itos(I num
, C
* buf
, e_size_t
const& n
)
575 # ifdef EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT
576 return EXTL_NS_DETAIL(sign_selector
)
578 (is_unsigned
<I
>::value
),
579 (is_signed
<I
>::value
),
581 >::convert(num
, buf
, n
);
583 return EXTL_NS_DETAIL(sign_selector
)
585 (is_unsigned
<I
>::value
),
586 (is_signed
<I
>::value
)
587 >::template_qual_k itos_impl
<I
, C
, 10>::convert(num
, buf
, n
);
591 template < typename_param_k I
, typename_param_k C
>
592 inline C
const* itos(I num
, C
* buf
, e_size_t
const& n
, e_size_t
& result_count
)
594 C
const* p
= itos(num
, buf
, n
);
595 result_count
= n
- (p
- buf
+ 1);
598 #endif /* defined(EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT) || \
599 defined(EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT) */
601 # ifdef EXTL_STATIC_ARRAY_SIZE_DETERMINATION_SUPPORT
603 template < typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
604 inline C
const* uitos(I num
, C (&buf
)[BUF_COUNT
])
606 return EXTL_NS_DETAIL(uitos_impl
)<I
, C
, 10>::convert(num
, buf
, BUF_COUNT
);
609 template < typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
610 inline C
const* uitos(I num
, C (&buf
)[BUF_COUNT
], e_size_t
& result_count
)
612 return EXTL_NS_DETAIL(uitos_impl
)<I
, C
, 10>::convert(num
, buf
, BUF_COUNT
, result_count
);
615 template < typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
616 inline C
const* sitos(I num
, C (&buf
)[BUF_COUNT
])
618 return EXTL_NS_DETAIL(sitos_impl
)<I
, C
, 10>::convert(num
, buf
, BUF_COUNT
);
621 template < typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
622 inline C
const* sitos(I num
, C (&buf
)[BUF_COUNT
], e_size_t
& result_count
)
624 return EXTL_NS_DETAIL(sitos_impl
)<I
, C
, 10>::convert(num
, buf
, BUF_COUNT
, result_count
);
627 # if defined(EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT) || \
628 defined(EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT)
630 template < typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
631 inline C
const* itos(I num
, C (&buf
)[BUF_COUNT
])
633 return itos(num
, buf
, BUF_COUNT
);
636 template < typename_param_k I
, typename_param_k C
, e_size_t BUF_COUNT
>
637 inline C
const* itos(I num
, C (&buf
)[BUF_COUNT
], e_size_t
& result_count
)
639 return itos(num
, buf
, BUF_COUNT
, result_count
);
641 # endif /* defined(EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT) || \
642 defined(EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT) */
644 # endif /* EXTL_STATIC_ARRAY_SIZE_DETERMINATION_SUPPORT */
646 #endif /* !defined(EXTL_TEMPLATE_TYPE_REQUIRED_IN_ARGLIST) && \
647 defined(EXTL_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS_SUPPORT) */
649 /// i2s<> conversion shim
650 #if defined(EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT) || \
651 defined(EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT)
653 #if defined(EXTL_CONVERSION_ITOS_WITH_PARAM_SUPPORT)
654 # ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
655 template < typename_param_k C
= e_tchar_t
, e_size_t N
= 10 >
657 template < typename_param_k C
, e_size_t N
>
660 template < typename_param_k C
>
664 #ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
665 : public stack_buffer
<C
, EXTL_ITOS_MAX_CHAR_NUM
>
667 : public stack_buffer
< C
668 , EXTL_ITOS_MAX_CHAR_NUM
669 , typename_type_k memory_traits_selector
<C
>::memory_traits_type
675 #ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
676 typedef stack_buffer
<C
, EXTL_ITOS_MAX_CHAR_NUM
> base_type
;
678 typedef stack_buffer
< C
679 , EXTL_ITOS_MAX_CHAR_NUM
680 , typename_type_k memory_traits_selector
<C
>::memory_traits_type
685 #if defined(EXTL_CONVERSION_ITOS_WITH_PARAM_SUPPORT)
686 typedef i2s
<C
, N
> class_type
;
688 typedef i2s
<C
> class_type
;
690 typedef typename_type_k
base_type::size_type size_type
;
691 typedef typename_type_k
base_type::value_type dest_type
;
692 typedef typename_type_k
base_type::pointer pointer
;
693 typedef typename_type_k
base_type::const_pointer const_pointer
;
696 size_type m_result_count
;
699 template < typename_param_k I
>
700 explicit_k
i2s(I
const& src
)
701 : base_type(EXTL_ITOS_MAX_CHAR_NUM
), /* 64 + 1 */
707 operator dest_type
const*() const
709 const size_type n
= base_type::size();
710 const_pointer buf
= base_type::data();
712 return (buf
+ n
- m_result_count
- 1);
715 template < typename_param_k I
>
716 void convert(I
const& src
)
718 const size_type n
= base_type::size();
719 const pointer buf
= base_type::data();
721 #if defined(EXTL_CONVERSION_ITOS_WITH_PARAM_SUPPORT)
722 itos
<N
, I
, C
>(src
, buf
, n
, m_result_count
);
724 itos(src
, buf
, n
, m_result_count
);
728 #endif /* defined(EXTL_TEMPLATE_PARTIAL_SPEC_SUPPORT) || \
729 defined(EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT) */
731 /* ///////////////////////////////////////////////////////////////////////
734 #ifdef EXTL_CONVERSION_ITOS_TEST_ENABLE
735 # include "unit_test/itos_test.h"
737 /* ///////////////////////////////////////////////////////////////////////
742 /* //////////////////////////////////////////////////////////////////// */
743 #endif /* EXTL_CONVERSION_ITOS_H */
744 /* //////////////////////////////////////////////////////////////////// */