Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 2c9d30f3cf217a6cae41860ebc0d6704 > files > 169

libid3lib3.8_0-devel-3.8.0-0.pre2.1.1mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>include/id3/readers.h Source File</title>
<link href="id3lib.css" rel="stylesheet" type="text/css">
</head><body bgcolor="#ffffff">
<!-- Generated by Doxygen 1.2.12 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </center>
<hr><h1>include/id3/readers.h</h1><a href="readers_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">// -*- C++ -*-</font>
00002 <font class="comment">// $Id: readers.h,v 1.10 2001/08/26 23:33:23 dmazzoni Exp $</font>
00003 
00004 <font class="comment">// id3lib: a software library for creating and manipulating id3v1/v2 tags</font>
00005 <font class="comment">// Copyright 1999, 2000  Scott Thomas Haug</font>
00006 
00007 <font class="comment">// This library is free software; you can redistribute it and/or modify it</font>
00008 <font class="comment">// under the terms of the GNU Library General Public License as published by</font>
00009 <font class="comment">// the Free Software Foundation; either version 2 of the License, or (at your</font>
00010 <font class="comment">// option) any later version.</font>
00011 <font class="comment">//</font>
00012 <font class="comment">// This library is distributed in the hope that it will be useful, but WITHOUT</font>
00013 <font class="comment">// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or</font>
00014 <font class="comment">// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public</font>
00015 <font class="comment">// License for more details.</font>
00016 <font class="comment">//</font>
00017 <font class="comment">// You should have received a copy of the GNU Library General Public License</font>
00018 <font class="comment">// along with this library; if not, write to the Free Software Foundation,</font>
00019 <font class="comment">// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</font>
00020 
00021 <font class="comment">// The id3lib authors encourage improvements and optimisations to be sent to</font>
00022 <font class="comment">// the id3lib coordinator.  Please see the README file for details on where to</font>
00023 <font class="comment">// send such submissions.  See the AUTHORS file for a list of people who have</font>
00024 <font class="comment">// contributed to id3lib.  See the ChangeLog file for a list of changes to</font>
00025 <font class="comment">// id3lib.  These files are distributed with id3lib at</font>
00026 <font class="comment">// http://download.sourceforge.net/id3lib/</font>
00027 
00028 <font class="preprocessor">#ifndef _ID3LIB_READERS_H_</font>
00029 <font class="preprocessor"></font><font class="preprocessor">#define _ID3LIB_READERS_H_</font>
00030 <font class="preprocessor"></font>
00031 <font class="preprocessor">#include &lt;fstream.h&gt;</font>
00032 <font class="preprocessor">#include &lt;iostream.h&gt;</font>
00033 <font class="preprocessor">#include &lt;<a class="code" href="reader_8h.html">id3/reader.h</a>&gt;</font>
00034 
<a name="l00035"></a><a class="code" href="class_i_d3___i_stream_reader.html">00035</a> <font class="keyword">class </font><a class="code" href="globals_8h.html#a1">ID3_CPP_EXPORT</a> <a class="code" href="class_i_d3___i_stream_reader.html">ID3_IStreamReader</a> : <font class="keyword">public</font> <a class="code" href="class_i_d3___reader.html">ID3_Reader</a>
00036 {
00037   istream&amp; _stream;
00038  <font class="keyword">protected</font>:
<a name="l00039"></a><a class="code" href="class_i_d3___i_stream_reader.html#b0">00039</a>   istream&amp; getReader()<font class="keyword"> const </font>{ <font class="keywordflow">return</font> _stream; }
00040  <font class="keyword">public</font>:
<a name="l00041"></a><a class="code" href="class_i_d3___i_stream_reader.html#a0">00041</a>   <a class="code" href="class_i_d3___i_stream_reader.html">ID3_IStreamReader</a>(istream&amp; reader) : _stream(reader) { ; }
<a name="l00042"></a><a class="code" href="class_i_d3___i_stream_reader.html#a1">00042</a>   <font class="keyword">virtual</font> ~<a class="code" href="class_i_d3___i_stream_reader.html">ID3_IStreamReader</a>() { ; }
<a name="l00043"></a><a class="code" href="class_i_d3___i_stream_reader.html#a2">00043</a>   <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="class_i_d3___reader.html#a0">close</a>() { ; }
00044   
<a name="l00045"></a><a class="code" href="class_i_d3___i_stream_reader.html#a3">00045</a>   <font class="keyword">virtual</font> int_type <a class="code" href="class_i_d3___reader.html#a6">peekChar</a>() { <font class="keywordflow">return</font> _stream.peek(); }
00046     
<a name="l00050"></a><a class="code" href="class_i_d3___i_stream_reader.html#a4">00050</a>   <font class="keyword">virtual</font> size_type <a class="code" href="class_i_d3___reader.html#a7">readChars</a>(<font class="keywordtype">char</font> buf[], size_type len)
00051   {
00052     <font class="keywordflow">return</font> this-&gt;<a class="code" href="class_i_d3___reader.html#a7">readChars</a>(reinterpret_cast&lt;uchar *&gt;(buf), len);
00053   }
<a name="l00054"></a><a class="code" href="class_i_d3___i_stream_reader.html#a5">00054</a>   <font class="keyword">virtual</font> size_type <a class="code" href="class_i_d3___reader.html#a7">readChars</a>(char_type buf[], size_type len)
00055   {
00056     _stream.read((<font class="keywordtype">char</font> *)buf, len);
00057     <font class="keywordflow">return</font> _stream.gcount();
00058   }
00059 
<a name="l00060"></a><a class="code" href="class_i_d3___i_stream_reader.html#a6">00060</a>   <font class="keyword">virtual</font> pos_type <a class="code" href="class_i_d3___reader.html#a1">getBeg</a>() { <font class="keywordflow">return</font> 0; }
<a name="l00061"></a><a class="code" href="class_i_d3___i_stream_reader.html#a7">00061</a>   <font class="keyword">virtual</font> pos_type <a class="code" href="class_i_d3___reader.html#a3">getCur</a>() { <font class="keywordflow">return</font> _stream.tellg(); }
<a name="l00062"></a><a class="code" href="class_i_d3___i_stream_reader.html#a8">00062</a>   <font class="keyword">virtual</font> pos_type <a class="code" href="class_i_d3___reader.html#a2">getEnd</a>() 
00063   { 
00064     pos_type cur = this-&gt;<a class="code" href="class_i_d3___reader.html#a3">getCur</a>();
00065     _stream.seekg(0, ios::end);
00066     pos_type end = this-&gt;<a class="code" href="class_i_d3___reader.html#a3">getCur</a>();
00067     this-&gt;<a class="code" href="class_i_d3___reader.html#a4">setCur</a>(cur);
00068     <font class="keywordflow">return</font> end;
00069   }
00070     
<a name="l00073"></a><a class="code" href="class_i_d3___i_stream_reader.html#a9">00073</a>   <font class="keyword">virtual</font> pos_type <a class="code" href="class_i_d3___reader.html#a4">setCur</a>(pos_type pos) { _stream.seekg(pos); <font class="keywordflow">return</font> pos; }
00074 };
00075   
<a name="l00076"></a><a class="code" href="class_i_d3___i_f_stream_reader.html">00076</a> <font class="keyword">class </font><a class="code" href="globals_8h.html#a1">ID3_CPP_EXPORT</a> ID3_IFStreamReader : <font class="keyword">public</font> <a class="code" href="class_i_d3___i_stream_reader.html">ID3_IStreamReader</a>
00077 {
00078   ifstream&amp; _file;
00079  <font class="keyword">public</font>:
<a name="l00080"></a><a class="code" href="class_i_d3___i_f_stream_reader.html#a0">00080</a>   ID3_IFStreamReader(ifstream&amp; reader)
00081     : <a class="code" href="class_i_d3___i_stream_reader.html">ID3_IStreamReader</a>(reader), _file(reader) { ; }
00082     
<a name="l00083"></a><a class="code" href="class_i_d3___i_f_stream_reader.html#a1">00083</a>   <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="class_i_d3___i_stream_reader.html#a2">close</a>() 
00084   { 
00085     _file.close();
00086   }
00087 };
00088   
<a name="l00089"></a><a class="code" href="class_i_d3___memory_reader.html">00089</a> <font class="keyword">class </font><a class="code" href="globals_8h.html#a1">ID3_CPP_EXPORT</a> ID3_MemoryReader : <font class="keyword">public</font> <a class="code" href="class_i_d3___reader.html">ID3_Reader</a>
00090 {
00091   <font class="keyword">const</font> char_type* _beg;
00092   <font class="keyword">const</font> char_type* _cur;
00093   <font class="keyword">const</font> char_type* _end;
00094  <font class="keyword">protected</font>:
<a name="l00095"></a><a class="code" href="class_i_d3___memory_reader.html#b0">00095</a>   <font class="keywordtype">void</font> setBuffer(<font class="keyword">const</font> char_type* buf, size_type size)
00096   {
00097     _beg = buf;
00098     _cur = buf;
00099     _end = buf + size;
00100   };
00101  <font class="keyword">public</font>:
<a name="l00102"></a><a class="code" href="class_i_d3___memory_reader.html#a0">00102</a>   ID3_MemoryReader()
00103   {
00104     this-&gt;setBuffer(<a class="code" href="globals_8h.html#a24">NULL</a>, 0);
00105   }
<a name="l00106"></a><a class="code" href="class_i_d3___memory_reader.html#a1">00106</a>   ID3_MemoryReader(<font class="keyword">const</font> char_type* buf, size_type size)
00107   {
00108     this-&gt;setBuffer(buf, size);
00109   };
<a name="l00110"></a><a class="code" href="class_i_d3___memory_reader.html#a2">00110</a>   ID3_MemoryReader(<font class="keyword">const</font> <font class="keywordtype">char</font>* buf, size_type size)
00111   {
00112     this-&gt;setBuffer(reinterpret_cast&lt;const char_type*&gt;(buf), size);
00113   };
<a name="l00114"></a><a class="code" href="class_i_d3___memory_reader.html#a3">00114</a>   <font class="keyword">virtual</font> ~ID3_MemoryReader() { ; }
<a name="l00115"></a><a class="code" href="class_i_d3___memory_reader.html#a4">00115</a>   <font class="keyword">virtual</font> <font class="keywordtype">void</font> <a class="code" href="class_i_d3___reader.html#a0">close</a>() { ; }
00116     
<a name="l00117"></a><a class="code" href="class_i_d3___memory_reader.html#a5">00117</a>   <font class="keyword">virtual</font> int_type <a class="code" href="class_i_d3___reader.html#a6">peekChar</a>() 
00118   { 
00119     <font class="keywordflow">if</font> (!this-&gt;<a class="code" href="class_i_d3___reader.html#a11">atEnd</a>())
00120     {
00121       <font class="keywordflow">return</font> *_cur; 
00122     }
00123     <font class="keywordflow">return</font> END_OF_READER;
00124   }
00125     
<a name="l00129"></a><a class="code" href="class_i_d3___memory_reader.html#a6">00129</a>   <font class="keyword">virtual</font> size_type <a class="code" href="class_i_d3___reader.html#a7">readChars</a>(<font class="keywordtype">char</font> buf[], size_type len)
00130   {
00131     <font class="keywordflow">return</font> this-&gt;<a class="code" href="class_i_d3___reader.html#a7">readChars</a>(reinterpret_cast&lt;char_type *&gt;(buf), len);
00132   }
00133   <font class="keyword">virtual</font> size_type <a class="code" href="class_i_d3___reader.html#a7">readChars</a>(char_type buf[], size_type len);
00134     
<a name="l00135"></a><a class="code" href="class_i_d3___memory_reader.html#a8">00135</a>   <font class="keyword">virtual</font> pos_type <a class="code" href="class_i_d3___reader.html#a3">getCur</a>() 
00136   { 
00137     <font class="keywordflow">return</font> _cur - _beg; 
00138   }
00139     
<a name="l00140"></a><a class="code" href="class_i_d3___memory_reader.html#a9">00140</a>   <font class="keyword">virtual</font> pos_type <a class="code" href="class_i_d3___reader.html#a1">getBeg</a>()
00141   {
00142     <font class="keywordflow">return</font> _beg - _beg;
00143   }
00144     
<a name="l00145"></a><a class="code" href="class_i_d3___memory_reader.html#a10">00145</a>   <font class="keyword">virtual</font> pos_type <a class="code" href="class_i_d3___reader.html#a2">getEnd</a>()
00146   {
00147     <font class="keywordflow">return</font> _end - _beg;
00148   }
00149     
<a name="l00152"></a><a class="code" href="class_i_d3___memory_reader.html#a11">00152</a>   <font class="keyword">virtual</font> pos_type <a class="code" href="class_i_d3___reader.html#a4">setCur</a>(pos_type pos)
00153   {
00154     pos_type end = this-&gt;<a class="code" href="class_i_d3___reader.html#a2">getEnd</a>();
00155     size_type size = (pos &lt; end) ? pos : end;
00156     _cur = _beg + size;
00157     <font class="keywordflow">return</font> this-&gt;<a class="code" href="class_i_d3___reader.html#a3">getCur</a>();
00158   }
00159 };
00160 
00161 <font class="preprocessor">#endif </font><font class="comment">/* _ID3LIB_READERS_H_ */</font>
</pre></div><hr><address><small>Generated on Thu Jan 3 07:35:55 2002 for id3lib by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.gif" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.12 written by <a href="mailto:dimitri@stack.nl">Dimitri van Heesch</a>,
 &copy;&nbsp;1997-2001</small></address>
</body>
</html>