id3lib  3.8.3
header_tag.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 // $Id: header_tag.h,v 1.2 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_TAG_H_
30 #define _ID3LIB_HEADER_TAG_H_
31 
32 #include "header.h"
33 
34 class ID3_TagHeader : public ID3_Header
35 {
36 public:
37 
38  enum
39  {
43  HEADER_FLAG_FOOTER = 1 << 4
44  };
45 
46  enum
47  {
51  EXT_HEADER_FLAG_BIT4 = 1 << 4
52  };
53 
55  virtual ~ID3_TagHeader() { ; }
56  ID3_TagHeader(const ID3_TagHeader& rhs) : ID3_Header() { *this = rhs; }
57 
58  bool SetSpec(ID3_V2Spec);
59  size_t Size() const;
60  void Render(ID3_Writer&) const;
61  bool Parse(ID3_Reader&);
64  { this->ID3_Header::operator=(hdr); return *this; }
65 
66  bool SetUnsync(bool b)
67  {
68  bool changed = _flags.set(HEADER_FLAG_UNSYNC, b);
69  _changed = _changed || changed;
70  return changed;
71  }
72  bool GetUnsync() const { return _flags.test(HEADER_FLAG_UNSYNC); }
73  bool SetExtended(bool b)
74  {
75  bool changed = _flags.set(HEADER_FLAG_EXTENDED, b);
76  _changed = _changed || changed;
77  return changed;
78  }
79  bool GetExtended() const { return _flags.test(HEADER_FLAG_EXTENDED); }
80  bool SetExperimental(bool b)
81  {
82  bool changed = _flags.set(HEADER_FLAG_EXPERIMENTAL, b);
83  _changed = _changed || changed;
84  return changed;
85  }
87  bool SetFooter(bool b)
88  {
89  bool changed = _flags.set(HEADER_FLAG_FOOTER, b);
90  _changed = _changed || changed;
91  return changed;
92  }
93  bool GetFooter() const { return _flags.test(HEADER_FLAG_FOOTER); }
94 
95  // id3v2 tag header signature: $49 44 33 MM mm GG ss ss ss ss
96  // MM = major version (will never be 0xFF)
97  // mm = minor version (will never be 0xFF)
98  // ff = flags byte
99  // ss = size bytes (less than $80)
100  static const char* const ID;
101  enum
102  {
103  ID_SIZE = 3,
108  SIZE = 10 // does not include extented headers
109  };
110 
111 };
112 
113 #endif /* _ID3LIB_HEADER_TAG_H_ */
bool test(TYPE f) const
Definition: flags.h:42
bool set(TYPE f)
Definition: flags.h:43
bool _changed
Definition: header.h:106
ID3_Header & operator=(const ID3_Header &rhs)
Definition: header.h:90
ID3_Flags _flags
Definition: header.h:104
ID3_TagHeader(const ID3_TagHeader &rhs)
Definition: header_tag.h:56
bool SetExperimental(bool b)
Definition: header_tag.h:80
void Render(ID3_Writer &) const
Definition: header_tag.cpp:66
bool GetUnsync() const
Definition: header_tag.h:72
bool Parse(ID3_Reader &)
Definition: header_tag.cpp:101
void ParseExtended(ID3_Reader &)
Definition: header_tag.cpp:134
static const char *const ID
Definition: header_tag.h:100
virtual ~ID3_TagHeader()
Definition: header_tag.h:55
bool SetFooter(bool b)
Definition: header_tag.h:87
size_t Size() const
Definition: header_tag.cpp:53
bool GetExtended() const
Definition: header_tag.h:79
bool GetExperimental() const
Definition: header_tag.h:86
bool SetSpec(ID3_V2Spec)
Definition: header_tag.cpp:39
@ EXT_HEADER_FLAG_BIT4
Definition: header_tag.h:51
@ EXT_HEADER_FLAG_BIT2
Definition: header_tag.h:49
@ EXT_HEADER_FLAG_BIT1
Definition: header_tag.h:48
@ EXT_HEADER_FLAG_BIT3
Definition: header_tag.h:50
bool SetExtended(bool b)
Definition: header_tag.h:73
bool SetUnsync(bool b)
Definition: header_tag.h:66
@ HEADER_FLAG_FOOTER
Definition: header_tag.h:43
@ HEADER_FLAG_EXPERIMENTAL
Definition: header_tag.h:42
@ HEADER_FLAG_UNSYNC
Definition: header_tag.h:40
@ HEADER_FLAG_EXTENDED
Definition: header_tag.h:41
ID3_TagHeader & operator=(const ID3_TagHeader &hdr)
Definition: header_tag.h:63
bool GetFooter() const
Definition: header_tag.h:93
ID3_V2Spec
Definition: globals.h:162