Tawara  0.1.0
Public Member Functions | List of all members
tawara::VoidElement Class Reference

Void primitive element. More...

#include <tawara/void_element.h>

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

Public Member Functions

 VoidElement (std::streamsize tgt_size, bool fill=false)
 Create a new void element. More...
 
 VoidElement (Element const &element, bool fill=false)
 Create a new VoidElement that replaces another element. More...
 
void set_size (std::streamsize tgt_size)
 Set the size of this element. More...
 
std::streamsize size () const
 Get the total size of the element. More...
 
bool fill () const
 Get the fill setting. More...
 
void fill (bool fill)
 Set the fill setting. More...
 
virtual std::streamsize write (std::ostream &output)
 Element writing. More...
 
virtual std::streamsize write_body (std::ostream &output)
 Element body writing. More...
 
std::streamsize read (std::istream &input)
 Element reading. 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...
 

Additional Inherited Members

- 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 inherited from tawara::Element
tawara::ids::ID id_
 
std::streampos offset_
 

Detailed Description

Void primitive element.

This is a void element, specified with the EBML ID 0xEC. Void elements are ignored by the parser. They are typically used to reserve some space in a byte stream for later writing, or to blank out an element that is no longer used without re-writing the entire file.

Definition at line 60 of file void_element.h.

Constructor & Destructor Documentation

tawara::VoidElement::VoidElement ( std::streamsize  tgt_size,
bool  fill = false 
)

Create a new void element.

Parameters
[in]tgt_sizeThe size of the element, in bytes. This much space will be reserved in the file.
[in]fillIf true, when writing the element, the element's body will be filled with 0x00.
Exceptions
VoidTooSmallif tgt_size is less than 2 bytes.
tawara::VoidElement::VoidElement ( Element const &  element,
bool  fill = false 
)

Create a new VoidElement that replaces another element.

This constructor creates a VoidElement with its fill set to the necessary size to completely and exactly cover the element passed to it.

Parameters
[in]elementThe element to replace.
[in]fillWhether to fill the space in the file with zeros.

Member Function Documentation

bool tawara::VoidElement::fill ( ) const
inline

Get the fill setting.

Definition at line 98 of file void_element.h.

void tawara::VoidElement::fill ( bool  fill)
inline

Set the fill setting.

A void element may fill its body when written. This is typically used when writing it at the end of a byte stream, such as reserving space in a file to be filled in later with other data. Set fill to true to do so.

On the other hand, void elements are also used for blanking out existing elements that are no longer used, such as when removing a tag, without needing to rewrite the entire file. In this case, only the element ID and size need to be written, with the remainder of the element's body being left as-is. Set fill to false for this style of writing.

Definition at line 113 of file void_element.h.

std::streamsize tawara::VoidElement::read ( std::istream &  input)
virtual

Element reading.

Reimplemented from tawara::Element.

void tawara::VoidElement::set_size ( std::streamsize  tgt_size)

Set the size of this element.

A void element has a size value, given in bytes, which determines how much space it reserves in the byte stream.

Exceptions
VoidTooSmallif tgt_size is less than 2 bytes.
std::streamsize tawara::VoidElement::size ( ) const
virtual

Get the total size of the element.

Reimplemented from tawara::Element.

virtual std::streamsize tawara::VoidElement::write ( std::ostream &  output)
virtual

Element writing.

Reimplemented from tawara::Element.

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

Element body writing.

Writes the element's size and body to a byte stream providing a std::ostream interface.

Void elements may or may not fill their body with 0x00, based on the setting of the fill member property. Whether or not the body is actually filled by this method, the return value and the write position pointer in the output stream will reflect the full size of the void element.

Returns
The number of bytes written.

Implements tawara::Element.


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