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) : m_wname(name) {}
40  FileName(const char *name) : m_name(name) {}
41  operator const wchar_t *() const { return m_wname.c_str(); }
42  operator const char *() const { return m_name.c_str(); }
43  private:
44  std::string m_name;
45  std::wstring m_wname;
46  };
47 #else
48  typedef const char *FileName;
49 #endif
50 
52 
54  {
55  public:
59  enum Position {
65  End
66  };
67 
68  IOStream();
69 
73  virtual ~IOStream();
74 
78  virtual FileName name() const = 0;
79 
83  virtual ByteVector readBlock(ulong length) = 0;
84 
94  virtual void writeBlock(const ByteVector &data) = 0;
95 
103  virtual void insert(const ByteVector &data, ulong start = 0, ulong replace = 0) = 0;
104 
112  virtual void removeBlock(ulong start = 0, ulong length = 0) = 0;
113 
117  virtual bool readOnly() const = 0;
118 
123  virtual bool isOpen() const = 0;
124 
131  virtual void seek(long offset, Position p = Beginning) = 0;
132 
136  virtual void clear();
137 
141  virtual long tell() const = 0;
142 
146  virtual long length() = 0;
147 
151  virtual void truncate(long length) = 0;
152 
153  private:
154  IOStream(const IOStream &);
155  IOStream &operator=(const IOStream &);
156  };
157 
158 }
159 
160 #endif
std::basic_string< wchar > wstring
Definition: taglib.h:90
Seek from the current position in the file.
Definition: tiostream.h:63
An abstract class that provides operations on a sequence of bytes.
Definition: tiostream.h:53
Position
Definition: tiostream.h:59
A byte vector.
Definition: tbytevector.h:45
unsigned long ulong
Definition: taglib.h:84
#define TAGLIB_EXPORT
Definition: taglib_export.h:40
const char * FileName
Definition: tiostream.h:48
Seek from the beginning of the file.
Definition: tiostream.h:61