Sophie

Sophie

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

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/tag_find.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/tag_find.cpp</h1><a href="tag__find_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">// $Id: tag_find.cpp,v 1.26 2000/10/29 01:37:29 eldamitri 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 &lt;string.h&gt;</font>
00034 
00035 <font class="preprocessor">#include "<a class="code" href="tag__impl_8h.html">tag_impl.h</a>"</font>
00036 <font class="preprocessor">#include "<a class="code" href="field_8h.html">field.h</a>"</font>
00037 <font class="preprocessor">#include "utils.h"</font>
00038 
00039 <font class="keyword">using</font> <font class="keyword">namespace </font>dami;
00040 
<a name="l00041"></a><a class="code" href="class_i_d3___tag_impl.html#b0">00041</a> <a class="code" href="class_i_d3___tag_impl.html#s1">ID3_TagImpl::const_iterator</a> <a class="code" href="class_i_d3___tag_impl.html#a25">ID3_TagImpl::Find</a>(<font class="keyword">const</font> <a class="code" href="class_i_d3___frame.html">ID3_Frame</a> *frame)<font class="keyword"> const</font>
00042 <font class="keyword"></font>{
00043   <a class="code" href="class_i_d3___tag_impl.html#s1">const_iterator</a> cur = _frames.begin();
00044   
00045   <font class="keywordflow">for</font> (; cur != _frames.end(); ++cur)
00046   {
00047     <font class="keywordflow">if</font> (*cur == frame)
00048     {
00049       <font class="keywordflow">break</font>;
00050     }
00051   }
00052   
00053   <font class="keywordflow">return</font> cur;
00054 }
00055 
<a name="l00056"></a><a class="code" href="class_i_d3___tag_impl.html#b1">00056</a> <a class="code" href="class_i_d3___tag_impl.html#s0">ID3_TagImpl::iterator</a> <a class="code" href="class_i_d3___tag_impl.html#a25">ID3_TagImpl::Find</a>(<font class="keyword">const</font> <a class="code" href="class_i_d3___frame.html">ID3_Frame</a> *frame)
00057 {
00058   <a class="code" href="class_i_d3___tag_impl.html#s0">iterator</a> cur = _frames.begin();
00059   
00060   <font class="keywordflow">for</font> (; cur != _frames.end(); ++cur)
00061   {
00062     <font class="keywordflow">if</font> (*cur == frame)
00063     {
00064       <font class="keywordflow">break</font>;
00065     }
00066   }
00067   
00068   <font class="keywordflow">return</font> cur;
00069 }
00070 
<a name="l00071"></a><a class="code" href="class_i_d3___tag_impl.html#a25">00071</a> <a class="code" href="class_i_d3___frame.html">ID3_Frame</a> *<a class="code" href="class_i_d3___tag_impl.html#a25">ID3_TagImpl::Find</a>(<a class="code" href="globals_8h.html#a219">ID3_FrameID</a> id)<font class="keyword"> const</font>
00072 <font class="keyword"></font>{
00073   <a class="code" href="class_i_d3___frame.html">ID3_Frame</a> *frame = <a class="code" href="globals_8h.html#a24">NULL</a>;
00074   
00075   <font class="comment">// reset the cursor if it isn't set</font>
00076   <font class="keywordflow">if</font> (_frames.end() == _cursor)
00077   {
00078     _cursor = _frames.begin();
00079   }
00080 
00081 
00082   <font class="keywordflow">for</font> (<font class="keywordtype">int</font> iCount = 0; iCount &lt; 2 &amp;&amp; frame == NULL; iCount++)
00083   {
00084     <font class="comment">// We want to cycle through the list to find the matching frame.  We</font>
00085     <font class="comment">// should begin from the cursor, search each successive frame, wrapping</font>
00086     <font class="comment">// if necessary.  The enclosing loop and the assignment statments below</font>
00087     <font class="comment">// ensure that we first begin at the cursor and search to the end of the</font>
00088     <font class="comment">// list and, if unsuccessful, start from the beginning of the list and</font>
00089     <font class="comment">// search to the cursor.</font>
00090     <a class="code" href="class_i_d3___tag_impl.html#s1">const_iterator</a>
00091       <a class="code" href="class_i_d3___tag_impl.html#a34">begin</a>  = (0 == iCount ? _cursor       : _frames.begin()), 
00092       <a class="code" href="class_i_d3___tag_impl.html#a35">end</a>    = (0 == iCount ? _frames.end() : _cursor);
00093     <font class="comment">// search from the cursor to the end</font>
00094     <font class="keywordflow">for</font> (<a class="code" href="class_i_d3___tag_impl.html#s1">const_iterator</a> cur = <a class="code" href="class_i_d3___tag_impl.html#a34">begin</a>; cur != <a class="code" href="class_i_d3___tag_impl.html#a35">end</a>; ++cur)
00095     {
00096       <font class="keywordflow">if</font> ((*cur != NULL) &amp;&amp; ((*cur)-&gt;GetID() == id))
00097       {
00098         <font class="comment">// We've found a valid frame.  Set the cursor to be the next element</font>
00099         frame = *cur;
00100         _cursor = ++cur;
00101         <font class="keywordflow">break</font>;
00102       }
00103     }
00104   }
00105   
00106   <font class="keywordflow">return</font> frame;
00107 }
00108 
<a name="l00109"></a><a class="code" href="class_i_d3___tag_impl.html#a27">00109</a> <a class="code" href="class_i_d3___frame.html">ID3_Frame</a> *<a class="code" href="class_i_d3___tag_impl.html#a25">ID3_TagImpl::Find</a>(<a class="code" href="globals_8h.html#a219">ID3_FrameID</a> id, <a class="code" href="globals_8h.html#a218">ID3_FieldID</a> fldID, String data)<font class="keyword"> const</font>
00110 <font class="keyword"></font>{
00111   <a class="code" href="class_i_d3___frame.html">ID3_Frame</a> *frame = <a class="code" href="globals_8h.html#a24">NULL</a>;
00112   ID3D_NOTICE( <font class="stringliteral">"Find: looking for comment with data = "</font> &lt;&lt; data.c_str() );
00113   
00114   <font class="comment">// reset the cursor if it isn't set</font>
00115   <font class="keywordflow">if</font> (_frames.end() == _cursor)
00116   {
00117     _cursor = _frames.begin();
00118     ID3D_NOTICE( <font class="stringliteral">"Find: resetting cursor"</font> );
00119   }
00120 
00121   <font class="keywordflow">for</font> (<font class="keywordtype">int</font> iCount = 0; iCount &lt; 2 &amp;&amp; frame == NULL; iCount++)
00122   {
00123     ID3D_NOTICE( <font class="stringliteral">"Find: iCount = "</font> &lt;&lt; iCount );
00124     <font class="comment">// We want to cycle through the list to find the matching frame.  We</font>
00125     <font class="comment">// should begin from the cursor, search each successive frame, wrapping</font>
00126     <font class="comment">// if necessary.  The enclosing loop and the assignment statments below</font>
00127     <font class="comment">// ensure that we first begin at the cursor and search to the end of the</font>
00128     <font class="comment">// list and, if unsuccessful, start from the beginning of the list and</font>
00129     <font class="comment">// search to the cursor.</font>
00130     <a class="code" href="class_i_d3___tag_impl.html#s1">const_iterator</a>
00131       <a class="code" href="class_i_d3___tag_impl.html#a34">begin</a>  = (0 == iCount ? _cursor       : _frames.begin()), 
00132       <a class="code" href="class_i_d3___tag_impl.html#a35">end</a>    = (0 == iCount ? _frames.end() : _cursor);
00133     <font class="comment">// search from the cursor to the end</font>
00134     <font class="keywordflow">for</font> (<a class="code" href="class_i_d3___tag_impl.html#s1">const_iterator</a> cur = <a class="code" href="class_i_d3___tag_impl.html#a34">begin</a>; cur != <a class="code" href="class_i_d3___tag_impl.html#a35">end</a>; ++cur)
00135     {
00136       ID3D_NOTICE( <font class="stringliteral">"Find: frame = 0x"</font> &lt;&lt; hex &lt;&lt; (<a class="code" href="sized__types_8h.html#a4">uint32</a>) *cur &lt;&lt; dec );
00137       <font class="keywordflow">if</font> ((*cur != NULL) &amp;&amp; ((*cur)-&gt;GetID() == id) &amp;&amp;
00138           (*cur)-&gt;Contains(fldID))
00139       {
00140         <a class="code" href="class_i_d3___field.html">ID3_Field</a>* fld = (*cur)-&gt;GetField(fldID);
00141         <font class="keywordflow">if</font> (NULL == fld)
00142         {
00143           <font class="keywordflow">continue</font>;
00144           ID3D_NOTICE( <font class="stringliteral">"Find: didn't have the right field"</font> );
00145         }
00146 
00147         String text(fld-&gt;<a class="code" href="class_i_d3___field.html#a11">GetRawText</a>(), fld-&gt;<a class="code" href="class_i_d3___field.html#a1">Size</a>());
00148         ID3D_NOTICE( <font class="stringliteral">"Find: text = "</font> &lt;&lt; text.c_str() );
00149 
00150         <font class="keywordflow">if</font> (text == data)
00151         {
00152           <font class="comment">// We've found a valid frame.  Set cursor to be the next element</font>
00153           frame = *cur;
00154           _cursor = ++cur;
00155           <font class="keywordflow">break</font>;
00156         }
00157       }
00158     }
00159   }
00160   
00161   <font class="keywordflow">return</font> frame;
00162 }
00163 
<a name="l00164"></a><a class="code" href="class_i_d3___tag_impl.html#a28">00164</a> <a class="code" href="class_i_d3___frame.html">ID3_Frame</a> *<a class="code" href="class_i_d3___tag_impl.html#a25">ID3_TagImpl::Find</a>(<a class="code" href="globals_8h.html#a219">ID3_FrameID</a> id, <a class="code" href="globals_8h.html#a218">ID3_FieldID</a> fldID, WString data)<font class="keyword"> const</font>
00165 <font class="keyword"></font>{
00166   <a class="code" href="class_i_d3___frame.html">ID3_Frame</a> *frame = <a class="code" href="globals_8h.html#a24">NULL</a>;
00167   
00168   <font class="comment">// reset the cursor if it isn't set</font>
00169   <font class="keywordflow">if</font> (_frames.end() == _cursor)
00170   {
00171     _cursor = _frames.begin();
00172   }
00173 
00174   <font class="keywordflow">for</font> (<font class="keywordtype">int</font> iCount = 0; iCount &lt; 2 &amp;&amp; frame == NULL; iCount++)
00175   {
00176     <font class="comment">// We want to cycle through the list to find the matching frame.  We</font>
00177     <font class="comment">// should begin from the cursor, search each successive frame, wrapping</font>
00178     <font class="comment">// if necessary.  The enclosing loop and the assignment statments below</font>
00179     <font class="comment">// ensure that we first begin at the cursor and search to the end of the</font>
00180     <font class="comment">// list and, if unsuccessful, start from the beginning of the list and</font>
00181     <font class="comment">// search to the cursor.</font>
00182     <a class="code" href="class_i_d3___tag_impl.html#s1">const_iterator</a>
00183       <a class="code" href="class_i_d3___tag_impl.html#a34">begin</a>  = (0 == iCount ? _cursor       : _frames.begin()), 
00184       <a class="code" href="class_i_d3___tag_impl.html#a35">end</a>    = (0 == iCount ? _frames.end() : _cursor);
00185     <font class="comment">// search from the cursor to the end</font>
00186     <font class="keywordflow">for</font> (<a class="code" href="class_i_d3___tag_impl.html#s1">const_iterator</a> cur = <a class="code" href="class_i_d3___tag_impl.html#a34">begin</a>; cur != <a class="code" href="class_i_d3___tag_impl.html#a35">end</a>; ++cur)
00187     {
00188       <font class="keywordflow">if</font> ((*cur != NULL) &amp;&amp; ((*cur)-&gt;GetID() == id) &amp;&amp;
00189           (*cur)-&gt;Contains(fldID))
00190       {
00191         <a class="code" href="class_i_d3___field.html">ID3_Field</a>* fld = (*cur)-&gt;GetField(fldID);
00192         <font class="keywordflow">if</font> (NULL == fld)
00193         {
00194           <font class="keywordflow">continue</font>;
00195         }
00196         WString text = toWString(fld-&gt;<a class="code" href="class_i_d3___field.html#a18">GetRawUnicodeText</a>(), fld-&gt;<a class="code" href="class_i_d3___field.html#a1">Size</a>());
00197 
00198         <font class="keywordflow">if</font> (text == data)
00199         {
00200           <font class="comment">// We've found a valid frame.  Set cursor to be the next element</font>
00201           frame = *cur;
00202           _cursor = ++cur;
00203           <font class="keywordflow">break</font>;
00204         }
00205       }
00206     }
00207   }
00208   
00209   <font class="keywordflow">return</font> frame;
00210 }
00211 
<a name="l00212"></a><a class="code" href="class_i_d3___tag_impl.html#a26">00212</a> <a class="code" href="class_i_d3___frame.html">ID3_Frame</a> *<a class="code" href="class_i_d3___tag_impl.html#a25">ID3_TagImpl::Find</a>(<a class="code" href="globals_8h.html#a219">ID3_FrameID</a> id, <a class="code" href="globals_8h.html#a218">ID3_FieldID</a> fldID, <a class="code" href="sized__types_8h.html#a4">uint32</a> data)<font class="keyword"> const</font>
00213 <font class="keyword"></font>{
00214   <a class="code" href="class_i_d3___frame.html">ID3_Frame</a> *frame = <a class="code" href="globals_8h.html#a24">NULL</a>;
00215   
00216   <font class="comment">// reset the cursor if it isn't set</font>
00217   <font class="keywordflow">if</font> (_frames.end() == _cursor)
00218   {
00219     _cursor = _frames.begin();
00220   }
00221 
00222   <font class="keywordflow">for</font> (<font class="keywordtype">int</font> iCount = 0; iCount &lt; 2 &amp;&amp; frame == NULL; iCount++)
00223   {
00224     <font class="comment">// We want to cycle through the list to find the matching frame.  We</font>
00225     <font class="comment">// should begin from the cursor, search each successive frame, wrapping</font>
00226     <font class="comment">// if necessary.  The enclosing loop and the assignment statments below</font>
00227     <font class="comment">// ensure that we first begin at the cursor and search to the end of the</font>
00228     <font class="comment">// list and, if unsuccessful, start from the beginning of the list and</font>
00229     <font class="comment">// search to the cursor.</font>
00230     <a class="code" href="class_i_d3___tag_impl.html#s1">const_iterator</a>
00231       <a class="code" href="class_i_d3___tag_impl.html#a34">begin</a>  = (0 == iCount ? _cursor       : _frames.begin()), 
00232       <a class="code" href="class_i_d3___tag_impl.html#a35">end</a>    = (0 == iCount ? _frames.end() : _cursor);
00233     <font class="comment">// search from the cursor to the end</font>
00234     <font class="keywordflow">for</font> (<a class="code" href="class_i_d3___tag_impl.html#s1">const_iterator</a> cur = <a class="code" href="class_i_d3___tag_impl.html#a34">begin</a>; cur != <a class="code" href="class_i_d3___tag_impl.html#a35">end</a>; ++cur)
00235     {
00236       <font class="keywordflow">if</font> ((*cur != NULL) &amp;&amp; ((*cur)-&gt;GetID() == id) &amp;&amp;
00237           ((*cur)-&gt;GetField(fldID)-&gt;Get() == data))
00238       {
00239         <font class="comment">// We've found a valid frame.  Set the cursor to be the next element</font>
00240         frame = *cur;
00241         _cursor = ++cur;
00242         <font class="keywordflow">break</font>;
00243       }
00244     }
00245   }
00246   
00247   <font class="keywordflow">return</font> frame;
00248 }
00249 
</pre></div><hr><address><small>Generated on Thu Jan 3 07:35:56 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>