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
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
00279 long long toLongLong(bool mostSignificantByteFirst = true) const;
00280
00290 static ByteVector fromUInt(uint value, bool mostSignificantByteFirst = true);
00291
00300 static ByteVector fromShort(short value, bool mostSignificantByteFirst = true);
00301
00311 static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst = true);
00312
00316 static ByteVector fromCString(const char *s, uint length = 0xffffffff);
00317
00321 const char &operator[](int index) const;
00322
00326 char &operator[](int index);
00327
00331 bool operator==(const ByteVector &v) const;
00332
00336 bool operator!=(const ByteVector &v) const;
00337
00342 bool operator==(const char *s) const;
00343
00348 bool operator!=(const char *s) const;
00349
00355 bool operator<(const ByteVector &v) const;
00356
00360 bool operator>(const ByteVector &v) const;
00361
00365 ByteVector operator+(const ByteVector &v) const;
00366
00370 ByteVector &operator=(const ByteVector &v);
00371
00375 ByteVector &operator=(char c);
00376
00380 ByteVector &operator=(const char *data);
00381
00386 static ByteVector null;
00387
00388 protected:
00389
00390
00391
00392
00393
00394 void detach();
00395
00396 private:
00397 class ByteVectorPrivate;
00398 ByteVectorPrivate *d;
00399 };
00400
00401 }
00402
00407 TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::ByteVector &v);
00408
00409 #endif