Tawara  0.1.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tawara::FloatElement Class Reference

Float primitive element. More...

#include <tawara/float_element.h>

Inheritance diagram for tawara::FloatElement:
Inheritance graph
[legend]
Collaboration diagram for tawara::FloatElement:
Collaboration graph
[legend]

Public Member Functions

 FloatElement (uint32_t id, double value, EBMLFloatPrec precision=EBML_FLOAT_PREC_DOUBLE)
 Create a new float element with no default. More...
 
 FloatElement (uint32_t id, double value, double default_value, EBMLFloatPrec precision=EBML_FLOAT_PREC_DOUBLE)
 Create a new float element with a default value. More...
 
virtual FloatElementoperator= (double const &rhs)
 Value assignment operator. More...
 
virtual EBMLFloatPrec precision () const
 Get the precision setting. More...
 
virtual void precision (EBMLFloatPrec precision)
 Set the precision setting. More...
 
virtual std::streamsize write_body (std::ostream &output)
 Element body writing. More...
 
- Public Member Functions inherited from tawara::PrimitiveElement< double >
 PrimitiveElement (uint32_t id, doublevalue)
 Create a new element with no default. More...
 
 PrimitiveElement (uint32_t id, doublevalue, doubledefault_value)
 Create a signed integer element with a default value. More...
 
virtual uint32_t id () const
 Get the element's ID. More...
 
virtual void id (uint32_t id)
 Set the element's ID. More...
 
virtual double value () const
 Get the value. More...
 
virtual void value (doublevalue)
 Set the value. More...
 
 operator double () const
 Cast to the stored type. More...
 
virtual bool has_default () const
 Check if a default value is set. More...
 
virtual double get_default () const
 Get the default value. More...
 
virtual void set_default (doubledefault_value)
 Set the default value. More...
 
virtual double remove_default ()
 Remove the default value. More...
 
virtual bool is_default () const
 Check if this element is at the default value. More...
 
- Public Member Functions inherited from tawara::Element
 Element (tawara::ids::ID id)
 Create a new Element. More...
 
virtual ~Element ()
 Destructor. More...
 
uint32_t id () const
 Get the element's ID. More...
 
std::streampos offset () const
 Get the element's offset in the byte stream. More...
 
virtual std::streamsize size () const
 Get the total size of the element. More...
 
virtual std::streamsize write (std::ostream &output)
 Element writing. More...
 
virtual std::streamsize read (std::istream &input)
 Element reading. More...
 

Protected Member Functions

virtual std::streamsize body_size () const
 Get the size of the body of this element. More...
 
virtual std::streamsize read_body (std::istream &input, std::streamsize size)
 Element body loading. More...
 
- Protected Member Functions inherited from tawara::PrimitiveElement< double >
virtual bool equal_ (PrimitiveElement< double > const &rhs)
 
- Protected Member Functions inherited from tawara::Element
std::streamsize write_id (std::ostream &output)
 Element ID writing. More...
 
virtual std::streamsize write_size (std::ostream &output)
 Element size writing. More...
 

Protected Attributes

EBMLFloatPrec prec_
 
- Protected Attributes inherited from tawara::PrimitiveElement< double >
double value_
 
double default_
 
bool has_default_
 
- Protected Attributes inherited from tawara::Element
tawara::ids::ID id_
 
std::streampos offset_
 

Detailed Description

Float primitive element.

This element stores an IEEE floating-point number. 4-byte and 8-byte floats are allowed.

Definition at line 64 of file float_element.h.

Constructor & Destructor Documentation

tawara::FloatElement::FloatElement ( uint32_t  id,
double  value,
EBMLFloatPrec  precision = EBML_FLOAT_PREC_DOUBLE 
)

Create a new float element with no default.

Parameters
[in]idThe element's ID, as an unsigned integer up to 28 bits.
[in]valueThe element's value.
[in]precisionThe element's precision, single or double. This only has an effect when writing the float to file.
tawara::FloatElement::FloatElement ( uint32_t  id,
double  value,
double  default_value,
EBMLFloatPrec  precision = EBML_FLOAT_PREC_DOUBLE 
)

Create a new float element with a default value.

Parameters
[in]idThe element's ID, as an unsigned integer up to 28 bits.
[in]valueThe element's value.
[in]precisionThe element's precision, single or double. This only has an effect when writing the float to a file.
[in]default_valueThe default value of the element.

Member Function Documentation

virtual std::streamsize tawara::FloatElement::body_size ( ) const
protectedvirtual

Get the size of the body of this element.

Implements tawara::Element.

virtual FloatElement& tawara::FloatElement::operator= ( double const &  rhs)
virtual

Value assignment operator.

Reimplemented from tawara::PrimitiveElement< double >.

virtual EBMLFloatPrec tawara::FloatElement::precision ( ) const
inlinevirtual

Get the precision setting.

Definition at line 94 of file float_element.h.

virtual void tawara::FloatElement::precision ( EBMLFloatPrec  precision)
inlinevirtual

Set the precision setting.

This value determines if the float is single or double precision. The precision value has no effect until the float is written to a file, at which point single-precision floats are written using 4 bytes while double-precision floats are written using 8 bytes.

Definition at line 103 of file float_element.h.

virtual std::streamsize tawara::FloatElement::read_body ( std::istream &  input,
std::streamsize  size 
)
protectedvirtual

Element body loading.

Exceptions
BadElementLengthif the float element is an incorrect length (i.e. not 4 or 8 bytes).

Implements tawara::Element.

virtual std::streamsize tawara::FloatElement::write_body ( std::ostream &  output)
virtual

Element body writing.

Implements tawara::Element.

Member Data Documentation

EBMLFloatPrec tawara::FloatElement::prec_
protected

Definition at line 110 of file float_element.h.


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