Tawara
0.1.0
|
Common block functionality implementation. More...
#include <tawara/block_impl.h>
Public Types | |
typedef std::pair < std::streamsize, uint8_t > | ReadResult |
The return result of a read. More... | |
typedef boost::shared_ptr < std::vector< char > > | value_type |
The stored type. More... | |
![]() | |
enum | LacingType { LACING_NONE, LACING_EBML, LACING_FIXED } |
Lacing types. More... | |
typedef boost::shared_ptr< Block > | Ptr |
Pointer to a block. More... | |
typedef boost::shared_ptr < Block const > | ConstPtr |
Constant pointer to a block. More... | |
typedef std::vector< char > | Frame |
The type of a single frame of data. More... | |
typedef boost::shared_ptr< Frame > | FramePtr |
A pointer to a frame of data. More... | |
typedef std::vector< FramePtr > ::value_type | value_type |
The value type of this container. More... | |
typedef std::vector< FramePtr > ::size_type | size_type |
The size type of this container. More... | |
typedef std::vector< FramePtr > ::reference | reference |
The reference type. More... | |
typedef std::vector< FramePtr > ::const_reference | const_reference |
The constant reference type. More... | |
typedef std::vector< FramePtr > ::iterator | iterator |
The random access iterator type. More... | |
typedef std::vector< FramePtr > ::const_iterator | const_iterator |
The constant random access iterator type. More... | |
typedef std::vector< FramePtr > ::reverse_iterator | reverse_iterator |
The reversed random access iterator type. More... | |
typedef std::vector< FramePtr > ::const_reverse_iterator | const_reverse_iterator |
The constant reversed random access iterator type. More... | |
Public Member Functions | |
BlockImpl (uint64_t track_number, int16_t timecode, LacingType lacing=LACING_NONE) | |
Constructor. More... | |
uint64_t | track_number () const |
The block's track number. More... | |
void | track_number (uint64_t track_number) |
Set the block's track number. More... | |
int16_t | timecode () const |
The timecode of this block. More... | |
void | timecode (int16_t timecode) |
Set the block's timecode. More... | |
bool | invisible () const |
If this block is invisible. More... | |
void | invisible (bool invisible) |
Set if this block is invisible. More... | |
LacingType | lacing () const |
Get the lacing type in use. More... | |
void | lacing (LacingType lacing) |
Set the lacing type in use. More... | |
BlockImpl & | operator= (BlockImpl const &other) |
Replace the content of this block with another block. More... | |
value_type & | at (size_type pos) |
Get the frame at the given position, with bounds checking. More... | |
value_type const & | at (size_type pos) const |
Get the frame at the given position, with bounds checking. More... | |
value_type & | operator[] (size_type pos) |
Get a reference to a frame. More... | |
value_type const & | operator[] (size_type pos) const |
Get a reference to a frame. More... | |
iterator | begin () |
Get an iterator to the first frame. More... | |
const_iterator | begin () const |
Get an iterator to the first frame. More... | |
iterator | end () |
Get an iterator to the position past the last frame. More... | |
const_iterator | end () const |
Get an iterator to the position past the last frame. More... | |
reverse_iterator | rbegin () |
Get a reverse iterator to the last frame. More... | |
const_reverse_iterator | rbegin () const |
Get a reverse iterator to the last frame. More... | |
reverse_iterator | rend () |
Get a reverse iterator to the position before the first frame. More... | |
const_reverse_iterator | rend () const |
Get a reverse iterator to the position before the first frame. More... | |
bool | empty () const |
Check if there are no frames. More... | |
size_type | count () const |
Get the number of frames. More... | |
size_type | max_count () const |
Get the maximum number of frames. More... | |
void | clear () |
Remove all frames. More... | |
void | erase (iterator position) |
Erase the frame at the specified iterator. More... | |
void | erase (iterator first, iterator last) |
Erase a range of frames. More... | |
void | push_back (value_type const &value) |
Add a frame to this block. More... | |
void | resize (size_type count) |
Resizes the frames storage. More... | |
void | swap (BlockImpl &other) |
Swaps the contents of this block with another. More... | |
std::streamsize | size () const |
Gets the size of the block data. More... | |
std::streamsize | write (std::ostream &output, uint8_t extra_flags) |
Write the block data to an output stream. More... | |
ReadResult | read (std::istream &input, std::streamsize size) |
Read the block data from an input stream. More... | |
![]() | |
Block (uint64_t track_number, int16_t timecode, LacingType lacing=LACING_NONE) | |
Constructor. More... | |
virtual | ~Block ()=0 |
Desctructor. More... | |
virtual void | push_back (value_type const &value)=0 |
Add a frame to this block. More... | |
virtual void | swap (Block &other) |
Swaps the contents of this block with another. More... | |
Protected Member Functions | |
void | validate () const |
Checks that the block is in a good condition to write. More... | |
void | reset () |
Resets this block to an empty state. More... | |
std::streamsize | read_ebml_laced_frames (std::istream &input, std::streamsize size) |
Reads frames laced using EBML lacing, including the lace header. More... | |
std::streamsize | read_fixed_frames (std::istream &input, std::streamsize size, unsigned int count) |
Reads frames laced using fixed lacing. More... | |
Protected Attributes | |
uint64_t | track_num_ |
int16_t | timecode_ |
bool | invisible_ |
LacingType | lacing_ |
std::vector< value_type > | frames_ |
Friends | |
bool | operator== (BlockImpl const &lhs, BlockImpl const &rhs) |
Equality operator. More... | |
Common block functionality implementation.
This class provides an implementation of the Block interface functionality.
Definition at line 57 of file block_impl.h.
typedef std::pair<std::streamsize, uint8_t> tawara::BlockImpl::ReadResult |
The return result of a read.
The first contains the number of bytes read. The second contains any extra flags that were stored in the block.
Definition at line 191 of file block_impl.h.
typedef boost::shared_ptr<std::vector<char> > tawara::BlockImpl::value_type |
The stored type.
Definition at line 210 of file block_impl.h.
tawara::BlockImpl::BlockImpl | ( | uint64_t | track_number, |
int16_t | timecode, | ||
LacingType | lacing = LACING_NONE |
||
) |
Constructor.
|
inlinevirtual |
Get the frame at the given position, with bounds checking.
Implements tawara::Block.
Definition at line 92 of file block_impl.h.
|
inlinevirtual |
Get the frame at the given position, with bounds checking.
Implements tawara::Block.
Definition at line 97 of file block_impl.h.
|
inlinevirtual |
Get an iterator to the first frame.
Implements tawara::Block.
Definition at line 112 of file block_impl.h.
|
inlinevirtual |
Get an iterator to the first frame.
Implements tawara::Block.
Definition at line 114 of file block_impl.h.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Check if there are no frames.
Implements tawara::Block.
Definition at line 133 of file block_impl.h.
|
inlinevirtual |
Get an iterator to the position past the last frame.
Implements tawara::Block.
Definition at line 116 of file block_impl.h.
|
inlinevirtual |
Get an iterator to the position past the last frame.
Implements tawara::Block.
Definition at line 118 of file block_impl.h.
|
inlinevirtual |
Erase the frame at the specified iterator.
Implements tawara::Block.
Definition at line 143 of file block_impl.h.
|
inlinevirtual |
|
inlinevirtual |
Set if this block is invisible.
Implements tawara::Block.
Definition at line 79 of file block_impl.h.
|
inlinevirtual |
|
inlinevirtual |
|
virtual |
Get the maximum number of frames.
Implements tawara::Block.
Replace the content of this block with another block.
|
inlinevirtual |
Get a reference to a frame.
No bounds checking is performed.
Implements tawara::Block.
Definition at line 103 of file block_impl.h.
|
inlinevirtual |
Get a reference to a frame.
No bounds checking is performed.
Implements tawara::Block.
Definition at line 108 of file block_impl.h.
void tawara::BlockImpl::push_back | ( | value_type const & | value | ) |
Add a frame to this block.
|
inlinevirtual |
Get a reverse iterator to the last frame.
Implements tawara::Block.
Definition at line 120 of file block_impl.h.
|
inlinevirtual |
Get a reverse iterator to the last frame.
Implements tawara::Block.
Definition at line 122 of file block_impl.h.
ReadResult tawara::BlockImpl::read | ( | std::istream & | input, |
std::streamsize | size | ||
) |
Read the block data from an input stream.
This function reads a block header and all stored frames.
[in] | input | The input byte stream to read from. |
[in] | size | The number of bytes used by the block. |
ReadError | if an error occurs reading data. |
BadBlockSize | if the block size is too small or too big. |
|
protected |
Reads frames laced using EBML lacing, including the lace header.
[in] | input | The input byte stream to read from. |
[in] | size | The number of bytes available. |
ReadError | if an error occurs reading data. |
BadElementSize | if the block size is too small or too big. |
|
protected |
Reads frames laced using fixed lacing.
The number of frames to read is specified. The value of size must be evenly dividable by this count with no remainder (i.e. every frame must be the same size).
[in] | input | The input byte stream to read from. |
[in] | size | The number of bytes available. |
[in] | count | The number of frames to read. |
ReadError | if an error occurs reading data. |
BadLacedFrameSize | if the block size is too small or too big. |
|
inlinevirtual |
Get a reverse iterator to the position before the first frame.
Implements tawara::Block.
Definition at line 126 of file block_impl.h.
|
inlinevirtual |
Get a reverse iterator to the position before the first frame.
Implements tawara::Block.
Definition at line 130 of file block_impl.h.
|
protected |
Resets this block to an empty state.
|
virtual |
Resizes the frames storage.
Implements tawara::Block.
std::streamsize tawara::BlockImpl::size | ( | ) | const |
Gets the size of the block data.
This includes the block header bytes, the frame data, and the lacing header (if present).
void tawara::BlockImpl::swap | ( | BlockImpl & | other | ) |
Swaps the contents of this block with another.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
protected |
Checks that the block is in a good condition to write.
std::streamsize tawara::BlockImpl::write | ( | std::ostream & | output, |
uint8_t | extra_flags | ||
) |
Write the block data to an output stream.
This function performs the write of the block header and all stored frames.
Before performing the write, the block is validated. This may cause exceptions to be raised if the block is in an invalid state.
[in] | output | The output byte stream to write data to. |
[in] | extra_flags | Extra flags to add to the flags contained in this block. |
EmptyFrame | if an empty frame is found. |
BadLacedFrameSize | if fixed lacing is used and all frames are not the same size. |
WriteError | if an error occurs writing data. |
|
protected |
Definition at line 217 of file block_impl.h.
|
protected |
Definition at line 215 of file block_impl.h.
|
protected |
Definition at line 216 of file block_impl.h.
|
protected |
Definition at line 214 of file block_impl.h.
|
protected |
Definition at line 213 of file block_impl.h.