id3lib  3.8.3
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 
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:
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 
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 
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; }
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_ */

Generated for id3lib by doxygen 1.8.4