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

Signed integer. More...

#include <base/Integer.h>

Inherits Object.

Public Types

enum  { FLAG_ALLOW_SPACES = 1 << 0, FLAG_ALLOW_SIGN = 1 << 1, FLAG_DEFAULT = FLAG_ALLOW_SPACES | FLAG_ALLOW_SIGN }
 

Public Member Functions

 Integer () noexcept
 
 Integer (int value) noexcept
 
 Integer (const Integer &copy) noexcept
 
Integeroperator= (const Integer &assign) noexcept
 
Integeroperator= (int value) noexcept
 
int getValue () const noexcept
 
void setValue (int value) noexcept
 
 operator int () const noexcept
 

Static Public Member Functions

static int parse (const char *src, const char *end, unsigned int flags=FLAG_DEFAULT)
 
static int parse (const String &string, unsigned int flags=FLAG_DEFAULT)
 
static int parse (const wchar *src, const wchar *end, unsigned int flags=FLAG_DEFAULT)
 
static int parse (const ucs4 *src, const ucs4 *end, unsigned int flags=FLAG_DEFAULT)
 
static int parse (const WideString &string, unsigned int flags=FLAG_DEFAULT)
 

Static Public Attributes

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

Protected Attributes

int value = 0
 

Detailed Description

Signed integer.

Signed integer (32 bits or more).

Version
1.2
Examples
testsuite/server.cpp.

Constructor & Destructor Documentation

◆ Integer() [1/3]

Integer::Integer ( )
inlinenoexcept

Initializes the integer as zero.

◆ Integer() [2/3]

Integer::Integer ( int  value)
inlinenoexcept

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

Parameters
valueThe desired value.

◆ Integer() [3/3]

Integer::Integer ( const Integer copy)
inlinenoexcept

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

Member Function Documentation

◆ getValue()

int Integer::getValue ( ) const
inlinenoexcept

Gets the value of the integer.

◆ operator int()

Integer::operator int ( ) const
inlinenoexcept

Casts integer to native type.

◆ operator=() [1/2]

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

Assignment of integer to this integer.

◆ operator=() [2/2]

Integer& Integer::operator= ( int  value)
inlinenoexcept

Assignment of native type to this integer.

◆ parse() [1/5]

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

Returns the value of the integer string representation.

Parameters
stringThe string representation.
flagsThe parsing flags.

◆ parse() [2/5]

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

Returns the value of the integer string representation.

Parameters
stringThe string representation.
withoutSignEffectively prevents signs from being parsed. Default is to allow a single sign.

◆ parse() [3/5]

static int Integer::parse ( const ucs4 *  src,
const ucs4 *  end,
unsigned int  flags = FLAG_DEFAULT 
)
static

Returns the value of the integer string representation.

Parameters
stringThe string representation.
flagsThe parsing flags.

◆ parse() [4/5]

static int Integer::parse ( const wchar *  src,
const wchar *  end,
unsigned int  flags = FLAG_DEFAULT 
)
static

Returns the value of the integer string representation.

Parameters
stringThe string representation.
flagsThe parsing flags.

◆ parse() [5/5]

static int Integer::parse ( const WideString string,
unsigned int  flags = FLAG_DEFAULT 
)
inlinestatic

Returns the value of the integer string representation.

Parameters
stringThe string representation.
withoutSignEffectively prevents signs from being parsed. Default is to allow a single sign.

◆ setValue()

void Integer::setValue ( int  value)
inlinenoexcept

Sets the value of the integer.

Parameters
valueThe desired value.

Member Data Documentation

◆ MAXIMUM

const int Integer::MAXIMUM = PrimitiveTraits<int>::MAXIMUM
static

Specifies the maximum value.

◆ MINIMUM

const int Integer::MINIMUM = PrimitiveTraits<int>::MINIMUM
static

Specifies the minimum value.

◆ SIGNED

const bool Integer::SIGNED = true
static

True if the integer type is signed.

◆ value

int Integer::value = 0
protected

The value.