GlobalObjects
Loading...
Searching...
No Matches
eut::UnsignedMagicNumber Class Reference

A UnsignedMagicNumber is an artificial number consisting of numbers and letters (similar to hex numbers). More...

#include <EuUnsignedMagicNumber.h>

Public Member Functions

 UnsignedMagicNumber ()
 
 UnsignedMagicNumber (const UnsignedMagicNumber &rT)
 
 UnsignedMagicNumber (unsigned int uiMaxSize)
 
 UnsignedMagicNumber (unsigned int uiMaxSize, char chFirstRangeDigit, char chLastRangeDigit)
 
 UnsignedMagicNumber (unsigned int uiMaxSize, char chFirstRangeDigit, char chLastRangeDigit, const char *pchValue)
 
 UnsignedMagicNumber (unsigned int uiMaxSize, char chFirstRangeDigit, char chLastRangeDigit, const std::string &rsValue)
 
 UnsignedMagicNumber (unsigned int uiMaxSize, char chLastRangeDigit)
 
 UnsignedMagicNumber (unsigned int uiMaxSize, char chLastRangeDigit, const char *pchValue)
 
 UnsignedMagicNumber (unsigned int uiMaxSize, char chLastRangeDigit, const std::string &rsValue)
 
 UnsignedMagicNumber (unsigned int uiMaxSize, const char *pchValue)
 
 UnsignedMagicNumber (unsigned int uiMaxSize, const std::string &rsValue)
 
virtual ~UnsignedMagicNumber ()
 
char getFirstRangeDigit () const
 
int getLastError ()
 
char getLastRangeDigit () const
 
unsigned int getMaxSize () const
 
bool isAsciiInRange (const char chCharacter) const
 
bool isNULL () const
 
UnsignedMagicNumberoperator= (const UnsignedMagicNumber &rT)
 
void setNULL ()
 
int setValue (const char *pchValue)
 
std::string toString () const
 
bool operator== (const UnsignedMagicNumber &rT) const
 Comparison operator.
 
bool operator!= (const UnsignedMagicNumber &rT) const
 Comparison operator.
 
bool operator> (const UnsignedMagicNumber &rT) const
 Comparison operator for size comparison.
 
bool operator>= (const UnsignedMagicNumber &rT) const
 Comparison operator for size comparison.
 
bool operator< (const UnsignedMagicNumber &rT) const
 Comparison operator for size comparison.
 
bool operator<= (const UnsignedMagicNumber &rT) const
 Comparison operator for size comparison.
 
UnsignedMagicNumberoperator++ ()
 Computational operators.
 
UnsignedMagicNumber operator++ (int)
 Computational operators.
 
UnsignedMagicNumberoperator+= (const UnsignedMagicNumber &rrT)
 Computational operators.
 
UnsignedMagicNumberoperator-- ()
 Computational operators.
 
UnsignedMagicNumber operator-- (int)
 Computational operators.
 
UnsignedMagicNumberoperator-= (const UnsignedMagicNumber &rrT)
 Computational operators.
 

Private Types

enum  EnCalcType { eADD , eSUBTRACT }
 

Private Member Functions

bool addChar (char &rchTarget, const char chSource, char chLastRangeDigit)
 
int addValue (char *pchTarget, const char *pchSource, unsigned int uiMaxSize, char chFirstRangeDigit, char chLastRangeDigit)
 
int calculateValue (char *pchTarget, const char *pchSource, unsigned int uiMaxSize, char chFirstRangeDigit, char chLastRangeDigit, EnCalcType eCalcType)
 
bool checkFirstLast (char chFirstRangeDigit, char chLastRangeDigit)
 
void convertAsciiCharArrayInOwn (char *pchChar) const
 
void convertAsciiCharInOwn (char &rchChar) const
 
void convertOwnCharArrayInAscii (char *pchChar) const
 
void convertOwnCharInAscii (char &rchChar) const
 
char getAsciiCharInOwn (const char &rchChar) const
 
char getOwnCharInAscii (const char &rchChar) const
 
void init (char chFirstRangeDigit, char chLastRangeDigit)
 
bool isInRange (const char chCharacter) const
 
bool subtractChar (char &rchTarget, const char chSource, char chLastRangeDigit)
 
int subtractValue (char *pchTarget, const char *pchSource, unsigned int uiMaxSize, char chFirstRangeDigit, char chLastRangeDigit)
 

Private Attributes

char m_chFirstRangeDigit
 
char m_chLastRangeDigit
 
int m_iLastError
 
char * m_pchValue
 
unsigned int m_uiMaxSize
 

Friends

UnsignedMagicNumber operator+ (UnsignedMagicNumber lT, const UnsignedMagicNumber &rrT)
 
UnsignedMagicNumber operator- (UnsignedMagicNumber lT, const UnsignedMagicNumber &rrT)
 
std::ostream & operator<< (std::ostream &rOStream, const UnsignedMagicNumber &rMagicNumber)
 
std::istream & operator>> (std::istream &rIStream, UnsignedMagicNumber &rMagicNumber)
 

Detailed Description

A UnsignedMagicNumber is an artificial number consisting of numbers and letters (similar to hex numbers).

A maximum value of 0-9, A-Z and a-z can be assigned to this number per digit, which means a maximum of 10 + 26 + 26 states per digit. This makes 62^10 -> 839,299,365,868,340,000 for a 10-digit value. In the standard setting (0-Z), this would be 31^10 -> 3,656,158,440,062,980.

This number is used accordingly; it is counted from 0 to z (i.e. from 0 to 9 and after 9 comes A to z -> e.g. 12 + A = 1C ).

This was born from the idea that I used an unsigned long as index and the range seemed too small to me. The unsigned long reaches to 4,294,967,295, but I did not want to change the length of the index. The first idea was to extend the number range to 9,999,999,999, but there are still the letters similar to the hex numbers. An additional requirement is that all numbers are printable and can be used as letters for file names.

The length of the UnsignedMagicNumber and the value range can be determined. E.g. length 10 and value range from 0 to Z (inclusive).

But the most important thing is that this UnsignedMagicNumber can be added and subtracted, e.g. to get a unique index by decrementing.

A side effect is that with the m_chFirstRangeDigit == '0' and the m_chLastRangeDigit == 'F' a hexadecimal representation with simple calculation is possible.

Author
Helmut Jakoby

Member Enumeration Documentation

◆ EnCalcType

For UnsignedMagicNumber::calculateValue (...)

Enumerator
eADD 

It should be added.

eSUBTRACT 

It should be subtracted.

Constructor & Destructor Documentation

◆ UnsignedMagicNumber() [1/11]

eut::UnsignedMagicNumber::UnsignedMagicNumber ( )

The standard constructor is not available.

◆ UnsignedMagicNumber() [2/11]

eut::UnsignedMagicNumber::UnsignedMagicNumber ( unsigned int uiMaxSize)

Constructor with length of the value.

Parameters
[in]uiMaxSizeThe maximum length of the value.
Note
Sets the start value to '0' and the end value to 'Z'.
Exceptions
eut::ErrorNExceptionAn exception is thrown if uiMaxSize == 0.

◆ UnsignedMagicNumber() [3/11]

eut::UnsignedMagicNumber::UnsignedMagicNumber ( unsigned int uiMaxSize,
const char * pchValue )

Constructor with length of the value and the value itself.

Parameters
[in]uiMaxSizeThe maximum length of the value.
[in]pchValueThe value as a 0-terminated char array. The length of the value must not be greater than passed with uiMaxSize and all characters must be in the range of the start and end value.
Note
Sets the start value to '0' and the end value to 'Z'.
Exceptions
eut::ErrorNExceptionAn exception will be thrown if uiMaxSize == 0.

◆ UnsignedMagicNumber() [4/11]

eut::UnsignedMagicNumber::UnsignedMagicNumber ( unsigned int uiMaxSize,
const std::string & rsValue )

Constructor with length of the value and the value itself.

Parameters
[in]uiMaxSizeThe maximum length of the value.
[in]rsValueThe value as a std::string. The length of the value must not be greater than passed with uiMaxSize and all characters must be in the range of the start and end value.
Note
Sets the start value to '0' and the end value to 'Z'.
Exceptions
eut::ErrorNExceptionAn exception will be thrown if uiMaxSize == 0.

◆ UnsignedMagicNumber() [5/11]

eut::UnsignedMagicNumber::UnsignedMagicNumber ( unsigned int uiMaxSize,
char chLastRangeDigit )

Constructor with length of the value and the last range value.

Parameters
[in]uiMaxSizeThe maximum length of the value.
[in]chLastRangeDigitThe largest allowed value, i.e. the final value.
Note
Sets the start value to '0'.
Exceptions
eut::ErrorNExceptionAn exception is thrown if uiMaxSize == 0 or chLastRangeDigit is not in the ranges '0' - '9', 'A' - 'Z' and 'a' - 'z'.

◆ UnsignedMagicNumber() [6/11]

eut::UnsignedMagicNumber::UnsignedMagicNumber ( unsigned int uiMaxSize,
char chLastRangeDigit,
const char * pchValue )

Constructor with length of the value, the last range value and the value itself.

Parameters
[in]uiMaxSizeThe maximum length of the value.
[in]chLastRangeDigitThe largest allowed value, i.e. the final value.
[in]pchValueThe value as a 0-terminated char array. The length of the value must not be greater than specified in uiMaxSize and all characters must be in the range of '0' and chLastRangeDigit.
Note
Sets the start value to '0'.
Exceptions
eut::ErrorNExceptionAn exception is thrown if uiMaxSize == 0 or chLastRangeDigit is not in the ranges '0' - '9', 'A' - 'Z' and 'a' - 'z'.

◆ UnsignedMagicNumber() [7/11]

eut::UnsignedMagicNumber::UnsignedMagicNumber ( unsigned int uiMaxSize,
char chLastRangeDigit,
const std::string & rsValue )

Constructor with length of the value, the last range value and the value itself.

Parameters
[in]uiMaxSizeThe maximum length of the value.
[in]chLastRangeDigitThe largest allowed value, i.e. the final value.
[in]rsValueThe value as a std::string. The length of the value must not be greater than specified in uiMaxSize and all characters must be in the range of '0' and chLastRangeDigit.
Note
Sets the start value to '0'.
Exceptions
eut::ErrorNExceptionAn exception is thrown if uiMaxSize == 0 or chLastRangeDigit is not in the ranges '0' - '9', 'A' - 'Z' and 'a' - 'z'.

◆ UnsignedMagicNumber() [8/11]

eut::UnsignedMagicNumber::UnsignedMagicNumber ( unsigned int uiMaxSize,
char chFirstRangeDigit,
char chLastRangeDigit )

Constructor with length of the value and the range values.

Parameters
[in]uiMaxSizeThe maximum length of the value.
[in]chFirstRangeDigitThe smallest allowed value, i.e. the start value.
[in]chLastRangeDigitThe largest permitted value, i.e. the end value.
Exceptions
eut::ErrorNExceptionAn exception is thrown if uiMaxSize == 0 or chLastRangeDigit is not in the ranges '0' - '9', 'A' - 'Z' and 'a' - 'z'.

◆ UnsignedMagicNumber() [9/11]

eut::UnsignedMagicNumber::UnsignedMagicNumber ( unsigned int uiMaxSize,
char chFirstRangeDigit,
char chLastRangeDigit,
const char * pchValue )

Constructor with the length of the value, the range values and the value itself.

Parameters
[in]uiMaxSizeThe maximum length of the value.
[in]chFirstRangeDigitThe smallest allowed value, i.e. the start value.
[in]chLastRangeDigitThe largest permitted value, i.e. the end value.
[in]pchValueThe value as a 0-terminated char array. The length of the value must not be greater than specified in uiMaxSize and all characters must be within the range of chFirstRangeDigit and chLastRangeDigit.
Exceptions
eut::ErrorNExceptionAn exception is thrown if uiMaxSize == 0 or chLastRangeDigit is not in the ranges '0' - '9', 'A' - 'Z' and 'a' - 'z'.

◆ UnsignedMagicNumber() [10/11]

eut::UnsignedMagicNumber::UnsignedMagicNumber ( unsigned int uiMaxSize,
char chFirstRangeDigit,
char chLastRangeDigit,
const std::string & rsValue )

Constructor with the length of the value, the range values and the value itself.

Parameters
[in]uiMaxSizeThe maximum length of the value.
[in]chFirstRangeDigitThe smallest allowed value, i.e. the start value.
[in]chLastRangeDigitThe largest permitted value, i.e. the end value.
[in]rsValueThe value as a std::string. The length of the value must not be greater than specified in uiMaxSize and all characters must be within the range of chFirstRangeDigit and chLastRangeDigit.
Exceptions
eut::ErrorNExceptionAn exception is thrown if uiMaxSize == 0 or chLastRangeDigit is not in the ranges '0' - '9', 'A' - 'Z' and 'a' - 'z'.

◆ UnsignedMagicNumber() [11/11]

eut::UnsignedMagicNumber::UnsignedMagicNumber ( const UnsignedMagicNumber & rT)

Copy constructor.

Parameters
[in]rTThe data is copied from this object.

◆ ~UnsignedMagicNumber()

virtual eut::UnsignedMagicNumber::~UnsignedMagicNumber ( )
virtual

Destrctor.

Member Function Documentation

◆ addChar()

bool eut::UnsignedMagicNumber::addChar ( char & rchTarget,
const char chSource,
char chLastRangeDigit )
private

Adds second to the first transferred char.

Parameters
[in,out]rchTargetThe char to which to add up.
[in]chSourceThe char to be summed up to chTarget.
[in]chLastRangeDigitThe largest allowed value.
Returns
If true, an overflow has occurred (e.g. if chLastRangeDigit == '9', rchTarget == '8' and chSource == '3').
Note
There is no check whether and how the two Char rchTarget and chSource are within the permitted range. Even chLastRangeDigit will not checked for plausibility.

◆ addValue()

int eut::UnsignedMagicNumber::addValue ( char * pchTarget,
const char * pchSource,
unsigned int uiMaxSize,
char chFirstRangeDigit,
char chLastRangeDigit )
private

Adds a second char array to the first char array passed. This method is only called by operators, so there is no need to check here.

Parameters
[in,out]pchTargetThe value to be added to (0-terminated char array of own characters). The length of the value is defined in uiMaxSize and all characters must be in the range of chFirstRangeDigit and chLastRangeDigit.
[in]pchSourceThe value to be summed up on pchTarget (0-terminated char array of own characters). The length of the value is defined in uiMaxSize and all characters must be in the range of chFirstRangeDigit and chLastRangeDigit.
[in]uiMaxSizeThe maximum length of the passed char arrays.
[in]chFirstRangeDigitThe first allowed value of each char in the char arrays.
[in]chLastRangeDigitThe last allowed value of each char in the char-arrays.
Returns
If return != 0 an error has occurred.
Note
It is not checked if and how the two char-arrays pchTarget and pchSource were instantiated!
Parameter chFirstRangeDigit and chLastRangeDigit are not checked for plausibility.

◆ calculateValue()

int eut::UnsignedMagicNumber::calculateValue ( char * pchTarget,
const char * pchSource,
unsigned int uiMaxSize,
char chFirstRangeDigit,
char chLastRangeDigit,
EnCalcType eCalcType )
private

Adds the second passed Char-Array to the first passed Char-Array or subtracts the second passed Char-Array from the first passed Char-Array. Is used by addValue (...) and subtractValue (...).

Parameters
[in,out]pchTargetThe value to be processed (0-terminated Char-Array of own characters). The length of the value is defined in uiMaxSize and all characters must be in the range of chFirstRangeDigit and chLastRangeDigit.
[in]pchSourceThe value to be calculated with rchTarget (0-terminated char array of own characters). The length of the value is defined in uiMaxSize and all characters must be in the range of chFirstRangeDigit and chLastRangeDigit.
[in]uiMaxSizeThe maximum length of the passed char arrays.
[in]chFirstRangeDigitThe first allowed value of each char in the char arrays.
[in]chLastRangeDigitThe last allowed value of each char in the char-arrays.
[in]eCalcTypeShould be added or subtracted.
Returns
If return != 0 an error has occurred.
Note
It is not checked if and how the two char-arrays pchTarget and pchSource were instantiated!
Parameter chFirstRangeDigit and chLastRangeDigit are not checked for plausibility.

◆ checkFirstLast()

bool eut::UnsignedMagicNumber::checkFirstLast ( char chFirstRangeDigit,
char chLastRangeDigit )
private

Checks if the passed Range is within the allowed range.

Parameters
[in]chFirstRangeDigitThe smallest value.
[in]chLastRangeDigitThe largest value.
Returns
If true, then the range is within the permitted range.

◆ convertAsciiCharArrayInOwn()

void eut::UnsignedMagicNumber::convertAsciiCharArrayInOwn ( char * pchChar) const
private

Changes the ASCII characters in the passed ASCII char array to the corresponding custom chars.

Parameters
[in]pchCharThe ASCII char array whose contents are to be converted into custom chars.
Exceptions
eut::ErrorNExceptionAn exception is thrown if the characters in pchChar are not in the ranges '0' - '9', 'A' - 'Z' or 'a' - 'z'.

◆ convertAsciiCharInOwn()

void eut::UnsignedMagicNumber::convertAsciiCharInOwn ( char & rchChar) const
private

Converts the transferred char into its own char.

Parameters
[in]rchCharThe ASCII char to be converted into your own char.
Exceptions
eut::ErrorNExceptionAn exception is thrown if rchChar is not in the ranges '0' - '9', 'A' - 'Z' or 'a' - 'z'.

◆ convertOwnCharArrayInAscii()

void eut::UnsignedMagicNumber::convertOwnCharArrayInAscii ( char * pchChar) const
private

Changes the own characters in the passed char array to the corresponding ASCII char.

Parameters
[in]pchCharThe char array with its own characters, whose content is to be converted to ASCII char.
Exceptions
eut::ErrorNExceptionAn exception is thrown if the characters in pchChar are not in the ranges '0' - '9', 'A' - 'Z' or 'a' - 'z'.

◆ convertOwnCharInAscii()

void eut::UnsignedMagicNumber::convertOwnCharInAscii ( char & rchChar) const
private

Changes the transferred custom char to the corresponding ASCII char.

Parameters
[in]rchCharThe own char to be converted into an ASCII char.
Exceptions
eut::ErrorNExceptioneut::ErrorNExceptionAn exception is thrown if rchChar is not in the ranges '0' - '9', 'A' - 'Z' or 'a' - 'z'.

◆ getAsciiCharInOwn()

char eut::UnsignedMagicNumber::getAsciiCharInOwn ( const char & rchChar) const
private

Returns the own char, which corresponds to the ASCII char.

Parameters
[in]rchCharThe ASCII char to be converted into a custom char.
Returns
The char converted to its own format.
Exceptions
eut::ErrorNExceptionAn exception is thrown if rchChar is not in the ranges '0' - '9', 'A' - 'Z' or 'a' - 'z'.

◆ getFirstRangeDigit()

char eut::UnsignedMagicNumber::getFirstRangeDigit ( ) const

Returns the smallest valid ASCII character.

Returns
The smallest valid ASCII character.

◆ getLastError()

int eut::UnsignedMagicNumber::getLastError ( )

Returns the last error that occurred.

Returns
The last error that occurred.

◆ getLastRangeDigit()

char eut::UnsignedMagicNumber::getLastRangeDigit ( ) const

Returns the largest valid ASCII character.

Returns
The largest valid ASCII character.

◆ getMaxSize()

unsigned int eut::UnsignedMagicNumber::getMaxSize ( ) const

Returns the maximum length of the value.

Returns
The maximum length of the value.

◆ getOwnCharInAscii()

char eut::UnsignedMagicNumber::getOwnCharInAscii ( const char & rchChar) const
private

Returns the ASCII char which corresponds to the own char.

Parameters
[in]rchCharThe own char which should be converted into an ASCII char.
Returns
The char converted to ASCII format.
Exceptions
eut::ErrorNExceptioneut::ErrorNExceptionAn exception is thrown if rchChar is not in the ranges '0' - '9', 'A' - 'Z' or 'a' - 'z'.

◆ init()

void eut::UnsignedMagicNumber::init ( char chFirstRangeDigit,
char chLastRangeDigit )
private

Initializes and checks its values.

Parameters
[in]chFirstRangeDigitThe smallest allowed value, i.e. the start value.
[in]chLastRangeDigitThe largest permitted value, i.e. the end value.
Exceptions
eut::ErrorNExceptionAn exception is thrown if uiMaxSize == 0 or chFirstRangeDigit and chLastRangeDigit are not in the ranges '0' - '9', 'A' - 'Z' and 'a' - 'z'.

◆ isAsciiInRange()

bool eut::UnsignedMagicNumber::isAsciiInRange ( const char chCharacter) const

Checks if the passed ASCII character is in the range of m_chFirstRangeDigit and m_chLastRangeDigit

Parameters
[in]chCharacterThe ASCII character to check.
Returns
If true, then the passed ASCII character is in the allowed range.

◆ isInRange()

bool eut::UnsignedMagicNumber::isInRange ( const char chCharacter) const
private

Checks if the passed character is in the specified range of m_chFirstRangeDigit and m_chLastRangeDigit

Parameters
[in]chCharacterThe character to check.
Returns
If true, then the passed character is in the allowed range.

◆ isNULL()

bool eut::UnsignedMagicNumber::isNULL ( ) const

Checks if the smallest value (the value from m_chFirstRangeDigit) is seted.

Returns
If true, then the smallest value is in m_pchValue.

◆ operator!=()

bool eut::UnsignedMagicNumber::operator!= ( const UnsignedMagicNumber & rT) const

Comparison operator.

◆ operator++() [1/2]

UnsignedMagicNumber & eut::UnsignedMagicNumber::operator++ ( )

Computational operators.

If another UnsignedMagicNumber is involved, it is checked if both EuUnsignedMagicNumbers have the same settings.

Note
It will not be calculated, if another UnsignedMagicNumber is involved, if it has different settings. The attributes m_uiMaxSize, m_chFirstRangeDigit and m_chLastRangeDigit must match.
In addition, an overflow (exceeding m_uiMaxSize) or falling below the smallest allowed value is not calculated and an error is set. With getLastError() the last error should be queried.

◆ operator++() [2/2]

UnsignedMagicNumber eut::UnsignedMagicNumber::operator++ ( int )

Computational operators.

If another UnsignedMagicNumber is involved, it is checked if both EuUnsignedMagicNumbers have the same settings.

Note
It will not be calculated, if another UnsignedMagicNumber is involved, if it has different settings. The attributes m_uiMaxSize, m_chFirstRangeDigit and m_chLastRangeDigit must match.
In addition, an overflow (exceeding m_uiMaxSize) or falling below the smallest allowed value is not calculated and an error is set. With getLastError() the last error should be queried.

◆ operator+=()

UnsignedMagicNumber & eut::UnsignedMagicNumber::operator+= ( const UnsignedMagicNumber & rrT)

Computational operators.

If another UnsignedMagicNumber is involved, it is checked if both EuUnsignedMagicNumbers have the same settings.

Note
It will not be calculated, if another UnsignedMagicNumber is involved, if it has different settings. The attributes m_uiMaxSize, m_chFirstRangeDigit and m_chLastRangeDigit must match.
In addition, an overflow (exceeding m_uiMaxSize) or falling below the smallest allowed value is not calculated and an error is set. With getLastError() the last error should be queried.

◆ operator--() [1/2]

UnsignedMagicNumber & eut::UnsignedMagicNumber::operator-- ( )

Computational operators.

If another UnsignedMagicNumber is involved, it is checked if both EuUnsignedMagicNumbers have the same settings.

Note
It will not be calculated, if another UnsignedMagicNumber is involved, if it has different settings. The attributes m_uiMaxSize, m_chFirstRangeDigit and m_chLastRangeDigit must match.
In addition, an overflow (exceeding m_uiMaxSize) or falling below the smallest allowed value is not calculated and an error is set. With getLastError() the last error should be queried.

◆ operator--() [2/2]

UnsignedMagicNumber eut::UnsignedMagicNumber::operator-- ( int )

Computational operators.

If another UnsignedMagicNumber is involved, it is checked if both EuUnsignedMagicNumbers have the same settings.

Note
It will not be calculated, if another UnsignedMagicNumber is involved, if it has different settings. The attributes m_uiMaxSize, m_chFirstRangeDigit and m_chLastRangeDigit must match.
In addition, an overflow (exceeding m_uiMaxSize) or falling below the smallest allowed value is not calculated and an error is set. With getLastError() the last error should be queried.

◆ operator-=()

UnsignedMagicNumber & eut::UnsignedMagicNumber::operator-= ( const UnsignedMagicNumber & rrT)

Computational operators.

If another UnsignedMagicNumber is involved, it is checked if both EuUnsignedMagicNumbers have the same settings.

Note
It will not be calculated, if another UnsignedMagicNumber is involved, if it has different settings. The attributes m_uiMaxSize, m_chFirstRangeDigit and m_chLastRangeDigit must match.
In addition, an overflow (exceeding m_uiMaxSize) or falling below the smallest allowed value is not calculated and an error is set. With getLastError() the last error should be queried.

◆ operator<()

bool eut::UnsignedMagicNumber::operator< ( const UnsignedMagicNumber & rT) const

Comparison operator for size comparison.

◆ operator<=()

bool eut::UnsignedMagicNumber::operator<= ( const UnsignedMagicNumber & rT) const

Comparison operator for size comparison.

◆ operator=()

UnsignedMagicNumber & eut::UnsignedMagicNumber::operator= ( const UnsignedMagicNumber & rT)

Assignment operator, all attributes are considered.

Note
Via getLastError() the last error should be queried.

◆ operator==()

bool eut::UnsignedMagicNumber::operator== ( const UnsignedMagicNumber & rT) const

Comparison operator.

◆ operator>()

bool eut::UnsignedMagicNumber::operator> ( const UnsignedMagicNumber & rT) const

Comparison operator for size comparison.

◆ operator>=()

bool eut::UnsignedMagicNumber::operator>= ( const UnsignedMagicNumber & rT) const

Comparison operator for size comparison.

◆ setNULL()

void eut::UnsignedMagicNumber::setNULL ( )

Sets m_pchValue to the smallest value (m_chFirstRangeDigit)

◆ setValue()

int eut::UnsignedMagicNumber::setValue ( const char * pchValue)

Sets its own value.

Parameters
[in]pchValueThe value as 0-terminated ASCII char array. The length of the value must not be greater than specified in m_uiMaxSize and all characters must be within the range of m_chFirstRangeDigit and m_chLastRangeDigit.
Returns
If return != 0 an error has occurred.

◆ subtractChar()

bool eut::UnsignedMagicNumber::subtractChar ( char & rchTarget,
const char chSource,
char chLastRangeDigit )
private

Subtracts the second char from the first one transferred.

Parameters
[in,out]rchTargetThe char from which to subtract
[in]chSourceThe char to be subtracted from chTarget.
[in]chLastRangeDigitThe last allowed value.
Returns
If true, an underflow has occurred (e.g. if m chTarget == '3' and chSource == '4').
Note
There is no check whether and how the two Char rchTarget and chSource are within the permitted range. Even chLastRangeDigit will not checked for plausibility.

◆ subtractValue()

int eut::UnsignedMagicNumber::subtractValue ( char * pchTarget,
const char * pchSource,
unsigned int uiMaxSize,
char chFirstRangeDigit,
char chLastRangeDigit )
private

Subtracts the second passed Char-Array from the first passed Char-Array. This method is only called by operators, so there is no need to perform checks here.

Parameters
[in,out]pchTargetThe value to subtract from (0-terminated char array of own characters). The length of the value is defined in uiMaxSize and all characters must be in the range of chFirstRangeDigit and chLastRangeDigit.
[in]pchSourceThe value to be subtracted from pchTarget (0-terminated char array of own characters). The length of the value is defined in uiMaxSize and all characters must be in the range of chFirstRangeDigit and chLastRangeDigit.
[in]uiMaxSizeThe maximum length of the passed char arrays.
[in]chFirstRangeDigitThe first allowed value of each char in the char arrays.
[in]chLastRangeDigitThe last allowed value of each char in the char-arrays.
Returns
If return != 0 an error has occurred.
Note
It is not checked if and how the two char-arrays pchTarget and pchSource were instantiated!
Parameter chFirstRangeDigit and chLastRangeDigit are not checked for plausibility.

◆ toString()

std::string eut::UnsignedMagicNumber::toString ( ) const

Returns its value as std::string.

Returns
Its value as std::string.

Friends And Related Symbol Documentation

◆ operator+

UnsignedMagicNumber operator+ ( UnsignedMagicNumber lT,
const UnsignedMagicNumber & rrT )
friend

◆ operator-

UnsignedMagicNumber operator- ( UnsignedMagicNumber lT,
const UnsignedMagicNumber & rrT )
friend

◆ operator<<

std::ostream & operator<< ( std::ostream & rOStream,
const UnsignedMagicNumber & rMagicNumber )
friend

◆ operator>>

std::istream & operator>> ( std::istream & rIStream,
UnsignedMagicNumber & rMagicNumber )
friend

Member Data Documentation

◆ m_chFirstRangeDigit

char eut::UnsignedMagicNumber::m_chFirstRangeDigit
private

The start value, default is '0'.

◆ m_chLastRangeDigit

char eut::UnsignedMagicNumber::m_chLastRangeDigit
private

The final value, default setting is 'Z'.

◆ m_iLastError

int eut::UnsignedMagicNumber::m_iLastError
private

Last error.

◆ m_pchValue

char* eut::UnsignedMagicNumber::m_pchValue
private

The value of MagicNumber.

◆ m_uiMaxSize

unsigned int eut::UnsignedMagicNumber::m_uiMaxSize
private

The maximum length (number of characters) of m_pchValue (default is 10).


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