tiostream.h
Go to the documentation of this file.
1 /***************************************************************************
2  copyright : (C) 2011 by Lukas Lalinsky
3  email : lalinsky@gmail.com
4  ***************************************************************************/
5 
6 /***************************************************************************
7  * This library is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU Lesser General Public License version *
9  * 2.1 as published by the Free Software Foundation. *
10  * *
11  * This library is distributed in the hope that it will be useful, but *
12  * WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the Free Software *
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19  * 02110-1301 USA *
20  * *
21  * Alternatively, this file is available under the Mozilla Public *
22  * License Version 1.1. You may obtain a copy of the License at *
23  * http://www.mozilla.org/MPL/ *
24  ***************************************************************************/
25 
26 #ifndef TAGLIB_IOSTREAM_H
27 #define TAGLIB_IOSTREAM_H
28 
29 #include "taglib_export.h"
30 #include "taglib.h"
31 #include "tbytevector.h"
32 
33 namespace TagLib {
34 
35 #ifdef _WIN32
37  {
38  public:
39  FileName(const wchar_t *name);
40  FileName(const char *name);
41 
42  FileName(const FileName &name);
43 
44  operator const wchar_t *() const;
45  operator const char *() const;
46 
47  const std::wstring &wstr() const;
48  const std::string &str() const;
49 
50  String toString() const;
51 
52  private:
53  const std::string m_name;
54  const std::wstring m_wname;
55  };
56 #else
57  typedef const char *FileName;
58 #endif
59 
61 
63  {
64  public:
68  enum Position {
74  End
75  };
76 
77  IOStream();
78 
82  virtual ~IOStream();
83 
87  virtual FileName name() const = 0;
88 
92  virtual ByteVector readBlock(ulong length) = 0;
93 
103  virtual void writeBlock(const ByteVector &data) = 0;
104 
112  virtual void insert(const ByteVector &data, ulong start = 0, ulong replace = 0) = 0;
113 
121  virtual void removeBlock(ulong start = 0, ulong length = 0) = 0;
122 
126  virtual bool readOnly() const = 0;
127 
132  virtual bool isOpen() const = 0;
133 
140  virtual void seek(long offset, Position p = Beginning) = 0;
141 
145  virtual void clear();
146 
150  virtual long tell() const = 0;
151 
155  virtual long length() = 0;
156 
160  virtual void truncate(long length) = 0;
161 
162  private:
163  IOStream(const IOStream &);
164  IOStream &operator=(const IOStream &);
165  };
166 
167 }
168 
169 #endif