TagLib API Documentation
tbytevector.h
Go to the documentation of this file.
1/***************************************************************************
2 copyright : (C) 2002 - 2008 by Scott Wheeler
3 email : wheeler@kde.org
4 ***************************************************************************/
5
6/***************************************************************************
7 * This library is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU Lesser General Public License version *
9 * 2.1 as published by the Free Software Foundation. *
10 * *
11 * This library is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the Free Software *
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 * 02110-1301 USA *
20 * *
21 * Alternatively, this file is available under the Mozilla Public *
22 * License Version 1.1. You may obtain a copy of the License at *
23 * http://www.mozilla.org/MPL/ *
24 ***************************************************************************/
25
26#ifndef TAGLIB_BYTEVECTOR_H
27#define TAGLIB_BYTEVECTOR_H
28
29#include <memory>
30#include <vector>
31#include <iosfwd>
32
33#include "taglib_export.h"
34
35namespace TagLib {
36
38
46 {
47 public:
48#ifndef DO_NOT_DOCUMENT
49 using Iterator = std::vector<char>::iterator;
50 using ConstIterator = std::vector<char>::const_iterator;
51 using ReverseIterator = std::vector<char>::reverse_iterator;
52 using ConstReverseIterator = std::vector<char>::const_reverse_iterator;
53#endif
54
59
64 ByteVector(unsigned int size, char value = 0);
65
70
74 ByteVector(const ByteVector &v, unsigned int offset, unsigned int length);
75
79 ByteVector(char c);
80
84 ByteVector(const char *data, unsigned int length);
85
93 ByteVector(const char *data);
94
99
103 ByteVector &setData(const char *s, unsigned int length);
104
109 ByteVector &setData(const char *data);
110
118 char *data();
119
123 const char *data() const;
124
130 ByteVector mid(unsigned int index, unsigned int length = 0xffffffff) const;
131
136 char at(unsigned int index) const;
137
144 int find(const ByteVector &pattern, unsigned int offset = 0, int byteAlign = 1) const;
145
152 int find(char c, unsigned int offset = 0, int byteAlign = 1) const;
153
160 int rfind(const ByteVector &pattern, unsigned int offset = 0, int byteAlign = 1) const;
161
169 bool containsAt(const ByteVector &pattern, unsigned int offset,
170 unsigned int patternOffset = 0, unsigned int patternLength = 0xffffffff) const;
171
175 bool startsWith(const ByteVector &pattern) const;
176
180 bool endsWith(const ByteVector &pattern) const;
181
186 ByteVector &replace(char oldByte, char newByte);
187
192 ByteVector &replace(const ByteVector &pattern, const ByteVector &with);
193
204 int endsWithPartialMatch(const ByteVector &pattern) const;
205
210
215
220
224 unsigned int size() const;
225
231 ByteVector &resize(unsigned int size, char padding = 0);
232
236 Iterator begin();
237
241 ConstIterator begin() const;
242
246 ConstIterator cbegin() const;
247
251 Iterator end();
252
256 ConstIterator end() const;
257
261 ConstIterator cend() const;
262
266 ReverseIterator rbegin();
267
271 ConstReverseIterator rbegin() const;
272
276 ReverseIterator rend();
277
281 ConstReverseIterator rend() const;
282
288 bool isEmpty() const;
289
300 unsigned int toUInt(bool mostSignificantByteFirst = true) const;
301
312 unsigned int toUInt(unsigned int offset, bool mostSignificantByteFirst = true) const;
313
325 unsigned int toUInt(unsigned int offset, unsigned int length,
326 bool mostSignificantByteFirst = true) const;
327
337 short toShort(bool mostSignificantByteFirst = true) const;
338
348 short toShort(unsigned int offset, bool mostSignificantByteFirst = true) const;
349
359 unsigned short toUShort(bool mostSignificantByteFirst = true) const;
360
370 unsigned short toUShort(unsigned int offset, bool mostSignificantByteFirst = true) const;
371
382 long long toLongLong(bool mostSignificantByteFirst = true) const;
383
394 long long toLongLong(unsigned int offset, bool mostSignificantByteFirst = true) const;
395
406 unsigned long long toULongLong(bool mostSignificantByteFirst = true) const;
407
418 unsigned long long toULongLong(unsigned int offset, bool mostSignificantByteFirst = true) const;
419
426 float toFloat32LE(size_t offset) const;
427
434 float toFloat32BE(size_t offset) const;
435
442 double toFloat64LE(size_t offset) const;
443
450 double toFloat64BE(size_t offset) const;
451
458 long double toFloat80LE(size_t offset) const;
459
466 long double toFloat80BE(size_t offset) const;
467
477 static ByteVector fromUInt(unsigned int value, bool mostSignificantByteFirst = true);
478
487 static ByteVector fromShort(short value, bool mostSignificantByteFirst = true);
488
497 static ByteVector fromUShort(unsigned short value, bool mostSignificantByteFirst = true);
498
508 static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst = true);
509
519 static ByteVector fromULongLong(unsigned long long value, bool mostSignificantByteFirst = true);
520
527 static ByteVector fromFloat32LE(float value);
528
535 static ByteVector fromFloat32BE(float value);
536
543 static ByteVector fromFloat64LE(double value);
544
551 static ByteVector fromFloat64BE(double value);
552
556 static ByteVector fromCString(const char *s, unsigned int length = 0xffffffff);
557
561 const char &operator[](int index) const;
562
566 char &operator[](int index);
567
571 bool operator==(const ByteVector &v) const;
572
576 bool operator!=(const ByteVector &v) const;
577
582 bool operator==(const char *s) const;
583
588 bool operator!=(const char *s) const;
589
595 bool operator<(const ByteVector &v) const;
596
600 bool operator>(const ByteVector &v) const;
601
606
611
616
622 ByteVector &operator=(const char *data);
623
627 void swap(ByteVector &v) noexcept;
628
633
640
647
648 protected:
654 void detach();
655
656 private:
657 class ByteVectorPrivate;
659 std::unique_ptr<ByteVectorPrivate> d;
660 };
661} // namespace TagLib
662
667TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::ByteVector &v);
668
669#endif
A byte vector.
Definition: tbytevector.h:46
ReverseIterator rbegin()
long double toFloat80BE(size_t offset) const
void swap(ByteVector &v) noexcept
int endsWithPartialMatch(const ByteVector &pattern) const
char at(unsigned int index) const
static ByteVector fromCString(const char *s, unsigned int length=0xffffffff)
static ByteVector fromShort(short value, bool mostSignificantByteFirst=true)
ReverseIterator rend()
ConstIterator cbegin() const
int find(char c, unsigned int offset=0, int byteAlign=1) const
long long toLongLong(unsigned int offset, bool mostSignificantByteFirst=true) const
static ByteVector fromBase64(const ByteVector &)
ByteVector & append(char c)
ConstReverseIterator rbegin() const
bool operator!=(const char *s) const
unsigned short toUShort(bool mostSignificantByteFirst=true) const
ByteVector(unsigned int size, char value=0)
int rfind(const ByteVector &pattern, unsigned int offset=0, int byteAlign=1) const
ByteVector & clear()
ConstIterator end() const
ByteVector & replace(const ByteVector &pattern, const ByteVector &with)
TAGLIB_EXPORT std::ostream & operator<<(std::ostream &s, const TagLib::ByteVector &v)
char & operator[](int index)
ByteVector toHex() const
long double toFloat80LE(size_t offset) const
bool operator!=(const ByteVector &v) const
static ByteVector fromUShort(unsigned short value, bool mostSignificantByteFirst=true)
double toFloat64LE(size_t offset) const
int find(const ByteVector &pattern, unsigned int offset=0, int byteAlign=1) const
bool isEmpty() const
float toFloat32LE(size_t offset) const
static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst=true)
static ByteVector fromFloat64LE(double value)
short toShort(unsigned int offset, bool mostSignificantByteFirst=true) const
ByteVector(const ByteVector &v)
bool endsWith(const ByteVector &pattern) const
ByteVector toBase64() const
unsigned long long toULongLong(bool mostSignificantByteFirst=true) const
ConstIterator begin() const
static ByteVector fromFloat32LE(float value)
ConstReverseIterator rend() const
ByteVector & operator=(const char *data)
bool containsAt(const ByteVector &pattern, unsigned int offset, unsigned int patternOffset=0, unsigned int patternLength=0xffffffff) const
static ByteVector fromUInt(unsigned int value, bool mostSignificantByteFirst=true)
ByteVector & resize(unsigned int size, char padding=0)
float toFloat32BE(size_t offset) const
ByteVector & replace(char oldByte, char newByte)
bool operator==(const char *s) const
bool operator<(const ByteVector &v) const
ByteVector(const char *data)
ByteVector & append(const ByteVector &v)
ByteVector & setData(const char *data)
bool startsWith(const ByteVector &pattern) const
static ByteVector fromFloat64BE(double value)
unsigned int toUInt(bool mostSignificantByteFirst=true) const
unsigned int size() const
ByteVector & operator=(const ByteVector &v)
double toFloat64BE(size_t offset) const
unsigned int toUInt(unsigned int offset, bool mostSignificantByteFirst=true) const
ByteVector operator+(const ByteVector &v) const
ByteVector & operator=(char c)
const char * data() const
unsigned long long toULongLong(unsigned int offset, bool mostSignificantByteFirst=true) const
bool operator==(const ByteVector &v) const
static ByteVector fromFloat32BE(float value)
ByteVector mid(unsigned int index, unsigned int length=0xffffffff) const
long long toLongLong(bool mostSignificantByteFirst=true) const
bool operator>(const ByteVector &v) const
unsigned int toUInt(unsigned int offset, unsigned int length, bool mostSignificantByteFirst=true) const
const char & operator[](int index) const
ByteVector(const char *data, unsigned int length)
ByteVector & setData(const char *s, unsigned int length)
ByteVector(const ByteVector &v, unsigned int offset, unsigned int length)
static ByteVector fromULongLong(unsigned long long value, bool mostSignificantByteFirst=true)
unsigned short toUShort(unsigned int offset, bool mostSignificantByteFirst=true) const
ConstIterator cend() const
short toShort(bool mostSignificantByteFirst=true) const
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41
#define TAGLIB_EXPORT
Definition: taglib_export.h:40
#define TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
Definition: taglib_export.h:55