Base Framework
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
UnsignedInteger Class Reference

Unsigned integer. More...

#include <base/UnsignedInteger.h>

Inherits Object.

Public Types

enum  { FLAG_ALLOW_SPACES = 1 << 0 }
 
enum  BaseFlags {
  BIN = 1 << 0, DEC = 1 << 2, OCT = 1 << 3, HEX = 1 << 4,
  PREFIX = 1 << 5, ANY =BIN|DEC|OCT|HEX|PREFIX, FLAG_DEFAULT = FLAG_ALLOW_SPACES | ANY
}
 

Public Member Functions

 UnsignedInteger () noexcept
 
 UnsignedInteger (unsigned int value) noexcept
 
 UnsignedInteger (const UnsignedInteger &copy) noexcept
 
UnsignedIntegeroperator= (const UnsignedInteger &assign) noexcept
 
UnsignedIntegeroperator= (unsigned int value) noexcept
 
unsigned int getValue () const noexcept
 
void setValue (unsigned int value) noexcept
 
 operator unsigned int () const noexcept
 

Static Public Member Functions

static unsigned int parse (const char *src, const char *end, unsigned int flags=FLAG_DEFAULT)
 
static unsigned int parse (const String &string, unsigned int flags=FLAG_DEFAULT)
 
static Validified< unsigned int > parseNoThrow (const char *src, const char *end, unsigned int flags=FLAG_DEFAULT) noexcept
 
static Validified< unsigned int > parseNoThrow (const String &string, unsigned int flags=FLAG_DEFAULT) noexcept
 

Static Public Attributes

static const bool SIGNED = false
 
static const unsigned int MINIMUM = PrimitiveTraits<unsigned int>::MINIMUM
 
static const unsigned int MAXIMUM = PrimitiveTraits<unsigned int>::MAXIMUM
 

Protected Attributes

unsigned int value = 0
 

Detailed Description

Unsigned integer.

Unsigned integer (32 bits or more).

Version
1.0
Examples
testsuite/echod.cpp, testsuite/ftp.cpp, testsuite/http.cpp, and testsuite/ping.cpp.

Member Enumeration Documentation

◆ BaseFlags

Enumerator
BIN 

Specifies binary integer base (2).

DEC 

Specifies decimal integer base (10).

OCT 

Specifies octal integer base (8).

HEX 

Specifies hexadecimal integer base (16).

PREFIX 

Specifies that prefix is required.

ANY 

Specifies any supported base (integer base is derived from prefix).

Constructor & Destructor Documentation

◆ UnsignedInteger() [1/3]

UnsignedInteger::UnsignedInteger ( )
inlinenoexcept

Initializes the integer as zero.

◆ UnsignedInteger() [2/3]

UnsignedInteger::UnsignedInteger ( unsigned int  value)
inlinenoexcept

Initializes the integer with the specified value. Implicit initialization allowed.

Parameters
valueThe desired value.

◆ UnsignedInteger() [3/3]

UnsignedInteger::UnsignedInteger ( const UnsignedInteger copy)
inlinenoexcept

Copy constructor. Initializes a new Integer from other Integer object.

Member Function Documentation

◆ getValue()

unsigned int UnsignedInteger::getValue ( ) const
inlinenoexcept

Gets the value of the integer.

Examples
testsuite/ftp.cpp.

◆ operator unsigned int()

UnsignedInteger::operator unsigned int ( ) const
inlinenoexcept

Casts integer to native type.

◆ operator=() [1/2]

UnsignedInteger& UnsignedInteger::operator= ( const UnsignedInteger assign)
inlinenoexcept

Assignment of integer to this integer.

◆ operator=() [2/2]

UnsignedInteger& UnsignedInteger::operator= ( unsigned int  value)
inlinenoexcept

Assignment of native type to this integer.

◆ parse() [1/2]

static unsigned int UnsignedInteger::parse ( const char *  src,
const char *  end,
unsigned int  flags = FLAG_DEFAULT 
)
static

Returns the value of the integer string representation.

Parameters
srcThe string representation.
endThe string representation.
acceptSpecifies the integer bases to accept. Default is ANY.
Examples
testsuite/IEEE1394.cpp.

◆ parse() [2/2]

static unsigned int UnsignedInteger::parse ( const String string,
unsigned int  flags = FLAG_DEFAULT 
)
inlinestatic

Parse string.

◆ parseNoThrow() [1/2]

static Validified<unsigned int> UnsignedInteger::parseNoThrow ( const char *  src,
const char *  end,
unsigned int  flags = FLAG_DEFAULT 
)
staticnoexcept

Returns the value of the integer string representation.

Parameters
srcThe string representation.
endThe string representation.
acceptSpecifies the integer bases to accept. Default is FLAG_DEFAULT.

◆ parseNoThrow() [2/2]

static Validified<unsigned int> UnsignedInteger::parseNoThrow ( const String string,
unsigned int  flags = FLAG_DEFAULT 
)
inlinestaticnoexcept

Parse string.

◆ setValue()

void UnsignedInteger::setValue ( unsigned int  value)
inlinenoexcept

Sets the value of the integer.

Parameters
valueThe desired value.

Member Data Documentation

◆ MAXIMUM

const unsigned int UnsignedInteger::MAXIMUM = PrimitiveTraits<unsigned int>::MAXIMUM
static

Specifies the maximum value.

◆ MINIMUM

const unsigned int UnsignedInteger::MINIMUM = PrimitiveTraits<unsigned int>::MINIMUM
static

Specifies the minimum value.

◆ SIGNED

const bool UnsignedInteger::SIGNED = false
static

True if the integer type is signed.

◆ value

unsigned int UnsignedInteger::value = 0
protected

The value.