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);
00040     FileName(const char *name);
00041 
00042     FileName(const FileName &name);
00043 
00044     operator const wchar_t *() const;
00045     operator const char *() const;
00046 
00047     const std::wstring &wstr() const;
00048     const std::string  &str() const;
00049 
00050     String toString() const;
00051 
00052   private:
00053     const std::string  m_name;
00054     const std::wstring m_wname;
00055   };
00056 #else
00057   typedef const char *FileName;
00058 #endif
00059 
00061 
00062   class TAGLIB_EXPORT IOStream
00063   {
00064   public:
00068     enum Position {
00070       Beginning,
00072       Current,
00074       End
00075     };
00076 
00077     IOStream();
00078 
00082     virtual ~IOStream();
00083 
00087     virtual FileName name() const = 0;
00088 
00092     virtual ByteVector readBlock(unsigned long length) = 0;
00093 
00103     virtual void writeBlock(const ByteVector &data) = 0;
00104 
00112     virtual void insert(const ByteVector &data,
00113                         unsigned long start = 0, unsigned long replace = 0) = 0;
00114 
00122     virtual void removeBlock(unsigned long start = 0, unsigned long length = 0) = 0;
00123 
00127     virtual bool readOnly() const = 0;
00128 
00133     virtual bool isOpen() const = 0;
00134 
00141     virtual void seek(long offset, Position p = Beginning) = 0;
00142 
00146     virtual void clear();
00147 
00151     virtual long tell() const = 0;
00152 
00156     virtual long length() = 0;
00157 
00161     virtual void truncate(long length) = 0;
00162 
00163   private:
00164     IOStream(const IOStream &);
00165     IOStream &operator=(const IOStream &);
00166   };
00167 
00168 }
00169 
00170 #endif