![]() |
Miam-Player
0.8.0
A nice music player
|
A byte vector. More...
#include <tbytevector.h>
Public Types | |
typedef std::vector< char >::iterator | Iterator |
typedef std::vector< char >::const_iterator | ConstIterator |
typedef std::vector< char >::reverse_iterator | ReverseIterator |
typedef std::vector< char >::const_reverse_iterator | ConstReverseIterator |
Public Member Functions | |
ByteVector () | |
Constructs an empty byte vector. More... | |
ByteVector (unsigned int size, char value=0) | |
Construct a vector of size size with all values set to value by default. More... | |
ByteVector (const ByteVector &v) | |
Constructs a byte vector that is a copy of v. More... | |
ByteVector (const ByteVector &v, unsigned int offset, unsigned int length) | |
Constructs a byte vector that is a copy of v. More... | |
ByteVector (char c) | |
Constructs a byte vector that contains c. More... | |
ByteVector (const char *data, unsigned int length) | |
Constructs a byte vector that copies data for up to length bytes. More... | |
ByteVector (const char *data) | |
Constructs a byte vector that copies data up to the first null byte. More... | |
virtual | ~ByteVector () |
Destroys this ByteVector instance. More... | |
ByteVector & | setData (const char *data, unsigned int length) |
Sets the data for the byte array using the first length bytes of data. More... | |
ByteVector & | setData (const char *data) |
Sets the data for the byte array copies data up to the first null byte. More... | |
char * | data () |
Returns a pointer to the internal data structure. More... | |
const char * | data () const |
Returns a pointer to the internal data structure which may not be modified. More... | |
ByteVector | mid (unsigned int index, unsigned int length=0xffffffff) const |
Returns a byte vector made up of the bytes starting at index and for length bytes. More... | |
char | at (unsigned int 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. More... | |
int | find (const ByteVector &pattern, unsigned int offset=0, int byteAlign=1) const |
Searches the ByteVector for pattern starting at offset and returns the offset. More... | |
int | find (char c, unsigned int offset=0, int byteAlign=1) const |
Searches the char for c starting at offset and returns the offset. More... | |
int | rfind (const ByteVector &pattern, unsigned int 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. More... | |
bool | containsAt (const ByteVector &pattern, unsigned int offset, unsigned int patternOffset=0, unsigned int patternLength=0xffffffff) const |
Checks to see if the vector contains the pattern starting at position offset. More... | |
bool | startsWith (const ByteVector &pattern) const |
Returns true if the vector starts with pattern. More... | |
bool | endsWith (const ByteVector &pattern) const |
Returns true if the vector ends with pattern. More... | |
ByteVector & | replace (char oldByte, char newByte) |
Replaces oldByte with newByte and returns a reference to the ByteVector after the operation. More... | |
ByteVector & | replace (const ByteVector &pattern, const ByteVector &with) |
Replaces pattern with with and returns a reference to the ByteVector after the operation. More... | |
int | endsWithPartialMatch (const ByteVector &pattern) const |
Checks for a partial match of pattern at the end of the vector. More... | |
ByteVector & | append (const ByteVector &v) |
Appends v to the end of the ByteVector. More... | |
ByteVector & | append (char c) |
Appends c to the end of the ByteVector. More... | |
ByteVector & | clear () |
Clears the data. More... | |
unsigned int | size () const |
Returns the size of the array. More... | |
ByteVector & | resize (unsigned int size, char padding=0) |
Resize the vector to size. More... | |
Iterator | begin () |
Returns an Iterator that points to the front of the vector. More... | |
ConstIterator | begin () const |
Returns a ConstIterator that points to the front of the vector. More... | |
Iterator | end () |
Returns an Iterator that points to the back of the vector. More... | |
ConstIterator | end () const |
Returns a ConstIterator that points to the back of the vector. More... | |
ReverseIterator | rbegin () |
Returns a ReverseIterator that points to the front of the vector. More... | |
ConstReverseIterator | rbegin () const |
Returns a ConstReverseIterator that points to the front of the vector. More... | |
ReverseIterator | rend () |
Returns a ReverseIterator that points to the back of the vector. More... | |
ConstReverseIterator | rend () const |
Returns a ConstReverseIterator that points to the back of the vector. More... | |
bool | isNull () const |
Returns true if the vector is null. More... | |
bool | isEmpty () const |
Returns true if the ByteVector is empty. More... | |
unsigned int | checksum () const |
Returns a CRC checksum of the byte vector's data. More... | |
unsigned int | toUInt (bool mostSignificantByteFirst=true) const |
Converts the first 4 bytes of the vector to an unsigned integer. More... | |
unsigned int | toUInt (unsigned int offset, bool mostSignificantByteFirst=true) const |
Converts the 4 bytes at offset of the vector to an unsigned integer. More... | |
unsigned int | toUInt (unsigned int offset, unsigned int length, bool mostSignificantByteFirst=true) const |
Converts the length bytes at offset of the vector to an unsigned integer. More... | |
short | toShort (bool mostSignificantByteFirst=true) const |
Converts the first 2 bytes of the vector to a (signed) short. More... | |
short | toShort (unsigned int offset, bool mostSignificantByteFirst=true) const |
Converts the 2 bytes at offset of the vector to a (signed) short. More... | |
unsigned short | toUShort (bool mostSignificantByteFirst=true) const |
Converts the first 2 bytes of the vector to a unsigned short. More... | |
unsigned short | toUShort (unsigned int offset, bool mostSignificantByteFirst=true) const |
Converts the 2 bytes at offset of the vector to a unsigned short. More... | |
long long | toLongLong (bool mostSignificantByteFirst=true) const |
Converts the first 8 bytes of the vector to a (signed) long long. More... | |
long long | toLongLong (unsigned int offset, bool mostSignificantByteFirst=true) const |
Converts the 8 bytes at offset of the vector to a (signed) long long. More... | |
float | toFloat32LE (size_t offset) const |
float | toFloat32BE (size_t offset) const |
double | toFloat64LE (size_t offset) const |
double | toFloat64BE (size_t offset) const |
long double | toFloat80LE (size_t offset) const |
long double | toFloat80BE (size_t offset) const |
const char & | operator[] (int index) const |
Returns a const reference to the byte at index. More... | |
char & | operator[] (int index) |
Returns a reference to the byte at index. More... | |
bool | operator== (const ByteVector &v) const |
Returns true if this ByteVector and v are equal. More... | |
bool | operator!= (const ByteVector &v) const |
Returns true if this ByteVector and v are not equal. More... | |
bool | operator== (const char *s) const |
Returns true if this ByteVector and the null terminated C string s contain the same data. More... | |
bool | operator!= (const char *s) const |
Returns true if this ByteVector and the null terminated C string s do not contain the same data. More... | |
bool | operator< (const ByteVector &v) const |
Returns true if this ByteVector is less than v. More... | |
bool | operator> (const ByteVector &v) const |
Returns true if this ByteVector is greater than v. More... | |
ByteVector | operator+ (const ByteVector &v) const |
Returns a vector that is v appended to this vector. More... | |
ByteVector & | operator= (const ByteVector &v) |
Copies ByteVector v. More... | |
ByteVector & | operator= (char c) |
Copies a byte c. More... | |
ByteVector & | operator= (const char *data) |
Copies data up to the first null byte. More... | |
void | swap (ByteVector &v) |
Exchanges the content of the ByteVector by the content of v. More... | |
ByteVector | toHex () const |
Returns a hex-encoded copy of the byte vector. More... | |
ByteVector | toBase64 () const |
Returns a base64 encoded copy of the byte vector. More... | |
Static Public Member Functions | |
static ByteVector | fromUInt (unsigned int value, bool mostSignificantByteFirst=true) |
Creates a 4 byte ByteVector based on value. More... | |
static ByteVector | fromShort (short value, bool mostSignificantByteFirst=true) |
Creates a 2 byte ByteVector based on value. More... | |
static ByteVector | fromLongLong (long long value, bool mostSignificantByteFirst=true) |
Creates a 8 byte ByteVector based on value. More... | |
static ByteVector | fromFloat32LE (float value) |
Creates a 4 byte ByteVector based on value as an IEEE754 32-bit little-endian floating point number. More... | |
static ByteVector | fromFloat32BE (float value) |
Creates a 4 byte ByteVector based on value as an IEEE754 32-bit big-endian floating point number. More... | |
static ByteVector | fromFloat64LE (double value) |
Creates a 8 byte ByteVector based on value as an IEEE754 64-bit little-endian floating point number. More... | |
static ByteVector | fromFloat64BE (double value) |
Creates a 8 byte ByteVector based on value as an IEEE754 64-bit big-endian floating point number. More... | |
static ByteVector | fromCString (const char *s, unsigned int length=0xffffffff) |
Returns a ByteVector based on the CString s. More... | |
static ByteVector | fromBase64 (const ByteVector &) |
Decodes the base64 encoded byte vector. More... | |
Static Public Attributes | |
static ByteVector | null |
A static, empty ByteVector which is convenient and fast (since returning an empty or "null" value does not require instantiating a new ByteVector). More... | |
Protected Member Functions | |
void | detach () |
Related Functions | |
(Note that these are not member functions.) | |
TAGLIB_EXPORT std::ostream & | operator<< (std::ostream &s, const TagLib::ByteVector &v) |
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 patterns in a data array.
typedef std::vector<char>::const_iterator TagLib::ByteVector::ConstIterator |
typedef std::vector<char>::const_reverse_iterator TagLib::ByteVector::ConstReverseIterator |
typedef std::vector<char>::iterator TagLib::ByteVector::Iterator |
typedef std::vector<char>::reverse_iterator TagLib::ByteVector::ReverseIterator |
TagLib::ByteVector::ByteVector | ( | ) |
Constructs an empty byte vector.
TagLib::ByteVector::ByteVector | ( | unsigned int | size, |
char | value = 0 |
||
) |
Construct a vector of size size with all values set to value by default.
TagLib::ByteVector::ByteVector | ( | const ByteVector & | v | ) |
Constructs a byte vector that is a copy of v.
TagLib::ByteVector::ByteVector | ( | const ByteVector & | v, |
unsigned int | offset, | ||
unsigned int | length | ||
) |
Constructs a byte vector that is a copy of v.
TagLib::ByteVector::ByteVector | ( | char | c | ) |
Constructs a byte vector that contains c.
TagLib::ByteVector::ByteVector | ( | const char * | data, |
unsigned int | 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.
This is particularly useful for constructing byte arrays from string constants.
|
virtual |
Destroys this ByteVector instance.
ByteVector& TagLib::ByteVector::append | ( | const ByteVector & | v | ) |
Appends v to the end of the ByteVector.
ByteVector& TagLib::ByteVector::append | ( | char | c | ) |
Appends c to the end of the ByteVector.
char TagLib::ByteVector::at | ( | unsigned int | 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.
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.
unsigned int TagLib::ByteVector::checksum | ( | ) | const |
Returns a CRC checksum of the byte vector's data.
ByteVector& TagLib::ByteVector::clear | ( | ) |
Clears the data.
bool TagLib::ByteVector::containsAt | ( | const ByteVector & | pattern, |
unsigned int | offset, | ||
unsigned int | patternOffset = 0 , |
||
unsigned int | 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.
char* TagLib::ByteVector::data | ( | ) |
Returns a pointer to the internal data structure.
const char* TagLib::ByteVector::data | ( | ) | const |
Returns a pointer to the internal data structure which may not be modified.
|
protected |
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::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.
int TagLib::ByteVector::find | ( | const ByteVector & | pattern, |
unsigned int | 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 byte divisible by byteAlign (starting from offset).
int TagLib::ByteVector::find | ( | char | c, |
unsigned int | offset = 0 , |
||
int | byteAlign = 1 |
||
) | const |
Searches the char for c 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 byte divisible by byteAlign (starting from offset).
|
static |
Decodes the base64 encoded byte vector.
|
static |
Returns a ByteVector based on the CString s.
|
static |
Creates a 4 byte ByteVector based on value as an IEEE754 32-bit big-endian floating point number.
|
static |
Creates a 4 byte ByteVector based on value as an IEEE754 32-bit little-endian floating point number.
|
static |
Creates a 8 byte ByteVector based on value as an IEEE754 64-bit big-endian floating point number.
|
static |
Creates a 8 byte ByteVector based on value as an IEEE754 64-bit little-endian floating point number.
|
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.
|
static |
Creates a 2 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 01 == 0x0001 == 1, if false, $01 00 == 0x0100 == 1.
|
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.
bool TagLib::ByteVector::isEmpty | ( | ) | const |
Returns true if the ByteVector is empty.
bool TagLib::ByteVector::isNull | ( | ) | const |
Returns true if the vector is null.
ByteVector TagLib::ByteVector::mid | ( | unsigned int | index, |
unsigned int | 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.
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 do not contain the same data.
ByteVector TagLib::ByteVector::operator+ | ( | const ByteVector & | v | ) | const |
Returns a vector that is v appended to this vector.
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.
ByteVector& TagLib::ByteVector::operator= | ( | const ByteVector & | v | ) |
Copies ByteVector v.
ByteVector& TagLib::ByteVector::operator= | ( | char | c | ) |
Copies a byte c.
ByteVector& TagLib::ByteVector::operator= | ( | const char * | data | ) |
Copies data up to the first null byte.
bool TagLib::ByteVector::operator== | ( | const ByteVector & | v | ) | const |
Returns true if this ByteVector and v are 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 ByteVector & | v | ) | const |
Returns true if this ByteVector is greater than v.
const char& TagLib::ByteVector::operator[] | ( | int | index | ) | const |
Returns a const reference to the byte at index.
char& TagLib::ByteVector::operator[] | ( | int | index | ) |
Returns a reference to the byte at index.
ReverseIterator TagLib::ByteVector::rbegin | ( | ) |
Returns a ReverseIterator that points to the front of the vector.
ConstReverseIterator TagLib::ByteVector::rbegin | ( | ) | const |
Returns a ConstReverseIterator that points to the front of the vector.
ReverseIterator TagLib::ByteVector::rend | ( | ) |
Returns a ReverseIterator that points to the back of the vector.
ConstReverseIterator TagLib::ByteVector::rend | ( | ) | const |
Returns a ConstReverseIterator that points to the back of the vector.
ByteVector& TagLib::ByteVector::replace | ( | char | oldByte, |
char | newByte | ||
) |
Replaces oldByte with newByte and returns a reference to the ByteVector after the operation.
This does modify the vector.
ByteVector& TagLib::ByteVector::replace | ( | const ByteVector & | pattern, |
const ByteVector & | with | ||
) |
Replaces pattern with with and returns a reference to the ByteVector after the operation.
This does modify the vector.
ByteVector& TagLib::ByteVector::resize | ( | unsigned int | 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.
int TagLib::ByteVector::rfind | ( | const ByteVector & | pattern, |
unsigned int | 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 byte divisible by byteAlign (starting from offset).
ByteVector& TagLib::ByteVector::setData | ( | const char * | data, |
unsigned int | length | ||
) |
Sets the data for the byte array using the first length bytes of data.
ByteVector& 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.
unsigned int TagLib::ByteVector::size | ( | ) | const |
Returns the size of the array.
bool TagLib::ByteVector::startsWith | ( | const ByteVector & | pattern | ) | const |
Returns true if the vector starts with pattern.
void TagLib::ByteVector::swap | ( | ByteVector & | v | ) |
Exchanges the content of the ByteVector by the content of v.
ByteVector TagLib::ByteVector::toBase64 | ( | ) | const |
Returns a base64 encoded copy of the byte vector.
float TagLib::ByteVector::toFloat32BE | ( | size_t | offset | ) | const |
float TagLib::ByteVector::toFloat32LE | ( | size_t | offset | ) | const |
double TagLib::ByteVector::toFloat64BE | ( | size_t | offset | ) | const |
double TagLib::ByteVector::toFloat64LE | ( | size_t | offset | ) | const |
long double TagLib::ByteVector::toFloat80BE | ( | size_t | offset | ) | const |
long double TagLib::ByteVector::toFloat80LE | ( | size_t | offset | ) | const |
ByteVector TagLib::ByteVector::toHex | ( | ) | const |
Returns a hex-encoded copy of the byte vector.
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.
long long TagLib::ByteVector::toLongLong | ( | unsigned int | offset, |
bool | mostSignificantByteFirst = true |
||
) | const |
Converts the 8 bytes at offset 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.
short TagLib::ByteVector::toShort | ( | bool | mostSignificantByteFirst = true | ) | const |
Converts the first 2 bytes of the vector to a (signed) short.
If mostSignificantByteFirst is true this will operate left to right evaluating the integer. For example if mostSignificantByteFirst is true then $00 $01 == 0x0001 == 1, if false, $01 00 == 0x01000000 == 1.
short TagLib::ByteVector::toShort | ( | unsigned int | offset, |
bool | mostSignificantByteFirst = true |
||
) | const |
Converts the 2 bytes at offset of the vector to a (signed) short.
If mostSignificantByteFirst is true this will operate left to right evaluating the integer. For example if mostSignificantByteFirst is true then $00 $01 == 0x0001 == 1, if false, $01 00 == 0x01000000 == 1.
unsigned int 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.
unsigned int TagLib::ByteVector::toUInt | ( | unsigned int | offset, |
bool | mostSignificantByteFirst = true |
||
) | const |
Converts the 4 bytes at offset 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.
unsigned int TagLib::ByteVector::toUInt | ( | unsigned int | offset, |
unsigned int | length, | ||
bool | mostSignificantByteFirst = true |
||
) | const |
Converts the length bytes at offset of the vector to an unsigned integer.
If length is larger than 4, the excess is ignored.
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.
unsigned short TagLib::ByteVector::toUShort | ( | bool | mostSignificantByteFirst = true | ) | const |
Converts the first 2 bytes of the vector to a unsigned short.
If mostSignificantByteFirst is true this will operate left to right evaluating the integer. For example if mostSignificantByteFirst is true then $00 $01 == 0x0001 == 1, if false, $01 00 == 0x01000000 == 1.
unsigned short TagLib::ByteVector::toUShort | ( | unsigned int | offset, |
bool | mostSignificantByteFirst = true |
||
) | const |
Converts the 2 bytes at offset of the vector to a unsigned short.
If mostSignificantByteFirst is true this will operate left to right evaluating the integer. For example if mostSignificantByteFirst is true then $00 $01 == 0x0001 == 1, if false, $01 00 == 0x01000000 == 1.
|
related |
Streams the ByteVector v to the output stream s.
|
static |
A static, empty ByteVector which is convenient and fast (since returning an empty or "null" value does not require instantiating a new ByteVector).