DCL 4.0
Loading...
Searching...
No Matches
UInt64 Class Reference

#include <Numeric.h>

Public Member Functions

 UInt64 (uint64_t _u)
String toString (unsigned _base=10) const

Static Public Member Functions

static String toString (uint64_t _u, unsigned _base=10)
static String toString (uint64_t _u, const wchar_t *_format)
static uint64_t parse (const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
static uint64_t parse (const wchar_t *_number, unsigned _base, uint64_t _default)
static ByteString toByteString (uint64_t _u, unsigned _base=10)

Public Attributes

uint64_t __u

Detailed Description

Definition at line 127 of file Numeric.h.

Constructor & Destructor Documentation

◆ UInt64()

UInt64::UInt64 ( uint64_t _u)
inline

Definition at line 118 of file Numeric.inl.

119{
120 __u = _u;
121}
uint64_t __u
Definition Numeric.h:130

Member Function Documentation

◆ parse() [1/2]

uint64_t UInt64::parse ( const wchar_t * _number,
unsigned _base,
uint64_t _default )
static

Definition at line 653 of file Numeric.cpp.

654{
655 __DCL_ASSERT(_number != NULL);
656 __DCL_ASSERT(_base > 1);
657
658 if (*_number == __T('\0') || iswspace((wint_t)*_number)) {
659 return _default;
660 }
661
662 NumericConvertException::Error error = NumericConvertException::NoError;
663 wchar_t* endptr = NULL;
664 unsigned long long n = wcstoull(_number, &endptr, _base);
665 if (ULONG_MAX == n) {
666 error = NumericConvertException::Overflow;
667 }
668
669 if (NumericConvertException::NoError != error) {
670 return _default;
671 }
672
673 if ((endptr && *endptr != '\0') || errno == EINVAL) {
674 return _default;
675 }
676
677 return (uint64_t) n;
678}
#define NULL
Definition Config.h:340
#define __DCL_ASSERT(expr)
Definition Object.h:371
#define __T(str)
Definition Object.h:44
void CharsetConvertException *size_t n
Definition SQLField.cpp:253

◆ parse() [2/2]

uint64_t UInt64::parse ( const wchar_t * _number,
unsigned _base = 10 )
static

Definition at line 617 of file Numeric.cpp.

619{
620 __DCL_ASSERT(_number != NULL);
621 __DCL_ASSERT(_base > 1);
622
623 if (*_number == __T('\0') || iswspace((wint_t)*_number)) {
624 throw new NumericConvertException(_number, _base, 0);
625 }
626
627 NumericConvertException::Error error = NumericConvertException::NoError;
628 wchar_t* endptr = NULL;
629 unsigned long long n = wcstoull(_number, &endptr, _base);
630 if (ULLONG_MAX == n) {
631 error = NumericConvertException::Overflow;
632 }
633
634 if (NumericConvertException::NoError != error) {
635 throw new NumericConvertException(
636 error,
637 _number,
638 _base
639 );
640 }
641
642 if ((endptr && *endptr != '\0') || errno == EINVAL) {
643 throw new NumericConvertException(
644 _number,
645 _base,
646 endptr ? (endptr - _number) : 0
647 );
648 }
649
650 return (uint64_t) n;
651}

◆ toByteString()

ByteString UInt64::toByteString ( uint64_t _u,
unsigned _base = 10 )
static

Definition at line 680 of file Numeric.cpp.

681{
682 __DCL_ASSERT_PARAM(2 <= _base && _base <= 32);
683 // 2진수일경우 32 + sign = 33
684 ByteBuffer* buf = ByteBuffer::create(70);
685 __uint64toa(_n, buf->data(), _base);
686 buf->__dataLength = ByteString::length(buf->data());
687 ByteString s(buf);
688 buf->release();
689 return s;
690}
char * __uint64toa(uint64_t _n, char *_buf, unsigned _base)
Definition __xtoa.cpp:53
#define __DCL_ASSERT_PARAM(expr)
Definition Object.h:384
ByteBuffer * buf

◆ toString() [1/3]

String UInt64::toString ( uint64_t _u,
const wchar_t * _format )
static

Definition at line 607 of file Numeric.cpp.

608{
609 if (!_format)
610 _format = __T("%ull");
611
612 __DCL_ASSERT(*_format != '\0');
613
614 return String::format(_format, _u);
615}

◆ toString() [2/3]

String UInt64::toString ( uint64_t _u,
unsigned _base = 10 )
static

Definition at line 595 of file Numeric.cpp.

596{
597 __DCL_ASSERT_PARAM(2 <= _base && _base <= 32);
598 // 2진수일경우 64 + sign = 65
599 CharBuffer* buf = CharBuffer::create(70);
600 __uint64tow(_u, buf->data(), _base);
601 buf->__dataLength = String::length(buf->data());
602 String s(buf);
603 buf->release();
604 return s;
605}
wchar_t * __uint64tow(uint64_t _n, wchar_t *_buf, unsigned _base)
Definition __xtoa.cpp:93

◆ toString() [3/3]

String UInt64::toString ( unsigned _base = 10) const
inline

Definition at line 123 of file Numeric.inl.

124{
125 return UInt64::toString(__u, _base);
126}
String toString(unsigned _base=10) const
Definition Numeric.inl:123

Member Data Documentation

◆ __u

uint64_t UInt64::__u

Definition at line 130 of file Numeric.h.


The documentation for this class was generated from the following files: