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

#include <Numeric.h>

Public Member Functions

 Int64 (int64_t _n)
String toString (unsigned _base=10) const

Static Public Member Functions

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

Public Attributes

int64_t __n

Detailed Description

Definition at line 107 of file Numeric.h.

Constructor & Destructor Documentation

◆ Int64()

Int64::Int64 ( int64_t _n)
inline

Definition at line 106 of file Numeric.inl.

107{
108 __n = _n;
109}
int64_t __n
Definition Numeric.h:110

Member Function Documentation

◆ parse() [1/2]

int64_t Int64::parse ( const wchar_t * _number,
unsigned _base,
int64_t _default )
static

Definition at line 551 of file Numeric.cpp.

553{
554 __DCL_ASSERT(_number != NULL);
555 __DCL_ASSERT(_base > 1);
556
557 if (*_number == __T('\0') || iswspace((wint_t)*_number)) {
558 return _default;
559 }
560
561 NumericConvertException::Error error = NumericConvertException::NoError;
562 wchar_t* endptr = NULL;
563 long long n = wcstoll(_number, &endptr, _base);
564 if (LLONG_MIN == n) {
565 error = NumericConvertException::Underflow;
566 } else if (LLONG_MAX == n) {
567 error = NumericConvertException::Overflow;
568 }
569
570 if (NumericConvertException::NoError != error) {
571 return _default;
572 }
573
574 if ((endptr && *endptr != '\0') || errno == EINVAL) {
575 return _default;
576 }
577
578 return (int64_t) n;
579}
#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]

int64_t Int64::parse ( const wchar_t * _number,
unsigned _base = 10 )
static

Definition at line 513 of file Numeric.cpp.

515{
516 __DCL_ASSERT(_number != NULL);
517 __DCL_ASSERT(_base > 1);
518
519 if (*_number == __T('\0') || iswspace((wint_t)*_number)) {
520 throw new NumericConvertException(_number, _base, 0);
521 }
522
523 NumericConvertException::Error error = NumericConvertException::NoError;
524 wchar_t* endptr = NULL;
525 long long n = wcstoll(_number, &endptr, _base);
526 if (LLONG_MIN == n) {
527 error = NumericConvertException::Underflow;
528 } else if (LLONG_MAX == n) {
529 error = NumericConvertException::Overflow;
530 }
531
532 if (NumericConvertException::NoError != error) {
533 throw new NumericConvertException(
534 error,
535 _number,
536 _base
537 );
538 }
539
540 if ((endptr && *endptr != '\0') || errno == EINVAL) {
541 throw new NumericConvertException(
542 _number,
543 _base,
544 endptr ? (endptr - _number) : 0
545 );
546 }
547
548 return (int64_t) n;
549}

◆ toByteString()

ByteString Int64::toByteString ( int64_t _n,
unsigned _base = 10 )
static

Definition at line 581 of file Numeric.cpp.

582{
583 __DCL_ASSERT_PARAM(2 <= _base && _base <= 32);
584 // 2진수일경우 32 + sign = 33
585 ByteBuffer* buf = ByteBuffer::create(70);
586 __int64toa(_n, buf->data(), _base);
587 buf->__dataLength = ByteString::length(buf->data());
588 ByteString s(buf);
589 buf->release();
590 return s;
591}
char * __int64toa(int64_t _n, char *_buf, unsigned _base)
Definition __xtoa.cpp:47
#define __DCL_ASSERT_PARAM(expr)
Definition Object.h:384
ByteBuffer * buf

◆ toString() [1/3]

String Int64::toString ( int64_t _n,
const wchar_t * _format )
static

Definition at line 498 of file Numeric.cpp.

499{
500 if (!_format)
501 _format = __T("%lld");
502
503 __DCL_ASSERT_PARAM(*_format != '\0');
504
505 return String::format(_format, _n);
506}

◆ toString() [2/3]

String Int64::toString ( int64_t _n,
unsigned _base = 10 )
static

Definition at line 486 of file Numeric.cpp.

487{
488 __DCL_ASSERT_PARAM(2 <= _base && _base <= 32);
489 // 2진수일경우 64 + sign = 65
490 CharBuffer* buf = CharBuffer::create(70);
491 __int64tow(_n, buf->data(), _base);
492 buf->__dataLength = String::length(buf->data());
493 String s(buf);
494 buf->release();
495 return s;
496}
wchar_t * __int64tow(int64_t _n, wchar_t *_buf, unsigned _base)
Definition __xtoa.cpp:87

◆ toString() [3/3]

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

Definition at line 111 of file Numeric.inl.

112{
113 return Int64::toString(__n, _base);
114}
String toString(unsigned _base=10) const
Definition Numeric.inl:111

Member Data Documentation

◆ __n

int64_t Int64::__n

Definition at line 110 of file Numeric.h.


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