tbytevector.h
Go to the documentation of this file.
/***************************************************************************
copyright : (C) 2002 - 2008 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#ifndef TAGLIB_BYTEVECTOR_H
#define TAGLIB_BYTEVECTOR_H
#include <memory>
#include <vector>
#include <iosfwd>
#include "taglib_export.h"
namespace TagLib {
class TAGLIB_EXPORT ByteVector
{
public:
#ifndef DO_NOT_DOCUMENT
using Iterator = std::vector<char>::iterator;
using ConstIterator = std::vector<char>::const_iterator;
using ReverseIterator = std::vector<char>::reverse_iterator;
using ConstReverseIterator = std::vector<char>::const_reverse_iterator;
#endif
ByteVector();
ByteVector(unsigned int size, char value = 0);
ByteVector(const ByteVector &v);
ByteVector(const ByteVector &v, unsigned int offset, unsigned int length);
ByteVector(char c);
ByteVector(const char *data, unsigned int length);
ByteVector(const char *data);
~ByteVector();
ByteVector &setData(const char *s, unsigned int length);
ByteVector &setData(const char *data);
char *data();
const char *data() const;
ByteVector mid(unsigned int index, unsigned int length = 0xffffffff) const;
char at(unsigned int index) const;
int find(const ByteVector &pattern, unsigned int offset = 0, int byteAlign = 1) const;
int find(char c, unsigned int offset = 0, int byteAlign = 1) const;
int rfind(const ByteVector &pattern, unsigned int offset = 0, int byteAlign = 1) const;
bool containsAt(const ByteVector &pattern, unsigned int offset,
unsigned int patternOffset = 0, unsigned int patternLength = 0xffffffff) const;
bool startsWith(const ByteVector &pattern) const;
bool endsWith(const ByteVector &pattern) const;
ByteVector &replace(char oldByte, char newByte);
ByteVector &replace(const ByteVector &pattern, const ByteVector &with);
int endsWithPartialMatch(const ByteVector &pattern) const;
ByteVector &append(const ByteVector &v);
ByteVector &append(char c);
ByteVector &clear();
unsigned int size() const;
ByteVector &resize(unsigned int size, char padding = 0);
Iterator begin();
ConstIterator begin() const;
ConstIterator cbegin() const;
Iterator end();
ConstIterator end() const;
ConstIterator cend() const;
ReverseIterator rbegin();
ConstReverseIterator rbegin() const;
ReverseIterator rend();
ConstReverseIterator rend() const;
bool isEmpty() const;
unsigned int toUInt(bool mostSignificantByteFirst = true) const;
unsigned int toUInt(unsigned int offset, bool mostSignificantByteFirst = true) const;
unsigned int toUInt(unsigned int offset, unsigned int length,
bool mostSignificantByteFirst = true) const;
short toShort(bool mostSignificantByteFirst = true) const;
short toShort(unsigned int offset, bool mostSignificantByteFirst = true) const;
unsigned short toUShort(bool mostSignificantByteFirst = true) const;
unsigned short toUShort(unsigned int offset, bool mostSignificantByteFirst = true) const;
long long toLongLong(bool mostSignificantByteFirst = true) const;
long long toLongLong(unsigned int offset, bool mostSignificantByteFirst = true) const;
unsigned long long toULongLong(bool mostSignificantByteFirst = true) const;
unsigned long long toULongLong(unsigned int offset, bool mostSignificantByteFirst = true) const;
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;
static ByteVector fromUInt(unsigned int value, bool mostSignificantByteFirst = true);
static ByteVector fromShort(short value, bool mostSignificantByteFirst = true);
static ByteVector fromUShort(unsigned short value, bool mostSignificantByteFirst = true);
static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst = true);
static ByteVector fromULongLong(unsigned long long value, bool mostSignificantByteFirst = true);
static ByteVector fromFloat32LE(float value);
static ByteVector fromFloat32BE(float value);
static ByteVector fromFloat64LE(double value);
static ByteVector fromFloat64BE(double value);
static ByteVector fromCString(const char *s, unsigned int length = 0xffffffff);
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;
ByteVector &operator=(const ByteVector &v);
ByteVector &operator=(char c);
ByteVector &operator=(const char *data);
void swap(ByteVector &v) noexcept;
ByteVector toHex() const;
ByteVector toBase64() const;
static ByteVector fromBase64(const ByteVector &);
protected:
void detach();
private:
class ByteVectorPrivate;
TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
std::unique_ptr<ByteVectorPrivate> d;
};
} // namespace TagLib
TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::ByteVector &v);
#endif
TagLib::ByteVector
A byte vector.
Definition tbytevector.h:46
TagLib::ByteVector::rbegin
ReverseIterator rbegin()
TagLib::ByteVector::toFloat80BE
long double toFloat80BE(size_t offset) const
TagLib::ByteVector::swap
void swap(ByteVector &v) noexcept
TagLib::ByteVector::endsWithPartialMatch
int endsWithPartialMatch(const ByteVector &pattern) const
TagLib::ByteVector::at
char at(unsigned int index) const
TagLib::ByteVector::fromCString
static ByteVector fromCString(const char *s, unsigned int length=0xffffffff)
TagLib::ByteVector::fromShort
static ByteVector fromShort(short value, bool mostSignificantByteFirst=true)
TagLib::ByteVector::rend
ReverseIterator rend()
TagLib::ByteVector::cbegin
ConstIterator cbegin() const
TagLib::ByteVector::find
int find(char c, unsigned int offset=0, int byteAlign=1) const
TagLib::ByteVector::toLongLong
long long toLongLong(unsigned int offset, bool mostSignificantByteFirst=true) const
TagLib::ByteVector::~ByteVector
~ByteVector()
TagLib::ByteVector::fromBase64
static ByteVector fromBase64(const ByteVector &)
TagLib::ByteVector::append
ByteVector & append(char c)
TagLib::ByteVector::rbegin
ConstReverseIterator rbegin() const
TagLib::ByteVector::operator!=
bool operator!=(const char *s) const
TagLib::ByteVector::toUShort
unsigned short toUShort(bool mostSignificantByteFirst=true) const
TagLib::ByteVector::ByteVector
ByteVector(unsigned int size, char value=0)
TagLib::ByteVector::rfind
int rfind(const ByteVector &pattern, unsigned int offset=0, int byteAlign=1) const
TagLib::ByteVector::clear
ByteVector & clear()
TagLib::ByteVector::end
ConstIterator end() const
TagLib::ByteVector::replace
ByteVector & replace(const ByteVector &pattern, const ByteVector &with)
TagLib::ByteVector::operator<<
TAGLIB_EXPORT std::ostream & operator<<(std::ostream &s, const TagLib::ByteVector &v)
TagLib::ByteVector::operator[]
char & operator[](int index)
TagLib::ByteVector::toHex
ByteVector toHex() const
TagLib::ByteVector::toFloat80LE
long double toFloat80LE(size_t offset) const
TagLib::ByteVector::operator!=
bool operator!=(const ByteVector &v) const
TagLib::ByteVector::fromUShort
static ByteVector fromUShort(unsigned short value, bool mostSignificantByteFirst=true)
TagLib::ByteVector::toFloat64LE
double toFloat64LE(size_t offset) const
TagLib::ByteVector::find
int find(const ByteVector &pattern, unsigned int offset=0, int byteAlign=1) const
TagLib::ByteVector::data
char * data()
TagLib::ByteVector::isEmpty
bool isEmpty() const
TagLib::ByteVector::toFloat32LE
float toFloat32LE(size_t offset) const
TagLib::ByteVector::fromLongLong
static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst=true)
TagLib::ByteVector::end
Iterator end()
TagLib::ByteVector::fromFloat64LE
static ByteVector fromFloat64LE(double value)
TagLib::ByteVector::toShort
short toShort(unsigned int offset, bool mostSignificantByteFirst=true) const
TagLib::ByteVector::ByteVector
ByteVector(const ByteVector &v)
TagLib::ByteVector::endsWith
bool endsWith(const ByteVector &pattern) const
TagLib::ByteVector::toBase64
ByteVector toBase64() const
TagLib::ByteVector::toULongLong
unsigned long long toULongLong(bool mostSignificantByteFirst=true) const
TagLib::ByteVector::begin
ConstIterator begin() const
TagLib::ByteVector::fromFloat32LE
static ByteVector fromFloat32LE(float value)
TagLib::ByteVector::rend
ConstReverseIterator rend() const
TagLib::ByteVector::operator=
ByteVector & operator=(const char *data)
TagLib::ByteVector::containsAt
bool containsAt(const ByteVector &pattern, unsigned int offset, unsigned int patternOffset=0, unsigned int patternLength=0xffffffff) const
TagLib::ByteVector::fromUInt
static ByteVector fromUInt(unsigned int value, bool mostSignificantByteFirst=true)
TagLib::ByteVector::resize
ByteVector & resize(unsigned int size, char padding=0)
TagLib::ByteVector::toFloat32BE
float toFloat32BE(size_t offset) const
TagLib::ByteVector::replace
ByteVector & replace(char oldByte, char newByte)
TagLib::ByteVector::begin
Iterator begin()
TagLib::ByteVector::operator==
bool operator==(const char *s) const
TagLib::ByteVector::operator<
bool operator<(const ByteVector &v) const
TagLib::ByteVector::ByteVector
ByteVector(char c)
TagLib::ByteVector::ByteVector
ByteVector(const char *data)
TagLib::ByteVector::append
ByteVector & append(const ByteVector &v)
TagLib::ByteVector::setData
ByteVector & setData(const char *data)
TagLib::ByteVector::startsWith
bool startsWith(const ByteVector &pattern) const
TagLib::ByteVector::fromFloat64BE
static ByteVector fromFloat64BE(double value)
TagLib::ByteVector::toUInt
unsigned int toUInt(bool mostSignificantByteFirst=true) const
TagLib::ByteVector::size
unsigned int size() const
TagLib::ByteVector::operator=
ByteVector & operator=(const ByteVector &v)
TagLib::ByteVector::toFloat64BE
double toFloat64BE(size_t offset) const
TagLib::ByteVector::toUInt
unsigned int toUInt(unsigned int offset, bool mostSignificantByteFirst=true) const
TagLib::ByteVector::operator+
ByteVector operator+(const ByteVector &v) const
TagLib::ByteVector::operator=
ByteVector & operator=(char c)
TagLib::ByteVector::data
const char * data() const
TagLib::ByteVector::toULongLong
unsigned long long toULongLong(unsigned int offset, bool mostSignificantByteFirst=true) const
TagLib::ByteVector::operator==
bool operator==(const ByteVector &v) const
TagLib::ByteVector::fromFloat32BE
static ByteVector fromFloat32BE(float value)
TagLib::ByteVector::mid
ByteVector mid(unsigned int index, unsigned int length=0xffffffff) const
TagLib::ByteVector::toLongLong
long long toLongLong(bool mostSignificantByteFirst=true) const
TagLib::ByteVector::operator>
bool operator>(const ByteVector &v) const
TagLib::ByteVector::toUInt
unsigned int toUInt(unsigned int offset, unsigned int length, bool mostSignificantByteFirst=true) const
TagLib::ByteVector::operator[]
const char & operator[](int index) const
TagLib::ByteVector::ByteVector
ByteVector(const char *data, unsigned int length)
TagLib::ByteVector::setData
ByteVector & setData(const char *s, unsigned int length)
TagLib::ByteVector::detach
void detach()
TagLib::ByteVector::ByteVector
ByteVector(const ByteVector &v, unsigned int offset, unsigned int length)
TagLib::ByteVector::fromULongLong
static ByteVector fromULongLong(unsigned long long value, bool mostSignificantByteFirst=true)
TagLib::ByteVector::toUShort
unsigned short toUShort(unsigned int offset, bool mostSignificantByteFirst=true) const
TagLib::ByteVector::ByteVector
ByteVector()
TagLib::ByteVector::cend
ConstIterator cend() const
TagLib::ByteVector::toShort
short toShort(bool mostSignificantByteFirst=true) const
TagLib
A namespace for all TagLib related classes and functions.
Definition apefile.h:41
taglib_export.h
TAGLIB_EXPORT
#define TAGLIB_EXPORT
Definition taglib_export.h:40
TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
#define TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
Definition taglib_export.h:55