id3lib  3.8.3
include/id3/io_helpers.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: io_helpers.h,v 1.7 2002/06/29 17:43:19 t1mpy Exp $
00003 
00004 // id3lib: a software library for creating and manipulating id3v1/v2 tags
00005 // Copyright 1999, 2000  Scott Thomas Haug
00006 
00007 // This library is free software; you can redistribute it and/or modify it
00008 // under the terms of the GNU Library General Public License as published by
00009 // the Free Software Foundation; either version 2 of the License, or (at your
00010 // option) any later version.
00011 //
00012 // This library is distributed in the hope that it will be useful, but WITHOUT
00013 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00015 // License for more details.
00016 //
00017 // You should have received a copy of the GNU Library General Public License
00018 // along with this library; if not, write to the Free Software Foundation,
00019 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00020 
00021 // The id3lib authors encourage improvements and optimisations to be sent to
00022 // the id3lib coordinator.  Please see the README file for details on where to
00023 // send such submissions.  See the AUTHORS file for a list of people who have
00024 // contributed to id3lib.  See the ChangeLog file for a list of changes to
00025 // id3lib.  These files are distributed with id3lib at
00026 // http://download.sourceforge.net/id3lib/
00027 
00028 #ifndef _ID3LIB_IO_HELPERS_H_
00029 #define _ID3LIB_IO_HELPERS_H_
00030 
00031 #include "id3/id3lib_strings.h"
00032 #include "reader.h"
00033 #include "writer.h"
00034 
00035 namespace dami
00036 {
00037   namespace io
00038   {
00041     class ID3_CPP_EXPORT ExitTrigger
00042     {
00043       ID3_Reader& _reader;
00044       ID3_Reader::pos_type _pos;
00045       bool _locked;
00046      public:
00047       ExitTrigger(ID3_Reader& rdr) 
00048         : _reader(rdr), _pos(rdr.getCur()), _locked(true)
00049       { ; }
00050       ExitTrigger(ID3_Reader& rdr, ID3_Reader::pos_type pos) 
00051         : _reader(rdr), _pos(pos) 
00052       { ; }
00053       virtual ~ExitTrigger() { if (_locked) _reader.setCur(_pos); }
00054     
00055       void release() { _locked = false; }
00056       void update() { _pos = _reader.getCur(); }
00057       void setExitPos(ID3_Reader::pos_type pos) { _pos = pos; }
00058     };
00059 
00060     ID3_C_EXPORT String      readString(ID3_Reader&);
00061     ID3_C_EXPORT String      readText(ID3_Reader&, size_t);
00062     ID3_C_EXPORT String      readUnicodeString(ID3_Reader&);
00063     ID3_C_EXPORT String      readUnicodeText(ID3_Reader&, size_t);
00064     ID3_C_EXPORT BString     readAllBinary(ID3_Reader&);
00065     ID3_C_EXPORT BString     readBinary(ID3_Reader&, size_t);
00066     ID3_C_EXPORT uint32      readLENumber(ID3_Reader&, size_t);
00067     ID3_C_EXPORT uint32      readBENumber(ID3_Reader&, size_t);
00068     ID3_C_EXPORT String      readTrailingSpaces(ID3_Reader&, size_t);
00069     ID3_C_EXPORT uint32      readUInt28(ID3_Reader&);
00070 
00071     ID3_C_EXPORT size_t      writeString(ID3_Writer&, String);
00072     ID3_C_EXPORT size_t      writeText(ID3_Writer&, String);
00073     ID3_C_EXPORT size_t      writeUnicodeString(ID3_Writer&, String, bool = true);
00074     ID3_C_EXPORT size_t      writeUnicodeText(ID3_Writer&, String, bool = true);
00075     ID3_C_EXPORT size_t      writeBENumber(ID3_Writer&, uint32 val, size_t);
00076     ID3_C_EXPORT size_t      writeTrailingSpaces(ID3_Writer&, String, size_t);
00077     ID3_C_EXPORT size_t      writeUInt28(ID3_Writer&, uint32);
00078   };
00079 };
00080 
00081 #endif /* _ID3LIB_IO_HELPERS_H_ */
00082