Tide 0.1.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends

tide::BlockImpl Class Reference

Common block functionality implementation. More...

#include <tide/block_impl.h>

Inheritance diagram for tide::BlockImpl:
Inheritance graph
[legend]
Collaboration diagram for tide::BlockImpl:
Collaboration graph
[legend]

List of all members.

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.
BlockImploperator= (BlockImpl const &other)
 Replace the content of this block with another block.
value_typeat (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_typeoperator[] (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_typeframes_

Friends

bool operator== (BlockImpl const &lhs, BlockImpl const &rhs)
 Equality operator.

Detailed Description

Common block functionality implementation.

This class provides an implementation of the Block interface functionality.

Definition at line 46 of file block_impl.h.


Member Typedef Documentation

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

The stored type.

Reimplemented from tide::Block.

Definition at line 199 of file block_impl.h.


Constructor & Destructor Documentation

tide::BlockImpl::BlockImpl ( uint64_t  track_number,
int16_t  timecode,
LacingType  lacing = LACING_NONE 
)

Constructor.


Member Function Documentation

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]

Remove all frames.

Implements tide::Block.

Definition at line 129 of file block_impl.h.

size_type tide::BlockImpl::count ( ) const [inline, virtual]

Get the number of frames.

Implements tide::Block.

Definition at line 124 of file block_impl.h.

bool tide::BlockImpl::empty ( ) const [inline, virtual]

Check if there are no frames.

Implements tide::Block.

Definition at line 122 of file block_impl.h.

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.

void tide::BlockImpl::erase ( iterator  first,
iterator  last 
) [inline, virtual]

Erase a range of frames.

Implements tide::Block.

Definition at line 135 of file block_impl.h.

bool tide::BlockImpl::invisible ( ) const [inline, virtual]

If this block is invisible.

Implements tide::Block.

Definition at line 66 of file block_impl.h.

void tide::BlockImpl::invisible ( bool  invisible) [inline, virtual]

Set if this block is invisible.

Implements tide::Block.

Definition at line 68 of file block_impl.h.

void tide::BlockImpl::lacing ( LacingType  lacing) [inline, virtual]

Set the lacing type in use.

Implements tide::Block.

Definition at line 73 of file block_impl.h.

LacingType tide::BlockImpl::lacing ( ) const [inline, virtual]

Get the lacing type in use.

Implements tide::Block.

Definition at line 71 of file block_impl.h.

size_type tide::BlockImpl::max_count ( ) const [virtual]

Get the maximum number of frames.

Implements tide::Block.

BlockImpl& tide::BlockImpl::operator= ( BlockImpl const &  other)

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.

Parameters:
[in]inputThe input byte stream to read from.
[in]sizeThe number of bytes used by the block.
Returns:
The number of bytes read and any extra flags that were present in the block.
Exceptions:
ReadErrorif an error occurs reading data.
BadBlockSizeif 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.

Parameters:
[in]inputThe input byte stream to read from.
[in]sizeThe number of bytes available.
Returns:
The number of bytes read.
Exceptions:
ReadErrorif an error occurs reading data.
BadElementSizeif 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).

Parameters:
[in]inputThe input byte stream to read from.
[in]sizeThe number of bytes available.
[in]countThe number of frames to read.
Returns:
The number of bytes read.
Exceptions:
ReadErrorif an error occurs reading data.
BadLacedFrameSizeif 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]

The timecode of this block.

Implements tide::Block.

Definition at line 61 of file block_impl.h.

void tide::BlockImpl::timecode ( int16_t  timecode) [inline, virtual]

Set the block's timecode.

Implements tide::Block.

Definition at line 63 of file block_impl.h.

void tide::BlockImpl::track_number ( uint64_t  track_number) [inline, virtual]

Set the block's track number.

Implements tide::Block.

Definition at line 57 of file block_impl.h.

uint64_t tide::BlockImpl::track_number ( ) const [inline, virtual]

The block's track number.

Implements tide::Block.

Definition at line 55 of file block_impl.h.

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.

Parameters:
[in]outputThe output byte stream to write data to.
[in]extra_flagsExtra flags to add to the flags contained in this block.
Returns:
The number of bytes written.
Exceptions:
EmptyFrameif an empty frame is found.
BadLacedFrameSizeif fixed lacing is used and all frames are not the same size.
WriteErrorif an error occurs writing data.

Friends And Related Function Documentation

bool operator== ( BlockImpl const &  lhs,
BlockImpl const &  rhs 
) [friend]

Equality operator.


Member Data Documentation

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.

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.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines