Tawara
0.1.0
|
The primitive data element interface. More...
#include <tawara/prim_element.h>
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 PrimitiveElement & | operator= (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... | |
![]() | |
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) |
![]() | |
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 | |
T | value_ |
T | default_ |
bool | has_default_ |
![]() | |
tawara::ids::ID | id_ |
std::streampos | offset_ |
Friends | |
bool | operator== (PrimitiveElement< T > const &lhs, PrimitiveElement< T > const &rhs) |
Equality operator. More... | |
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.
|
inline |
Create a new element with no default.
[in] | id | The element's ID, as an unsigned integer up to 28 bits. |
[in] | value | The element's value. |
Definition at line 86 of file prim_element.h.
|
inline |
Create a signed integer element with a default value.
[in] | id | The element's ID, as an unsigned integer up to 28 bits. |
[in] | value | The element's value. |
[in] | default_value | The default value of the element. |
Definition at line 99 of file prim_element.h.
|
inlineprotectedvirtual |
Definition at line 179 of file prim_element.h.
|
inlinevirtual |
Get the default value.
Definition at line 143 of file prim_element.h.
|
inlinevirtual |
Check if a default value is set.
Definition at line 141 of file prim_element.h.
|
inlinevirtual |
Get the element's ID.
Definition at line 113 of file prim_element.h.
|
inlinevirtual |
Set the element's ID.
[in] | id | The element's new ID, as an unsigned integer up to 28 bits. |
Definition at line 120 of file prim_element.h.
|
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.
|
inline |
Cast to the stored type.
Definition at line 138 of file prim_element.h.
|
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.
|
inlinevirtual |
Remove the default value.
Definition at line 154 of file prim_element.h.
|
inlinevirtual |
Set the default value.
Definition at line 145 of file prim_element.h.
|
inlinevirtual |
Get the value.
Definition at line 134 of file prim_element.h.
|
inlinevirtual |
Set the value.
Definition at line 136 of file prim_element.h.
|
friend |
Equality operator.
Definition at line 168 of file prim_element.h.
|
protected |
Definition at line 176 of file prim_element.h.
|
protected |
Definition at line 177 of file prim_element.h.
|
protected |
Definition at line 175 of file prim_element.h.