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
00092 ByteVector(const char *data);
00093
00097 virtual ~ByteVector();
00098
00102 ByteVector &setData(const char *data, uint length);
00103
00108 ByteVector &setData(const char *data);
00109
00117 char *data();
00118
00122 const char *data() const;
00123
00129 ByteVector mid(uint index, uint length = 0xffffffff) const;
00130
00135 char at(uint index) const;
00136
00143 int find(const ByteVector &pattern, uint offset = 0, int byteAlign = 1) const;
00144
00151 int find(char c, uint offset = 0, int byteAlign = 1) const;
00152
00159 int rfind(const ByteVector &pattern, uint offset = 0, int byteAlign = 1) const;
00160
00168 bool containsAt(const ByteVector &pattern, uint offset, uint patternOffset = 0, uint patternLength = 0xffffffff) const;
00169
00173 bool startsWith(const ByteVector &pattern) const;
00174
00178 bool endsWith(const ByteVector &pattern) const;
00179
00184 ByteVector &replace(const ByteVector &pattern, const ByteVector &with);
00185
00196 int endsWithPartialMatch(const ByteVector &pattern) const;
00197
00201 ByteVector &append(const ByteVector &v);
00202
00206 ByteVector &clear();
00207
00211 uint size() const;
00212
00218 ByteVector &resize(uint size, char padding = 0);
00219
00223 Iterator begin();
00224
00228 ConstIterator begin() const;
00229
00233 Iterator end();
00234
00238 ConstIterator end() const;
00239
00243 ReverseIterator rbegin();
00244
00248 ConstReverseIterator rbegin() const;
00249
00253 ReverseIterator rend();
00254
00258 ConstReverseIterator rend() const;
00259
00266 bool isNull() const;
00267
00274 bool isEmpty() const;
00275
00279 uint checksum() const;
00280
00291 uint toUInt(bool mostSignificantByteFirst = true) const;
00292
00303 uint toUInt(uint offset, bool mostSignificantByteFirst = true) const;
00304
00316 uint toUInt(uint offset, uint length, bool mostSignificantByteFirst = true) const;
00317
00327 short toShort(bool mostSignificantByteFirst = true) const;
00328
00338 short toShort(uint offset, bool mostSignificantByteFirst = true) const;
00339
00349 unsigned short toUShort(bool mostSignificantByteFirst = true) const;
00350
00360 unsigned short toUShort(uint offset, bool mostSignificantByteFirst = true) const;
00361
00372 long long toLongLong(bool mostSignificantByteFirst = true) const;
00373
00384 long long toLongLong(uint offset, bool mostSignificantByteFirst = true) const;
00385
00395 static ByteVector fromUInt(uint value, bool mostSignificantByteFirst = true);
00396
00405 static ByteVector fromShort(short value, bool mostSignificantByteFirst = true);
00406
00416 static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst = true);
00417
00421 static ByteVector fromCString(const char *s, uint length = 0xffffffff);
00422
00426 const char &operator[](int index) const;
00427
00431 char &operator[](int index);
00432
00436 bool operator==(const ByteVector &v) const;
00437
00441 bool operator!=(const ByteVector &v) const;
00442
00447 bool operator==(const char *s) const;
00448
00453 bool operator!=(const char *s) const;
00454
00460 bool operator<(const ByteVector &v) const;
00461
00465 bool operator>(const ByteVector &v) const;
00466
00470 ByteVector operator+(const ByteVector &v) const;
00471
00475 ByteVector &operator=(const ByteVector &v);
00476
00480 ByteVector &operator=(char c);
00481
00485 ByteVector &operator=(const char *data);
00486
00491 static ByteVector null;
00492
00496 ByteVector toHex() const;
00497
00498 protected:
00499
00500
00501
00502
00503
00504 void detach();
00505
00506 private:
00507 class ByteVectorPrivate;
00508 ByteVectorPrivate *d;
00509 };
00510 }
00511
00516 TAGLIB_EXPORT std::ostream &operator<<(std::ostream &s, const TagLib::ByteVector &v);
00517
00518 #endif