id3lib 3.8.3
header.h
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: header.h,v 1.3 2002/07/31 13:20:49 t1mpy Exp $
3
4// id3lib: a C++ library for creating and manipulating id3v1/v2 tags
5// Copyright 1999, 2000 Scott Thomas Haug
6// Copyright 2002 Thijmen Klok (thijmen@id3lib.org)
7
8// This library is free software; you can redistribute it and/or modify it
9// under the terms of the GNU Library General Public License as published by
10// the Free Software Foundation; either version 2 of the License, or (at your
11// option) any later version.
12//
13// This library is distributed in the hope that it will be useful, but WITHOUT
14// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
16// License for more details.
17//
18// You should have received a copy of the GNU Library General Public License
19// along with this library; if not, write to the Free Software Foundation,
20// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22// The id3lib authors encourage improvements and optimisations to be sent to
23// the id3lib coordinator. Please see the README file for details on where to
24// send such submissions. See the AUTHORS file for a list of people who have
25// contributed to id3lib. See the ChangeLog file for a list of changes to
26// id3lib. These files are distributed with id3lib at
27// http://download.sourceforge.net/id3lib/
28
29#ifndef _ID3LIB_HEADER_H_
30#define _ID3LIB_HEADER_H_
31
32#include "id3/globals.h" //has <stdlib.h> "id3/sized_types.h"
33#include "flags.h"
34
35class ID3_Reader;
36class ID3_Writer;
37
39{
40public:
41 struct Info
42 {
47 size_t extended_bytes; //including the extended header, so everything!
49 };
50
53 _data_size (0),
54 _changed (false)
55 {
56 this->Clear();
57 _changed = false;
58 }
59 virtual ~ID3_Header() { ; }
60
61 virtual bool SetSpec(ID3_V2Spec);
62 /* */ ID3_V2Spec GetSpec() const { return _spec; }
63
64 /* */ bool SetDataSize(size_t size)
65 {
66 bool changed = size != _data_size;
67 _changed = _changed || changed;
68 _data_size = size;
69 return changed;
70 }
71 /* */ size_t GetDataSize() const { return _data_size; }
72
73 virtual bool Clear()
74 {
75 bool changed = this->SetDataSize(0);
76 if (this->GetSpec() == ID3V2_UNKNOWN)
77 {
78 this->SetSpec(ID3V2_LATEST);
79 changed = true;
80 }
81 changed = _flags.clear() || changed;
82 _changed = changed || _changed;
83 return changed;
84 }
85 virtual size_t Size() const = 0;
86
87 virtual void Render(ID3_Writer&) const = 0;
88 virtual bool Parse(ID3_Reader&) = 0;
89
91 {
92 if (this != &rhs)
93 {
94 this->SetSpec(rhs.GetSpec());
95 this->SetDataSize(rhs.GetSpec());
96 this->_flags = rhs._flags;
97 }
98 return *this;
99 }
100
101protected:
102 ID3_V2Spec _spec; // which version of the spec
103 size_t _data_size; // how big is the data?
104 ID3_Flags _flags; // header flags
105 Info* _info; // header info w.r.t. id3v2 spec
106 bool _changed; // has the header changed since parsing
107}
108;
109
110#endif /* _ID3LIB_HEADER_H */
bool clear()
Definition flags.h:46
ID3_V2Spec _spec
Definition header.h:102
virtual bool Clear()
Definition header.h:73
virtual void Render(ID3_Writer &) const =0
bool _changed
Definition header.h:106
ID3_Header & operator=(const ID3_Header &rhs)
Definition header.h:90
virtual ~ID3_Header()
Definition header.h:59
bool SetDataSize(size_t size)
Definition header.h:64
ID3_Header()
Definition header.h:51
ID3_V2Spec GetSpec() const
Definition header.h:62
size_t _data_size
Definition header.h:103
virtual size_t Size() const =0
Info * _info
Definition header.h:105
size_t GetDataSize() const
Definition header.h:71
virtual bool SetSpec(ID3_V2Spec)
Definition header.cpp:34
virtual bool Parse(ID3_Reader &)=0
ID3_Flags _flags
Definition header.h:104
ID3_V2Spec
Definition globals.h:162
@ ID3V2_LATEST
Definition globals.h:169
@ ID3V2_UNKNOWN
Definition globals.h:163
unsigned char uchar
Definition globals.h:114
size_t extended_bytes
Definition header.h:47
bool is_experimental
Definition header.h:48
uchar frame_bytes_size
Definition header.h:44
uchar frame_bytes_id
Definition header.h:43
uchar frame_bytes_flags
Definition header.h:45
bool is_extended
Definition header.h:46

Generated for id3lib by doxygen 1.10.0