tiostream.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     copyright            : (C) 2011 by Lukas Lalinsky
00003     email                : lalinsky@gmail.com
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., 51 Franklin Street, Fifth Floor, Boston, MA         *
00019  *   02110-1301  USA                                                       *
00020  *                                                                         *
00021  *   Alternatively, this file is available under the Mozilla Public        *
00022  *   License Version 1.1.  You may obtain a copy of the License at         *
00023  *   http://www.mozilla.org/MPL/                                           *
00024  ***************************************************************************/
00025 
00026 #ifndef TAGLIB_IOSTREAM_H
00027 #define TAGLIB_IOSTREAM_H
00028 
00029 #include "taglib_export.h"
00030 #include "taglib.h"
00031 #include "tbytevector.h"
00032 
00033 namespace TagLib {
00034 
00035 #ifdef _WIN32
00036   class TAGLIB_EXPORT FileName
00037   {
00038   public:
00039     FileName(const wchar_t *name) : m_wname(name) {}
00040     FileName(const char *name) : m_name(name) {}
00041     operator const wchar_t *() const { return m_wname.c_str(); }
00042     operator const char *() const { return m_name.c_str(); }
00043   private:
00044     std::string m_name;
00045     std::wstring m_wname;
00046   };
00047 #else
00048   typedef const char *FileName;
00049 #endif
00050 
00052 
00053   class TAGLIB_EXPORT IOStream
00054   {
00055   public:
00059     enum Position {
00061       Beginning,
00063       Current,
00065       End
00066     };
00067 
00068     IOStream();
00069 
00073     virtual ~IOStream();
00074 
00078     virtual FileName name() const = 0;
00079 
00083     virtual ByteVector readBlock(ulong length) = 0;
00084 
00094     virtual void writeBlock(const ByteVector &data) = 0;
00095 
00103     virtual void insert(const ByteVector &data, ulong start = 0, ulong replace = 0) = 0;
00104 
00112     virtual void removeBlock(ulong start = 0, ulong length = 0) = 0;
00113 
00117     virtual bool readOnly() const = 0;
00118 
00123     virtual bool isOpen() const = 0;
00124 
00131     virtual void seek(long offset, Position p = Beginning) = 0;
00132 
00136     virtual void clear();
00137 
00141     virtual long tell() const = 0;
00142 
00146     virtual long length() = 0;
00147 
00151     virtual void truncate(long length) = 0;
00152 
00153   private:
00154     IOStream(const IOStream &);
00155     IOStream &operator=(const IOStream &);
00156   };
00157 
00158 }
00159 
00160 #endif