ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
ucommon::Number Class Reference

A number manipulation class. More...

#include <numbers.h>

Inheritance diagram for ucommon::Number:
[legend]

Public Member Functions

 Number (char *buffer, unsigned size)
 Create an instance of a number. More...
 
void set (long value)
 Set string based on a new value. More...
 
const char * c_str () const
 Get string buffer representing the number. More...
 
long get () const
 Get value of string buffer as a long integer. More...
 
long operator() () const
 Get value of string buffer as expression of object. More...
 
 operator long () const
 Cast string as long integer and get value of buffer. More...
 
 operator char * () const
 Cast object as a string to retrieve buffer. More...
 
long operator= (long value)
 Assign a value to the number. More...
 
long operator= (const Number &number)
 Assign another number to this number. More...
 
long operator+= (const long value)
 Add a value to the number. More...
 
long operator-= (const long value)
 Subtract a value from the number. More...
 
long operator-- ()
 Decrement the number object. More...
 
long operator++ ()
 Increment the number object. More...
 
bool operator== (const long value) const
 
bool operator!= (const long value) const
 
bool operator< (const long value) const
 
bool operator> (const long value) const
 
bool operator<= (const long value) const
 
bool operator>= (const long value) const
 

Protected Attributes

char * buffer
 
unsigned size
 

Detailed Description

A number manipulation class.

This is used to extract, convert, and manage simple numbers that are represented in C ascii strings in a very quick and optimal way. This class modifies the string representation each time the value is changed. No math expressions or explicit comparison operators are supported for the Numbers class because these are best done by casting to long first.

Author
David Sugar dyfet.nosp@m.@ost.nosp@m.el.co.nosp@m.m

number manipulation.

Definition at line 47 of file numbers.h.

Constructor & Destructor Documentation

◆ Number()

ucommon::Number::Number ( char *  buffer,
unsigned  size 
)

Create an instance of a number.

Parameters
bufferor NULL if created internally.
sizeof field if not null terminated.

Definition at line 30 of file numbers.cpp.

References buffer, and size.

Member Function Documentation

◆ c_str()

const char * ucommon::Number::c_str ( ) const
inline

Get string buffer representing the number.

Returns
string buffer.

Definition at line 71 of file numbers.h.

References buffer.

◆ get()

long ucommon::Number::get ( void  ) const

Get value of string buffer as a long integer.

Returns
long integer value of string buffer.

Definition at line 41 of file numbers.cpp.

References buffer, and size.

Referenced by operator++(), operator+=(), operator--(), operator-=(), and operator=().

◆ operator char *()

ucommon::Number::operator char * ( ) const
inline

Cast object as a string to retrieve buffer.

Returns
string buffer of value.

Definition at line 101 of file numbers.h.

References buffer.

◆ operator long()

ucommon::Number::operator long ( ) const
inline

Cast string as long integer and get value of buffer.

Returns
long integer value of string buffer.

Definition at line 93 of file numbers.h.

◆ operator!=()

bool ucommon::Number::operator!= ( const long  value) const
inline

Definition at line 149 of file numbers.h.

◆ operator()()

long ucommon::Number::operator() ( ) const
inline

Get value of string buffer as expression of object.

Returns
long integer value of string buffer.

Definition at line 85 of file numbers.h.

◆ operator++()

long ucommon::Number::operator++ ( )

Increment the number object.

This rewrites the string buffer.

Returns
new value of number object.

Definition at line 134 of file numbers.cpp.

References get(), and set().

Here is the call graph for this function:

◆ operator+=()

long ucommon::Number::operator+= ( const long  value)

Add a value to the number.

This rewrites the string buffer.

Parameters
valueto add.
Returns
new value of number object.

Definition at line 113 of file numbers.cpp.

References get(), and set().

Here is the call graph for this function:

◆ operator--()

long ucommon::Number::operator-- ( )

Decrement the number object.

This rewrites the string buffer.

Returns
new value of number object.

Definition at line 127 of file numbers.cpp.

References get(), and set().

Here is the call graph for this function:

◆ operator-=()

long ucommon::Number::operator-= ( const long  value)

Subtract a value from the number.

This rewrites the string buffer.

Parameters
valueto subtract.
Returns
new value of number object.

Definition at line 120 of file numbers.cpp.

References get(), and set().

Here is the call graph for this function:

◆ operator<()

bool ucommon::Number::operator< ( const long  value) const
inline

Definition at line 153 of file numbers.h.

◆ operator<=()

bool ucommon::Number::operator<= ( const long  value) const
inline

Definition at line 161 of file numbers.h.

◆ operator=() [1/2]

long ucommon::Number::operator= ( const Number number)

Assign another number to this number.

Parameters
numberto assign to assign.
Returns
new value of number object assigned.

Definition at line 107 of file numbers.cpp.

References get(), and set().

Here is the call graph for this function:

◆ operator=() [2/2]

long ucommon::Number::operator= ( long  value)

Assign a value to the number.

This rewrites the string buffer.

Parameters
valueto assign.
Returns
new value of number object assigned.

Definition at line 101 of file numbers.cpp.

References set().

Here is the call graph for this function:

◆ operator==()

bool ucommon::Number::operator== ( const long  value) const
inline

Definition at line 145 of file numbers.h.

◆ operator>()

bool ucommon::Number::operator> ( const long  value) const
inline

Definition at line 157 of file numbers.h.

◆ operator>=()

bool ucommon::Number::operator>= ( const long  value) const
inline

Definition at line 165 of file numbers.h.

◆ set()

void ucommon::Number::set ( long  value)

Set string based on a new value.

Parameters
valueto set.

Definition at line 68 of file numbers.cpp.

References buffer, ucommon::max(), and size.

Referenced by operator++(), operator+=(), operator--(), operator-=(), and operator=().

Here is the call graph for this function:

Member Data Documentation

◆ buffer

char* ucommon::Number::buffer
protected

Definition at line 50 of file numbers.h.

Referenced by get(), Number(), set(), ucommon::ZNumber::set(), and ucommon::DateNumber::update().

◆ size

unsigned ucommon::Number::size
protected

Definition at line 51 of file numbers.h.

Referenced by get(), Number(), set(), and ucommon::ZNumber::set().


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