<!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/header_tag.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> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center> <hr><h1>src/header_tag.cpp</h1><a href="header__tag_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">// $Id: header_tag.cpp,v 1.21 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 <config.h></font> 00029 <font class="preprocessor">#endif</font> 00030 <font class="preprocessor"></font> 00031 00032 00033 <font class="preprocessor">#include <string.h></font> 00034 00035 <font class="preprocessor">#include "<a class="code" href="header__tag_8h.html">header_tag.h</a>"</font> 00036 <font class="preprocessor">#include "utils.h"</font> 00037 <font class="preprocessor">#include "<a class="code" href="tag_8h.html">tag.h</a>"</font> 00038 <font class="preprocessor">#include "io_helpers.h"</font> 00039 <font class="preprocessor">#include "<a class="code" href="spec_8h.html">spec.h</a>"</font> 00040 00041 <font class="keyword">using</font> <font class="keyword">namespace </font>dami; 00042 <a name="l00043"></a><a class="code" href="class_i_d3___tag_header.html#p0">00043</a> <font class="keyword">const</font> <font class="keywordtype">char</font>* <font class="keyword">const</font> <a class="code" href="class_i_d3___tag_header.html#p0">ID3_TagHeader::ID</a> = <font class="stringliteral">"ID3"</font>; 00044 <a name="l00045"></a><a class="code" href="class_i_d3___tag_header.html#a3">00045</a> <font class="keywordtype">bool</font> <a class="code" href="class_i_d3___tag_header.html#a3">ID3_TagHeader::SetSpec</a>(<a class="code" href="globals_8h.html#a216">ID3_V2Spec</a> spec) 00046 { 00047 <font class="keywordtype">bool</font> changed = this-><a class="code" href="class_i_d3___header.html#a2">ID3_Header::SetSpec</a>(spec); 00048 <font class="keywordflow">if</font> (changed) 00049 { 00050 <font class="keywordflow">if</font> (_info) 00051 { 00052 <a class="code" href="class_i_d3___header.html#n2">_flags</a>.<a class="code" href="class_i_d3___flags.html#a4">set</a>(<a class="code" href="class_i_d3___tag_header.html#s9s2">EXPERIMENTAL</a>, <a class="code" href="class_i_d3___header.html#n3">_info</a>->is_experimental); 00053 <a class="code" href="class_i_d3___header.html#n2">_flags</a>.<a class="code" href="class_i_d3___flags.html#a4">set</a>(<a class="code" href="class_i_d3___tag_header.html#s9s1">EXTENDED</a>, <a class="code" href="class_i_d3___header.html#n3">_info</a>->is_extended); 00054 } 00055 } 00056 <font class="keywordflow">return</font> changed; 00057 } 00058 <a name="l00059"></a><a class="code" href="class_i_d3___tag_header.html#a4">00059</a> size_t <a class="code" href="class_i_d3___tag_header.html#a4">ID3_TagHeader::Size</a>()<font class="keyword"> const</font> 00060 <font class="keyword"></font>{ 00061 size_t bytesUsed = <a class="code" href="class_i_d3___tag_header.html#s10s8">ID3_TagHeader::SIZE</a>; 00062 00063 <font class="keywordflow">if</font> (<a class="code" href="class_i_d3___header.html#n3">_info</a>->is_extended) 00064 { 00065 bytesUsed += <a class="code" href="class_i_d3___header.html#n3">_info</a>->extended_bytes + <font class="keyword">sizeof</font>(uint32); 00066 } 00067 00068 <font class="keywordflow">return</font> bytesUsed; 00069 } 00070 00071 <a name="l00072"></a><a class="code" href="class_i_d3___tag_header.html#a5">00072</a> <font class="keywordtype">void</font> <a class="code" href="class_i_d3___tag_header.html#a5">ID3_TagHeader::Render</a>(<a class="code" href="class_i_d3___writer.html">ID3_Writer</a>& writer)<font class="keyword"> const</font> 00073 <font class="keyword"></font>{ 00074 writer.<a class="code" href="class_i_d3___writer.html#a8">writeChars</a>((<a class="code" href="globals_8h.html#a33">uchar</a> *) <a class="code" href="class_i_d3___tag_header.html#p0">ID</a>, strlen(<a class="code" href="class_i_d3___tag_header.html#p0">ID</a>)); 00075 00076 writer.<a class="code" href="class_i_d3___writer.html#a7">writeChar</a>(<a class="code" href="spec_8h.html#a1">ID3_V2SpecToVer</a>(<a class="code" href="globals_8h.html#a216a58">ID3V2_LATEST</a>)); 00077 writer.<a class="code" href="class_i_d3___writer.html#a7">writeChar</a>(<a class="code" href="spec_8h.html#a2">ID3_V2SpecToRev</a>(<a class="code" href="globals_8h.html#a216a58">ID3V2_LATEST</a>)); 00078 00079 <font class="comment">// set the flags byte in the header</font> 00080 writer.<a class="code" href="class_i_d3___writer.html#a7">writeChar</a>(static_cast<uchar>(<a class="code" href="class_i_d3___header.html#n2">_flags</a>.<a class="code" href="class_i_d3___flags.html#a2">get</a>() & <a class="code" href="globals_8h.html#a19">MASK8</a>)); 00081 io::writeUInt28(writer, this->GetDataSize()); 00082 00083 <font class="comment">// now we render the extended header</font> 00084 <font class="keywordflow">if</font> (<a class="code" href="class_i_d3___header.html#n2">_flags</a>.<a class="code" href="class_i_d3___flags.html#a3">test</a>(<a class="code" href="class_i_d3___tag_header.html#s9s1">EXTENDED</a>)) 00085 { 00086 io::writeBENumber(writer, <a class="code" href="class_i_d3___header.html#n3">_info</a>->extended_bytes, <font class="keyword">sizeof</font>(<a class="code" href="sized__types_8h.html#a4">uint32</a>)); 00087 } 00088 } 00089 <a name="l00090"></a><a class="code" href="class_i_d3___tag_header.html#a6">00090</a> <font class="keywordtype">bool</font> <a class="code" href="class_i_d3___tag_header.html#a6">ID3_TagHeader::Parse</a>(<a class="code" href="class_i_d3___reader.html">ID3_Reader</a>& reader) 00091 { 00092 io::ExitTrigger et(reader); 00093 <font class="keywordflow">if</font> (!<a class="code" href="class_i_d3___tag.html#d0">ID3_Tag::IsV2Tag</a>(reader)) 00094 { 00095 ID3D_NOTICE( <font class="stringliteral">"ID3_TagHeader::Parse(): not an id3v2 header"</font> ); 00096 <font class="keywordflow">return</font> <font class="keyword">false</font>; 00097 } 00098 00099 <a class="code" href="globals_8h.html#a33">uchar</a> id[3]; 00100 reader.<a class="code" href="class_i_d3___reader.html#a7">readChars</a>(id, 3); 00101 <font class="comment">// The spec version is determined with the MAJOR and MINOR OFFSETs</font> 00102 <a class="code" href="globals_8h.html#a33">uchar</a> major = reader.<a class="code" href="class_i_d3___reader.html#a5">readChar</a>(); 00103 <a class="code" href="globals_8h.html#a33">uchar</a> minor = reader.<a class="code" href="class_i_d3___reader.html#a5">readChar</a>(); 00104 this-><a class="code" href="class_i_d3___tag_header.html#a3">SetSpec</a>(<a class="code" href="spec_8h.html#a0">ID3_VerRevToV2Spec</a>(major, minor)); 00105 00106 <font class="comment">// Get the flags at the appropriate offset</font> 00107 <a class="code" href="class_i_d3___header.html#n2">_flags</a>.<a class="code" href="class_i_d3___flags.html#a4">set</a>(static_cast<ID3_Flags::TYPE>(reader.<a class="code" href="class_i_d3___reader.html#a5">readChar</a>())); 00108 00109 <font class="comment">// set the data size</font> 00110 this-><a class="code" href="class_i_d3___header.html#a4">SetDataSize</a>(io::readUInt28(reader)); 00111 00112 <font class="keywordflow">if</font> (<a class="code" href="class_i_d3___header.html#n2">_flags</a>.<a class="code" href="class_i_d3___flags.html#a3">test</a>(<a class="code" href="class_i_d3___tag_header.html#s9s1">EXTENDED</a>)) 00113 { 00114 <font class="keywordflow">if</font> (this-><a class="code" href="class_i_d3___header.html#a3">GetSpec</a>() == <a class="code" href="globals_8h.html#a216a54">ID3V2_2_1</a>) 00115 { 00116 <font class="comment">// okay, if we are ID3v2.2.1, then let's skip over the extended header</font> 00117 <font class="comment">// for now because I am lazy</font> 00118 } 00119 00120 <font class="keywordflow">if</font> (this-><a class="code" href="class_i_d3___header.html#a3">GetSpec</a>() == <a class="code" href="globals_8h.html#a216a55">ID3V2_3_0</a>) 00121 { 00122 <font class="comment">// okay, if we are ID3v2.3.0, then let's actually parse the extended</font> 00123 <font class="comment">// header (for now, we skip it because we are lazy)</font> 00124 } 00125 } 00126 et.setExitPos(reader.<a class="code" href="class_i_d3___reader.html#a3">getCur</a>()); 00127 <font class="keywordflow">return</font> <font class="keyword">true</font>; 00128 } </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>, © 1997-2001</small></address> </body> </html>