| TagLib 1.13 |  |

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 "taglib.h"
30#include "taglib_export.h"
31
32#include <vector>
33#include <iostream>
34
35 namespace TagLib {
36
38
45 class TAGLIB_EXPORT ByteVector
46 {
47 public:
48#ifndef DO_NOT_DOCUMENT
49 typedef std::vector<char>::iterator Iterator;
50 typedef std::vector<char>::const_iterator ConstIterator;
51 typedef std::vector<char>::reverse_iterator ReverseIterator;
52 typedef std::vector<char>::const_reverse_iterator ConstReverseIterator;
53#endif
54
58 ByteVector();
59
64 ByteVector(unsigned int size, char value = 0);
65
69 ByteVector(const ByteVector &v);
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
98 virtual ~ByteVector();
99
103 ByteVector &setData(const char *data, 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
209 ByteVector &append(const ByteVector &v);
210
214 ByteVector &append(char c);
215
219 ByteVector &clear();
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 Iterator end();
247
251 ConstIterator end() const;
252
256 ReverseIterator rbegin();
257
261 ConstReverseIterator rbegin() const;
262
266 ReverseIterator rend();
267
271 ConstReverseIterator rend() const;
272
283 // BIC: remove
284 TAGLIB_DEPRECATED bool isNull() const;
285
292 bool isEmpty() const;
293
299 // BIC: Remove or make generic.
300 unsigned int checksum() const;
301
312 unsigned int toUInt(bool mostSignificantByteFirst = true) const;
313
324 unsigned int toUInt(unsigned int offset, bool mostSignificantByteFirst = true) const;
325
337 unsigned int toUInt(unsigned int offset, unsigned int length,
338 bool mostSignificantByteFirst = true) const;
339
349 short toShort(bool mostSignificantByteFirst = true) const;
350
360 short toShort(unsigned int offset, bool mostSignificantByteFirst = true) const;
361
371 unsigned short toUShort(bool mostSignificantByteFirst = true) const;
372
382 unsigned short toUShort(unsigned int offset, bool mostSignificantByteFirst = true) const;
383
394 long long toLongLong(bool mostSignificantByteFirst = true) const;
395
406 long long toLongLong(unsigned int offset, bool mostSignificantByteFirst = true) const;
407
408 /*
409 * Converts the 4 bytes at \a offset of the vector to a float as an IEEE754
410 * 32-bit little-endian floating point number.
411 */
412 float toFloat32LE(size_t offset) const;
413
414 /*
415 * Converts the 4 bytes at \a offset of the vector to a float as an IEEE754
416 * 32-bit big-endian floating point number.
417 */
418 float toFloat32BE(size_t offset) const;
419
420 /*
421 * Converts the 8 bytes at \a offset of the vector to a double as an IEEE754
422 * 64-bit little-endian floating point number.
423 */
424 double toFloat64LE(size_t offset) const;
425
426 /*
427 * Converts the 8 bytes at \a offset of the vector to a double as an IEEE754
428 * 64-bit big-endian floating point number.
429 */
430 double toFloat64BE(size_t offset) const;
431
432 /*
433 * Converts the 10 bytes at \a offset of the vector to a long double as an
434 * IEEE754 80-bit little-endian floating point number.
435 *
436 * \note This may compromise the precision depends on the size of long double.
437 */
438 long double toFloat80LE(size_t offset) const;
439
440 /*
441 * Converts the 10 bytes at \a offset of the vector to a long double as an
442 * IEEE754 80-bit big-endian floating point number.
443 *
444 * \note This may compromise the precision depends on the size of long double.
445 */
446 long double toFloat80BE(size_t offset) const;
447
457 static ByteVector fromUInt(unsigned int value, bool mostSignificantByteFirst = true);
458
467 static ByteVector fromShort(short value, bool mostSignificantByteFirst = true);
468
478 static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst = true);
479
486 static ByteVector fromFloat32LE(float value);
487
494 static ByteVector fromFloat32BE(float value);
495
502 static ByteVector fromFloat64LE(double value);
503
510 static ByteVector fromFloat64BE(double value);
511
515 static ByteVector fromCString(const char *s, unsigned int length = 0xffffffff);
516
520 const char &operator[](int index) const;
521
525 char &operator[](int index);
526
530 bool operator==(const ByteVector &v) const;
531
535 bool operator!=(const ByteVector &v) const;
536
541 bool operator==(const char *s) const;
542
547 bool operator!=(const char *s) const;
548
554 bool operator<(const ByteVector &v) const;
555
559 bool operator>(const ByteVector &v) const;
560
564 ByteVector operator+(const ByteVector &v) const;
565
569 ByteVector &operator=(const ByteVector &v);
570
574 ByteVector &operator=(char c);
575
581 ByteVector &operator=(const char *data);
582
586 void swap(ByteVector &v);
587
597 // BIC: remove
598 TAGLIB_DEPRECATED static ByteVector null;
599
603 ByteVector toHex() const;
604
608 ByteVector toBase64() const;
609
613 static ByteVector fromBase64(const ByteVector &);
614
615 protected:
616 /*
617 * If this ByteVector is being shared via implicit sharing, do a deep copy
618 * of the data and separate from the shared members. This should be called
619 * by all non-const subclass members.
620 */
621 void detach();
622
623 private:
624 class ByteVectorPrivate;
625 ByteVectorPrivate *d;
626 };
627}
628
633 TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::ByteVector &v);
634
635#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::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::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::checksum
unsigned int checksum() const
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::setData
ByteVector & setData(const char *data, unsigned int length)
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::~ByteVector
virtual ~ByteVector()
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::null
static TAGLIB_DEPRECATED ByteVector null
Definition: tbytevector.h:598
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::begin
ConstIterator begin() const
TagLib::ByteVector::fromFloat32LE
static ByteVector fromFloat32LE(float value)
TagLib::ByteVector::swap
void swap(ByteVector &v)
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::isNull
TAGLIB_DEPRECATED bool isNull() 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::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::detach
void detach()
TagLib::ByteVector::ByteVector
ByteVector(const ByteVector &v, unsigned int offset, unsigned int length)
TagLib::ByteVector::toUShort
unsigned short toUShort(unsigned int offset, bool mostSignificantByteFirst=true) const
TagLib::ByteVector::ByteVector
ByteVector()
TagLib::ByteVector::toShort
short toShort(bool mostSignificantByteFirst=true) const
TagLib
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41
taglib.h
TAGLIB_DEPRECATED
#define TAGLIB_DEPRECATED
Definition: taglib.h:54
taglib_export.h
TAGLIB_EXPORT
#define TAGLIB_EXPORT
Definition: taglib_export.h:40