Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef TAGLIB_BYTEVECTOR_H
00027 #define TAGLIB_BYTEVECTOR_H
00028
00029 #include "taglib.h"
00030 #include "taglib_export.h"
00031
00032 #include <vector>
00033 #include <iostream>
00034
00035 namespace TagLib {
00036
00038
00045 class TAGLIB_EXPORT ByteVector
00046 {
00047 public:
00048 #ifndef DO_NOT_DOCUMENT
00049 typedef std::vector<char>::iterator Iterator;
00050 typedef std::vector<char>::const_iterator ConstIterator;
00051 #endif
00052
00056 ByteVector();
00057
00062 ByteVector(uint size, char value = 0);
00063
00067 ByteVector(const ByteVector &v);
00068
00072 ByteVector(char c);
00073
00077 ByteVector(const char *data, uint length);
00078
00085 ByteVector(const char *data);
00086
00090 virtual ~ByteVector();
00091
00095 ByteVector &setData(const char *data, uint length);
00096
00101 ByteVector &setData(const char *data);
00102
00110 char *data();
00111
00115 const char *data() const;
00116
00122 ByteVector mid(uint index, uint length = 0xffffffff) const;
00123
00128 char at(uint index) const;
00129
00136 int find(const ByteVector &pattern, uint offset = 0, int byteAlign = 1) const;
00137
00144 int rfind(const ByteVector &pattern, uint offset = 0, int byteAlign = 1) const;
00145
00153 bool containsAt(const ByteVector &pattern, uint offset, uint patternOffset = 0, uint patternLength = 0xffffffff) const;
00154
00158 bool startsWith(const ByteVector &pattern) const;
00159
00163 bool endsWith(const ByteVector &pattern) const;
00164
00169 ByteVector &replace(const ByteVector &pattern, const ByteVector &with);
00170
00181 int endsWithPartialMatch(const ByteVector &pattern) const;
00182
00186 ByteVector &append(const ByteVector &v);
00187
00191 ByteVector &clear();
00192
00196 uint size() const;
00197
00203 ByteVector &resize(uint size, char padding = 0);
00204
00208 Iterator begin();
00209
00213 ConstIterator begin() const;
00214
00218 Iterator end();
00219
00223 ConstIterator end() const;
00224
00231 bool isNull() const;
00232
00239 bool isEmpty() const;
00240
00244 uint checksum() const;
00245
00256 uint toUInt(bool mostSignificantByteFirst = true) const;
00257
00267 short toShort(bool mostSignificantByteFirst = true) const;
00268
00278 unsigned short toUShort(bool mostSignificantByteFirst = true) const;
00279
00290 long long toLongLong(bool mostSignificantByteFirst = true) const;
00291
00301 static ByteVector fromUInt(uint value, bool mostSignificantByteFirst = true);
00302
00311 static ByteVector fromShort(short value, bool mostSignificantByteFirst = true);
00312
00322 static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst = true);
00323
00327 static ByteVector fromCString(const char *s, uint length = 0xffffffff);
00328
00332 const char &operator[](int index) const;
00333
00337 char &operator[](int index);
00338
00342 bool operator==(const ByteVector &v) const;
00343
00347 bool operator!=(const ByteVector &v) const;
00348
00353 bool operator==(const char *s) const;
00354
00359 bool operator!=(const char *s) const;
00360
00366 bool operator<(const ByteVector &v) const;
00367
00371 bool operator>(const ByteVector &v) const;
00372
00376 ByteVector operator+(const ByteVector &v) const;
00377
00381 ByteVector &operator=(const ByteVector &v);
00382
00386 ByteVector &operator=(char c);
00387
00391 ByteVector &operator=(const char *data);
00392
00397 static ByteVector null;
00398
00402 ByteVector toHex() const;
00403
00404 protected:
00405
00406
00407
00408
00409
00410 void detach();
00411
00412 private:
00413 class ByteVectorPrivate;
00414 ByteVectorPrivate *d;
00415 };
00416
00417 }
00418
00423 TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::ByteVector &v);
00424
00425 #endif