Generic SmartRest library

Dependents:   SmartRestUnitTest MbedSmartRest MbedSmartRestStreaming

Embed: (wiki syntax)

« Back to documentation index

FloatValue Class Reference

FloatValue Class Reference

A floating-point value. More...

#include <FloatValue.h>

Inherits Value.

Public Member Functions

 FloatValue (double, uint8_t, bool=true)
 Creates a new instance of a floating-point value.
uint8_t valueType () const
 Returns the value type which can be VALUE_NULL, VALUE_INTEGER, VALUE_FLOAT or VALUE_CHARACTER.
long integerValue () const
 Returns the integer value if an integer type, otherwise zero.
double floatValue () const
 Returns the float value if a float type, otherwise zero.
const char * characterValue () const
 Returns the character value if a character type, otherwise zero.
size_t write (AbstractDataSink &) const
 Writes the value to a sink.
size_t length () const
 Returns the number of bytes required to write this value to a sink.
Valuecopy () const
 Copies this value to the heap.

Detailed Description

A floating-point value.

Definition at line 42 of file FloatValue.h.


Constructor & Destructor Documentation

FloatValue ( double  number,
uint8_t  digits,
bool  zflag = true 
)

Creates a new instance of a floating-point value.

Parameters:
numberthe floating-point number
digitsprecision in number of digits
zflagwhether to write a zero before the floating point

Definition at line 32 of file FloatValue.cpp.


Member Function Documentation

const char * characterValue (  ) const [virtual]

Returns the character value if a character type, otherwise zero.

Returns:
character value

Implements Value.

Definition at line 58 of file FloatValue.cpp.

Value * copy (  ) const [virtual]

Copies this value to the heap.

Referenced contents must also be copied.

Returns:
a new value instance allocated on the heap

Implements Value.

Definition at line 130 of file FloatValue.cpp.

double floatValue (  ) const [virtual]

Returns the float value if a float type, otherwise zero.

Returns:
float value

Implements Value.

Definition at line 53 of file FloatValue.cpp.

long integerValue (  ) const [virtual]

Returns the integer value if an integer type, otherwise zero.

Returns:
integer value

Implements Value.

Definition at line 48 of file FloatValue.cpp.

size_t length (  ) const [virtual]

Returns the number of bytes required to write this value to a sink.

Returns:
number of bytes required to write this value

Implements Value.

Definition at line 100 of file FloatValue.cpp.

uint8_t valueType (  ) const [virtual]

Returns the value type which can be VALUE_NULL, VALUE_INTEGER, VALUE_FLOAT or VALUE_CHARACTER.

Returns:
the value type

Implements Value.

Definition at line 43 of file FloatValue.cpp.

size_t write ( AbstractDataSink &   ) const [virtual]

Writes the value to a sink.

If necessary, quotes and escape characters may be added.

Parameters:
sinkthe sink to write the value to
Returns:
the number of bytes written

Implements Value.

Definition at line 63 of file FloatValue.cpp.