id3lib 3.8.3
field_integer.cpp
Go to the documentation of this file.
1// $Id: field_integer.cpp,v 1.21 2002/07/02 22:12:13 t1mpy Exp $
2
3// id3lib: a C++ library for creating and manipulating id3v1/v2 tags
4// Copyright 1999, 2000 Scott Thomas Haug
5
6// This library is free software; you can redistribute it and/or modify it
7// under the terms of the GNU Library General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or (at your
9// option) any later version.
10//
11// This library is distributed in the hope that it will be useful, but WITHOUT
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14// License for more details.
15//
16// You should have received a copy of the GNU Library General Public License
17// along with this library; if not, write to the Free Software Foundation,
18// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20// The id3lib authors encourage improvements and optimisations to be sent to
21// the id3lib coordinator. Please see the README file for details on where to
22// send such submissions. See the AUTHORS file for a list of people who have
23// contributed to id3lib. See the ChangeLog file for a list of changes to
24// id3lib. These files are distributed with id3lib at
25// http://download.sourceforge.net/id3lib/
26
27#include "field_impl.h"
28#include "id3/utils.h" // has <config.h> "id3/id3lib_streams.h" "id3/globals.h" "id3/id3lib_strings.h"
29#include "io_helpers.h"
30
31using namespace dami;
32
47void ID3_FieldImpl::Set(uint32 val)
48{
49 this->SetInteger(val);
50}
51
53{
54 if (this->GetType() == ID3FTY_INTEGER)
55 {
56 this->Clear();
57
58 _integer = val;
59 _changed = true;
60 }
61}
62
72uint32 ID3_FieldImpl::Get() const
73{
74 return this->GetInteger();
75}
76
78{
79 uint32 val = 0;
80 if (this->GetType() == ID3FTY_INTEGER)
81 {
82 val = _integer;
83 }
84 return val;
85}
86
88{
89 ID3D_NOTICE( "ID3_FieldImpl::ParseInteger(): beg = " << reader.getBeg() );
90 ID3D_NOTICE( "ID3_FieldImpl::ParseInteger(): cur = " << reader.getCur() );
91 ID3D_NOTICE( "ID3_FieldImpl::ParseInteger(): end = " << reader.getEnd() );
92 bool success = false;
93 if (!reader.atEnd())
94 {
95 this->Clear();
96 size_t fixed = this->Size();
97 size_t nBytes = (fixed > 0) ? fixed : sizeof(uint32);
98 this->Set(io::readBENumber(reader, nBytes));
99 _changed = false;
100 success = true;
101 }
102 return success;
103}
104
106{
107 io::writeBENumber(writer, _integer, this->Size());
108}
109
bool ParseInteger(ID3_Reader &)
void RenderInteger(ID3_Writer &) const
uint32 GetInteger() const
void SetInteger(uint32)
ID3_FieldType GetType() const
Definition field_impl.h:103
void Set(uint32)
Sets the value of the field to the specified integer.
void Clear()
Clears any data and frees any memory associated with the field.
Definition field.cpp:923
uint32 Get() const
Returns the value of the integer field.
size_t Size() const
Returns the size of a field.
Definition field.cpp:1018
virtual pos_type getCur()=0
Return the current position in the reader.
virtual bool atEnd()
Definition reader.h:125
virtual pos_type getEnd()
Return the ending position in the reader.
Definition reader.h:51
virtual pos_type getBeg()
Return the beginning position in the reader.
Definition reader.h:48
@ ID3FTY_INTEGER
Definition globals.h:354

Generated for id3lib by doxygen 1.10.0