Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

tbytevector.h

Go to the documentation of this file.
00001 /*************************************************************************** 00002 copyright : (C) 2002, 2003 by Scott Wheeler 00003 email : wheeler@kde.org 00004 ***************************************************************************/ 00005 00006 /*************************************************************************** 00007 * This library is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU Lesser General Public License version * 00009 * 2.1 as published by the Free Software Foundation. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, but * 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the Free Software * 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * 00019 * USA * 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 00246 00257 long long toLongLong(bool mostSignificantByteFirst = true) const; 00258 00268 static ByteVector fromUInt(uint value, bool mostSignificantByteFirst = true); 00269 00279 static ByteVector fromLongLong(long long value, bool mostSignificantByteFirst = true); 00280 00284 static ByteVector fromCString(const char *s, uint length = 0xffffffff); 00285 00289 const char &operator[](int index) const; 00290 00294 char &operator[](int index); 00295 00299 bool operator==(const ByteVector &v) const; 00300 00304 bool operator!=(const ByteVector &v) const; 00305 00310 bool operator==(const char *s) const; 00311 00316 bool operator!=(const char *s) const; 00317 00323 bool operator<(const ByteVector &v) const; 00324 00328 bool operator>(const ByteVector &v) const; 00329 00333 ByteVector operator+(const ByteVector &v) const; 00334 00338 ByteVector &operator=(const ByteVector &v); 00339 00343 ByteVector &operator=(char c); 00344 00348 ByteVector &operator=(const char *data); 00349 00354 static ByteVector null; 00355 00356 protected: 00357 /* 00358 * If this ByteVector is being shared via implicit sharing, do a deep copy 00359 * of the data and separate from the shared members. This should be called 00360 * by all non-const subclass members. 00361 */ 00362 void detach(); 00363 00364 private: 00365 class ByteVectorPrivate; 00366 ByteVectorPrivate *d; 00367 }; 00368 00369 } 00370 00375 std::ostream &operator<<(std::ostream &s, const TagLib::ByteVector &v); 00376 00377 #endif

Generated on Wed Jul 28 16:43:07 2004 for TagLib by doxygen 1.3.7