tbytevector.h
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 #ifndef TAGLIB_BYTEVECTOR_H
00023 #define TAGLIB_BYTEVECTOR_H
00024
00025 #include "taglib.h"
00026
00027 #include <vector>
00028
00029 namespace TagLib {
00030
00032
00039 class ByteVector
00040 {
00041 public:
00042 #ifndef DO_NOT_DOCUMENT
00043 typedef std::vector<char>::iterator Iterator;
00044 typedef std::vector<char>::const_iterator ConstIterator;
00045 #endif
00046
00050 ByteVector();
00051
00056 ByteVector(uint size, char value = 0);
00057
00061 ByteVector(const ByteVector &v);
00062
00066 ByteVector(char c);
00067
00071 ByteVector(const char *data, uint length);
00072
00079 ByteVector(const char *data);
00080
00084 virtual ~ByteVector();
00085
00089 void setData(const char *data, uint length);
00090
00095 void setData(const char *data);
00096
00104 char *data();
00105
00109 const char *data() const;
00110
00116 ByteVector mid(uint index, uint length = 0xffffffff) const;
00117
00122 char at(uint index) const;
00123
00130 int find(const ByteVector &pattern, uint offset = 0, int byteAlign = 1) const;
00131
00138 int rfind(const ByteVector &pattern, uint offset = 0, int byteAlign = 1) const;
00139
00147 bool containsAt(const ByteVector &pattern, uint offset, uint patternOffset = 0, uint patternLength = 0xffffffff) const;
00148
00152 bool startsWith(const ByteVector &pattern) const;
00153
00157 bool endsWith(const ByteVector &pattern) const;
00158
00169 int endsWithPartialMatch(const ByteVector &pattern) const;
00170
00174 void append(const ByteVector &v);
00175
00179 void clear();
00180
00184 uint size() const;
00185
00191 ByteVector &resize(uint size, char padding = 0);
00192
00196 Iterator begin();
00197
00201 ConstIterator begin() const;
00202
00206 Iterator end();
00207
00211 ConstIterator end() const;
00212
00219 bool isNull() const;
00220
00227 bool isEmpty() const;
00228
00232 uint checksum() const;
00233
00244 uint toUInt(bool mostSignificantByteFirst = true) const;
00245
00255 short toShort(bool mostSignificantByteFirst = true) const;
00256
00267 long long toLongLong(bool mostSignificantByteFirst = true) const;
00268
00278 static ByteVector fromUInt(uint value, bool mostSignificantByteFirst = true);
00279
00288 static ByteVector fromShort(short value, bool mostSignificantByteFirst = true);
00289
00299 static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst = true);
00300
00304 static ByteVector fromCString(const char *s, uint length = 0xffffffff);
00305
00309 const char &operator[](int index) const;
00310
00314 char &operator[](int index);
00315
00319 bool operator==(const ByteVector &v) const;
00320
00324 bool operator!=(const ByteVector &v) const;
00325
00330 bool operator==(const char *s) const;
00331
00336 bool operator!=(const char *s) const;
00337
00343 bool operator<(const ByteVector &v) const;
00344
00348 bool operator>(const ByteVector &v) const;
00349
00353 ByteVector operator+(const ByteVector &v) const;
00354
00358 ByteVector &operator=(const ByteVector &v);
00359
00363 ByteVector &operator=(char c);
00364
00368 ByteVector &operator=(const char *data);
00369
00374 static ByteVector null;
00375
00376 protected:
00377
00378
00379
00380
00381
00382 void detach();
00383
00384 private:
00385 class ByteVectorPrivate;
00386 ByteVectorPrivate *d;
00387 };
00388
00389 }
00390
00395 std::ostream &operator<<(std::ostream &s, const TagLib::ByteVector &v);
00396
00397 #endif