Tide 0.1.0
|
Common block functionality implementation. More...
#include <tide/block_impl.h>
Public Types | |
typedef std::pair < std::streamsize, uint8_t > | ReadResult |
The return result of a read. | |
typedef boost::shared_ptr < std::vector< char > > | value_type |
The stored type. | |
Public Member Functions | |
BlockImpl (uint64_t track_number, int16_t timecode, LacingType lacing=LACING_NONE) | |
Constructor. | |
uint64_t | track_number () const |
The block's track number. | |
void | track_number (uint64_t track_number) |
Set the block's track number. | |
int16_t | timecode () const |
The timecode of this block. | |
void | timecode (int16_t timecode) |
Set the block's timecode. | |
bool | invisible () const |
If this block is invisible. | |
void | invisible (bool invisible) |
Set if this block is invisible. | |
LacingType | lacing () const |
Get the lacing type in use. | |
void | lacing (LacingType lacing) |
Set the lacing type in use. | |
BlockImpl & | operator= (BlockImpl const &other) |
Replace the content of this block with another block. | |
value_type & | at (size_type pos) |
Get the frame at the given position, with bounds checking. | |
value_type const & | at (size_type pos) const |
Get the frame at the given position, with bounds checking. | |
value_type & | operator[] (size_type pos) |
Get a reference to a frame. | |
value_type const & | operator[] (size_type pos) const |
Get a reference to a frame. | |
iterator | begin () |
Get an iterator to the first frame. | |
const_iterator | begin () const |
Get an iterator to the first frame. | |
iterator | end () |
Get an iterator to the position past the last frame. | |
const_iterator | end () const |
Get an iterator to the position past the last frame. | |
reverse_iterator | rbegin () |
Get a reverse iterator to the last frame. | |
const_reverse_iterator | rbegin () const |
Get a reverse iterator to the last frame. | |
reverse_iterator | rend () |
Get a reverse iterator to the position before the first frame. | |
const_reverse_iterator | rend () const |
Get a reverse iterator to the position before the first frame. | |
bool | empty () const |
Check if there are no frames. | |
size_type | count () const |
Get the number of frames. | |
size_type | max_count () const |
Get the maximum number of frames. | |
void | clear () |
Remove all frames. | |
void | erase (iterator position) |
Erase the frame at the specified iterator. | |
void | erase (iterator first, iterator last) |
Erase a range of frames. | |
void | push_back (value_type const &value) |
Add a frame to this block. | |
void | resize (size_type count) |
Resizes the frames storage. | |
void | swap (BlockImpl &other) |
Swaps the contents of this block with another. | |
std::streamsize | size () const |
Gets the size of the block data. | |
std::streamsize | write (std::ostream &output, uint8_t extra_flags) |
Write the block data to an output stream. | |
ReadResult | read (std::istream &input, std::streamsize size) |
Read the block data from an input stream. | |
Protected Member Functions | |
void | validate () const |
Checks that the block is in a good condition to write. | |
void | reset () |
Resets this block to an empty state. | |
std::streamsize | read_ebml_laced_frames (std::istream &input, std::streamsize size) |
Reads frames laced using EBML lacing, including the lace header. | |
std::streamsize | read_fixed_frames (std::istream &input, std::streamsize size, unsigned int count) |
Reads frames laced using fixed lacing. | |
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. |
Common block functionality implementation.
This class provides an implementation of the Block interface functionality.
Definition at line 46 of file block_impl.h.
typedef std::pair<std::streamsize, uint8_t> tide::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 180 of file block_impl.h.
typedef boost::shared_ptr<std::vector<char> > tide::BlockImpl::value_type |
tide::BlockImpl::BlockImpl | ( | uint64_t | track_number, |
int16_t | timecode, | ||
LacingType | lacing = LACING_NONE |
||
) |
Constructor.
value_type& tide::BlockImpl::at | ( | size_type | pos | ) | [inline, virtual] |
Get the frame at the given position, with bounds checking.
Implements tide::Block.
Definition at line 81 of file block_impl.h.
value_type const& tide::BlockImpl::at | ( | size_type | pos | ) | const [inline, virtual] |
Get the frame at the given position, with bounds checking.
Implements tide::Block.
Definition at line 86 of file block_impl.h.
iterator tide::BlockImpl::begin | ( | ) | [inline, virtual] |
Get an iterator to the first frame.
Implements tide::Block.
Definition at line 101 of file block_impl.h.
const_iterator tide::BlockImpl::begin | ( | ) | const [inline, virtual] |
Get an iterator to the first frame.
Implements tide::Block.
Definition at line 103 of file block_impl.h.
void tide::BlockImpl::clear | ( | ) | [inline, virtual] |
size_type tide::BlockImpl::count | ( | ) | const [inline, virtual] |
bool tide::BlockImpl::empty | ( | ) | const [inline, virtual] |
iterator tide::BlockImpl::end | ( | ) | [inline, virtual] |
Get an iterator to the position past the last frame.
Implements tide::Block.
Definition at line 105 of file block_impl.h.
const_iterator tide::BlockImpl::end | ( | ) | const [inline, virtual] |
Get an iterator to the position past the last frame.
Implements tide::Block.
Definition at line 107 of file block_impl.h.
void tide::BlockImpl::erase | ( | iterator | position | ) | [inline, virtual] |
Erase the frame at the specified iterator.
Implements tide::Block.
Definition at line 132 of file block_impl.h.
bool tide::BlockImpl::invisible | ( | ) | const [inline, virtual] |
void tide::BlockImpl::invisible | ( | bool | invisible | ) | [inline, virtual] |
void tide::BlockImpl::lacing | ( | LacingType | lacing | ) | [inline, virtual] |
LacingType tide::BlockImpl::lacing | ( | ) | const [inline, virtual] |
size_type tide::BlockImpl::max_count | ( | ) | const [virtual] |
Get the maximum number of frames.
Implements tide::Block.
Replace the content of this block with another block.
value_type& tide::BlockImpl::operator[] | ( | size_type | pos | ) | [inline, virtual] |
Get a reference to a frame.
No bounds checking is performed.
Implements tide::Block.
Definition at line 92 of file block_impl.h.
value_type const& tide::BlockImpl::operator[] | ( | size_type | pos | ) | const [inline, virtual] |
Get a reference to a frame.
No bounds checking is performed.
Implements tide::Block.
Definition at line 97 of file block_impl.h.
void tide::BlockImpl::push_back | ( | value_type const & | value | ) | [virtual] |
Add a frame to this block.
Implements tide::Block.
reverse_iterator tide::BlockImpl::rbegin | ( | ) | [inline, virtual] |
Get a reverse iterator to the last frame.
Implements tide::Block.
Definition at line 109 of file block_impl.h.
const_reverse_iterator tide::BlockImpl::rbegin | ( | ) | const [inline, virtual] |
Get a reverse iterator to the last frame.
Implements tide::Block.
Definition at line 111 of file block_impl.h.
ReadResult tide::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. |
std::streamsize tide::BlockImpl::read_ebml_laced_frames | ( | std::istream & | input, |
std::streamsize | size | ||
) | [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. |
std::streamsize tide::BlockImpl::read_fixed_frames | ( | std::istream & | input, |
std::streamsize | size, | ||
unsigned int | count | ||
) | [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. |
reverse_iterator tide::BlockImpl::rend | ( | ) | [inline, virtual] |
Get a reverse iterator to the position before the first frame.
Implements tide::Block.
Definition at line 115 of file block_impl.h.
const_reverse_iterator tide::BlockImpl::rend | ( | ) | const [inline, virtual] |
Get a reverse iterator to the position before the first frame.
Implements tide::Block.
Definition at line 119 of file block_impl.h.
void tide::BlockImpl::reset | ( | ) | [protected] |
Resets this block to an empty state.
void tide::BlockImpl::resize | ( | size_type | count | ) | [virtual] |
Resizes the frames storage.
Implements tide::Block.
std::streamsize tide::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 tide::BlockImpl::swap | ( | BlockImpl & | other | ) |
Swaps the contents of this block with another.
int16_t tide::BlockImpl::timecode | ( | ) | const [inline, virtual] |
void tide::BlockImpl::timecode | ( | int16_t | timecode | ) | [inline, virtual] |
void tide::BlockImpl::track_number | ( | uint64_t | track_number | ) | [inline, virtual] |
uint64_t tide::BlockImpl::track_number | ( | ) | const [inline, virtual] |
void tide::BlockImpl::validate | ( | ) | const [protected] |
Checks that the block is in a good condition to write.
std::streamsize tide::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. |
std::vector<value_type> tide::BlockImpl::frames_ [protected] |
Definition at line 206 of file block_impl.h.
bool tide::BlockImpl::invisible_ [protected] |
Definition at line 204 of file block_impl.h.
LacingType tide::BlockImpl::lacing_ [protected] |
Definition at line 205 of file block_impl.h.
int16_t tide::BlockImpl::timecode_ [protected] |
Definition at line 203 of file block_impl.h.
uint64_t tide::BlockImpl::track_num_ [protected] |
Definition at line 202 of file block_impl.h.