Tawara  0.1.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
tawara::PrimitiveElement< T > Class Template Reference

The primitive data element interface. More...

#include <tawara/prim_element.h>

Inheritance diagram for tawara::PrimitiveElement< T >:
Inheritance graph
[legend]
Collaboration diagram for tawara::PrimitiveElement< T >:
Collaboration graph
[legend]

Public Member Functions

 PrimitiveElement (uint32_t id, T value)
 Create a new element with no default. More...
 
 PrimitiveElement (uint32_t id, T value, T default_value)
 Create a signed integer element with a default value. More...
 
virtual PrimitiveElementoperator= (T const &rhs)
 Value assignment operator. 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 T value () const
 Get the value. More...
 
virtual void value (T value)
 Set the value. More...
 
 operator T () const
 Cast to the stored type. More...
 
virtual bool has_default () const
 Check if a default value is set. More...
 
virtual T get_default () const
 Get the default value. More...
 
virtual void set_default (T default_value)
 Set the default value. More...
 
virtual T 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 bool equal_ (PrimitiveElement< T > const &rhs)
 
- Protected Member Functions inherited from tawara::Element
virtual std::streamsize body_size () const =0
 Get the size of the body of this element. More...
 
std::streamsize write_id (std::ostream &output)
 Element ID writing. More...
 
virtual std::streamsize write_size (std::ostream &output)
 Element size writing. More...
 
virtual std::streamsize write_body (std::ostream &output)=0
 Element body writing. More...
 
virtual std::streamsize read_body (std::istream &input, std::streamsize size)=0
 Element body reading implementation. More...
 

Protected Attributes

value_
 
default_
 
bool has_default_
 
- Protected Attributes inherited from tawara::Element
tawara::ids::ID id_
 
std::streampos offset_
 

Friends

bool operator== (PrimitiveElement< T > const &lhs, PrimitiveElement< T > const &rhs)
 Equality operator. More...
 

Detailed Description

template<typename T>
class tawara::PrimitiveElement< T >

The primitive data element interface.

Primitive elements store one of the EBML primitive data types. These are:

A default value can be specified for the element. If a default is given, it may allow the element to be skipped when writing to a store.

Any type specified for T must initialise itself upon construction, be copy-constructable, have an assignment operator, and perform its own clean-up in its destructor. POD types qualify for this.

Definition at line 76 of file prim_element.h.

Constructor & Destructor Documentation

template<typename T>
tawara::PrimitiveElement< T >::PrimitiveElement ( uint32_t  id,
value 
)
inline

Create a new element with no default.

Parameters
[in]idThe element's ID, as an unsigned integer up to 28 bits.
[in]valueThe element's value.

Definition at line 86 of file prim_element.h.

template<typename T>
tawara::PrimitiveElement< T >::PrimitiveElement ( uint32_t  id,
value,
default_value 
)
inline

Create a signed integer 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]default_valueThe default value of the element.

Definition at line 99 of file prim_element.h.

Member Function Documentation

template<typename T>
virtual bool tawara::PrimitiveElement< T >::equal_ ( PrimitiveElement< T > const &  rhs)
inlineprotectedvirtual

Definition at line 179 of file prim_element.h.

template<typename T>
virtual T tawara::PrimitiveElement< T >::get_default ( ) const
inlinevirtual

Get the default value.

Definition at line 143 of file prim_element.h.

template<typename T>
virtual bool tawara::PrimitiveElement< T >::has_default ( ) const
inlinevirtual

Check if a default value is set.

Definition at line 141 of file prim_element.h.

template<typename T>
virtual uint32_t tawara::PrimitiveElement< T >::id ( ) const
inlinevirtual

Get the element's ID.

Definition at line 113 of file prim_element.h.

template<typename T>
virtual void tawara::PrimitiveElement< T >::id ( uint32_t  id)
inlinevirtual

Set the element's ID.

Parameters
[in]idThe element's new ID, as an unsigned integer up to 28 bits.

Definition at line 120 of file prim_element.h.

template<typename T>
virtual bool tawara::PrimitiveElement< T >::is_default ( ) const
inlinevirtual

Check if this element is at the default value.

If the current value is the same as the default value, this element may not need to be stored when being written.

Definition at line 164 of file prim_element.h.

template<typename T>
tawara::PrimitiveElement< T >::operator T ( ) const
inline

Cast to the stored type.

Definition at line 138 of file prim_element.h.

template<typename T>
virtual PrimitiveElement& tawara::PrimitiveElement< T >::operator= ( T const &  rhs)
inlinevirtual

Value assignment operator.

Reimplemented in tawara::FloatElement, tawara::BinaryElement, tawara::StringElement, tawara::DateElement, tawara::IntElement, and tawara::UIntElement.

Definition at line 106 of file prim_element.h.

template<typename T>
virtual T tawara::PrimitiveElement< T >::remove_default ( )
inlinevirtual

Remove the default value.

Returns
The value of the default that was removed.

Definition at line 154 of file prim_element.h.

template<typename T>
virtual void tawara::PrimitiveElement< T >::set_default ( default_value)
inlinevirtual

Set the default value.

Definition at line 145 of file prim_element.h.

template<typename T>
virtual T tawara::PrimitiveElement< T >::value ( ) const
inlinevirtual

Get the value.

Definition at line 134 of file prim_element.h.

template<typename T>
virtual void tawara::PrimitiveElement< T >::value ( value)
inlinevirtual

Set the value.

Definition at line 136 of file prim_element.h.

Friends And Related Function Documentation

template<typename T>
bool operator== ( PrimitiveElement< T > const &  lhs,
PrimitiveElement< T > const &  rhs 
)
friend

Equality operator.

Definition at line 168 of file prim_element.h.

Member Data Documentation

template<typename T>
T tawara::PrimitiveElement< T >::default_
protected

Definition at line 176 of file prim_element.h.

template<typename T>
bool tawara::PrimitiveElement< T >::has_default_
protected

Definition at line 177 of file prim_element.h.

template<typename T>
T tawara::PrimitiveElement< T >::value_
protected

Definition at line 175 of file prim_element.h.


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