TagLib API Documentation

TagLib::ByteVector Class Reference

A byte vector. More...

#include <tbytevector.h>

List of all members.

Public Member Functions

 ByteVector ()
 ByteVector (uint size, char value=0)
 ByteVector (const ByteVector &v)
 ByteVector (char c)
 ByteVector (const char *data, uint length)
 ByteVector (const char *data)
virtual ~ByteVector ()
void setData (const char *data, uint length)
void setData (const char *data)
char * data ()
const char * data () const
ByteVector mid (uint index, uint length=0xffffffff) const
char at (uint index) const
int find (const ByteVector &pattern, uint offset=0, int byteAlign=1) const
int rfind (const ByteVector &pattern, uint offset=0, int byteAlign=1) const
bool containsAt (const ByteVector &pattern, uint offset, uint patternOffset=0, uint patternLength=0xffffffff) const
bool startsWith (const ByteVector &pattern) const
bool endsWith (const ByteVector &pattern) const
int endsWithPartialMatch (const ByteVector &pattern) const
void append (const ByteVector &v)
void clear ()
uint size () const
ByteVectorresize (uint size, char padding=0)
Iterator begin ()
ConstIterator begin () const
Iterator end ()
ConstIterator end () const
bool isNull () const
bool isEmpty () const
uint checksum () const
uint toUInt (bool mostSignificantByteFirst=true) const
long long toLongLong (bool mostSignificantByteFirst=true) const
const char & operator[] (int index) const
char & operator[] (int index)
bool operator== (const ByteVector &v) const
bool operator!= (const ByteVector &v) const
bool operator== (const char *s) const
bool operator!= (const char *s) const
bool operator< (const ByteVector &v) const
bool operator> (const ByteVector &v) const
ByteVector operator+ (const ByteVector &v) const
ByteVectoroperator= (const ByteVector &v)
ByteVectoroperator= (char c)
ByteVectoroperator= (const char *data)

Static Public Member Functions

ByteVector fromUInt (uint value, bool mostSignificantByteFirst=true)
ByteVector fromLongLong (long long value, bool mostSignificantByteFirst=true)
ByteVector fromCString (const char *s, uint length=0xffffffff)

Static Public Attributes

ByteVector null

Protected Member Functions

void detach ()

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &s, const TagLib::ByteVector &v)


Detailed Description

A byte vector.

This class provides a byte vector with some methods that are useful for tagging purposes. Many of the search functions are tailored to what is useful for finding tag related paterns in a data array.

Definition at line 39 of file tbytevector.h.


Constructor & Destructor Documentation

TagLib::ByteVector::ByteVector  ) 
 

Constructs an empty byte vector.

TagLib::ByteVector::ByteVector uint  size,
char  value = 0
 

Construct a vector of size size with all values set to value by default.

TagLib::ByteVector::ByteVector const ByteVector v  ) 
 

Contructs a byte vector that is a copy of v.

TagLib::ByteVector::ByteVector char  c  ) 
 

Contructs a byte vector that contains c.

TagLib::ByteVector::ByteVector const char *  data,
uint  length
 

Constructs a byte vector that copies data for up to length bytes.

TagLib::ByteVector::ByteVector const char *  data  ) 
 

Constructs a byte vector that copies data up to the first null byte. The behavior is undefined if data is not null terminated. This is particularly useful for constructing byte arrays from string constants.

virtual TagLib::ByteVector::~ByteVector  )  [virtual]
 

Destroys this ByteVector instance.


Member Function Documentation

void TagLib::ByteVector::setData const char *  data,
uint  length
 

Sets the data for the byte array using the first length bytes of data

void TagLib::ByteVector::setData const char *  data  ) 
 

Sets the data for the byte array copies data up to the first null byte. The behavior is undefined if data is not null terminated.

char* TagLib::ByteVector::data  ) 
 

Returns a pointer to the internal data structure.

Warning:
Care should be taken when modifying this data structure as it is easy to corrupt the ByteVector when doing so. Specifically, while the data may be changed, its length may not be.

const char* TagLib::ByteVector::data  )  const
 

Returns a pointer to the internal data structure which may not be modified.

ByteVector TagLib::ByteVector::mid uint  index,
uint  length = 0xffffffff
const
 

Returns a byte vector made up of the bytes starting at index and for length bytes. If length is not specified it will return the bytes from index to the end of the vector.

char TagLib::ByteVector::at uint  index  )  const
 

This essentially performs the same as operator[](), but instead of causing a runtime error if the index is out of bounds, it will return a null byte.

int TagLib::ByteVector::find const ByteVector pattern,
uint  offset = 0,
int  byteAlign = 1
const
 

Searches the ByteVector for pattern starting at offset and returns the offset. Returns -1 if the pattern was not found. If byteAlign is specified the pattern will only be matched if it starts on a byteDivisible by byteAlign.

int TagLib::ByteVector::rfind const ByteVector pattern,
uint  offset = 0,
int  byteAlign = 1
const
 

Searches the ByteVector for pattern starting from either the end of the vector or offset and returns the offset. Returns -1 if the pattern was not found. If byteAlign is specified the pattern will only be matched if it starts on a byteDivisible by byteAlign.

bool TagLib::ByteVector::containsAt const ByteVector pattern,
uint  offset,
uint  patternOffset = 0,
uint  patternLength = 0xffffffff
const
 

Checks to see if the vector contains the pattern starting at position offset. Optionally, if you only want to search for part of the pattern you can specify an offset within the pattern to start from. Also, you can specify to only check for the first patternLength bytes of pattern with the patternLength argument.

bool TagLib::ByteVector::startsWith const ByteVector pattern  )  const
 

Returns true if the vector starts with pattern.

bool TagLib::ByteVector::endsWith const ByteVector pattern  )  const
 

Returns true if the vector ends with pattern.

int TagLib::ByteVector::endsWithPartialMatch const ByteVector pattern  )  const
 

Checks for a partial match of pattern at the end of the vector. It returns the offset of the partial match within the vector, or -1 if the pattern is not found. This method is particularly useful when searching for patterns that start in one vector and end in another. When combined with startsWith() it can be used to find a pattern that overlaps two buffers.

Note:
This will not match the complete pattern at the end of the string; use endsWith() for that.

void TagLib::ByteVector::append const ByteVector v  ) 
 

Appends v to the end of the ByteVector.

void TagLib::ByteVector::clear  ) 
 

Clears the data.

uint TagLib::ByteVector::size  )  const
 

Returns the size of the array.

ByteVector& TagLib::ByteVector::resize uint  size,
char  padding = 0
 

Resize the vector to size. If the vector is currently less than size, pad the remaining spaces with padding. Returns a reference to the resized vector.

Iterator TagLib::ByteVector::begin  ) 
 

Returns an Iterator that points to the front of the vector.

ConstIterator TagLib::ByteVector::begin  )  const
 

Returns a ConstIterator that points to the front of the vector.

Iterator TagLib::ByteVector::end  ) 
 

Returns an Iterator that points to the back of the vector.

ConstIterator TagLib::ByteVector::end  )  const
 

Returns a ConstIterator that points to the back of the vector.

bool TagLib::ByteVector::isNull  )  const
 

Returns true if the vector is null.

Note:
A vector may be empty without being null.
See also:
isEmpty()

bool TagLib::ByteVector::isEmpty  )  const
 

Returns true if the ByteVector is empty.

See also:
size()

isNull()

uint TagLib::ByteVector::checksum  )  const
 

Returns a CRC checksum of the byte vector's data.

uint TagLib::ByteVector::toUInt bool  mostSignificantByteFirst = true  )  const
 

Converts the first 4 bytes of the vector to an unsigned integer.

If mostSignificantByteFirst is true this will operate left to right evaluating the integer. For example if mostSignificantByteFirst is true then $00 $00 $00 $01 == 0x00000001 == 1, if false, $01 00 00 00 == 0x01000000 == 1.

See also:
fromUInt()

long long TagLib::ByteVector::toLongLong bool  mostSignificantByteFirst = true  )  const
 

Converts the first 8 bytes of the vector to a (signed) long long.

If mostSignificantByteFirst is true this will operate left to right evaluating the integer. For example if mostSignificantByteFirst is true then $00 00 00 00 00 00 00 01 == 0x0000000000000001 == 1, if false, $01 00 00 00 00 00 00 00 == 0x0100000000000000 == 1.

See also:
fromUInt()

ByteVector TagLib::ByteVector::fromUInt uint  value,
bool  mostSignificantByteFirst = true
[static]
 

Creates a 4 byte ByteVector based on value. If mostSignificantByteFirst is true, then this will operate left to right in building the ByteVector. For example if mostSignificantByteFirst is true then $00 00 00 01 == 0x00000001 == 1, if false, $01 00 00 00 == 0x01000000 == 1.

See also:
toUInt()

ByteVector TagLib::ByteVector::fromLongLong long long  value,
bool  mostSignificantByteFirst = true
[static]
 

Creates a 8 byte ByteVector based on value. If mostSignificantByteFirst is true, then this will operate left to right in building the ByteVector. For example if mostSignificantByteFirst is true then $00 00 00 01 == 0x0000000000000001 == 1, if false, $01 00 00 00 00 00 00 00 == 0x0100000000000000 == 1.

See also:
toLongLong()

ByteVector TagLib::ByteVector::fromCString const char *  s,
uint  length = 0xffffffff
[static]
 

Returns a ByteVector based on the CString s.

const char& TagLib::ByteVector::operator[] int  index  )  const
 

Returns a const refernence to the byte at index.

char& TagLib::ByteVector::operator[] int  index  ) 
 

Returns a reference to the byte at index.

bool TagLib::ByteVector::operator== const ByteVector v  )  const
 

Returns true if this ByteVector and v are equal.

bool TagLib::ByteVector::operator!= const ByteVector v  )  const
 

Returns true if this ByteVector and v are not equal.

bool TagLib::ByteVector::operator== const char *  s  )  const
 

Returns true if this ByteVector and the null terminated C string s contain the same data.

bool TagLib::ByteVector::operator!= const char *  s  )  const
 

Returns true if this ByteVector and the null terminated C string s do not contain the same data.

bool TagLib::ByteVector::operator< const ByteVector v  )  const
 

Returns true if this ByteVector is less than v. The value of the vectors is determined by evaluating the character from left to right, and in the event one vector is a superset of the other, the size is used.

bool TagLib::ByteVector::operator> const ByteVector v  )  const
 

Returns true if this ByteVector is greater than v.

ByteVector TagLib::ByteVector::operator+ const ByteVector v  )  const
 

Returns a vector that is v appended to this vector.

ByteVector& TagLib::ByteVector::operator= const ByteVector v  ) 
 

Copies ByteVector v.

ByteVector& TagLib::ByteVector::operator= char  c  ) 
 

Copies ByteVector v.

ByteVector& TagLib::ByteVector::operator= const char *  data  ) 
 

Copies ByteVector v.

void TagLib::ByteVector::detach  )  [protected]
 


Friends And Related Function Documentation

std::ostream & operator<< std::ostream &  s,
const TagLib::ByteVector v
[related]
 

Streams the ByteVector v to the output stream s.


Member Data Documentation

ByteVector TagLib::ByteVector::null [static]
 

A static, empty ByteVector which is convenient and fast (since returning an empty or "null" value does not require instantiating a new ByteVector).

Definition at line 354 of file tbytevector.h.


The documentation for this class was generated from the following file:
KDE Logo
This file is part of the documentation for TagLib Version 1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Jan 22 05:44:22 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2003