Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-release > by-pkgid > 1b812d1b0e765bcc0430721ff58676d2 > files > 137

libid3_3.8_3-devel-3.8.3-19.mga1.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>id3lib: src/field_string_ascii.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="id3lib.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.3 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>src/field_string_ascii.cpp</h1><a href="field__string__ascii_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// $Id: field_string_ascii.cpp,v 1.29 2003/03/02 14:23:58 t1mpy Exp $</span>
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="comment">// id3lib: a C++ library for creating and manipulating id3v1/v2 tags</span>
<a name="l00004"></a>00004 <span class="comment">// Copyright 1999, 2000  Scott Thomas Haug</span>
<a name="l00005"></a>00005 
<a name="l00006"></a>00006 <span class="comment">// This library is free software; you can redistribute it and/or modify it</span>
<a name="l00007"></a>00007 <span class="comment">// under the terms of the GNU Library General Public License as published by</span>
<a name="l00008"></a>00008 <span class="comment">// the Free Software Foundation; either version 2 of the License, or (at your</span>
<a name="l00009"></a>00009 <span class="comment">// option) any later version.</span>
<a name="l00010"></a>00010 <span class="comment">//</span>
<a name="l00011"></a>00011 <span class="comment">// This library is distributed in the hope that it will be useful, but WITHOUT</span>
<a name="l00012"></a>00012 <span class="comment">// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or</span>
<a name="l00013"></a>00013 <span class="comment">// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public</span>
<a name="l00014"></a>00014 <span class="comment">// License for more details.</span>
<a name="l00015"></a>00015 <span class="comment">//</span>
<a name="l00016"></a>00016 <span class="comment">// You should have received a copy of the GNU Library General Public License</span>
<a name="l00017"></a>00017 <span class="comment">// along with this library; if not, write to the Free Software Foundation,</span>
<a name="l00018"></a>00018 <span class="comment">// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="comment">// The id3lib authors encourage improvements and optimisations to be sent to</span>
<a name="l00021"></a>00021 <span class="comment">// the id3lib coordinator.  Please see the README file for details on where to</span>
<a name="l00022"></a>00022 <span class="comment">// send such submissions.  See the AUTHORS file for a list of people who have</span>
<a name="l00023"></a>00023 <span class="comment">// contributed to id3lib.  See the ChangeLog file for a list of changes to</span>
<a name="l00024"></a>00024 <span class="comment">// id3lib.  These files are distributed with id3lib at</span>
<a name="l00025"></a>00025 <span class="comment">// http://download.sourceforge.net/id3lib/</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="preprocessor">#include &quot;<a class="code" href="field__impl_8h.html">field_impl.h</a>&quot;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &quot;id3/utils.h&quot;</span> <span class="comment">// has &lt;config.h&gt; &quot;id3/id3lib_streams.h&quot; &quot;id3/globals.h&quot; &quot;id3/id3lib_strings.h&quot;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &quot;<a class="code" href="io__helpers_8h.html">io_helpers.h</a>&quot;</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="keyword">using namespace </span>dami;
<a name="l00032"></a>00032 
<a name="l00045"></a><a class="code" href="class_i_d3___field_impl.html#af2d525110fda890ff94dd86d7806c23a">00045</a> <span class="keywordtype">size_t</span> <a class="code" href="class_i_d3___field_impl.html#a6daa86b940122734d9bee75d7b57d6cf" title="Sets the value of the field to the specified integer.">ID3_FieldImpl::Set</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* data)
<a name="l00046"></a>00046 {
<a name="l00047"></a>00047   <span class="keywordtype">size_t</span> len = 0;
<a name="l00048"></a>00048   <span class="keywordflow">if</span> ((this-&gt;<a class="code" href="class_i_d3___field_impl.html#a52bf3b506788dbfb3adad6af6c413b90">GetType</a>() == <a class="code" href="globals_8h.html#adc0ffe8cf70623e6d4d17092b20bdd6ba2ee1dd56f8581f7c930d8ae610d9fb55">ID3FTY_TEXTSTRING</a>) &amp;&amp; data)
<a name="l00049"></a>00049   {
<a name="l00050"></a>00050     String str(data);
<a name="l00051"></a>00051     len = this-&gt;SetText_i(str);
<a name="l00052"></a>00052   }
<a name="l00053"></a>00053   <span class="keywordflow">return</span> len;
<a name="l00054"></a>00054 }
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 <span class="comment">// the ::Get() function for ASCII</span>
<a name="l00057"></a>00057 
<a name="l00087"></a><a class="code" href="class_i_d3___field_impl.html#aff27e177c13c8e06120af2ef3f91e2f8">00087</a> <span class="keywordtype">size_t</span> <a class="code" href="class_i_d3___field_impl.html#ab0e321c609325a38f29bc279bfb7b2be" title="Returns the value of the integer field.">ID3_FieldImpl::Get</a>(<span class="keywordtype">char</span>* buffer, <span class="keywordtype">size_t</span> maxLength)<span class="keyword"> const</span>
<a name="l00088"></a>00088 <span class="keyword"></span>{
<a name="l00089"></a>00089   <span class="keywordtype">size_t</span> size = 0;
<a name="l00090"></a>00090   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___field_impl.html#a52bf3b506788dbfb3adad6af6c413b90">GetType</a>() == <a class="code" href="globals_8h.html#adc0ffe8cf70623e6d4d17092b20bdd6ba2ee1dd56f8581f7c930d8ae610d9fb55">ID3FTY_TEXTSTRING</a> &amp;&amp;
<a name="l00091"></a>00091       this-&gt;<a class="code" href="class_i_d3___field_impl.html#a3c56d7c248d7e5c5e4fd210ea8ec1ee6">GetEncoding</a>() == <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39aad49ff1fa495df3aaca00c18a3302ea9">ID3TE_ASCII</a> &amp;&amp;
<a name="l00092"></a>00092       buffer != <a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> &amp;&amp; maxLength &gt; 0)
<a name="l00093"></a>00093   {
<a name="l00094"></a>00094     String data = this-&gt;<a class="code" href="class_i_d3___field_impl.html#a85436947f2a3e8c06eed4523de0a263f">GetText</a>();
<a name="l00095"></a>00095     size = <a class="code" href="io__strings_8h.html#ac6afabdc09a49a433ee19d8a9486056d">dami::min</a>(maxLength, data.size());
<a name="l00096"></a>00096     ::memcpy(buffer, data.data(), size);
<a name="l00097"></a>00097     <span class="keywordflow">if</span> (size &lt; maxLength)
<a name="l00098"></a>00098     {
<a name="l00099"></a>00099       buffer[size] = <span class="charliteral">&#39;\0&#39;</span>;
<a name="l00100"></a>00100     }
<a name="l00101"></a>00101   }
<a name="l00102"></a>00102 
<a name="l00103"></a>00103   <span class="keywordflow">return</span> size;
<a name="l00104"></a>00104 }
<a name="l00105"></a>00105 
<a name="l00106"></a><a class="code" href="class_i_d3___field_impl.html#a0bd3e89ee529f3b35e0591b7f31142ef">00106</a> <span class="keywordtype">size_t</span> <a class="code" href="class_i_d3___field_impl.html#ab0e321c609325a38f29bc279bfb7b2be" title="Returns the value of the integer field.">ID3_FieldImpl::Get</a>(<span class="keywordtype">char</span>* buf, <span class="keywordtype">size_t</span> maxLen, <span class="keywordtype">size_t</span> index)<span class="keyword"> const</span>
<a name="l00107"></a>00107 <span class="keyword"></span>{
<a name="l00108"></a>00108   <span class="keywordtype">size_t</span> size = 0;
<a name="l00109"></a>00109   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___field_impl.html#a52bf3b506788dbfb3adad6af6c413b90">GetType</a>() == <a class="code" href="globals_8h.html#adc0ffe8cf70623e6d4d17092b20bdd6ba2ee1dd56f8581f7c930d8ae610d9fb55">ID3FTY_TEXTSTRING</a> &amp;&amp;
<a name="l00110"></a>00110       this-&gt;<a class="code" href="class_i_d3___field_impl.html#a3c56d7c248d7e5c5e4fd210ea8ec1ee6">GetEncoding</a>() == <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39aad49ff1fa495df3aaca00c18a3302ea9">ID3TE_ASCII</a> &amp;&amp;
<a name="l00111"></a>00111       buf != <a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> &amp;&amp; maxLen &gt; 0)
<a name="l00112"></a>00112   {
<a name="l00113"></a>00113     String data = this-&gt;<a class="code" href="class_i_d3___field_impl.html#a074a470458de12775b368c00387fe689">GetTextItem</a>(index);
<a name="l00114"></a>00114     size = <a class="code" href="io__strings_8h.html#ac6afabdc09a49a433ee19d8a9486056d">dami::min</a>(maxLen, data.size());
<a name="l00115"></a>00115     ::memcpy(buf, data.data(), size);
<a name="l00116"></a>00116     <span class="keywordflow">if</span> (size &lt; maxLen)
<a name="l00117"></a>00117     {
<a name="l00118"></a>00118       buf[size] = <span class="charliteral">&#39;\0&#39;</span>;
<a name="l00119"></a>00119     }
<a name="l00120"></a>00120   }
<a name="l00121"></a>00121   <span class="keywordflow">return</span> size;
<a name="l00122"></a>00122 }
<a name="l00123"></a>00123 
<a name="l00124"></a><a class="code" href="class_i_d3___field_impl.html#a85436947f2a3e8c06eed4523de0a263f">00124</a> String <a class="code" href="class_i_d3___field_impl.html#a85436947f2a3e8c06eed4523de0a263f">ID3_FieldImpl::GetText</a>()<span class="keyword"> const</span>
<a name="l00125"></a>00125 <span class="keyword"></span>{
<a name="l00126"></a>00126   String data;
<a name="l00127"></a>00127   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___field_impl.html#a52bf3b506788dbfb3adad6af6c413b90">GetType</a>() == <a class="code" href="globals_8h.html#adc0ffe8cf70623e6d4d17092b20bdd6ba2ee1dd56f8581f7c930d8ae610d9fb55">ID3FTY_TEXTSTRING</a>)
<a name="l00128"></a>00128   {
<a name="l00129"></a>00129     data = _text;
<a name="l00130"></a>00130   }
<a name="l00131"></a>00131   <span class="keywordflow">return</span> data;
<a name="l00132"></a>00132 }
<a name="l00133"></a>00133 
<a name="l00134"></a><a class="code" href="class_i_d3___field_impl.html#a074a470458de12775b368c00387fe689">00134</a> String <a class="code" href="class_i_d3___field_impl.html#a074a470458de12775b368c00387fe689">ID3_FieldImpl::GetTextItem</a>(<span class="keywordtype">size_t</span> index)<span class="keyword"> const</span>
<a name="l00135"></a>00135 <span class="keyword"></span>{
<a name="l00136"></a>00136   String data;
<a name="l00137"></a>00137   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___field_impl.html#a52bf3b506788dbfb3adad6af6c413b90">GetType</a>() == <a class="code" href="globals_8h.html#adc0ffe8cf70623e6d4d17092b20bdd6ba2ee1dd56f8581f7c930d8ae610d9fb55">ID3FTY_TEXTSTRING</a> &amp;&amp;
<a name="l00138"></a>00138       this-&gt;<a class="code" href="class_i_d3___field_impl.html#a3c56d7c248d7e5c5e4fd210ea8ec1ee6">GetEncoding</a>() == <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39aad49ff1fa495df3aaca00c18a3302ea9">ID3TE_ASCII</a>)
<a name="l00139"></a>00139   {
<a name="l00140"></a>00140     <span class="keyword">const</span> <span class="keywordtype">char</span>* raw = this-&gt;<a class="code" href="class_i_d3___field_impl.html#ac8c4f35492f4f4fd9845657368a14544">GetRawTextItem</a>(index);
<a name="l00141"></a>00141     <span class="keywordflow">if</span> (raw != <a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>)
<a name="l00142"></a>00142     {
<a name="l00143"></a>00143       data = raw;
<a name="l00144"></a>00144     }
<a name="l00145"></a>00145   }
<a name="l00146"></a>00146   <span class="keywordflow">return</span> data;
<a name="l00147"></a>00147 }
<a name="l00148"></a>00148 
<a name="l00149"></a>00149 <span class="keyword">namespace</span>
<a name="l00150"></a>00150 {
<a name="l00151"></a>00151   String getFixed(String data, <span class="keywordtype">size_t</span> size)
<a name="l00152"></a>00152   {
<a name="l00153"></a>00153     String text(data, 0, size);
<a name="l00154"></a>00154     <span class="keywordflow">if</span> (text.size() &lt; size)
<a name="l00155"></a>00155     {
<a name="l00156"></a>00156       text.append(size - text.size(), <span class="charliteral">&#39;\0&#39;</span>);
<a name="l00157"></a>00157     }
<a name="l00158"></a>00158     <span class="keywordflow">return</span> text;
<a name="l00159"></a>00159   }
<a name="l00160"></a>00160 }
<a name="l00161"></a>00161 
<a name="l00162"></a>00162 
<a name="l00163"></a>00163 <span class="keywordtype">size_t</span> ID3_FieldImpl::SetText_i(String data)
<a name="l00164"></a>00164 {
<a name="l00165"></a>00165   this-&gt;<a class="code" href="class_i_d3___field_impl.html#a70599ecbe8fc8a4a55c348a15bcb3928" title="Clears any data and frees any memory associated with the field.">Clear</a>();
<a name="l00166"></a>00166   <span class="keywordflow">if</span> (_fixed_size &gt; 0)
<a name="l00167"></a>00167   {
<a name="l00168"></a>00168     _text = getFixed(data, _fixed_size);
<a name="l00169"></a>00169   }
<a name="l00170"></a>00170   <span class="keywordflow">else</span>
<a name="l00171"></a>00171   {
<a name="l00172"></a>00172     _text = data;
<a name="l00173"></a>00173   }
<a name="l00174"></a>00174   ID3D_NOTICE( <span class="stringliteral">&quot;SetText_i: text = \&quot;&quot;</span> &lt;&lt; _text &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span> );
<a name="l00175"></a>00175   _changed = <span class="keyword">true</span>;
<a name="l00176"></a>00176 
<a name="l00177"></a>00177   <span class="keywordflow">if</span> (_text.size() == 0)
<a name="l00178"></a>00178   {
<a name="l00179"></a>00179     _num_items = 0;
<a name="l00180"></a>00180   }
<a name="l00181"></a>00181   <span class="keywordflow">else</span>
<a name="l00182"></a>00182   {
<a name="l00183"></a>00183     _num_items = 1;
<a name="l00184"></a>00184   }
<a name="l00185"></a>00185 
<a name="l00186"></a>00186   <span class="keywordflow">return</span> _text.size();
<a name="l00187"></a>00187 }
<a name="l00188"></a>00188 
<a name="l00189"></a>00189 <span class="keywordtype">size_t</span> <a class="code" href="class_i_d3___field_impl.html#a2f4d15e7925cfa0120cbc4499ca2b3d7">ID3_FieldImpl::SetText</a>(String data)
<a name="l00190"></a>00190 {
<a name="l00191"></a>00191   <span class="keywordtype">size_t</span> len = 0;
<a name="l00192"></a>00192   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___field_impl.html#a52bf3b506788dbfb3adad6af6c413b90">GetType</a>() == <a class="code" href="globals_8h.html#adc0ffe8cf70623e6d4d17092b20bdd6ba2ee1dd56f8581f7c930d8ae610d9fb55">ID3FTY_TEXTSTRING</a>)
<a name="l00193"></a>00193   {
<a name="l00194"></a>00194     len = this-&gt;SetText_i(data);
<a name="l00195"></a>00195   }
<a name="l00196"></a>00196   <span class="keywordflow">return</span> len;
<a name="l00197"></a>00197 }
<a name="l00198"></a>00198 
<a name="l00199"></a>00199 
<a name="l00213"></a>00213 <span class="keywordtype">size_t</span> ID3_FieldImpl::AddText_i(String data)
<a name="l00214"></a>00214 {
<a name="l00215"></a>00215   <span class="keywordtype">size_t</span> len = 0;  <span class="comment">// how much of str we copied into this field (max is strLen)</span>
<a name="l00216"></a>00216   ID3D_NOTICE (<span class="stringliteral">&quot;ID3_FieldImpl::AddText_i: Adding \&quot;&quot;</span> &lt;&lt; data &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span> );
<a name="l00217"></a>00217   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___field_impl.html#a0232e29cabdf6761a033216e3ce580cd" title="Returns the number of items in a text list.">GetNumTextItems</a>() == 0)
<a name="l00218"></a>00218   {
<a name="l00219"></a>00219     <span class="comment">// there aren&#39;t any text items in the field so just assign the string to</span>
<a name="l00220"></a>00220     <span class="comment">// the field</span>
<a name="l00221"></a>00221     len = this-&gt;SetText_i(data);
<a name="l00222"></a>00222   }
<a name="l00223"></a>00223   <span class="keywordflow">else</span>
<a name="l00224"></a>00224   {
<a name="l00225"></a>00225 
<a name="l00226"></a>00226     <span class="comment">// ASSERT(_fixed_size == 0)</span>
<a name="l00227"></a>00227     _text += <span class="charliteral">&#39;\0&#39;</span>;
<a name="l00228"></a>00228     <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___field_impl.html#a3c56d7c248d7e5c5e4fd210ea8ec1ee6">GetEncoding</a>() == <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39ac5345a1533e33f6d71840f30e83e0d02">ID3TE_UNICODE</a>)
<a name="l00229"></a>00229     {
<a name="l00230"></a>00230       _text += <span class="charliteral">&#39;\0&#39;</span>;
<a name="l00231"></a>00231     }
<a name="l00232"></a>00232     _text.append(data);
<a name="l00233"></a>00233     len = data.size();
<a name="l00234"></a>00234     _num_items++;
<a name="l00235"></a>00235   }
<a name="l00236"></a>00236 
<a name="l00237"></a>00237   <span class="keywordflow">return</span> len;
<a name="l00238"></a>00238 }
<a name="l00239"></a>00239 
<a name="l00240"></a>00240 <span class="keywordtype">size_t</span> <a class="code" href="class_i_d3___field_impl.html#a6191197ca2261034d68867636574b89a">ID3_FieldImpl::AddText</a>(String data)
<a name="l00241"></a>00241 {
<a name="l00242"></a>00242   <span class="keywordtype">size_t</span> len = 0;
<a name="l00243"></a>00243   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___field_impl.html#a52bf3b506788dbfb3adad6af6c413b90">GetType</a>() == <a class="code" href="globals_8h.html#adc0ffe8cf70623e6d4d17092b20bdd6ba2ee1dd56f8581f7c930d8ae610d9fb55">ID3FTY_TEXTSTRING</a>)
<a name="l00244"></a>00244   {
<a name="l00245"></a>00245     len = this-&gt;AddText_i(data);
<a name="l00246"></a>00246   }
<a name="l00247"></a>00247   <span class="keywordflow">return</span> len;
<a name="l00248"></a>00248 }
<a name="l00249"></a>00249 
<a name="l00250"></a><a class="code" href="class_i_d3___field_impl.html#a0493b19b836899394d02839bd14d1e28">00250</a> <span class="keywordtype">size_t</span> <a class="code" href="class_i_d3___field_impl.html#a0493b19b836899394d02839bd14d1e28">ID3_FieldImpl::Add</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* data)
<a name="l00251"></a>00251 {
<a name="l00252"></a>00252   <span class="keywordtype">size_t</span> len = 0;
<a name="l00253"></a>00253   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___field_impl.html#a52bf3b506788dbfb3adad6af6c413b90">GetType</a>() == <a class="code" href="globals_8h.html#adc0ffe8cf70623e6d4d17092b20bdd6ba2ee1dd56f8581f7c930d8ae610d9fb55">ID3FTY_TEXTSTRING</a>)
<a name="l00254"></a>00254   {
<a name="l00255"></a>00255     String str(data);
<a name="l00256"></a>00256     len = this-&gt;AddText_i(str);
<a name="l00257"></a>00257   }
<a name="l00258"></a>00258   <span class="keywordflow">return</span> len;
<a name="l00259"></a>00259 }
<a name="l00260"></a>00260 
<a name="l00261"></a><a class="code" href="class_i_d3___field_impl.html#a919d4edfb70125f3b17b2708dde10ba9">00261</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="class_i_d3___field_impl.html#a919d4edfb70125f3b17b2708dde10ba9">ID3_FieldImpl::GetRawText</a>()<span class="keyword"> const</span>
<a name="l00262"></a>00262 <span class="keyword"></span>{
<a name="l00263"></a>00263   <span class="keyword">const</span> <span class="keywordtype">char</span>* text = <a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00264"></a>00264   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___field_impl.html#a52bf3b506788dbfb3adad6af6c413b90">GetType</a>() == <a class="code" href="globals_8h.html#adc0ffe8cf70623e6d4d17092b20bdd6ba2ee1dd56f8581f7c930d8ae610d9fb55">ID3FTY_TEXTSTRING</a> &amp;&amp;
<a name="l00265"></a>00265       this-&gt;<a class="code" href="class_i_d3___field_impl.html#a3c56d7c248d7e5c5e4fd210ea8ec1ee6">GetEncoding</a>() == <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39aad49ff1fa495df3aaca00c18a3302ea9">ID3TE_ASCII</a>)
<a name="l00266"></a>00266   {
<a name="l00267"></a>00267     text = _text.c_str();
<a name="l00268"></a>00268   }
<a name="l00269"></a>00269   <span class="keywordflow">return</span> text;
<a name="l00270"></a>00270 }
<a name="l00271"></a>00271 
<a name="l00272"></a><a class="code" href="class_i_d3___field_impl.html#ac8c4f35492f4f4fd9845657368a14544">00272</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="class_i_d3___field_impl.html#ac8c4f35492f4f4fd9845657368a14544">ID3_FieldImpl::GetRawTextItem</a>(<span class="keywordtype">size_t</span> index)<span class="keyword"> const</span>
<a name="l00273"></a>00273 <span class="keyword"></span>{
<a name="l00274"></a>00274   <span class="keyword">const</span> <span class="keywordtype">char</span>* text = <a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00275"></a>00275   <span class="keywordflow">if</span> (this-&gt;<a class="code" href="class_i_d3___field_impl.html#a52bf3b506788dbfb3adad6af6c413b90">GetType</a>() == <a class="code" href="globals_8h.html#adc0ffe8cf70623e6d4d17092b20bdd6ba2ee1dd56f8581f7c930d8ae610d9fb55">ID3FTY_TEXTSTRING</a> &amp;&amp;
<a name="l00276"></a>00276       this-&gt;<a class="code" href="class_i_d3___field_impl.html#a3c56d7c248d7e5c5e4fd210ea8ec1ee6">GetEncoding</a>() == <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39aad49ff1fa495df3aaca00c18a3302ea9">ID3TE_ASCII</a> &amp;&amp;
<a name="l00277"></a>00277       index &lt; this-&gt;<a class="code" href="class_i_d3___field_impl.html#a0232e29cabdf6761a033216e3ce580cd" title="Returns the number of items in a text list.">GetNumTextItems</a>())
<a name="l00278"></a>00278   {
<a name="l00279"></a>00279     text = _text.c_str();
<a name="l00280"></a>00280     <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; index; ++i)
<a name="l00281"></a>00281     {
<a name="l00282"></a>00282       text += strlen(text) + 1;
<a name="l00283"></a>00283     }
<a name="l00284"></a>00284   }
<a name="l00285"></a>00285   <span class="keywordflow">return</span> text;
<a name="l00286"></a>00286 }
<a name="l00287"></a>00287 
<a name="l00288"></a>00288 <span class="keyword">namespace</span>
<a name="l00289"></a>00289 {
<a name="l00290"></a>00290   String readEncodedText(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader, <span class="keywordtype">size_t</span> len, <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39" title="Enumeration of the types of text encodings: ascii or unicode.">ID3_TextEnc</a> enc)
<a name="l00291"></a>00291   {
<a name="l00292"></a>00292     <span class="keywordflow">if</span> (enc == <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39aad49ff1fa495df3aaca00c18a3302ea9">ID3TE_ASCII</a>)
<a name="l00293"></a>00293     {
<a name="l00294"></a>00294       <span class="keywordflow">return</span> <a class="code" href="namespacedami_1_1io.html#a6a5f04ebd2a255b1e4b6fe8dca8f6b4c">io::readText</a>(reader, len);
<a name="l00295"></a>00295     }
<a name="l00296"></a>00296     <span class="keywordflow">return</span> <a class="code" href="namespacedami_1_1io.html#acfb2361ea58790054d50b9b29491e5f0">io::readUnicodeText</a>(reader, len);
<a name="l00297"></a>00297   }
<a name="l00298"></a>00298 
<a name="l00299"></a>00299   String readEncodedString(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader, <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39" title="Enumeration of the types of text encodings: ascii or unicode.">ID3_TextEnc</a> enc)
<a name="l00300"></a>00300   {
<a name="l00301"></a>00301     <span class="keywordflow">if</span> (enc == <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39aad49ff1fa495df3aaca00c18a3302ea9">ID3TE_ASCII</a>)
<a name="l00302"></a>00302     {
<a name="l00303"></a>00303       <span class="keywordflow">return</span> <a class="code" href="namespacedami_1_1io.html#a85756229971b914c312adaacb48d9772">io::readString</a>(reader);
<a name="l00304"></a>00304     }
<a name="l00305"></a>00305     <span class="keywordflow">return</span> <a class="code" href="namespacedami_1_1io.html#a6d39a66d892d7ca34bd3e2f41c17f674">io::readUnicodeString</a>(reader);
<a name="l00306"></a>00306   }
<a name="l00307"></a>00307 
<a name="l00308"></a>00308   <span class="keywordtype">size_t</span> writeEncodedText(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer, String data, <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39" title="Enumeration of the types of text encodings: ascii or unicode.">ID3_TextEnc</a> enc)
<a name="l00309"></a>00309   {
<a name="l00310"></a>00310     <span class="keywordflow">if</span> (enc == <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39aad49ff1fa495df3aaca00c18a3302ea9">ID3TE_ASCII</a>)
<a name="l00311"></a>00311     {
<a name="l00312"></a>00312       <span class="keywordflow">return</span> <a class="code" href="namespacedami_1_1io.html#a82a7316211b308abcb2022cbacc2db75">io::writeText</a>(writer, data);
<a name="l00313"></a>00313     }
<a name="l00314"></a>00314     <span class="keywordflow">return</span> <a class="code" href="namespacedami_1_1io.html#ae5dd27dc8370c88796cdc9b21eb27f62">io::writeUnicodeText</a>(writer, data);
<a name="l00315"></a>00315   }
<a name="l00316"></a>00316 
<a name="l00317"></a>00317   <span class="keywordtype">size_t</span> writeEncodedString(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer, String data, <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39" title="Enumeration of the types of text encodings: ascii or unicode.">ID3_TextEnc</a> enc)
<a name="l00318"></a>00318   {
<a name="l00319"></a>00319     <span class="keywordflow">if</span> (enc == <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39aad49ff1fa495df3aaca00c18a3302ea9">ID3TE_ASCII</a>)
<a name="l00320"></a>00320     {
<a name="l00321"></a>00321       <span class="keywordflow">return</span> <a class="code" href="namespacedami_1_1io.html#a7d050db3f65d89a3e7b28b4417e62f77">io::writeString</a>(writer, data);
<a name="l00322"></a>00322     }
<a name="l00323"></a>00323     <span class="keywordflow">return</span> <a class="code" href="namespacedami_1_1io.html#a90e1e7414445e9dd670d9a5425701360">io::writeUnicodeString</a>(writer, data);
<a name="l00324"></a>00324   }
<a name="l00325"></a>00325 }
<a name="l00326"></a>00326 
<a name="l00327"></a><a class="code" href="class_i_d3___field_impl.html#aab5d452d3dfb2d931997aa68cf1cb6bb">00327</a> <span class="keywordtype">bool</span> <a class="code" href="class_i_d3___field_impl.html#aab5d452d3dfb2d931997aa68cf1cb6bb">ID3_FieldImpl::ParseText</a>(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>&amp; reader)
<a name="l00328"></a>00328 {
<a name="l00329"></a>00329   ID3D_NOTICE( <span class="stringliteral">&quot;ID3_Field::ParseText(): reader.getBeg() = &quot;</span> &lt;&lt; reader.<a class="code" href="class_i_d3___reader.html#aeaf468ffe03c08731dcaf268fff3391b" title="Return the beginning position in the reader.">getBeg</a>() );
<a name="l00330"></a>00330   ID3D_NOTICE( <span class="stringliteral">&quot;ID3_Field::ParseText(): reader.getCur() = &quot;</span> &lt;&lt; reader.<a class="code" href="class_i_d3___reader.html#a232935e138e44ea49e5a289fb8d7ac94" title="Return the current position in the reader.">getCur</a>() );
<a name="l00331"></a>00331   ID3D_NOTICE( <span class="stringliteral">&quot;ID3_Field::ParseText(): reader.getEnd() = &quot;</span> &lt;&lt; reader.<a class="code" href="class_i_d3___reader.html#a5872b6813a652d831b770bfb7d65aec8" title="Return the ending position in the reader.">getEnd</a>() );
<a name="l00332"></a>00332   this-&gt;<a class="code" href="class_i_d3___field_impl.html#a70599ecbe8fc8a4a55c348a15bcb3928" title="Clears any data and frees any memory associated with the field.">Clear</a>();
<a name="l00333"></a>00333 
<a name="l00334"></a>00334   <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39" title="Enumeration of the types of text encodings: ascii or unicode.">ID3_TextEnc</a> enc = this-&gt;<a class="code" href="class_i_d3___field_impl.html#a3c56d7c248d7e5c5e4fd210ea8ec1ee6">GetEncoding</a>();
<a name="l00335"></a>00335   <span class="keywordtype">size_t</span> fixed_size = this-&gt;<a class="code" href="class_i_d3___field_impl.html#a42c87589e147efabe0e2eb30bdc6938b" title="Returns the size of a field.">Size</a>();
<a name="l00336"></a>00336   <span class="keywordflow">if</span> (fixed_size)
<a name="l00337"></a>00337   {
<a name="l00338"></a>00338     ID3D_NOTICE( <span class="stringliteral">&quot;ID3_Field::ParseText(): fixed size string&quot;</span> );
<a name="l00339"></a>00339     <span class="comment">// The string is of fixed length</span>
<a name="l00340"></a>00340     String text = readEncodedText(reader, fixed_size, enc);
<a name="l00341"></a>00341     this-&gt;<a class="code" href="class_i_d3___field_impl.html#a2f4d15e7925cfa0120cbc4499ca2b3d7">SetText</a>(text);
<a name="l00342"></a>00342     ID3D_NOTICE( <span class="stringliteral">&quot;ID3_Field::ParseText(): fixed size string = &quot;</span> &lt;&lt; text );
<a name="l00343"></a>00343   }
<a name="l00344"></a>00344   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (_flags &amp; <a class="code" href="globals_8h.html#aa21de7543342d7db7b81e31376a8de38ae4a05ca021e53df7e28529127566c2f8">ID3FF_LIST</a>)
<a name="l00345"></a>00345   {
<a name="l00346"></a>00346     ID3D_NOTICE( <span class="stringliteral">&quot;ID3_Field::ParseText(): text list&quot;</span> );
<a name="l00347"></a>00347     <span class="comment">// lists are always the last field in a frame.  parse all remaining</span>
<a name="l00348"></a>00348     <span class="comment">// characters in the reader</span>
<a name="l00349"></a>00349     <span class="keywordflow">while</span> (!reader.<a class="code" href="class_i_d3___reader.html#a2d7e9a6e4c4c5f751035ea507c6cadb5">atEnd</a>())
<a name="l00350"></a>00350     {
<a name="l00351"></a>00351       String text = readEncodedString(reader, enc);
<a name="l00352"></a>00352       this-&gt;<a class="code" href="class_i_d3___field_impl.html#a6191197ca2261034d68867636574b89a">AddText</a>(text);
<a name="l00353"></a>00353       ID3D_NOTICE( <span class="stringliteral">&quot;ID3_Field::ParseText(): adding string = &quot;</span> &lt;&lt; text );
<a name="l00354"></a>00354     }
<a name="l00355"></a>00355   }
<a name="l00356"></a>00356   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (_flags &amp; <a class="code" href="globals_8h.html#aa21de7543342d7db7b81e31376a8de38aaaa9f63fa2ab5107c449182c25cfecaa">ID3FF_CSTR</a>)
<a name="l00357"></a>00357   {
<a name="l00358"></a>00358     ID3D_NOTICE( <span class="stringliteral">&quot;ID3_Field::ParseText(): null terminated string&quot;</span> );
<a name="l00359"></a>00359     String text = readEncodedString(reader, enc);
<a name="l00360"></a>00360     this-&gt;<a class="code" href="class_i_d3___field_impl.html#a2f4d15e7925cfa0120cbc4499ca2b3d7">SetText</a>(text);
<a name="l00361"></a>00361     ID3D_NOTICE( <span class="stringliteral">&quot;ID3_Field::ParseText(): null terminated string = &quot;</span> &lt;&lt; text );
<a name="l00362"></a>00362   }
<a name="l00363"></a>00363   <span class="keywordflow">else</span>
<a name="l00364"></a>00364   {
<a name="l00365"></a>00365     ID3D_NOTICE( <span class="stringliteral">&quot;ID3_Field::ParseText(): last field string&quot;</span> );
<a name="l00366"></a>00366     String text = readEncodedText(reader, reader.<a class="code" href="class_i_d3___reader.html#a8b516ba5335293c2f278c711161a3aec">remainingBytes</a>(), enc);
<a name="l00367"></a>00367     <span class="comment">// not null terminated.</span>
<a name="l00368"></a>00368     this-&gt;<a class="code" href="class_i_d3___field_impl.html#a6191197ca2261034d68867636574b89a">AddText</a>(text);
<a name="l00369"></a>00369     ID3D_NOTICE( <span class="stringliteral">&quot;ID3_Field::ParseText(): last field string = &quot;</span> &lt;&lt; text );
<a name="l00370"></a>00370   }
<a name="l00371"></a>00371 
<a name="l00372"></a>00372   _changed = <span class="keyword">false</span>;
<a name="l00373"></a>00373   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00374"></a>00374 }
<a name="l00375"></a>00375 
<a name="l00376"></a><a class="code" href="class_i_d3___field_impl.html#a0bf04cd66e28b9f629c822ef33906b9e">00376</a> <span class="keywordtype">void</span> <a class="code" href="class_i_d3___field_impl.html#a0bf04cd66e28b9f629c822ef33906b9e">ID3_FieldImpl::RenderText</a>(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>&amp; writer)<span class="keyword"> const</span>
<a name="l00377"></a>00377 <span class="keyword"></span>{
<a name="l00378"></a>00378   <a class="code" href="globals_8h.html#a2a414b8e1666bd6dd8dce86cdcf74a39" title="Enumeration of the types of text encodings: ascii or unicode.">ID3_TextEnc</a> enc = this-&gt;<a class="code" href="class_i_d3___field_impl.html#a3c56d7c248d7e5c5e4fd210ea8ec1ee6">GetEncoding</a>();
<a name="l00379"></a>00379 
<a name="l00380"></a>00380   <span class="keywordflow">if</span> (_flags &amp; <a class="code" href="globals_8h.html#aa21de7543342d7db7b81e31376a8de38aaaa9f63fa2ab5107c449182c25cfecaa">ID3FF_CSTR</a>)
<a name="l00381"></a>00381   {
<a name="l00382"></a>00382     writeEncodedString(writer, _text, enc);
<a name="l00383"></a>00383   }
<a name="l00384"></a>00384   <span class="keywordflow">else</span>
<a name="l00385"></a>00385   {
<a name="l00386"></a>00386     writeEncodedText(writer, _text, enc);
<a name="l00387"></a>00387   }
<a name="l00388"></a>00388   _changed = <span class="keyword">false</span>;
<a name="l00389"></a>00389 };
<a name="l00390"></a>00390 
<a name="l00399"></a><a class="code" href="class_i_d3___field_impl.html#a0232e29cabdf6761a033216e3ce580cd">00399</a> <span class="keywordtype">size_t</span> <a class="code" href="class_i_d3___field_impl.html#a0232e29cabdf6761a033216e3ce580cd" title="Returns the number of items in a text list.">ID3_FieldImpl::GetNumTextItems</a>()<span class="keyword"> const</span>
<a name="l00400"></a>00400 <span class="keyword"></span>{
<a name="l00401"></a>00401   <span class="keywordflow">return</span> _num_items;
<a name="l00402"></a>00402 }
<a name="l00403"></a>00403 
</pre></div></div>
<hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Jan 12 23:46:35 2011 for id3lib by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address>
</body>
</html>