Sophie

Sophie

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

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>src/io_helpers.cpp 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>src/io_helpers.cpp</h1><a href="io__helpers_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">// $Id: io_helpers.cpp,v 1.8 2001/09/08 21:19:49 shadrack Exp $</font>
00002 
00003 <font class="comment">// id3lib: a C++ library for creating and manipulating id3v1/v2 tags</font>
00004 <font class="comment">// Copyright 1999, 2000  Scott Thomas Haug</font>
00005 
00006 <font class="comment">// This library is free software; you can redistribute it and/or modify it</font>
00007 <font class="comment">// under the terms of the GNU Library General Public License as published by</font>
00008 <font class="comment">// the Free Software Foundation; either version 2 of the License, or (at your</font>
00009 <font class="comment">// option) any later version.</font>
00010 <font class="comment">//</font>
00011 <font class="comment">// This library is distributed in the hope that it will be useful, but WITHOUT</font>
00012 <font class="comment">// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or</font>
00013 <font class="comment">// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public</font>
00014 <font class="comment">// License for more details.</font>
00015 <font class="comment">//</font>
00016 <font class="comment">// You should have received a copy of the GNU Library General Public License</font>
00017 <font class="comment">// along with this library; if not, write to the Free Software Foundation,</font>
00018 <font class="comment">// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</font>
00019 
00020 <font class="comment">// The id3lib authors encourage improvements and optimisations to be sent to</font>
00021 <font class="comment">// the id3lib coordinator.  Please see the README file for details on where to</font>
00022 <font class="comment">// send such submissions.  See the AUTHORS file for a list of people who have</font>
00023 <font class="comment">// contributed to id3lib.  See the ChangeLog file for a list of changes to</font>
00024 <font class="comment">// id3lib.  These files are distributed with id3lib at</font>
00025 <font class="comment">// http://download.sourceforge.net/id3lib/</font>
00026 
00027 <font class="preprocessor">#if defined HAVE_CONFIG_H</font>
00028 <font class="preprocessor"></font><font class="preprocessor">#include &lt;config.h&gt;</font>
00029 <font class="preprocessor">#endif</font>
00030 <font class="preprocessor"></font>
00031 
00032 
00033 <font class="preprocessor">#include "io_decorators.h"</font>
00034 <font class="preprocessor">#include "io_helpers.h"</font>
00035 <font class="preprocessor">#include "utils.h"</font>
00036 
00037 <font class="keyword">using</font> <font class="keyword">namespace </font>dami;
00038 
00039 String io::readString(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader)
00040 {
00041   String str;
00042   <font class="keywordflow">while</font> (!reader.<a class="code" href="class_i_d3___reader.html#a11">atEnd</a>())
00043   {
00044     <a class="code" href="class_i_d3___reader.html#s1">ID3_Reader::char_type</a> ch = reader.<a class="code" href="class_i_d3___reader.html#a5">readChar</a>();
00045     <font class="keywordflow">if</font> (ch == <font class="charliteral">'\0'</font>)
00046     {
00047       <font class="keywordflow">break</font>;
00048     }
00049     str += static_cast&lt;char&gt;(ch);
00050   }
00051   <font class="keywordflow">return</font> str;
00052 }
00053 
00054 String io::readText(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader, size_t len)
00055 {
00056   String str;
00057   str.reserve(len);
00058   <font class="keyword">const</font> size_t SIZE = 1024;
00059   <a class="code" href="class_i_d3___reader.html#s1">ID3_Reader::char_type</a> buf[SIZE];
00060   size_t remaining = len;
00061   <font class="keywordflow">while</font> (remaining &gt; 0 &amp;&amp; !reader.<a class="code" href="class_i_d3___reader.html#a11">atEnd</a>())
00062   {
00063     size_t numRead = reader.<a class="code" href="class_i_d3___reader.html#a7">readChars</a>(buf, min(remaining, SIZE));
00064     remaining -= numRead;
00065     str.append(reinterpret_cast&lt;String::value_type *&gt;(buf), numRead);
00066   }
00067   <font class="keywordflow">return</font> str;
00068 }
00069 
00070 <font class="keyword">namespace</font>
00071 <font class="keyword"></font>{
00072   <font class="keywordtype">bool</font> isNull(<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> ch1, <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> ch2)
00073   {
00074     <font class="keywordflow">return</font> ch1 == <font class="charliteral">'\0'</font> &amp;&amp; ch2 == <font class="charliteral">'\0'</font>;
00075   }
00076 
00077   <font class="keywordtype">int</font> isBOM(<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> ch1, <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> ch2)
00078   {
00079   <font class="comment">// The following is taken from the following URL:</font>
00080   <font class="comment">// http://community.roxen.com/developers/idocs/rfc/rfc2781.html</font>
00081   <font class="comment">/* The Unicode Standard and ISO 10646 define the character "ZERO WIDTH</font>
00082 <font class="comment">     NON-BREAKING SPACE" (0xFEFF), which is also known informally as</font>
00083 <font class="comment">     "BYTE ORDER MARK" (abbreviated "BOM"). The latter name hints at a</font>
00084 <font class="comment">     second possible usage of the character, in addition to its normal</font>
00085 <font class="comment">     use as a genuine "ZERO WIDTH NON-BREAKING SPACE" within text. This</font>
00086 <font class="comment">     usage, suggested by Unicode section 2.4 and ISO 10646 Annex F</font>
00087 <font class="comment">     (informative), is to prepend a 0xFEFF character to a stream of</font>
00088 <font class="comment">     Unicode characters as a "signature"; a receiver of such a serialized</font>
00089 <font class="comment">     stream may then use the initial character both as a hint that the</font>
00090 <font class="comment">     stream consists of Unicode characters and as a way to recognize the</font>
00091 <font class="comment">     serialization order. In serialized UTF-16 prepended with such a</font>
00092 <font class="comment">     signature, the order is big-endian if the first two octets are 0xFE</font>
00093 <font class="comment">     followed by 0xFF; if they are 0xFF followed by 0xFE, the order is</font>
00094 <font class="comment">     little-endian. Note that 0xFFFE is not a Unicode character,</font>
00095 <font class="comment">     precisely to preserve the usefulness of 0xFEFF as a byte-order</font>
00096 <font class="comment">     mark. */</font>
00097 
00098     <font class="keywordflow">if</font> (ch1 == 0xFE &amp;&amp; ch2 == 0xFF)
00099     {
00100       <font class="keywordflow">return</font> 1;
00101     }
00102     <font class="keywordflow">else</font> <font class="keywordflow">if</font> (ch1 == 0xFF &amp;&amp; ch2 == 0xFE)
00103     {
00104       <font class="keywordflow">return</font> -1;
00105     }
00106     <font class="keywordflow">return</font> 0;
00107   }
00108 
00109   <font class="keywordtype">bool</font> readTwoChars(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader, 
00110                     <a class="code" href="class_i_d3___reader.html#s1">ID3_Reader::char_type</a>&amp; ch1, 
00111                     <a class="code" href="class_i_d3___reader.html#s1">ID3_Reader::char_type</a>&amp; ch2)
00112   {
00113     <font class="keywordflow">if</font> (reader.<a class="code" href="class_i_d3___reader.html#a11">atEnd</a>())
00114     {
00115       <font class="keywordflow">return</font> <font class="keyword">false</font>;
00116     }
00117     io::ExitTrigger et(reader);
00118     ch1 = reader.<a class="code" href="class_i_d3___reader.html#a5">readChar</a>();
00119     <font class="keywordflow">if</font> (reader.<a class="code" href="class_i_d3___reader.html#a11">atEnd</a>())
00120     {
00121       <font class="keywordflow">return</font> <font class="keyword">false</font>;
00122     }
00123     et.release();
00124     ch2 = reader.<a class="code" href="class_i_d3___reader.html#a5">readChar</a>();
00125     <font class="keywordflow">return</font> <font class="keyword">true</font>;
00126   }
00127 }
00128 
00129 String io::readUnicodeString(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader)
00130 {
00131   String unicode;
00132   <a class="code" href="class_i_d3___reader.html#s1">ID3_Reader::char_type</a> ch1, ch2;
00133   <font class="keywordflow">if</font> (!readTwoChars(reader, ch1, ch2) || isNull(ch1, ch2))
00134   {
00135     <font class="keywordflow">return</font> unicode;
00136   }
00137   <font class="keywordtype">int</font> bom = isBOM(ch1, ch2);
00138   <font class="keywordflow">if</font> (!bom)
00139   {
00140     unicode += static_cast&lt;char&gt;(ch1);
00141     unicode += static_cast&lt;char&gt;(ch2);
00142   }
00143   <font class="keywordflow">while</font> (!reader.<a class="code" href="class_i_d3___reader.html#a11">atEnd</a>())
00144   {
00145     <font class="keywordflow">if</font> (!readTwoChars(reader, ch1, ch2) || isNull(ch1, ch2))
00146     {
00147       <font class="keywordflow">break</font>;
00148     }
00149     <font class="keywordflow">if</font> (bom == -1)
00150     {
00151       unicode += static_cast&lt;char&gt;(ch2);
00152       unicode += static_cast&lt;char&gt;(ch1);
00153     }
00154     <font class="keywordflow">else</font>
00155     {
00156       unicode += static_cast&lt;char&gt;(ch1);
00157       unicode += static_cast&lt;char&gt;(ch2);
00158     }
00159   }
00160   <font class="keywordflow">return</font> unicode;
00161 }
00162 
00163 String io::readUnicodeText(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader, size_t len)
00164 {
00165   String unicode;
00166   <a class="code" href="class_i_d3___reader.html#s1">ID3_Reader::char_type</a> ch1, ch2;
00167   <font class="keywordflow">if</font> (!readTwoChars(reader, ch1, ch2))
00168   {
00169     <font class="keywordflow">return</font> unicode;
00170   }
00171   len -= 2;
00172   <font class="keywordtype">int</font> bom = isBOM(ch1, ch2);
00173   <font class="keywordflow">if</font> (!bom)
00174   {
00175     unicode += ch1;
00176     unicode += ch2;
00177     unicode += readText(reader, len);
00178   }
00179   <font class="keywordflow">else</font> <font class="keywordflow">if</font> (bom == 1)
00180   {
00181     unicode = readText(reader, len);
00182   }
00183   <font class="keywordflow">else</font>
00184   {
00185     <font class="keywordflow">for</font> (<a class="code" href="globals_8h.html#a7">index_t</a> i = 0; i &lt; len; i += 2)
00186     {
00187       <font class="keywordflow">if</font> (!readTwoChars(reader, ch1, ch2))
00188       {
00189         <font class="keywordflow">break</font>;
00190       }
00191       unicode += ch2;
00192       unicode += ch1;
00193     }
00194   }
00195   <font class="keywordflow">return</font> unicode;
00196 }
00197 
00198 BString io::readAllBinary(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader)
00199 {
00200   <font class="keywordflow">return</font> readBinary(reader, reader.<a class="code" href="class_i_d3___reader.html#a10">remainingBytes</a>());
00201 }
00202 
00203 BString io::readBinary(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader, size_t len)
00204 {
00205   BString binary;
00206   binary.reserve(len);
00207   
00208   size_t remaining = len;
00209   <font class="keyword">const</font> size_t SIZE = 1024;
00210   <a class="code" href="class_i_d3___reader.html#s1">ID3_Reader::char_type</a> buf[SIZE];
00211   <font class="keywordflow">while</font> (!reader.<a class="code" href="class_i_d3___reader.html#a11">atEnd</a>() &amp;&amp; remaining &gt; 0)
00212   {
00213     size_t numRead = reader.<a class="code" href="class_i_d3___reader.html#a7">readChars</a>(buf, min(remaining, SIZE));
00214     remaining -= numRead;
00215     binary.append(reinterpret_cast&lt;BString::value_type *&gt;(buf), numRead);
00216   }
00217   
00218   <font class="keywordflow">return</font> binary;
00219 }
00220 
00221 <a class="code" href="sized__types_8h.html#a4">uint32</a> io::readLENumber(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader, size_t len)
00222 {
00223   <a class="code" href="sized__types_8h.html#a4">uint32</a> val = 0;
00224   <font class="keywordflow">for</font> (size_t i = 0; i &lt; len; i++)
00225   {
00226     <font class="keywordflow">if</font> (reader.<a class="code" href="class_i_d3___reader.html#a11">atEnd</a>())
00227     {
00228       <font class="keywordflow">break</font>;
00229     }
00230     val += (static_cast&lt;uint32&gt;(0xFF &amp; reader.<a class="code" href="class_i_d3___reader.html#a5">readChar</a>()) &lt;&lt; (i * 8));
00231   }
00232   <font class="keywordflow">return</font> val;
00233 }
00234 
00235 <a class="code" href="sized__types_8h.html#a4">uint32</a> io::readBENumber(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader, size_t len)
00236 {
00237   <a class="code" href="sized__types_8h.html#a4">uint32</a> val = 0;
00238   
00239   <font class="keywordflow">for</font> (<a class="code" href="class_i_d3___reader.html#s0">ID3_Reader::size_type</a> i = 0; i &lt; len &amp;&amp; !reader.<a class="code" href="class_i_d3___reader.html#a11">atEnd</a>(); ++i)
00240   {
00241     val *= 256; <font class="comment">// 2^8</font>
00242     val += static_cast&lt;uint32&gt;(0xFF &amp; reader.<a class="code" href="class_i_d3___reader.html#a5">readChar</a>());
00243   }
00244   <font class="keywordflow">return</font> val;
00245 }
00246 
00247 String io::readTrailingSpaces(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader, size_t len)
00248 {
00249   io::WindowedReader wr(reader, len);
00250   String str;
00251   String spaces;
00252   str.reserve(len);
00253   spaces.reserve(len);
00254   <font class="keywordflow">while</font> (!wr.atEnd())
00255   {
00256     <a class="code" href="class_i_d3___reader.html#s1">ID3_Reader::char_type</a> ch = wr.readChar();
00257     <font class="keywordflow">if</font> (ch == <font class="charliteral">'\0'</font> || ch == <font class="charliteral">' '</font>)
00258     {
00259       spaces += ch;
00260     }
00261     <font class="keywordflow">else</font>
00262     {
00263       str += spaces + (char) ch;
00264       spaces.erase();
00265     }
00266   }
00267   <font class="keywordflow">return</font> str;
00268 }
00269 
00270 <a class="code" href="sized__types_8h.html#a4">uint32</a> io::readUInt28(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader)
00271 {
00272   <a class="code" href="sized__types_8h.html#a4">uint32</a> val = 0;
00273   <font class="keyword">const</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> BITSUSED = 7;
00274   <font class="keyword">const</font> <a class="code" href="sized__types_8h.html#a4">uint32</a> MAXVAL = <a class="code" href="globals_8h.html#a11">MASK</a>(BITSUSED * <font class="keyword">sizeof</font>(<a class="code" href="sized__types_8h.html#a4">uint32</a>));
00275   <font class="comment">// For each byte of the first 4 bytes in the string...</font>
00276   <font class="keywordflow">for</font> (size_t i = 0; i &lt; <font class="keyword">sizeof</font>(uint32); ++i)
00277   {
00278     <font class="keywordflow">if</font> (reader.<a class="code" href="class_i_d3___reader.html#a11">atEnd</a>())
00279     {
00280       <font class="keywordflow">break</font>;
00281     }
00282     <font class="comment">// ...append the last 7 bits to the end of the temp integer...</font>
00283     val = (val &lt;&lt; BITSUSED) | static_cast&lt;uint32&gt;(reader.<a class="code" href="class_i_d3___reader.html#a5">readChar</a>()) &amp; <a class="code" href="globals_8h.html#a11">MASK</a>(BITSUSED);
00284   }
00285 
00286   <font class="comment">// We should always parse 4 characters</font>
00287   <font class="keywordflow">return</font> min(val, MAXVAL);
00288 }
00289 
00290 size_t io::writeBENumber(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer, <a class="code" href="sized__types_8h.html#a4">uint32</a> val, size_t len)
00291 {
00292   <a class="code" href="class_i_d3___writer.html#s1">ID3_Writer::char_type</a> bytes[<font class="keyword">sizeof</font>(uint32)];
00293   <a class="code" href="class_i_d3___writer.html#s0">ID3_Writer::size_type</a> size = min&lt;ID3_Reader::size_type&gt;(len, <font class="keyword">sizeof</font>(uint32));
00294   renderNumber(bytes, val, size);
00295   <font class="keywordflow">return</font> writer.<a class="code" href="class_i_d3___writer.html#a8">writeChars</a>(bytes, size);
00296 }
00297 
00298 size_t io::writeTrailingSpaces(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer, String buf, size_t len)
00299 {
00300   <a class="code" href="class_i_d3___writer.html#s2">ID3_Writer::pos_type</a> beg = writer.<a class="code" href="class_i_d3___writer.html#a4">getCur</a>();
00301   <a class="code" href="class_i_d3___writer.html#s0">ID3_Writer::size_type</a> strLen = buf.size();
00302   <a class="code" href="class_i_d3___writer.html#s0">ID3_Writer::size_type</a> size = min(len,strLen);
00303   writer.<a class="code" href="class_i_d3___writer.html#a8">writeChars</a>(buf.data(), size);
00304   <font class="keywordflow">for</font> (; size &lt; len; ++size)
00305   {
00306     writer.<a class="code" href="class_i_d3___writer.html#a7">writeChar</a>(<font class="charliteral">' '</font>);
00307   }
00308   <font class="keywordflow">return</font> writer.<a class="code" href="class_i_d3___writer.html#a4">getCur</a>() - beg;
00309 }
00310 
00311 size_t io::writeUInt28(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer, <a class="code" href="sized__types_8h.html#a4">uint32</a> val)
00312 {
00313   <a class="code" href="globals_8h.html#a33">uchar</a> data[<font class="keyword">sizeof</font>(uint32)];
00314   <font class="keyword">const</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> BITSUSED = 7;
00315   <font class="keyword">const</font> <a class="code" href="sized__types_8h.html#a4">uint32</a> MAXVAL = <a class="code" href="globals_8h.html#a11">MASK</a>(BITSUSED * <font class="keyword">sizeof</font>(<a class="code" href="sized__types_8h.html#a4">uint32</a>));
00316   val = min(val, MAXVAL);
00317   <font class="comment">// This loop renders the value to the character buffer in reverse order, as </font>
00318   <font class="comment">// it is easy to extract the last 7 bits of an integer.  This is why the</font>
00319   <font class="comment">// loop shifts the value of the integer by 7 bits for each iteration.</font>
00320   <font class="keywordflow">for</font> (size_t i = 0; i &lt; <font class="keyword">sizeof</font>(uint32); ++i)
00321   {
00322     <font class="comment">// Extract the last BITSUSED bits from val and put it in its appropriate</font>
00323     <font class="comment">// place in the data buffer</font>
00324     data[<font class="keyword">sizeof</font>(uint32) - i - 1] = static_cast&lt;uchar&gt;(val &amp; <a class="code" href="globals_8h.html#a11">MASK</a>(BITSUSED));
00325 
00326     <font class="comment">// The last BITSUSED bits were extracted from the val.  So shift it to the</font>
00327     <font class="comment">// right by that many bits for the next iteration</font>
00328     val &gt;&gt;= BITSUSED;
00329   }
00330   
00331   <font class="comment">// Should always render 4 bytes</font>
00332   <font class="keywordflow">return</font> writer.<a class="code" href="class_i_d3___writer.html#a8">writeChars</a>(data, <font class="keyword">sizeof</font>(<a class="code" href="sized__types_8h.html#a4">uint32</a>));
00333 }
00334 
00335 size_t io::writeString(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer, String data)
00336 {
00337   size_t size = writeText(writer, data);
00338   writer.<a class="code" href="class_i_d3___writer.html#a7">writeChar</a>(<font class="charliteral">'\0'</font>);
00339   <font class="keywordflow">return</font> size + 1;
00340 }
00341 
00342 size_t io::writeText(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer, String data)
00343 {
00344   <a class="code" href="class_i_d3___writer.html#s2">ID3_Writer::pos_type</a> beg = writer.<a class="code" href="class_i_d3___writer.html#a4">getCur</a>();
00345   writer.<a class="code" href="class_i_d3___writer.html#a8">writeChars</a>(data.data(), data.size());
00346   <font class="keywordflow">return</font> writer.<a class="code" href="class_i_d3___writer.html#a4">getCur</a>() - beg;
00347 }
00348 
00349 size_t io::writeUnicodeString(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer, String data, <font class="keywordtype">bool</font> bom)
00350 {
00351   size_t size = writeUnicodeText(writer, data, bom);
00352   <a class="code" href="globals_8h.html#a39">unicode_t</a> null = <a class="code" href="globals_8h.html#a8">NULL_UNICODE</a>;
00353   writer.<a class="code" href="class_i_d3___writer.html#a8">writeChars</a>((<font class="keyword">const</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>*) &amp;null, 2);
00354   <font class="keywordflow">return</font> size + 2;
00355 }
00356 
00357 size_t io::writeUnicodeText(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer, String data, <font class="keywordtype">bool</font> bom)
00358 {
00359   <a class="code" href="class_i_d3___writer.html#s2">ID3_Writer::pos_type</a> beg = writer.<a class="code" href="class_i_d3___writer.html#a4">getCur</a>();
00360   size_t size = (data.size() / 2) * 2;
00361   <font class="keywordflow">if</font> (size == 0)
00362   {
00363     <font class="keywordflow">return</font> 0;
00364   }
00365   <font class="keywordflow">if</font> (bom)
00366   {
00367     <font class="comment">// Write the BOM: 0xFEFF</font>
00368     <a class="code" href="globals_8h.html#a39">unicode_t</a> BOM = 0xFEFF;
00369     writer.<a class="code" href="class_i_d3___writer.html#a8">writeChars</a>((<font class="keyword">const</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>*) &amp;BOM, 2);
00370     <font class="keywordflow">for</font> (size_t i = 0; i &lt; size; i += 2)
00371     {
00372       <a class="code" href="globals_8h.html#a39">unicode_t</a> ch = (data[i] &lt;&lt; 8) | data[i+1];
00373       writer.<a class="code" href="class_i_d3___writer.html#a8">writeChars</a>((<font class="keyword">const</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>*) &amp;ch, 2);
00374     }
00375   }
00376   <font class="keywordflow">return</font> writer.<a class="code" href="class_i_d3___writer.html#a4">getCur</a>() - beg;
00377 }
</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>