Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

src/field_integer.cpp

Go to the documentation of this file.
00001 // $Id: field_integer.cpp,v 1.19 2000/10/29 01:37:28 eldamitri Exp $
00002 
00003 // id3lib: a C++ library for creating and manipulating id3v1/v2 tags
00004 // Copyright 1999, 2000  Scott Thomas Haug
00005 
00006 // This library is free software; you can redistribute it and/or modify it
00007 // under the terms of the GNU Library General Public License as published by
00008 // the Free Software Foundation; either version 2 of the License, or (at your
00009 // option) any later version.
00010 //
00011 // This library is distributed in the hope that it will be useful, but WITHOUT
00012 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014 // License for more details.
00015 //
00016 // You should have received a copy of the GNU Library General Public License
00017 // along with this library; if not, write to the Free Software Foundation,
00018 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019 
00020 // The id3lib authors encourage improvements and optimisations to be sent to
00021 // the id3lib coordinator.  Please see the README file for details on where to
00022 // send such submissions.  See the AUTHORS file for a list of people who have
00023 // contributed to id3lib.  See the ChangeLog file for a list of changes to
00024 // id3lib.  These files are distributed with id3lib at
00025 // http://download.sourceforge.net/id3lib/
00026 
00027 #if defined HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030 
00031 
00032 #include "field_impl.h"
00033 #include "utils.h"
00034 #include "io_helpers.h"
00035 
00036 using namespace dami;
00037 
00052 void ID3_FieldImpl::Set(uint32 val)
00053 {
00054   this->SetInteger(val);
00055 }
00056 
00057 void ID3_FieldImpl::SetInteger(uint32 val)
00058 {
00059   if (this->GetType() == ID3FTY_INTEGER)
00060   {
00061     this->Clear();
00062     
00063     _integer = val;
00064     _changed = true;
00065   }
00066 }
00067 
00077 uint32 ID3_FieldImpl::Get() const
00078 {
00079   return this->GetInteger();
00080 }
00081 
00082 uint32 ID3_FieldImpl::GetInteger() const
00083 {
00084   uint32 val = 0;
00085   if (this->GetType() == ID3FTY_INTEGER)
00086   {
00087     val = _integer;
00088   }
00089   return val;
00090 }
00091 
00092 bool ID3_FieldImpl::ParseInteger(ID3_Reader& reader)
00093 {
00094   ID3D_NOTICE( "ID3_FieldImpl::ParseInteger(): beg = " << reader.getBeg() );
00095   ID3D_NOTICE( "ID3_FieldImpl::ParseInteger(): cur = " << reader.getCur() );
00096   ID3D_NOTICE( "ID3_FieldImpl::ParseInteger(): end = " << reader.getEnd() );
00097   bool success = false;
00098   if (!reader.atEnd())
00099   {
00100     this->Clear();
00101     size_t fixed = this->Size();
00102     size_t nBytes = (fixed > 0) ? fixed : sizeof(uint32);
00103     this->Set(io::readBENumber(reader, nBytes));
00104     _changed = false;
00105     success = true;
00106   }
00107   return success;
00108 }
00109 
00110 void ID3_FieldImpl::RenderInteger(ID3_Writer& writer) const
00111 {
00112   io::writeBENumber(writer, _integer, this->Size());
00113 }

Generated at Sat Sep 8 15:51:08 2001 for id3lib by doxygen1.2.8 written by Dimitri van Heesch, © 1997-2001