Sophie

Sophie

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

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_unicode.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_unicode.cpp</h1><a href="field__string__unicode_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_unicode.cpp,v 1.33 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="l00049"></a><a class="code" href="class_i_d3___field_impl.html#a5e4ebdb241a1dde45d7b1f17ed4b7b99">00049</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> <a class="code" href="globals_8h.html#a781c2cce7ea2af8192d5f83427044add">unicode_t</a>* data)
<a name="l00050"></a>00050 {
<a name="l00051"></a>00051   <span class="keywordtype">size_t</span> size = 0;
<a name="l00052"></a>00052   <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="l00053"></a>00053       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> &amp;&amp; data)
<a name="l00054"></a>00054   {
<a name="l00055"></a>00055     String text((<span class="keyword">const</span> <span class="keywordtype">char</span>*) data, ucslen(data) * 2);
<a name="l00056"></a>00056     size = this-&gt;SetText_i(text);
<a name="l00057"></a>00057   }
<a name="l00058"></a>00058   <span class="keywordflow">return</span> size;
<a name="l00059"></a>00059 }
<a name="l00060"></a>00060 
<a name="l00061"></a><a class="code" href="class_i_d3___field_impl.html#a46406170d406d52ad395817fd483a50d">00061</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> <a class="code" href="globals_8h.html#a781c2cce7ea2af8192d5f83427044add">unicode_t</a>* data)
<a name="l00062"></a>00062 {
<a name="l00063"></a>00063   <span class="keywordtype">size_t</span> size = 0;
<a name="l00064"></a>00064   <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="l00065"></a>00065       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="l00066"></a>00066   {
<a name="l00067"></a>00067     String text((<span class="keyword">const</span> <span class="keywordtype">char</span>*) data, ucslen(data) * 2);
<a name="l00068"></a>00068     size = this-&gt;AddText_i(text);
<a name="l00069"></a>00069   }
<a name="l00070"></a>00070   <span class="keywordflow">return</span> size;
<a name="l00071"></a>00071 }
<a name="l00072"></a>00072 
<a name="l00093"></a><a class="code" href="class_i_d3___field_impl.html#a0b39bf7b3c161471b3ac94b6eec90014">00093</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>(<a class="code" href="globals_8h.html#a781c2cce7ea2af8192d5f83427044add">unicode_t</a> *buffer, <span class="keywordtype">size_t</span> maxLength)<span class="keyword"> const</span>
<a name="l00094"></a>00094 <span class="keyword"></span>{
<a name="l00095"></a>00095   <span class="keywordtype">size_t</span> length = 0;
<a name="l00096"></a>00096   <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="l00097"></a>00097       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> &amp;&amp;
<a name="l00098"></a>00098       buffer != <a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> &amp;&amp; maxLength &gt; 0)
<a name="l00099"></a>00099   {
<a name="l00100"></a>00100     <span class="keywordtype">size_t</span> 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="l00101"></a>00101     length = <a class="code" href="io__strings_8h.html#ac6afabdc09a49a433ee19d8a9486056d">dami::min</a>(maxLength, size);
<a name="l00102"></a>00102     ::memcpy((<span class="keywordtype">void</span> *)buffer, (<span class="keywordtype">void</span> *)_text.data(), length * 2);
<a name="l00103"></a>00103     <span class="keywordflow">if</span> (length &lt; maxLength)
<a name="l00104"></a>00104     {
<a name="l00105"></a>00105       buffer[length] = <a class="code" href="globals_8h.html#adf2f9dc565f7cb248d7baf38c543376f">NULL_UNICODE</a>;
<a name="l00106"></a>00106     }
<a name="l00107"></a>00107   }
<a name="l00108"></a>00108   <span class="keywordflow">return</span> length;
<a name="l00109"></a>00109 }
<a name="l00110"></a>00110 
<a name="l00111"></a><a class="code" href="class_i_d3___field_impl.html#ab8c9fd2ac15148731126895883532167">00111</a> <span class="keyword">const</span> <a class="code" href="globals_8h.html#a781c2cce7ea2af8192d5f83427044add">unicode_t</a>* <a class="code" href="class_i_d3___field_impl.html#ab8c9fd2ac15148731126895883532167">ID3_FieldImpl::GetRawUnicodeText</a>()<span class="keyword"> const</span>
<a name="l00112"></a>00112 <span class="keyword"></span>{
<a name="l00113"></a>00113   <span class="keyword">const</span> <a class="code" href="globals_8h.html#a781c2cce7ea2af8192d5f83427044add">unicode_t</a>* text = <a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00114"></a>00114   <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="l00115"></a>00115       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="l00116"></a>00116   {
<a name="l00117"></a>00117     text = (<a class="code" href="globals_8h.html#a781c2cce7ea2af8192d5f83427044add">unicode_t</a> *)_text.data();
<a name="l00118"></a>00118   }
<a name="l00119"></a>00119   <span class="keywordflow">return</span> text;
<a name="l00120"></a>00120 }
<a name="l00121"></a>00121 
<a name="l00122"></a><a class="code" href="class_i_d3___field_impl.html#a0b749211804be718ea62a216492944e6">00122</a> <span class="keyword">const</span> <a class="code" href="globals_8h.html#a781c2cce7ea2af8192d5f83427044add">unicode_t</a>* <a class="code" href="class_i_d3___field_impl.html#a0b749211804be718ea62a216492944e6">ID3_FieldImpl::GetRawUnicodeTextItem</a>(<span class="keywordtype">size_t</span> index)<span class="keyword"> const</span>
<a name="l00123"></a>00123 <span class="keyword"></span>{
<a name="l00124"></a>00124   <span class="keyword">const</span> <a class="code" href="globals_8h.html#a781c2cce7ea2af8192d5f83427044add">unicode_t</a>* text = <a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>;
<a name="l00125"></a>00125   <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="l00126"></a>00126       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> &amp;&amp;
<a name="l00127"></a>00127       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="l00128"></a>00128   {
<a name="l00129"></a>00129     String unicode = _text + <span class="charliteral">&#39;\0&#39;</span> + <span class="charliteral">&#39;\0&#39;</span>;
<a name="l00130"></a>00130     text = (<a class="code" href="globals_8h.html#a781c2cce7ea2af8192d5f83427044add">unicode_t</a> *) unicode.data();
<a name="l00131"></a>00131     <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i &lt; index; ++i)
<a name="l00132"></a>00132     {
<a name="l00133"></a>00133       text += ucslen(text) + 1;
<a name="l00134"></a>00134     }
<a name="l00135"></a>00135   }
<a name="l00136"></a>00136   <span class="keywordflow">return</span> text;
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138 
<a name="l00139"></a><a class="code" href="class_i_d3___field_impl.html#abddb3eb765d1659d58484606a66f938f">00139</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>(<a class="code" href="globals_8h.html#a781c2cce7ea2af8192d5f83427044add">unicode_t</a> *buffer, <span class="keywordtype">size_t</span> maxLength, <span class="keywordtype">size_t</span> itemNum)<span class="keyword"> const</span>
<a name="l00140"></a>00140 <span class="keyword"></span>{
<a name="l00141"></a>00141   <span class="keywordtype">size_t</span> length = 0;
<a name="l00142"></a>00142   <span class="keywordtype">size_t</span> total_items = 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="l00143"></a>00143   <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="l00144"></a>00144       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> &amp;&amp;
<a name="l00145"></a>00145       buffer != <a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> &amp;&amp; maxLength &gt; 0 &amp;&amp; itemNum &lt; total_items)
<a name="l00146"></a>00146   {
<a name="l00147"></a>00147     <span class="keyword">const</span> <a class="code" href="globals_8h.html#a781c2cce7ea2af8192d5f83427044add">unicode_t</a>* text = this-&gt;<a class="code" href="class_i_d3___field_impl.html#a0b749211804be718ea62a216492944e6">GetRawUnicodeTextItem</a>(itemNum);
<a name="l00148"></a>00148     <span class="keywordflow">if</span> (<a class="code" href="globals_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a> != text)
<a name="l00149"></a>00149     {
<a name="l00150"></a>00150       <span class="keywordtype">size_t</span> length = <a class="code" href="io__strings_8h.html#ac6afabdc09a49a433ee19d8a9486056d">dami::min</a>(maxLength, ucslen(text));
<a name="l00151"></a>00151       ::memcpy(buffer, text, length * 2);
<a name="l00152"></a>00152       <span class="keywordflow">if</span> (length &lt; maxLength)
<a name="l00153"></a>00153       {
<a name="l00154"></a>00154         buffer[length] = <a class="code" href="globals_8h.html#adf2f9dc565f7cb248d7baf38c543376f">NULL_UNICODE</a>;
<a name="l00155"></a>00155       }
<a name="l00156"></a>00156     }
<a name="l00157"></a>00157   }
<a name="l00158"></a>00158 
<a name="l00159"></a>00159   <span class="keywordflow">return</span> length;
<a name="l00160"></a>00160 }
<a name="l00161"></a>00161 
<a name="l00162"></a>00162 
</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>