id3lib 3.8.3

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
35 class ID3_Reader;
36 class ID3_Writer;
37
38 class ID3_Header
39 {
40 public:
41 struct Info
42 {
43 uchar frame_bytes_id;
44 uchar frame_bytes_size;
45 uchar frame_bytes_flags;
46 bool is_extended;
47 size_t extended_bytes; //including the extended header, so everything!
48 bool is_experimental;
49 };
50
51 ID3_Header()
52 : _spec (ID3V2_UNKNOWN),
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
90 ID3_Header &operator=( const ID3_Header &rhs)
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
101 protected:
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 */
ID3V2_UNKNOWN
Definition: globals.h:163
ID3_Header::Info::frame_bytes_id
uchar frame_bytes_id
Definition: header.h:43
ID3_Header::Info::frame_bytes_size
uchar frame_bytes_size
Definition: header.h:44
ID3_Header::Parse
virtual bool Parse(ID3_Reader &)=0
ID3_Header::Size
virtual size_t Size() const =0
ID3_Header::GetDataSize
size_t GetDataSize() const
Definition: header.h:71
globals.h
uchar
unsigned char uchar
Definition: globals.h:114
ID3_Header::Clear
virtual bool Clear()
Definition: header.h:73
ID3_Header::Info::is_extended
bool is_extended
Definition: header.h:46
ID3_Header::Info::extended_bytes
size_t extended_bytes
Definition: header.h:47
ID3_Header::SetDataSize
bool SetDataSize(size_t size)
Definition: header.h:64
ID3_Header::_data_size
size_t _data_size
Definition: header.h:103
ID3_Header::_spec
ID3_V2Spec _spec
Definition: header.h:102
ID3_Flags::clear
bool clear()
Definition: flags.h:46
ID3_Reader
Definition: reader.h:33
ID3_V2Spec
ID3_V2Spec
Definition: globals.h:161
ID3_Header::SetSpec
virtual bool SetSpec(ID3_V2Spec)
Definition: header.cpp:34
ID3_Header::GetSpec
ID3_V2Spec GetSpec() const
Definition: header.h:62
ID3_Header::Info::is_experimental
bool is_experimental
Definition: header.h:48
ID3_Header::~ID3_Header
virtual ~ID3_Header()
Definition: header.h:59
flags.h
ID3_Header::Render
virtual void Render(ID3_Writer &) const =0
ID3_Header::_changed
bool _changed
Definition: header.h:106
ID3_Writer
Definition: writer.h:33
ID3_Header::_info
Info * _info
Definition: header.h:105
ID3_Header::operator=
ID3_Header & operator=(const ID3_Header &rhs)
Definition: header.h:90
ID3_Header::Info::frame_bytes_flags
uchar frame_bytes_flags
Definition: header.h:45
ID3_Header::ID3_Header
ID3_Header()
Definition: header.h:51
ID3_Header::Info
Definition: header.h:41
ID3_Header::_flags
ID3_Flags _flags
Definition: header.h:104
ID3_Header
Definition: header.h:38
ID3_Flags
Definition: flags.h:33
ID3V2_LATEST
Definition: globals.h:169