blob: bcd1ccc3ce5614f473836c2658da1fd73ee77839 [file] [log] [blame]
Josh Coalsonfda98fb2002-05-17 06:33:39 +00001/* libFLAC++ - Free Lossless Audio Codec library
2 * Copyright (C) 2002 Josh Coalson
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20#ifndef FLACPP__METADATA_H
21#define FLACPP__METADATA_H
22
Josh Coalson55bc5872002-10-16 22:18:32 +000023#include "export.h"
24
Josh Coalsonfda98fb2002-05-17 06:33:39 +000025#include "FLAC/metadata.h"
26
Josh Coalsonfb74f102002-05-22 05:33:29 +000027// ===============================================================
28//
29// Full documentation for the metadata interface can be found
30// in the C layer in include/FLAC/metadata.h
31//
32// ===============================================================
33
Josh Coalsonf6efd9c2002-07-27 04:59:54 +000034/** \file include/FLAC++/metadata.h
35 *
36 * \brief
37 * This module provides classes for creating and manipulating FLAC
38 * metadata blocks in memory, and three progressively more powerful
39 * interfaces for traversing and editing metadata in FLAC files.
40 *
41 * See the detailed documentation for each interface in the
42 * \link flacpp_metadata metadata \endlink module.
43 */
44
45/** \defgroup flacpp_metadata FLAC++/metadata.h: metadata interfaces
46 * \ingroup flacpp
47 *
48 * \brief
49 * This module provides classes for creating and manipulating FLAC
50 * metadata blocks in memory, and three progressively more powerful
51 * interfaces for traversing and editing metadata in FLAC files.
52 *
53 * The behavior closely mimics the C layer interface; be sure to read
54 * the detailed description of the
55 * \link flac_metadata C metadata module \endlink.
56 */
57
Josh Coalsonfb74f102002-05-22 05:33:29 +000058
Josh Coalsonfda98fb2002-05-17 06:33:39 +000059namespace FLAC {
60 namespace Metadata {
61
Josh Coalsonfb74f102002-05-22 05:33:29 +000062 // ============================================================
63 //
64 // Metadata objects
65 //
66 // ============================================================
67
Josh Coalsonf6efd9c2002-07-27 04:59:54 +000068 /** \defgroup flacpp_metadata_object FLAC++/metadata.h: metadata object classes
69 * \ingroup flacpp_metadata
70 *
71 * This module contains classes representing FLAC metadata
72 * blocks in memory.
73 *
74 * The behavior closely mimics the C layer interface; be
75 * sure to read the detailed description of the
76 * \link flac_metadata_object C metadata object module \endlink.
77 *
78 * Any time a metadata object is constructed or assigned, you
79 * should check is_valid() to make sure the underlying
80 * ::FLAC__StreamMetadata object was able to be created.
81 *
82 * \warning
83 * When the get_*() methods of any metadata object method
84 * return you a const pointer, DO NOT disobey and write into it.
85 * Always use the set_*() methods.
86 *
87 * \{
88 */
Josh Coalsoncc682512002-06-08 04:53:42 +000089
Josh Coalsonf6efd9c2002-07-27 04:59:54 +000090 /** Base class for all metadata block types.
91 */
Josh Coalson55bc5872002-10-16 22:18:32 +000092 class FLACPP_API Prototype {
Josh Coalsonfda98fb2002-05-17 06:33:39 +000093 protected:
Josh Coalsonf6efd9c2002-07-27 04:59:54 +000094 //@{
95 /** Constructs a copy of the given object. This form
96 * always performs a deep copy.
97 */
98 Prototype(const Prototype &);
99 Prototype(const ::FLAC__StreamMetadata &);
100 Prototype(const ::FLAC__StreamMetadata *);
101 //@}
Josh Coalson83961752002-07-09 06:12:59 +0000102
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000103 /** Constructs an object with copy control. When \a copy
104 * is \c true, behaves identically to
105 * FLAC::Metadata::Prototype::Prototype(const ::FLAC__StreamMetadata *object).
106 * When \a copy is \c false, the instance takes ownership of
107 * the pointer and the ::FLAC__StreamMetadata object will
108 * be freed by the destructor.
109 *
110 * \assert
111 * \code object != NULL \endcode
112 */
Josh Coalson83961752002-07-09 06:12:59 +0000113 Prototype(::FLAC__StreamMetadata *object, bool copy);
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000114
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000115 //@{
116 /** Assign from another object. Always performs a deep copy. */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000117 void operator=(const Prototype &);
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000118 void operator=(const ::FLAC__StreamMetadata &);
119 void operator=(const ::FLAC__StreamMetadata *);
120 //@}
Josh Coalson57ba6f42002-06-07 05:27:37 +0000121
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000122 /** Deletes the underlying ::FLAC__StreamMetadata object.
123 */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000124 virtual void clear();
125
Josh Coalsoncc682512002-06-08 04:53:42 +0000126 ::FLAC__StreamMetadata *object_;
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000127 public:
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000128 /** Deletes the underlying ::FLAC__StreamMetadata object.
129 */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000130 virtual ~Prototype();
131
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000132 //@{
133 /** Check for equality, performing a deep compare by following pointers. */
Josh Coalsoncc682512002-06-08 04:53:42 +0000134 inline bool operator==(const Prototype &) const;
135 inline bool operator==(const ::FLAC__StreamMetadata &) const;
136 inline bool operator==(const ::FLAC__StreamMetadata *) const;
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000137 //@}
138
139 //@{
140 /** Check for inequality, performing a deep compare by following pointers. */
Josh Coalsoncc682512002-06-08 04:53:42 +0000141 inline bool operator!=(const Prototype &) const;
142 inline bool operator!=(const ::FLAC__StreamMetadata &) const;
143 inline bool operator!=(const ::FLAC__StreamMetadata *) const;
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000144 //@}
Josh Coalsoncc682512002-06-08 04:53:42 +0000145
Josh Coalsonfb74f102002-05-22 05:33:29 +0000146 friend class SimpleIterator;
147 friend class Iterator;
148
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000149 /** Returns \c true if the object was correctly constructed
150 * (i.e. the underlying ::FLAC__StreamMetadata object was
151 * properly allocated), else \c false.
152 */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000153 inline bool is_valid() const;
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000154
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000155 /** Returns \c true if this block is the last block in a
156 * stream, else \c false.
157 *
158 * \assert
159 * \code is_valid() \endcode
160 */
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000161 bool get_is_last() const;
Josh Coalsoncc682512002-06-08 04:53:42 +0000162
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000163 /** Returns the type of the block.
164 *
165 * \assert
166 * \code is_valid() \endcode
167 */
168 ::FLAC__MetadataType get_type() const;
169
170 /** Returns the stream length of the metadata block.
171 *
172 * \note
173 * The length does not include the metadata block header,
174 * per spec.
175 *
176 * \assert
177 * \code is_valid() \endcode
178 */
179 unsigned get_length() const;
180
181 /** Sets the "is_last" flag for the block. When using the iterators
182 * it is not necessary to set this flag; they will do it for you.
183 *
184 * \assert
185 * \code is_valid() \endcode
186 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000187 void set_is_last(bool);
Josh Coalsonfb74f102002-05-22 05:33:29 +0000188 private:
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000189 /** Private and undefined so you can't use it. */
190 Prototype();
Josh Coalsonfb74f102002-05-22 05:33:29 +0000191
192 // These are used only by Iterator
193 bool is_reference_;
194 inline void set_reference(bool x) { is_reference_ = x; }
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000195 };
196
Josh Coalson765ff502002-08-27 05:46:11 +0000197 inline bool Prototype::operator==(const Prototype &object) const
Josh Coalsond57c8d32002-06-11 06:15:28 +0000198 { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); }
Josh Coalson57ba6f42002-06-07 05:27:37 +0000199
Josh Coalson765ff502002-08-27 05:46:11 +0000200 inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const
Josh Coalsond57c8d32002-06-11 06:15:28 +0000201 { return (bool)::FLAC__metadata_object_is_equal(object_, &object); }
Josh Coalson57ba6f42002-06-07 05:27:37 +0000202
Josh Coalson765ff502002-08-27 05:46:11 +0000203 inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const
Josh Coalsond57c8d32002-06-11 06:15:28 +0000204 { return (bool)::FLAC__metadata_object_is_equal(object_, object); }
Josh Coalson57ba6f42002-06-07 05:27:37 +0000205
Josh Coalson765ff502002-08-27 05:46:11 +0000206 inline bool Prototype::operator!=(const Prototype &object) const
Josh Coalson57ba6f42002-06-07 05:27:37 +0000207 { return !operator==(object); }
208
Josh Coalson765ff502002-08-27 05:46:11 +0000209 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const
Josh Coalson57ba6f42002-06-07 05:27:37 +0000210 { return !operator==(object); }
211
Josh Coalson765ff502002-08-27 05:46:11 +0000212 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const
Josh Coalson57ba6f42002-06-07 05:27:37 +0000213 { return !operator==(object); }
214
215 inline bool Prototype::is_valid() const
216 { return 0 != object_; }
217
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000218 /** Create a deep copy of an object and return it. */
Josh Coalson55bc5872002-10-16 22:18:32 +0000219 FLACPP_API Prototype *clone(const Prototype *);
Josh Coalson57ba6f42002-06-07 05:27:37 +0000220
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000221
222 /** STREAMINFO metadata block.
Josh Coalson4dc35072002-08-20 03:56:52 +0000223 * See <A HREF="../format.html#metadata_block_streaminfo">format specification</A>.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000224 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000225 class FLACPP_API StreamInfo : public Prototype {
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000226 public:
227 StreamInfo();
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000228
229 //@{
230 /** Constructs a copy of the given object. This form
231 * always performs a deep copy.
232 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000233 inline StreamInfo(const StreamInfo &object): Prototype(object) { }
234 inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { }
235 inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { }
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000236 //@}
237
238 /** Constructs an object with copy control. See
239 * Prototype(::FLAC__StreamMetadata *object, bool copy).
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000240 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000241 inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000242
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000243 ~StreamInfo();
244
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000245 //@{
246 /** Assign from another object. Always performs a deep copy. */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000247 inline void operator=(const StreamInfo &object) { Prototype::operator=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000248 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
249 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000250 //@}
Josh Coalsonfb74f102002-05-22 05:33:29 +0000251
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000252 //@{
253 /** Check for equality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000254 inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000255 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
256 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000257 //@}
258
259 //@{
260 /** Check for inequality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000261 inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000262 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
263 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000264 //@}
Josh Coalson57ba6f42002-06-07 05:27:37 +0000265
Josh Coalson4dc35072002-08-20 03:56:52 +0000266 //@{
267 /** See <A HREF="../format.html#metadata_block_streaminfo">format specification</A>. */
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000268 unsigned get_min_blocksize() const;
269 unsigned get_max_blocksize() const;
270 unsigned get_min_framesize() const;
271 unsigned get_max_framesize() const;
272 unsigned get_sample_rate() const;
273 unsigned get_channels() const;
274 unsigned get_bits_per_sample() const;
275 FLAC__uint64 get_total_samples() const;
276 const FLAC__byte *get_md5sum() const;
277
278 void set_min_blocksize(unsigned value);
279 void set_max_blocksize(unsigned value);
280 void set_min_framesize(unsigned value);
281 void set_max_framesize(unsigned value);
282 void set_sample_rate(unsigned value);
283 void set_channels(unsigned value);
284 void set_bits_per_sample(unsigned value);
285 void set_total_samples(FLAC__uint64 value);
286 void set_md5sum(const FLAC__byte value[16]);
Josh Coalson4dc35072002-08-20 03:56:52 +0000287 //@}
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000288 };
289
Josh Coalson4dc35072002-08-20 03:56:52 +0000290 /** PADDING metadata block.
291 * See <A HREF="../format.html#metadata_block_padding">format specification</A>.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000292 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000293 class FLACPP_API Padding : public Prototype {
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000294 public:
295 Padding();
Josh Coalson4dc35072002-08-20 03:56:52 +0000296
297 //@{
298 /** Constructs a copy of the given object. This form
299 * always performs a deep copy.
300 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000301 inline Padding(const Padding &object): Prototype(object) { }
302 inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { }
303 inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000304 //@}
305
306 /** Constructs an object with copy control. See
307 * Prototype(::FLAC__StreamMetadata *object, bool copy).
308 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000309 inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000310
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000311 ~Padding();
Josh Coalsonfb74f102002-05-22 05:33:29 +0000312
Josh Coalson4dc35072002-08-20 03:56:52 +0000313 //@{
314 /** Assign from another object. Always performs a deep copy. */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000315 inline void operator=(const Padding &object) { Prototype::operator=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000316 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
317 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000318 //@}
Josh Coalsonb2b53582002-05-31 06:20:50 +0000319
Josh Coalson4dc35072002-08-20 03:56:52 +0000320 //@{
321 /** Check for equality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000322 inline bool operator==(const Padding &object) const { return Prototype::operator==(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000323 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
324 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000325 //@}
326
327 //@{
328 /** Check for inequality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000329 inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000330 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
331 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000332 //@}
Josh Coalson57ba6f42002-06-07 05:27:37 +0000333
Josh Coalsonb2b53582002-05-31 06:20:50 +0000334 void set_length(unsigned length);
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000335 };
336
Josh Coalson4dc35072002-08-20 03:56:52 +0000337 /** APPLICATION metadata block.
338 * See <A HREF="../format.html#metadata_block_application">format specification</A>.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000339 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000340 class FLACPP_API Application : public Prototype {
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000341 public:
342 Application();
Josh Coalson4dc35072002-08-20 03:56:52 +0000343 //
344 //@{
345 /** Constructs a copy of the given object. This form
346 * always performs a deep copy.
347 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000348 inline Application(const Application &object): Prototype(object) { }
349 inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { }
350 inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000351 //@}
352
353 /** Constructs an object with copy control. See
354 * Prototype(::FLAC__StreamMetadata *object, bool copy).
355 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000356 inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000357
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000358 ~Application();
359
Josh Coalson4dc35072002-08-20 03:56:52 +0000360 //@{
361 /** Assign from another object. Always performs a deep copy. */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000362 inline void operator=(const Application &object) { Prototype::operator=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000363 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
364 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000365 //@}
Josh Coalsonfb74f102002-05-22 05:33:29 +0000366
Josh Coalson4dc35072002-08-20 03:56:52 +0000367 //@{
368 /** Check for equality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000369 inline bool operator==(const Application &object) const { return Prototype::operator==(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000370 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
371 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000372 //@}
373
374 //@{
375 /** Check for inequality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000376 inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000377 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
378 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000379 //@}
Josh Coalson57ba6f42002-06-07 05:27:37 +0000380
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000381 const FLAC__byte *get_id() const;
382 const FLAC__byte *get_data() const;
383
Josh Coalsoncc682512002-06-08 04:53:42 +0000384 void set_id(const FLAC__byte value[4]);
Josh Coalson4dc35072002-08-20 03:56:52 +0000385 //! This form always copies \a data
386 bool set_data(const FLAC__byte *data, unsigned length);
Josh Coalsoncc682512002-06-08 04:53:42 +0000387 bool set_data(FLAC__byte *data, unsigned length, bool copy);
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000388 };
389
Josh Coalson4dc35072002-08-20 03:56:52 +0000390 /** SEEKTABLE metadata block.
391 * See <A HREF="../format.html#metadata_block_seektable">format specification</A>.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000392 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000393 class FLACPP_API SeekTable : public Prototype {
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000394 public:
395 SeekTable();
Josh Coalson4dc35072002-08-20 03:56:52 +0000396
397 //@{
398 /** Constructs a copy of the given object. This form
399 * always performs a deep copy.
400 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000401 inline SeekTable(const SeekTable &object): Prototype(object) { }
402 inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { }
403 inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000404 //@}
405
406 /** Constructs an object with copy control. See
407 * Prototype(::FLAC__StreamMetadata *object, bool copy).
408 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000409 inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000410
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000411 ~SeekTable();
Josh Coalsonfb74f102002-05-22 05:33:29 +0000412
Josh Coalson4dc35072002-08-20 03:56:52 +0000413 //@{
414 /** Assign from another object. Always performs a deep copy. */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000415 inline void operator=(const SeekTable &object) { Prototype::operator=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000416 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
417 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000418 //@}
Josh Coalsonb2b53582002-05-31 06:20:50 +0000419
Josh Coalson4dc35072002-08-20 03:56:52 +0000420 //@{
421 /** Check for equality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000422 inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000423 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
424 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000425 //@}
426
427 //@{
428 /** Check for inequality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000429 inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000430 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
431 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000432 //@}
Josh Coalson57ba6f42002-06-07 05:27:37 +0000433
Josh Coalsonb2b53582002-05-31 06:20:50 +0000434 unsigned get_num_points() const;
Josh Coalsoncc682512002-06-08 04:53:42 +0000435 ::FLAC__StreamMetadata_SeekPoint get_point(unsigned index) const;
Josh Coalsonb2b53582002-05-31 06:20:50 +0000436
Josh Coalson4dc35072002-08-20 03:56:52 +0000437 //! See FLAC__metadata_object_seektable_set_point()
Josh Coalsoncc682512002-06-08 04:53:42 +0000438 void set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
Josh Coalson4dc35072002-08-20 03:56:52 +0000439
440 //! See FLAC__metadata_object_seektable_insert_point()
Josh Coalsoncc682512002-06-08 04:53:42 +0000441 bool insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
Josh Coalson4dc35072002-08-20 03:56:52 +0000442
443 //! See FLAC__metadata_object_seektable_delete_point()
Josh Coalsonb2b53582002-05-31 06:20:50 +0000444 bool delete_point(unsigned index);
Josh Coalson28e08d82002-06-05 05:56:41 +0000445
Josh Coalson4dc35072002-08-20 03:56:52 +0000446 //! See FLAC__metadata_object_seektable_is_legal()
Josh Coalson28e08d82002-06-05 05:56:41 +0000447 bool is_legal() const;
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000448 };
449
Josh Coalson4dc35072002-08-20 03:56:52 +0000450 /** VORBIS_COMMENT metadata block.
451 * See <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000452 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000453 class FLACPP_API VorbisComment : public Prototype {
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000454 public:
Josh Coalson4dc35072002-08-20 03:56:52 +0000455 /** Convenience class for encapsulating Vorbis comment
456 * entries. An entry is a vendor string or a comment
457 * field. In the case of a vendor string, the field
458 * name is undefined; only the field value is relevant.
459 *
460 * A \a field as used in the methods refers to an
461 * entire 'NAME=VALUE' string; the string is not null-
462 * terminated and a length field is required since the
463 * string may contain embedded nulls.
464 *
465 * A \a field_name is what is on the left side of the
466 * first '=' in the \a field. By definition it is ASCII
467 * and so is null-terminated and does not require a
468 * length to describe it. \a field_name is undefined
469 * for a vendor string entry.
470 *
471 * A \a field_value is what is on the right side of the
472 * first '=' in the \a field. By definition, this may
473 * contain embedded nulls and so a \a field_value_length
474 * is requires to describe it.
475 *
476 * Always check is_valid() after the constructor or operator=
477 * to make sure memory was properly allocated.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000478 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000479 class FLACPP_API Entry {
Josh Coalsonb2b53582002-05-31 06:20:50 +0000480 public:
481 Entry();
482 Entry(const char *field, unsigned field_length);
483 Entry(const char *field_name, const char *field_value, unsigned field_value_length);
484 Entry(const Entry &entry);
485 void operator=(const Entry &entry);
486
487 virtual ~Entry();
488
489 virtual bool is_valid() const;
Josh Coalsonb2b53582002-05-31 06:20:50 +0000490
491 unsigned get_field_length() const;
492 unsigned get_field_name_length() const;
493 unsigned get_field_value_length() const;
494
Josh Coalsoncc682512002-06-08 04:53:42 +0000495 ::FLAC__StreamMetadata_VorbisComment_Entry get_entry() const;
Josh Coalsonb2b53582002-05-31 06:20:50 +0000496 const char *get_field() const;
497 const char *get_field_name() const;
498 const char *get_field_value() const;
499
500 bool set_field(const char *field, unsigned field_length);
501 bool set_field_name(const char *field_name);
502 bool set_field_value(const char *field_value, unsigned field_value_length);
503 protected:
504 bool is_valid_;
Josh Coalsoncc682512002-06-08 04:53:42 +0000505 ::FLAC__StreamMetadata_VorbisComment_Entry entry_;
Josh Coalsonb2b53582002-05-31 06:20:50 +0000506 char *field_name_;
507 unsigned field_name_length_;
508 char *field_value_;
509 unsigned field_value_length_;
510 private:
511 void zero();
512 void clear();
513 void clear_entry();
514 void clear_field_name();
515 void clear_field_value();
516 void construct(const char *field, unsigned field_length);
517 void construct(const char *field_name, const char *field_value, unsigned field_value_length);
518 void compose_field();
519 void parse_field();
520 };
521
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000522 VorbisComment();
Josh Coalson4dc35072002-08-20 03:56:52 +0000523
524 //@{
525 /** Constructs a copy of the given object. This form
526 * always performs a deep copy.
527 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000528 inline VorbisComment(const VorbisComment &object): Prototype(object) { }
529 inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { }
530 inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000531 //@}
532
533 /** Constructs an object with copy control. See
534 * Prototype(::FLAC__StreamMetadata *object, bool copy).
535 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000536 inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000537
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000538 ~VorbisComment();
Josh Coalsonfb74f102002-05-22 05:33:29 +0000539
Josh Coalson4dc35072002-08-20 03:56:52 +0000540 //@{
541 /** Assign from another object. Always performs a deep copy. */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000542 inline void operator=(const VorbisComment &object) { Prototype::operator=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000543 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
544 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000545 //@}
Josh Coalsonb2b53582002-05-31 06:20:50 +0000546
Josh Coalson4dc35072002-08-20 03:56:52 +0000547 //@{
548 /** Check for equality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000549 inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000550 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
551 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000552 //@}
553
554 //@{
555 /** Check for inequality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000556 inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000557 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
558 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000559 //@}
Josh Coalson57ba6f42002-06-07 05:27:37 +0000560
Josh Coalsonb2b53582002-05-31 06:20:50 +0000561 unsigned get_num_comments() const;
Josh Coalsoncc682512002-06-08 04:53:42 +0000562 Entry get_vendor_string() const; // only the Entry's field name should be used
Josh Coalsonb2b53582002-05-31 06:20:50 +0000563 Entry get_comment(unsigned index) const;
564
Josh Coalson87977ba2002-08-20 07:09:33 +0000565 //! See FLAC__metadata_object_vorbiscomment_set_vendor_string()
Josh Coalson4dc35072002-08-20 03:56:52 +0000566 //! \note Only the Entry's field name will be used.
Josh Coalson863dbf32002-11-16 06:30:30 +0000567 bool set_vendor_string(const Entry &entry);
Josh Coalson4dc35072002-08-20 03:56:52 +0000568
Josh Coalson87977ba2002-08-20 07:09:33 +0000569 //! See FLAC__metadata_object_vorbiscomment_set_comment()
Josh Coalsonb2b53582002-05-31 06:20:50 +0000570 bool set_comment(unsigned index, const Entry &entry);
Josh Coalson4dc35072002-08-20 03:56:52 +0000571
Josh Coalson87977ba2002-08-20 07:09:33 +0000572 //! See FLAC__metadata_object_vorbiscomment_insert_comment()
Josh Coalsonb2b53582002-05-31 06:20:50 +0000573 bool insert_comment(unsigned index, const Entry &entry);
Josh Coalson4dc35072002-08-20 03:56:52 +0000574
Josh Coalson87977ba2002-08-20 07:09:33 +0000575 //! See FLAC__metadata_object_vorbiscomment_delete_comment()
Josh Coalsonb2b53582002-05-31 06:20:50 +0000576 bool delete_comment(unsigned index);
Josh Coalsonfb74f102002-05-22 05:33:29 +0000577 };
578
Josh Coalson863dbf32002-11-16 06:30:30 +0000579 /** CUESHEET metadata block.
580 * See <A HREF="../format.html#metadata_block_cuesheet">format specification</A>.
581 */
582 class FLACPP_API CueSheet : public Prototype {
583 public:
584 /** Convenience class for encapsulating a cue sheet
585 * track.
586 *
587 * Always check is_valid() after the constructor or operator=
588 * to make sure memory was properly allocated.
589 */
590 class FLACPP_API Track {
591 protected:
592 ::FLAC__StreamMetadata_CueSheet_Track *object_;
593 public:
594 Track();
595 Track(const ::FLAC__StreamMetadata_CueSheet_Track *track);
596 Track(const Track &track);
597 void operator=(const Track &track);
598
599 virtual ~Track();
600
601 virtual bool is_valid() const;
602
603 inline FLAC__uint64 get_offset() const { return object_->offset; }
604 inline FLAC__byte get_number() const { return object_->number; }
605 inline const char *get_isrc() const { return object_->isrc; }
606 inline unsigned get_type() const { return object_->type; }
607 inline bool get_pre_emphasis() const { return object_->pre_emphasis; }
608
609 inline bool get_num_indices() const { return object_->num_indices; }
610 ::FLAC__StreamMetadata_CueSheet_Index get_index(unsigned i) const;
611
612 inline const ::FLAC__StreamMetadata_CueSheet_Track *get_track() const { return object_; }
613
614 inline void set_offset(FLAC__uint64 value) { object_->offset = value; }
615 inline void set_number(FLAC__byte value) { object_->number = value; }
Josh Coalson16219792002-11-19 06:19:29 +0000616 void set_isrc(const char value[12]);
Josh Coalson863dbf32002-11-16 06:30:30 +0000617 void set_type(unsigned value);
618 inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; }
619
Josh Coalson16219792002-11-19 06:19:29 +0000620 void set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index);
621 //@@@@ It's awkward but to insert/delete index points
622 //@@@@ you must use the routines in the CueSheet class.
Josh Coalson863dbf32002-11-16 06:30:30 +0000623 };
624
625 CueSheet();
626
627 //@{
628 /** Constructs a copy of the given object. This form
629 * always performs a deep copy.
630 */
631 inline CueSheet(const CueSheet &object): Prototype(object) { }
632 inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { }
633 inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { }
634 //@}
635
636 /** Constructs an object with copy control. See
637 * Prototype(::FLAC__StreamMetadata *object, bool copy).
638 */
639 inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
640
641 ~CueSheet();
642
643 //@{
644 /** Assign from another object. Always performs a deep copy. */
645 inline void operator=(const CueSheet &object) { Prototype::operator=(object); }
646 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
647 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
648 //@}
649
650 //@{
651 /** Check for equality, performing a deep compare by following pointers. */
652 inline bool operator==(const CueSheet &object) const { return Prototype::operator==(object); }
653 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
654 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
655 //@}
656
657 //@{
658 /** Check for inequality, performing a deep compare by following pointers. */
659 inline bool operator!=(const CueSheet &object) const { return Prototype::operator!=(object); }
660 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
661 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
662 //@}
663
664 const char *get_media_catalog_number() const;
665 FLAC__uint64 get_lead_in() const;
666
667 unsigned get_num_tracks() const;
668 Track get_track(unsigned i) const;
669
Josh Coalson16219792002-11-19 06:19:29 +0000670 void set_media_catalog_number(const char value[128]);
671 void set_lead_in(FLAC__uint64 value);
672
673 void set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
Josh Coalson863dbf32002-11-16 06:30:30 +0000674
675 //! See FLAC__metadata_object_cuesheet_track_insert_index()
676 bool insert_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
677
678 //! See FLAC__metadata_object_cuesheet_track_delete_index()
679 bool delete_index(unsigned track_num, unsigned index_num);
680
681 //! See FLAC__metadata_object_cuesheet_set_track()
682 bool set_track(unsigned i, const Track &track);
683
684 //! See FLAC__metadata_object_cuesheet_insert_track()
685 bool insert_track(unsigned i, const Track &track);
686
687 //! See FLAC__metadata_object_cuesheet_delete_track()
688 bool delete_track(unsigned i);
689
690 //! See FLAC__metadata_object_cuesheet_is_legal()
691 bool is_legal(bool check_cd_da_subset = false, const char **violation = 0) const;
692 };
693
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000694 /* \} */
695
Josh Coalsonb2b53582002-05-31 06:20:50 +0000696
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000697 /** \defgroup flacpp_metadata_level0 FLAC++/metadata.h: metadata level 0 interface
698 * \ingroup flacpp_metadata
699 *
700 * \brief
Josh Coalson4dc35072002-08-20 03:56:52 +0000701 * Level 0 metadata iterator.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000702 *
Josh Coalson4dc35072002-08-20 03:56:52 +0000703 * See the \link flac_metadata_level0 C layer equivalent \endlink
704 * for more.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000705 *
706 * \{
707 */
708
Josh Coalson4dc35072002-08-20 03:56:52 +0000709 //! See FLAC__metadata_get_streaminfo().
Josh Coalson55bc5872002-10-16 22:18:32 +0000710 FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo);
Josh Coalsonfb74f102002-05-22 05:33:29 +0000711
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000712 /* \} */
713
Josh Coalsonb2b53582002-05-31 06:20:50 +0000714
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000715 /** \defgroup flacpp_metadata_level1 FLAC++/metadata.h: metadata level 1 interface
716 * \ingroup flacpp_metadata
717 *
Josh Coalson4dc35072002-08-20 03:56:52 +0000718 * \brief
719 * Level 1 metadata iterator.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000720 *
Josh Coalson4dc35072002-08-20 03:56:52 +0000721 * The flow through the iterator in the C++ layer is similar
722 * to the C layer:
723 * - Create a SimpleIterator instance
724 * - Check SimpleIterator::is_valid()
725 * - Call SimpleIterator::init() and check the return
726 * - Traverse and/or edit. Edits are written to file
727 * immediately.
728 * - Destroy the SimpleIterator instance
729 *
730 * The ownership of pointers in the C++ layer follows that in
731 * the C layer, i.e.
732 * - The objects returned by get_block() are yours to
733 * modify, but changes are not reflected in the FLAC file
734 * until you call set_block(). The objects are also
735 * yours to delete; they are not automatically deleted
736 * when passed to set_block() or insert_block_after().
737 *
738 * See the \link flac_metadata_level1 C layer equivalent \endlink
739 * for more.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000740 *
741 * \{
742 */
743
Josh Coalson402da702002-08-21 03:40:11 +0000744 /** This class is a wrapper around the FLAC__metadata_simple_iterator
745 * structures and methods; see ::FLAC__Metadata_SimpleIterator.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000746 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000747 class FLACPP_API SimpleIterator {
Josh Coalsonfb74f102002-05-22 05:33:29 +0000748 public:
Josh Coalson55bc5872002-10-16 22:18:32 +0000749 class FLACPP_API Status {
Josh Coalsonfb74f102002-05-22 05:33:29 +0000750 public:
Josh Coalsoncc682512002-06-08 04:53:42 +0000751 inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { }
752 inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; }
753 inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; }
Josh Coalsonfb74f102002-05-22 05:33:29 +0000754 protected:
Josh Coalsoncc682512002-06-08 04:53:42 +0000755 ::FLAC__Metadata_SimpleIteratorStatus status_;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000756 };
757
758 SimpleIterator();
759 virtual ~SimpleIterator();
760
Josh Coalson3ac66932002-08-30 05:41:31 +0000761 bool init(const char *filename, bool read_only, bool preserve_file_stats);
Josh Coalsonfb74f102002-05-22 05:33:29 +0000762
763 bool is_valid() const;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000764 Status status();
765 bool is_writable() const;
766
767 bool next();
768 bool prev();
769
Josh Coalsoncc682512002-06-08 04:53:42 +0000770 ::FLAC__MetadataType get_block_type() const;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000771 Prototype *get_block();
772 bool set_block(Prototype *block, bool use_padding = true);
773 bool insert_block_after(Prototype *block, bool use_padding = true);
774 bool delete_block(bool use_padding = true);
775
776 protected:
Josh Coalsoncc682512002-06-08 04:53:42 +0000777 ::FLAC__Metadata_SimpleIterator *iterator_;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000778 void clear();
779 };
780
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000781 /* \} */
782
Josh Coalsonb2b53582002-05-31 06:20:50 +0000783
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000784 /** \defgroup flacpp_metadata_level2 FLAC++/metadata.h: metadata level 2 interface
785 * \ingroup flacpp_metadata
786 *
Josh Coalson4dc35072002-08-20 03:56:52 +0000787 * \brief
788 * Level 2 metadata iterator.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000789 *
Josh Coalson4dc35072002-08-20 03:56:52 +0000790 * The flow through the iterator in the C++ layer is similar
791 * to the C layer:
792 * - Create a Chain instance
793 * - Check Chain::is_valid()
794 * - Call Chain::read() and check the return
795 * - Traverse and/or edit with an Iterator or with
796 * Chain::merge_padding() or Chain::sort_padding()
797 * - Write changes back to FLAC file with Chain::write()
798 * - Destroy the Chain instance
799 *
800 * The ownership of pointers in the C++ layer follows that in
801 * the C layer, i.e.
802 * - The objects returned by Iterator::get_block() are
803 * owned by the iterator and should not be deleted.
804 * When you modify the block, you are directly editing
805 * what's in the chain and do not need to call
806 * Iterator::set_block(). However the changes will not
807 * be reflected in the FLAC file until the chain is
808 * written with Chain::write().
809 * - When you pass an object to Iterator::set_block(),
810 * Iterator::insert_block_before(), or
811 * Iterator::insert_block_after(), the iterator takes
812 * ownership of the block and it will be deleted with the
813 * chain.
814 *
815 * See the \link flac_metadata_level2 C layer equivalent \endlink
816 * for more.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000817 *
818 * \{
819 */
820
Josh Coalson402da702002-08-21 03:40:11 +0000821 /** This class is a wrapper around the FLAC__metadata_chain
822 * structures and methods; see ::FLAC__Metadata_Chain.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000823 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000824 class FLACPP_API Chain {
Josh Coalsonfb74f102002-05-22 05:33:29 +0000825 public:
Josh Coalson55bc5872002-10-16 22:18:32 +0000826 class FLACPP_API Status {
Josh Coalsonfb74f102002-05-22 05:33:29 +0000827 public:
Josh Coalsoncc682512002-06-08 04:53:42 +0000828 inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { }
829 inline operator ::FLAC__Metadata_ChainStatus() const { return status_; }
830 inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; }
Josh Coalsonfb74f102002-05-22 05:33:29 +0000831 protected:
Josh Coalsoncc682512002-06-08 04:53:42 +0000832 ::FLAC__Metadata_ChainStatus status_;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000833 };
834
835 Chain();
836 virtual ~Chain();
837
838 friend class Iterator;
839
840 bool is_valid() const;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000841 Status status();
842
843 bool read(const char *filename);
844 bool write(bool use_padding = true, bool preserve_file_stats = false);
845
846 void merge_padding();
847 void sort_padding();
848
849 protected:
Josh Coalsoncc682512002-06-08 04:53:42 +0000850 ::FLAC__Metadata_Chain *chain_;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000851 virtual void clear();
852 };
853
Josh Coalson402da702002-08-21 03:40:11 +0000854 /** This class is a wrapper around the FLAC__metadata_iterator
855 * structures and methods; see ::FLAC__Metadata_Iterator.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000856 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000857 class FLACPP_API Iterator {
Josh Coalsonfb74f102002-05-22 05:33:29 +0000858 public:
859 Iterator();
860 virtual ~Iterator();
861
862 bool is_valid() const;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000863
Josh Coalson999be3b2002-06-10 04:42:35 +0000864 void init(Chain &chain);
Josh Coalsonfb74f102002-05-22 05:33:29 +0000865
866 bool next();
867 bool prev();
868
Josh Coalsoncc682512002-06-08 04:53:42 +0000869 ::FLAC__MetadataType get_block_type() const;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000870 Prototype *get_block();
871 bool set_block(Prototype *block);
872 bool delete_block(bool replace_with_padding);
873 bool insert_block_before(Prototype *block);
874 bool insert_block_after(Prototype *block);
875
876 protected:
Josh Coalsoncc682512002-06-08 04:53:42 +0000877 ::FLAC__Metadata_Iterator *iterator_;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000878 virtual void clear();
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000879 };
880
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000881 /* \} */
882
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000883 };
884};
885
886#endif