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 typedef std::vector<char>::reverse_iterator ReverseIterator;
00052 typedef std::vector<char>::const_reverse_iterator ConstReverseIterator;
00053 #endif
00054
00058 ByteVector();
00059
00064 ByteVector(uint size, char value = 0);
00065
00069 ByteVector(const ByteVector &v);
00070
00074 ByteVector(const ByteVector &v, uint offset, uint length);
00075
00079 ByteVector(char c);
00080
00084 ByteVector(const char *data, uint length);
00085
00093 ByteVector(const char *data);
00094
00098 virtual ~ByteVector();
00099
00103 ByteVector &setData(const char *data, uint length);
00104
00109 ByteVector &setData(const char *data);
00110
00118 char *data();
00119
00123 const char *data() const;
00124
00130 ByteVector mid(uint index, uint length = 0xffffffff) const;
00131
00136 char at(uint index) const;
00137
00144 int find(const ByteVector &pattern, uint offset = 0, int byteAlign = 1) const;
00145
00152 int find(char c, uint offset = 0, int byteAlign = 1) const;
00153
00160 int rfind(const ByteVector &pattern, uint offset = 0, int byteAlign = 1) const;
00161
00169 bool containsAt(const ByteVector &pattern, uint offset, uint patternOffset = 0, uint patternLength = 0xffffffff) const;
00170
00174 bool startsWith(const ByteVector &pattern) const;
00175
00179 bool endsWith(const ByteVector &pattern) const;
00180
00185 ByteVector &replace(const ByteVector &pattern, const ByteVector &with);
00186
00197 int endsWithPartialMatch(const ByteVector &pattern) const;
00198
00202 ByteVector &append(const ByteVector &v);
00203
00207 ByteVector &clear();
00208
00212 uint size() const;
00213
00219 ByteVector &resize(uint size, char padding = 0);
00220
00224 Iterator begin();
00225
00229 ConstIterator begin() const;
00230
00234 Iterator end();
00235
00239 ConstIterator end() const;
00240
00244 ReverseIterator rbegin();
00245
00249 ConstReverseIterator rbegin() const;
00250
00254 ReverseIterator rend();
00255
00259 ConstReverseIterator rend() const;
00260
00267 bool isNull() const;
00268
00275 bool isEmpty() const;
00276
00282
00283 uint checksum() const;
00284
00295 uint toUInt(bool mostSignificantByteFirst = true) const;
00296
00307 uint toUInt(uint offset, bool mostSignificantByteFirst = true) const;
00308
00320 uint toUInt(uint offset, uint length, bool mostSignificantByteFirst = true) const;
00321
00331 short toShort(bool mostSignificantByteFirst = true) const;
00332
00342 short toShort(uint offset, bool mostSignificantByteFirst = true) const;
00343
00353 unsigned short toUShort(bool mostSignificantByteFirst = true) const;
00354
00364 unsigned short toUShort(uint offset, bool mostSignificantByteFirst = true) const;
00365
00376 long long toLongLong(bool mostSignificantByteFirst = true) const;
00377
00388 long long toLongLong(uint offset, bool mostSignificantByteFirst = true) const;
00389
00390
00391
00392
00393
00394 float toFloat32LE(size_t offset) const;
00395
00396
00397
00398
00399
00400 float toFloat32BE(size_t offset) const;
00401
00402
00403
00404
00405
00406 double toFloat64LE(size_t offset) const;
00407
00408
00409
00410
00411
00412 double toFloat64BE(size_t offset) const;
00413
00414
00415
00416
00417
00418
00419
00420 long double toFloat80LE(size_t offset) const;
00421
00422
00423
00424
00425
00426
00427
00428 long double toFloat80BE(size_t offset) const;
00429
00439 static ByteVector fromUInt(uint value, bool mostSignificantByteFirst = true);
00440
00449 static ByteVector fromShort(short value, bool mostSignificantByteFirst = true);
00450
00460 static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst = true);
00461
00468 static ByteVector fromFloat32LE(float value);
00469
00476 static ByteVector fromFloat32BE(float value);
00477
00484 static ByteVector fromFloat64LE(double value);
00485
00492 static ByteVector fromFloat64BE(double value);
00493
00497 static ByteVector fromCString(const char *s, uint length = 0xffffffff);
00498
00502 const char &operator[](int index) const;
00503
00507 char &operator[](int index);
00508
00512 bool operator==(const ByteVector &v) const;
00513
00517 bool operator!=(const ByteVector &v) const;
00518
00523 bool operator==(const char *s) const;
00524
00529 bool operator!=(const char *s) const;
00530
00536 bool operator<(const ByteVector &v) const;
00537
00541 bool operator>(const ByteVector &v) const;
00542
00546 ByteVector operator+(const ByteVector &v) const;
00547
00551 ByteVector &operator=(const ByteVector &v);
00552
00556 ByteVector &operator=(char c);
00557
00563 ByteVector &operator=(const char *data);
00564
00569 static ByteVector null;
00570
00574 ByteVector toHex() const;
00575
00576 protected:
00577
00578
00579
00580
00581
00582 void detach();
00583
00584 private:
00585 class ByteVectorPrivate;
00586 ByteVectorPrivate *d;
00587 };
00588 }
00589
00594 TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::ByteVector &v);
00595
00596 #endif