DCL 3.7.4
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 142 of file Numeric.h.

Constructor & Destructor Documentation

◆ UInt64()

UInt64::UInt64 ( uint64_t _u)
inline

Definition at line 124 of file Numeric.inl.

125{
126 __u = _u;
127}
uint64_t __u
Definition Numeric.h:145

Member Function Documentation

◆ parse() [1/2]

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

Definition at line 662 of file Numeric.cpp.

663{
664 __DCL_ASSERT(_number != NULL);
665 __DCL_ASSERT(_base > 1);
666
667 if (*_number == __T('\0') || iswspace((wint_t)*_number)) {
668 return _default;
669 }
670
671 NumericConvertException::Error error = NumericConvertException::NoError;
672 errno = 0;
673 wchar_t* endptr = NULL;
674 unsigned long long n = wcstoull(_number, &endptr, _base);
675 if (errno == ERANGE) {
676 if (ULONG_MAX == n) {
677 error = NumericConvertException::Overflow;
678 }
679 }
680
681 if (NumericConvertException::NoError != error) {
682 return _default;
683 }
684
685 if ((endptr && *endptr != '\0') || errno == EINVAL) {
686 return _default;
687 }
688
689 return (uint64_t) n;
690}
#define NULL
Definition Config.h:312
#define __DCL_ASSERT(expr)
Definition Object.h:394
#define __T(str)
Definition Object.h:60

◆ parse() [2/2]

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

Definition at line 623 of file Numeric.cpp.

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

◆ toByteString()

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

Definition at line 692 of file Numeric.cpp.

693{
694 __DCL_ASSERT_PARAM(2 <= _base && _base <= 32);
695 // 2진수일경우 32 + sign = 33
696 ByteBuffer* buf = ByteBuffer::create(70);
697 __uint64toa(_n, buf->data(), _base);
698 buf->__dataLength = ByteString::length(buf->data());
699 ByteString s(buf);
700 buf->release();
701 return s;
702}
char * __uint64toa(uint64_t _n, char *_buf, unsigned _base)
Definition __xtoa.cpp:53
#define __DCL_ASSERT_PARAM(expr)
Definition Object.h:409

◆ toString() [1/3]

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

Definition at line 613 of file Numeric.cpp.

614{
615 if (!_format)
616 _format = __T("%ull");
617
618 __DCL_ASSERT(*_format != '\0');
619
620 return String::format(_format, _u);
621}

◆ toString() [2/3]

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

Definition at line 601 of file Numeric.cpp.

602{
603 __DCL_ASSERT_PARAM(2 <= _base && _base <= 32);
604 // 2진수일경우 64 + sign = 65
605 CharBuffer* buf = CharBuffer::create(70);
606 __uint64tow(_u, buf->data(), _base);
607 buf->__dataLength = String::length(buf->data());
608 String s(buf);
609 buf->release();
610 return s;
611}
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 129 of file Numeric.inl.

130{
131 return UInt64::toString(__u, _base);
132}
String toString(unsigned _base=10) const
Definition Numeric.inl:129

Member Data Documentation

◆ __u

uint64_t UInt64::__u

Definition at line 145 of file Numeric.h.


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