id3lib 3.8.3

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

frame_impl.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: frame_impl.h,v 1.6 2002/08/10 10:50:31 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_FRAME_IMPL_H_
30 #define _ID3LIB_FRAME_IMPL_H_
31
32 #include <vector>
33 #ifndef HAVE_BITSET
34 #include "id3/id3lib_bitset"
35 #else
36 #include <bitset>
37 #endif
38 #include "id3/id3lib_frame.h"
39 #include "header_frame.h"
40
41 class ID3_FrameImpl
42 {
43 typedef std::bitset<ID3FN_LASTFIELDID> Bitset;
44 typedef std::vector<ID3_Field *> Fields;
45 public:
46 typedef Fields::iterator iterator;
47 typedef Fields::const_iterator const_iterator;
48 public:
49 ID3_FrameImpl(ID3_FrameID id = ID3FID_NOFRAME);
50 ID3_FrameImpl(const ID3_FrameHeader&);
51 ID3_FrameImpl(const ID3_Frame&);
52
54 virtual ~ID3_FrameImpl();
55
56 void Clear();
57
58 bool SetID(ID3_FrameID id);
59 ID3_FrameID GetID() const { return _hdr.GetFrameID(); }
60
61 ID3_Field* GetField(ID3_FieldID name) const;
62
63 size_t NumFields() const;
64
65 const char* GetDescription() const;
66 static const char* GetDescription(ID3_FrameID);
67
68 const char* GetTextID() const { return _hdr.GetTextID(); }
69
70 ID3_FrameImpl& operator=(const ID3_Frame &);
71 bool HasChanged() const;
72 bool Parse(ID3_Reader&);
73 void Render(ID3_Writer&) const;
74 size_t Size();
75 bool Contains(ID3_FieldID fld) const
76 { return _bitset.test(fld); }
77 bool SetSpec(ID3_V2Spec);
78 ID3_V2Spec GetSpec() const;
79
85 bool SetCompression(bool b) { return _hdr.SetCompression(b); }
94 bool GetCompression() const { return _hdr.GetCompression(); }
95 size_t GetDataSize() const { return _hdr.GetDataSize(); }
96
97 bool SetEncryptionID(uchar id)
98 {
99 bool changed = id != _encryption_id;
100 _encryption_id = id;
101 _changed = _changed || changed;
102 _hdr.SetEncryption(true);
103 return changed;
104 }
105 uchar GetEncryptionID() const { return _encryption_id; }
106 bool SetGroupingID(uchar id)
107 {
108 bool changed = id != _grouping_id;
109 _grouping_id = id;
110 _changed = _changed || changed;
111 _hdr.SetGrouping(true);
112 return changed;
113 }
114 uchar GetGroupingID() const { return _grouping_id; }
115
116 iterator begin() { return _fields.begin(); }
117 iterator end() { return _fields.end(); }
118 const_iterator begin() const { return _fields.begin(); }
119 const_iterator end() const { return _fields.end(); }
120
121 protected:
122 bool _SetID(ID3_FrameID);
123 bool _ClearFields();
124 void _InitFields();
125 void _InitFieldBits();
126 void _UpdateFieldDeps();
127
128 private:
129 mutable bool _changed; // frame changed since last parse/render?
130 Bitset _bitset; // which fields are present?
131 Fields _fields;
132 ID3_FrameHeader _hdr; //
133 uchar _encryption_id; // encryption id
134 uchar _grouping_id; // grouping id
135 }
136 ;
137
138 #endif /* _ID3LIB_FRAME_IMPL_H_ */
ID3_FrameImpl::_SetID
bool _SetID(ID3_FrameID)
Definition: frame_impl.cpp:132
ID3_FrameImpl::GetCompression
bool GetCompression() const
Returns whether or not the compression flag is set.
Definition: frame_impl.h:94
ID3_FrameImpl::GetGroupingID
uchar GetGroupingID() const
Definition: frame_impl.h:114
ID3_FrameImpl::_InitFields
void _InitFields()
Definition: frame_impl.cpp:97
ID3_FrameImpl::GetEncryptionID
uchar GetEncryptionID() const
Definition: frame_impl.h:105
ID3_FrameHeader::GetCompression
bool GetCompression() const
Definition: header_frame.h:67
ID3_FrameImpl::begin
const_iterator begin() const
Definition: frame_impl.h:118
ID3_FrameImpl::GetTextID
const char * GetTextID() const
Definition: frame_impl.h:68
ID3_FrameImpl::NumFields
size_t NumFields() const
Definition: frame_impl.cpp:167
ID3_FrameHeader::SetGrouping
bool SetGrouping(bool b)
Definition: header_frame.h:65
ID3_FrameImpl::iterator
Fields::iterator iterator
Definition: frame_impl.h:46
ID3_FrameImpl::GetDataSize
size_t GetDataSize() const
Definition: frame_impl.h:95
ID3_FrameImpl
Definition: frame_impl.h:41
ID3_FrameImpl::SetEncryptionID
bool SetEncryptionID(uchar id)
Definition: frame_impl.h:97
ID3_FrameImpl::_UpdateFieldDeps
void _UpdateFieldDeps()
ID3_FrameHeader::GetFrameID
ID3_FrameID GetFrameID() const
Definition: header_frame.cpp:209
ID3_Header::GetDataSize
size_t GetDataSize() const
Definition: header.h:71
ID3FID_NOFRAME
No known frame.
Definition: globals.h:231
ID3_FrameID
ID3_FrameID
Enumeration of the different types of frames recognized by id3lib.
Definition: globals.h:229
ID3_FrameHeader::SetCompression
bool SetCompression(bool b)
Definition: header_frame.h:63
ID3_FrameImpl::~ID3_FrameImpl
virtual ~ID3_FrameImpl()
Destructor.
Definition: frame_impl.cpp:70
ID3_FrameImpl::begin
iterator begin()
Definition: frame_impl.h:116
uchar
unsigned char uchar
Definition: globals.h:114
ID3_FrameImpl::SetGroupingID
bool SetGroupingID(uchar id)
Definition: frame_impl.h:106
ID3_FrameImpl::ID3_FrameImpl
ID3_FrameImpl(ID3_FrameID id=ID3FID_NOFRAME)
Definition: frame_impl.cpp:38
ID3_FrameImpl::SetID
bool SetID(ID3_FrameID id)
Definition: frame_impl.cpp:121
ID3_Reader
Definition: reader.h:33
ID3_FrameImpl::GetID
ID3_FrameID GetID() const
Definition: frame_impl.h:59
ID3_FrameHeader::SetEncryption
bool SetEncryption(bool b)
Definition: header_frame.h:64
ID3_V2Spec
ID3_V2Spec
Definition: globals.h:161
ID3_FrameImpl::end
const_iterator end() const
Definition: frame_impl.h:119
ID3_FrameImpl::HasChanged
bool HasChanged() const
Definition: frame_impl.cpp:207
ID3_FrameHeader
Definition: header_frame.h:36
ID3_FrameImpl::_InitFieldBits
void _InitFieldBits()
ID3_FrameImpl::Clear
void Clear()
Definition: frame_impl.cpp:89
ID3_Frame
The representative class of an id3v2 frame.
Definition: id3lib_frame.h:38
ID3_FrameImpl::GetDescription
const char * GetDescription() const
Definition: frame_impl.cpp:258
header_frame.h
ID3_FrameImpl::Parse
bool Parse(ID3_Reader &)
Definition: frame_parse.cpp:109
ID3_FrameImpl::SetSpec
bool SetSpec(ID3_V2Spec)
Definition: frame_impl.cpp:140
ID3_FrameImpl::const_iterator
Fields::const_iterator const_iterator
Definition: frame_impl.h:47
ID3_Field
The representative class of an ID3v2 field.
Definition: field.h:36
ID3_Writer
Definition: writer.h:33
ID3_FrameImpl::end
iterator end()
Definition: frame_impl.h:117
ID3_FrameImpl::SetCompression
bool SetCompression(bool b)
Sets the compression flag within the frame.
Definition: frame_impl.h:85
id3lib_frame.h
ID3_FrameImpl::_ClearFields
bool _ClearFields()
Definition: frame_impl.cpp:75
ID3_FrameHeader::GetTextID
const char * GetTextID() const
Definition: header_frame.cpp:163
ID3_FrameImpl::Size
size_t Size()
Definition: frame_impl.cpp:172
ID3_FrameImpl::GetSpec
ID3_V2Spec GetSpec() const
Definition: frame_impl.cpp:145
ID3_FrameImpl::Contains
bool Contains(ID3_FieldID fld) const
Definition: frame_impl.h:75
ID3_FrameImpl::Render
void Render(ID3_Writer &) const
Definition: frame_render.cpp:71
ID3_FieldID
ID3_FieldID
Enumeration of the different types of fields in a frame.
Definition: globals.h:197
ID3_FrameImpl::GetField
ID3_Field * GetField(ID3_FieldID name) const
Definition: frame_impl.cpp:150
ID3_FrameImpl::operator=
ID3_FrameImpl & operator=(const ID3_Frame &)
Definition: frame_impl.cpp:223