blob: 08b15b0eab83e8e259caa642ae67943839ddf4eb [file] [log] [blame]
Josh Coalsonfda98fb2002-05-17 06:33:39 +00001/* libFLAC++ - Free Lossless Audio Codec library
Josh Coalson95643902004-01-17 04:14:43 +00002 * Copyright (C) 2002,2003,2004 Josh Coalson
Josh Coalsonfda98fb2002-05-17 06:33:39 +00003 *
Josh Coalsonafd81072003-01-31 23:34:56 +00004 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
Josh Coalsonfda98fb2002-05-17 06:33:39 +00007 *
Josh Coalsonafd81072003-01-31 23:34:56 +00008 * - Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
Josh Coalsonfda98fb2002-05-17 06:33:39 +000010 *
Josh Coalsonafd81072003-01-31 23:34:56 +000011 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * - Neither the name of the Xiph.org Foundation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Josh Coalsonfda98fb2002-05-17 06:33:39 +000030 */
31
32#ifndef FLACPP__METADATA_H
33#define FLACPP__METADATA_H
34
Josh Coalson55bc5872002-10-16 22:18:32 +000035#include "export.h"
36
Josh Coalsonfda98fb2002-05-17 06:33:39 +000037#include "FLAC/metadata.h"
38
Josh Coalsonfb74f102002-05-22 05:33:29 +000039// ===============================================================
40//
41// Full documentation for the metadata interface can be found
42// in the C layer in include/FLAC/metadata.h
43//
44// ===============================================================
45
Josh Coalsonf6efd9c2002-07-27 04:59:54 +000046/** \file include/FLAC++/metadata.h
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 * See the detailed documentation for each interface in the
54 * \link flacpp_metadata metadata \endlink module.
55 */
56
57/** \defgroup flacpp_metadata FLAC++/metadata.h: metadata interfaces
58 * \ingroup flacpp
59 *
60 * \brief
61 * This module provides classes for creating and manipulating FLAC
62 * metadata blocks in memory, and three progressively more powerful
63 * interfaces for traversing and editing metadata in FLAC files.
64 *
65 * The behavior closely mimics the C layer interface; be sure to read
66 * the detailed description of the
67 * \link flac_metadata C metadata module \endlink.
68 */
69
Josh Coalsonfb74f102002-05-22 05:33:29 +000070
Josh Coalsonfda98fb2002-05-17 06:33:39 +000071namespace FLAC {
72 namespace Metadata {
73
Josh Coalsonfb74f102002-05-22 05:33:29 +000074 // ============================================================
75 //
76 // Metadata objects
77 //
78 // ============================================================
79
Josh Coalsonf6efd9c2002-07-27 04:59:54 +000080 /** \defgroup flacpp_metadata_object FLAC++/metadata.h: metadata object classes
81 * \ingroup flacpp_metadata
82 *
83 * This module contains classes representing FLAC metadata
84 * blocks in memory.
85 *
86 * The behavior closely mimics the C layer interface; be
87 * sure to read the detailed description of the
88 * \link flac_metadata_object C metadata object module \endlink.
89 *
90 * Any time a metadata object is constructed or assigned, you
91 * should check is_valid() to make sure the underlying
92 * ::FLAC__StreamMetadata object was able to be created.
93 *
94 * \warning
95 * When the get_*() methods of any metadata object method
96 * return you a const pointer, DO NOT disobey and write into it.
97 * Always use the set_*() methods.
98 *
99 * \{
100 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000101
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000102 /** Base class for all metadata block types.
103 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000104 class FLACPP_API Prototype {
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000105 protected:
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000106 //@{
107 /** Constructs a copy of the given object. This form
108 * always performs a deep copy.
109 */
110 Prototype(const Prototype &);
111 Prototype(const ::FLAC__StreamMetadata &);
112 Prototype(const ::FLAC__StreamMetadata *);
113 //@}
Josh Coalson83961752002-07-09 06:12:59 +0000114
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000115 /** Constructs an object with copy control. When \a copy
116 * is \c true, behaves identically to
117 * FLAC::Metadata::Prototype::Prototype(const ::FLAC__StreamMetadata *object).
118 * When \a copy is \c false, the instance takes ownership of
119 * the pointer and the ::FLAC__StreamMetadata object will
120 * be freed by the destructor.
121 *
122 * \assert
123 * \code object != NULL \endcode
124 */
Josh Coalson83961752002-07-09 06:12:59 +0000125 Prototype(::FLAC__StreamMetadata *object, bool copy);
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000126
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000127 //@{
128 /** Assign from another object. Always performs a deep copy. */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000129 void operator=(const Prototype &);
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000130 void operator=(const ::FLAC__StreamMetadata &);
131 void operator=(const ::FLAC__StreamMetadata *);
132 //@}
Josh Coalson57ba6f42002-06-07 05:27:37 +0000133
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000134 /** Deletes the underlying ::FLAC__StreamMetadata object.
135 */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000136 virtual void clear();
137
Josh Coalsoncc682512002-06-08 04:53:42 +0000138 ::FLAC__StreamMetadata *object_;
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000139 public:
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000140 /** Deletes the underlying ::FLAC__StreamMetadata object.
141 */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000142 virtual ~Prototype();
143
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000144 //@{
145 /** Check for equality, performing a deep compare by following pointers. */
Josh Coalsoncc682512002-06-08 04:53:42 +0000146 inline bool operator==(const Prototype &) const;
147 inline bool operator==(const ::FLAC__StreamMetadata &) const;
148 inline bool operator==(const ::FLAC__StreamMetadata *) const;
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000149 //@}
150
151 //@{
152 /** Check for inequality, performing a deep compare by following pointers. */
Josh Coalsoncc682512002-06-08 04:53:42 +0000153 inline bool operator!=(const Prototype &) const;
154 inline bool operator!=(const ::FLAC__StreamMetadata &) const;
155 inline bool operator!=(const ::FLAC__StreamMetadata *) const;
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000156 //@}
Josh Coalsoncc682512002-06-08 04:53:42 +0000157
Josh Coalsonfb74f102002-05-22 05:33:29 +0000158 friend class SimpleIterator;
159 friend class Iterator;
160
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000161 /** Returns \c true if the object was correctly constructed
162 * (i.e. the underlying ::FLAC__StreamMetadata object was
163 * properly allocated), else \c false.
164 */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000165 inline bool is_valid() const;
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000166
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000167 /** Returns \c true if this block is the last block in a
168 * stream, else \c false.
169 *
170 * \assert
171 * \code is_valid() \endcode
172 */
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000173 bool get_is_last() const;
Josh Coalsoncc682512002-06-08 04:53:42 +0000174
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000175 /** Returns the type of the block.
176 *
177 * \assert
178 * \code is_valid() \endcode
179 */
180 ::FLAC__MetadataType get_type() const;
181
182 /** Returns the stream length of the metadata block.
183 *
184 * \note
185 * The length does not include the metadata block header,
186 * per spec.
187 *
188 * \assert
189 * \code is_valid() \endcode
190 */
191 unsigned get_length() const;
192
193 /** Sets the "is_last" flag for the block. When using the iterators
194 * it is not necessary to set this flag; they will do it for you.
195 *
196 * \assert
197 * \code is_valid() \endcode
198 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000199 void set_is_last(bool);
Josh Coalsond113ca32004-07-22 01:03:43 +0000200
201 /** Returns a pointer to the underlying ::FLAC__StreamMetadata
202 * object. This can be useful for plugging any holes between
203 * the C++ and C interfaces.
204 *
205 * \assert
206 * \code is_valid() \endcode
207 */
208 inline operator const ::FLAC__StreamMetadata *() const;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000209 private:
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000210 /** Private and undefined so you can't use it. */
211 Prototype();
Josh Coalsonfb74f102002-05-22 05:33:29 +0000212
213 // These are used only by Iterator
214 bool is_reference_;
215 inline void set_reference(bool x) { is_reference_ = x; }
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000216 };
217
Josh Coalson765ff502002-08-27 05:46:11 +0000218 inline bool Prototype::operator==(const Prototype &object) const
Josh Coalsond57c8d32002-06-11 06:15:28 +0000219 { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); }
Josh Coalson57ba6f42002-06-07 05:27:37 +0000220
Josh Coalson765ff502002-08-27 05:46:11 +0000221 inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const
Josh Coalsond57c8d32002-06-11 06:15:28 +0000222 { return (bool)::FLAC__metadata_object_is_equal(object_, &object); }
Josh Coalson57ba6f42002-06-07 05:27:37 +0000223
Josh Coalson765ff502002-08-27 05:46:11 +0000224 inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const
Josh Coalsond57c8d32002-06-11 06:15:28 +0000225 { return (bool)::FLAC__metadata_object_is_equal(object_, object); }
Josh Coalson57ba6f42002-06-07 05:27:37 +0000226
Josh Coalson765ff502002-08-27 05:46:11 +0000227 inline bool Prototype::operator!=(const Prototype &object) const
Josh Coalson57ba6f42002-06-07 05:27:37 +0000228 { return !operator==(object); }
229
Josh Coalson765ff502002-08-27 05:46:11 +0000230 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const
Josh Coalson57ba6f42002-06-07 05:27:37 +0000231 { return !operator==(object); }
232
Josh Coalson765ff502002-08-27 05:46:11 +0000233 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const
Josh Coalson57ba6f42002-06-07 05:27:37 +0000234 { return !operator==(object); }
235
236 inline bool Prototype::is_valid() const
237 { return 0 != object_; }
238
Josh Coalsond113ca32004-07-22 01:03:43 +0000239 inline Prototype::operator const ::FLAC__StreamMetadata *() const
240 { return object_; }
241
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000242 /** Create a deep copy of an object and return it. */
Josh Coalson55bc5872002-10-16 22:18:32 +0000243 FLACPP_API Prototype *clone(const Prototype *);
Josh Coalson57ba6f42002-06-07 05:27:37 +0000244
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000245
246 /** STREAMINFO metadata block.
Josh Coalson4dc35072002-08-20 03:56:52 +0000247 * See <A HREF="../format.html#metadata_block_streaminfo">format specification</A>.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000248 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000249 class FLACPP_API StreamInfo : public Prototype {
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000250 public:
251 StreamInfo();
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000252
253 //@{
254 /** Constructs a copy of the given object. This form
255 * always performs a deep copy.
256 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000257 inline StreamInfo(const StreamInfo &object): Prototype(object) { }
258 inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { }
259 inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { }
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000260 //@}
261
262 /** Constructs an object with copy control. See
263 * Prototype(::FLAC__StreamMetadata *object, bool copy).
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000264 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000265 inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000266
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000267 ~StreamInfo();
268
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000269 //@{
270 /** Assign from another object. Always performs a deep copy. */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000271 inline void operator=(const StreamInfo &object) { Prototype::operator=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000272 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
273 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000274 //@}
Josh Coalsonfb74f102002-05-22 05:33:29 +0000275
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000276 //@{
277 /** Check for equality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000278 inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000279 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
280 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000281 //@}
282
283 //@{
284 /** Check for inequality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000285 inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000286 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
287 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000288 //@}
Josh Coalson57ba6f42002-06-07 05:27:37 +0000289
Josh Coalson4dc35072002-08-20 03:56:52 +0000290 //@{
291 /** See <A HREF="../format.html#metadata_block_streaminfo">format specification</A>. */
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000292 unsigned get_min_blocksize() const;
293 unsigned get_max_blocksize() const;
294 unsigned get_min_framesize() const;
295 unsigned get_max_framesize() const;
296 unsigned get_sample_rate() const;
297 unsigned get_channels() const;
298 unsigned get_bits_per_sample() const;
299 FLAC__uint64 get_total_samples() const;
300 const FLAC__byte *get_md5sum() const;
301
302 void set_min_blocksize(unsigned value);
303 void set_max_blocksize(unsigned value);
304 void set_min_framesize(unsigned value);
305 void set_max_framesize(unsigned value);
306 void set_sample_rate(unsigned value);
307 void set_channels(unsigned value);
308 void set_bits_per_sample(unsigned value);
309 void set_total_samples(FLAC__uint64 value);
310 void set_md5sum(const FLAC__byte value[16]);
Josh Coalson4dc35072002-08-20 03:56:52 +0000311 //@}
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000312 };
313
Josh Coalson4dc35072002-08-20 03:56:52 +0000314 /** PADDING metadata block.
315 * See <A HREF="../format.html#metadata_block_padding">format specification</A>.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000316 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000317 class FLACPP_API Padding : public Prototype {
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000318 public:
319 Padding();
Josh Coalson4dc35072002-08-20 03:56:52 +0000320
321 //@{
322 /** Constructs a copy of the given object. This form
323 * always performs a deep copy.
324 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000325 inline Padding(const Padding &object): Prototype(object) { }
326 inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { }
327 inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000328 //@}
329
330 /** Constructs an object with copy control. See
331 * Prototype(::FLAC__StreamMetadata *object, bool copy).
332 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000333 inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000334
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000335 ~Padding();
Josh Coalsonfb74f102002-05-22 05:33:29 +0000336
Josh Coalson4dc35072002-08-20 03:56:52 +0000337 //@{
338 /** Assign from another object. Always performs a deep copy. */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000339 inline void operator=(const Padding &object) { Prototype::operator=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000340 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
341 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000342 //@}
Josh Coalsonb2b53582002-05-31 06:20:50 +0000343
Josh Coalson4dc35072002-08-20 03:56:52 +0000344 //@{
345 /** Check for equality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000346 inline bool operator==(const Padding &object) const { return Prototype::operator==(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000347 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
348 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000349 //@}
350
351 //@{
352 /** Check for inequality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000353 inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000354 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
355 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000356 //@}
Josh Coalson57ba6f42002-06-07 05:27:37 +0000357
Josh Coalsonb2b53582002-05-31 06:20:50 +0000358 void set_length(unsigned length);
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000359 };
360
Josh Coalson4dc35072002-08-20 03:56:52 +0000361 /** APPLICATION metadata block.
362 * See <A HREF="../format.html#metadata_block_application">format specification</A>.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000363 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000364 class FLACPP_API Application : public Prototype {
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000365 public:
366 Application();
Josh Coalson4dc35072002-08-20 03:56:52 +0000367 //
368 //@{
369 /** Constructs a copy of the given object. This form
370 * always performs a deep copy.
371 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000372 inline Application(const Application &object): Prototype(object) { }
373 inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { }
374 inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000375 //@}
376
377 /** Constructs an object with copy control. See
378 * Prototype(::FLAC__StreamMetadata *object, bool copy).
379 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000380 inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000381
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000382 ~Application();
383
Josh Coalson4dc35072002-08-20 03:56:52 +0000384 //@{
385 /** Assign from another object. Always performs a deep copy. */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000386 inline void operator=(const Application &object) { Prototype::operator=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000387 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
388 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000389 //@}
Josh Coalsonfb74f102002-05-22 05:33:29 +0000390
Josh Coalson4dc35072002-08-20 03:56:52 +0000391 //@{
392 /** Check for equality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000393 inline bool operator==(const Application &object) const { return Prototype::operator==(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000394 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
395 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000396 //@}
397
398 //@{
399 /** Check for inequality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000400 inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000401 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
402 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000403 //@}
Josh Coalson57ba6f42002-06-07 05:27:37 +0000404
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000405 const FLAC__byte *get_id() const;
406 const FLAC__byte *get_data() const;
407
Josh Coalsoncc682512002-06-08 04:53:42 +0000408 void set_id(const FLAC__byte value[4]);
Josh Coalson4dc35072002-08-20 03:56:52 +0000409 //! This form always copies \a data
410 bool set_data(const FLAC__byte *data, unsigned length);
Josh Coalsoncc682512002-06-08 04:53:42 +0000411 bool set_data(FLAC__byte *data, unsigned length, bool copy);
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000412 };
413
Josh Coalson4dc35072002-08-20 03:56:52 +0000414 /** SEEKTABLE metadata block.
415 * See <A HREF="../format.html#metadata_block_seektable">format specification</A>.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000416 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000417 class FLACPP_API SeekTable : public Prototype {
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000418 public:
419 SeekTable();
Josh Coalson4dc35072002-08-20 03:56:52 +0000420
421 //@{
422 /** Constructs a copy of the given object. This form
423 * always performs a deep copy.
424 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000425 inline SeekTable(const SeekTable &object): Prototype(object) { }
426 inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { }
427 inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000428 //@}
429
430 /** Constructs an object with copy control. See
431 * Prototype(::FLAC__StreamMetadata *object, bool copy).
432 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000433 inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000434
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000435 ~SeekTable();
Josh Coalsonfb74f102002-05-22 05:33:29 +0000436
Josh Coalson4dc35072002-08-20 03:56:52 +0000437 //@{
438 /** Assign from another object. Always performs a deep copy. */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000439 inline void operator=(const SeekTable &object) { Prototype::operator=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000440 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
441 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000442 //@}
Josh Coalsonb2b53582002-05-31 06:20:50 +0000443
Josh Coalson4dc35072002-08-20 03:56:52 +0000444 //@{
445 /** Check for equality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000446 inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000447 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
448 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000449 //@}
450
451 //@{
452 /** Check for inequality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000453 inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000454 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
455 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000456 //@}
Josh Coalson57ba6f42002-06-07 05:27:37 +0000457
Josh Coalsonb2b53582002-05-31 06:20:50 +0000458 unsigned get_num_points() const;
Josh Coalsoncc682512002-06-08 04:53:42 +0000459 ::FLAC__StreamMetadata_SeekPoint get_point(unsigned index) const;
Josh Coalsonb2b53582002-05-31 06:20:50 +0000460
Josh Coalson4dc35072002-08-20 03:56:52 +0000461 //! See FLAC__metadata_object_seektable_set_point()
Josh Coalsoncc682512002-06-08 04:53:42 +0000462 void set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
Josh Coalson4dc35072002-08-20 03:56:52 +0000463
464 //! See FLAC__metadata_object_seektable_insert_point()
Josh Coalsoncc682512002-06-08 04:53:42 +0000465 bool insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
Josh Coalson4dc35072002-08-20 03:56:52 +0000466
467 //! See FLAC__metadata_object_seektable_delete_point()
Josh Coalsonb2b53582002-05-31 06:20:50 +0000468 bool delete_point(unsigned index);
Josh Coalson28e08d82002-06-05 05:56:41 +0000469
Josh Coalson4dc35072002-08-20 03:56:52 +0000470 //! See FLAC__metadata_object_seektable_is_legal()
Josh Coalson28e08d82002-06-05 05:56:41 +0000471 bool is_legal() const;
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000472 };
473
Josh Coalson4dc35072002-08-20 03:56:52 +0000474 /** VORBIS_COMMENT metadata block.
475 * See <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000476 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000477 class FLACPP_API VorbisComment : public Prototype {
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000478 public:
Josh Coalson4dc35072002-08-20 03:56:52 +0000479 /** Convenience class for encapsulating Vorbis comment
480 * entries. An entry is a vendor string or a comment
481 * field. In the case of a vendor string, the field
482 * name is undefined; only the field value is relevant.
483 *
484 * A \a field as used in the methods refers to an
485 * entire 'NAME=VALUE' string; the string is not null-
486 * terminated and a length field is required since the
487 * string may contain embedded nulls.
488 *
489 * A \a field_name is what is on the left side of the
490 * first '=' in the \a field. By definition it is ASCII
491 * and so is null-terminated and does not require a
492 * length to describe it. \a field_name is undefined
493 * for a vendor string entry.
494 *
495 * A \a field_value is what is on the right side of the
496 * first '=' in the \a field. By definition, this may
497 * contain embedded nulls and so a \a field_value_length
498 * is requires to describe it.
499 *
500 * Always check is_valid() after the constructor or operator=
501 * to make sure memory was properly allocated.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000502 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000503 class FLACPP_API Entry {
Josh Coalsonb2b53582002-05-31 06:20:50 +0000504 public:
505 Entry();
506 Entry(const char *field, unsigned field_length);
507 Entry(const char *field_name, const char *field_value, unsigned field_value_length);
508 Entry(const Entry &entry);
509 void operator=(const Entry &entry);
510
511 virtual ~Entry();
512
513 virtual bool is_valid() const;
Josh Coalsonb2b53582002-05-31 06:20:50 +0000514
515 unsigned get_field_length() const;
516 unsigned get_field_name_length() const;
517 unsigned get_field_value_length() const;
518
Josh Coalsoncc682512002-06-08 04:53:42 +0000519 ::FLAC__StreamMetadata_VorbisComment_Entry get_entry() const;
Josh Coalsonb2b53582002-05-31 06:20:50 +0000520 const char *get_field() const;
521 const char *get_field_name() const;
522 const char *get_field_value() const;
523
524 bool set_field(const char *field, unsigned field_length);
525 bool set_field_name(const char *field_name);
526 bool set_field_value(const char *field_value, unsigned field_value_length);
527 protected:
528 bool is_valid_;
Josh Coalsoncc682512002-06-08 04:53:42 +0000529 ::FLAC__StreamMetadata_VorbisComment_Entry entry_;
Josh Coalsonb2b53582002-05-31 06:20:50 +0000530 char *field_name_;
531 unsigned field_name_length_;
532 char *field_value_;
533 unsigned field_value_length_;
534 private:
535 void zero();
536 void clear();
537 void clear_entry();
538 void clear_field_name();
539 void clear_field_value();
540 void construct(const char *field, unsigned field_length);
541 void construct(const char *field_name, const char *field_value, unsigned field_value_length);
542 void compose_field();
543 void parse_field();
544 };
545
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000546 VorbisComment();
Josh Coalson4dc35072002-08-20 03:56:52 +0000547
548 //@{
549 /** Constructs a copy of the given object. This form
550 * always performs a deep copy.
551 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000552 inline VorbisComment(const VorbisComment &object): Prototype(object) { }
553 inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { }
554 inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000555 //@}
556
557 /** Constructs an object with copy control. See
558 * Prototype(::FLAC__StreamMetadata *object, bool copy).
559 */
Josh Coalsoncc682512002-06-08 04:53:42 +0000560 inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
Josh Coalson4dc35072002-08-20 03:56:52 +0000561
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000562 ~VorbisComment();
Josh Coalsonfb74f102002-05-22 05:33:29 +0000563
Josh Coalson4dc35072002-08-20 03:56:52 +0000564 //@{
565 /** Assign from another object. Always performs a deep copy. */
Josh Coalsonfb74f102002-05-22 05:33:29 +0000566 inline void operator=(const VorbisComment &object) { Prototype::operator=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000567 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
568 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000569 //@}
Josh Coalsonb2b53582002-05-31 06:20:50 +0000570
Josh Coalson4dc35072002-08-20 03:56:52 +0000571 //@{
572 /** Check for equality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000573 inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000574 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
575 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000576 //@}
577
578 //@{
579 /** Check for inequality, performing a deep compare by following pointers. */
Josh Coalson57ba6f42002-06-07 05:27:37 +0000580 inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); }
Josh Coalsoncc682512002-06-08 04:53:42 +0000581 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
582 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
Josh Coalson4dc35072002-08-20 03:56:52 +0000583 //@}
Josh Coalson57ba6f42002-06-07 05:27:37 +0000584
Josh Coalsonb2b53582002-05-31 06:20:50 +0000585 unsigned get_num_comments() const;
Josh Coalsoncc682512002-06-08 04:53:42 +0000586 Entry get_vendor_string() const; // only the Entry's field name should be used
Josh Coalsonb2b53582002-05-31 06:20:50 +0000587 Entry get_comment(unsigned index) const;
588
Josh Coalson87977ba2002-08-20 07:09:33 +0000589 //! See FLAC__metadata_object_vorbiscomment_set_vendor_string()
Josh Coalson4dc35072002-08-20 03:56:52 +0000590 //! \note Only the Entry's field name will be used.
Josh Coalson863dbf32002-11-16 06:30:30 +0000591 bool set_vendor_string(const Entry &entry);
Josh Coalson4dc35072002-08-20 03:56:52 +0000592
Josh Coalson87977ba2002-08-20 07:09:33 +0000593 //! See FLAC__metadata_object_vorbiscomment_set_comment()
Josh Coalsonb2b53582002-05-31 06:20:50 +0000594 bool set_comment(unsigned index, const Entry &entry);
Josh Coalson4dc35072002-08-20 03:56:52 +0000595
Josh Coalson87977ba2002-08-20 07:09:33 +0000596 //! See FLAC__metadata_object_vorbiscomment_insert_comment()
Josh Coalsonb2b53582002-05-31 06:20:50 +0000597 bool insert_comment(unsigned index, const Entry &entry);
Josh Coalson4dc35072002-08-20 03:56:52 +0000598
Josh Coalson87977ba2002-08-20 07:09:33 +0000599 //! See FLAC__metadata_object_vorbiscomment_delete_comment()
Josh Coalsonb2b53582002-05-31 06:20:50 +0000600 bool delete_comment(unsigned index);
Josh Coalsonfb74f102002-05-22 05:33:29 +0000601 };
602
Josh Coalson863dbf32002-11-16 06:30:30 +0000603 /** CUESHEET metadata block.
604 * See <A HREF="../format.html#metadata_block_cuesheet">format specification</A>.
605 */
606 class FLACPP_API CueSheet : public Prototype {
607 public:
608 /** Convenience class for encapsulating a cue sheet
609 * track.
610 *
611 * Always check is_valid() after the constructor or operator=
612 * to make sure memory was properly allocated.
613 */
614 class FLACPP_API Track {
615 protected:
616 ::FLAC__StreamMetadata_CueSheet_Track *object_;
617 public:
618 Track();
619 Track(const ::FLAC__StreamMetadata_CueSheet_Track *track);
620 Track(const Track &track);
621 void operator=(const Track &track);
622
623 virtual ~Track();
624
625 virtual bool is_valid() const;
626
627 inline FLAC__uint64 get_offset() const { return object_->offset; }
628 inline FLAC__byte get_number() const { return object_->number; }
629 inline const char *get_isrc() const { return object_->isrc; }
630 inline unsigned get_type() const { return object_->type; }
631 inline bool get_pre_emphasis() const { return object_->pre_emphasis; }
632
Josh Coalsona7038a92003-01-22 20:16:20 +0000633 inline FLAC__byte get_num_indices() const { return object_->num_indices; }
Josh Coalson863dbf32002-11-16 06:30:30 +0000634 ::FLAC__StreamMetadata_CueSheet_Index get_index(unsigned i) const;
635
636 inline const ::FLAC__StreamMetadata_CueSheet_Track *get_track() const { return object_; }
637
638 inline void set_offset(FLAC__uint64 value) { object_->offset = value; }
639 inline void set_number(FLAC__byte value) { object_->number = value; }
Josh Coalson16219792002-11-19 06:19:29 +0000640 void set_isrc(const char value[12]);
Josh Coalson863dbf32002-11-16 06:30:30 +0000641 void set_type(unsigned value);
642 inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; }
643
Josh Coalson16219792002-11-19 06:19:29 +0000644 void set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index);
Josh Coalsonb3538c82003-01-12 08:42:23 +0000645 //@@@ It's awkward but to insert/delete index points
646 //@@@ you must use the routines in the CueSheet class.
Josh Coalson863dbf32002-11-16 06:30:30 +0000647 };
648
649 CueSheet();
650
651 //@{
652 /** Constructs a copy of the given object. This form
653 * always performs a deep copy.
654 */
655 inline CueSheet(const CueSheet &object): Prototype(object) { }
656 inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { }
657 inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { }
658 //@}
659
660 /** Constructs an object with copy control. See
661 * Prototype(::FLAC__StreamMetadata *object, bool copy).
662 */
663 inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
664
665 ~CueSheet();
666
667 //@{
668 /** Assign from another object. Always performs a deep copy. */
669 inline void operator=(const CueSheet &object) { Prototype::operator=(object); }
670 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
671 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
672 //@}
673
674 //@{
675 /** Check for equality, performing a deep compare by following pointers. */
676 inline bool operator==(const CueSheet &object) const { return Prototype::operator==(object); }
677 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
678 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
679 //@}
680
681 //@{
682 /** Check for inequality, performing a deep compare by following pointers. */
683 inline bool operator!=(const CueSheet &object) const { return Prototype::operator!=(object); }
684 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
685 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
686 //@}
687
688 const char *get_media_catalog_number() const;
689 FLAC__uint64 get_lead_in() const;
Josh Coalson8f0c71b2002-12-05 06:37:46 +0000690 bool get_is_cd() const;
Josh Coalson863dbf32002-11-16 06:30:30 +0000691
692 unsigned get_num_tracks() const;
693 Track get_track(unsigned i) const;
694
Josh Coalson16219792002-11-19 06:19:29 +0000695 void set_media_catalog_number(const char value[128]);
696 void set_lead_in(FLAC__uint64 value);
Josh Coalson8f0c71b2002-12-05 06:37:46 +0000697 void set_is_cd(bool value);
Josh Coalson16219792002-11-19 06:19:29 +0000698
699 void set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
Josh Coalson863dbf32002-11-16 06:30:30 +0000700
701 //! See FLAC__metadata_object_cuesheet_track_insert_index()
702 bool insert_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
703
704 //! See FLAC__metadata_object_cuesheet_track_delete_index()
705 bool delete_index(unsigned track_num, unsigned index_num);
706
707 //! See FLAC__metadata_object_cuesheet_set_track()
708 bool set_track(unsigned i, const Track &track);
709
710 //! See FLAC__metadata_object_cuesheet_insert_track()
711 bool insert_track(unsigned i, const Track &track);
712
713 //! See FLAC__metadata_object_cuesheet_delete_track()
714 bool delete_track(unsigned i);
715
716 //! See FLAC__metadata_object_cuesheet_is_legal()
717 bool is_legal(bool check_cd_da_subset = false, const char **violation = 0) const;
718 };
719
Josh Coalson0eea34a2003-01-10 05:29:17 +0000720 /** Opaque metadata block for storing unknown types.
721 * This should not be used unless you know what you are doing;
722 * it is currently used only internally to support forward
723 * compatibility of metadata blocks.
724 */
725 class FLACPP_API Unknown : public Prototype {
726 public:
727 Unknown();
728 //
729 //@{
730 /** Constructs a copy of the given object. This form
731 * always performs a deep copy.
732 */
733 inline Unknown(const Unknown &object): Prototype(object) { }
734 inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { }
735 inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { }
736 //@}
737
738 /** Constructs an object with copy control. See
739 * Prototype(::FLAC__StreamMetadata *object, bool copy).
740 */
741 inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
742
743 ~Unknown();
744
745 //@{
746 /** Assign from another object. Always performs a deep copy. */
747 inline void operator=(const Unknown &object) { Prototype::operator=(object); }
748 inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); }
749 inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); }
750 //@}
751
752 //@{
753 /** Check for equality, performing a deep compare by following pointers. */
754 inline bool operator==(const Unknown &object) const { return Prototype::operator==(object); }
755 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
756 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
757 //@}
758
759 //@{
760 /** Check for inequality, performing a deep compare by following pointers. */
761 inline bool operator!=(const Unknown &object) const { return Prototype::operator!=(object); }
762 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
763 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
764 //@}
765
766 const FLAC__byte *get_data() const;
767
768 //! This form always copies \a data
769 bool set_data(const FLAC__byte *data, unsigned length);
770 bool set_data(FLAC__byte *data, unsigned length, bool copy);
771 };
772
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000773 /* \} */
774
Josh Coalsonb2b53582002-05-31 06:20:50 +0000775
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000776 /** \defgroup flacpp_metadata_level0 FLAC++/metadata.h: metadata level 0 interface
777 * \ingroup flacpp_metadata
778 *
779 * \brief
Josh Coalson4dc35072002-08-20 03:56:52 +0000780 * Level 0 metadata iterator.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000781 *
Josh Coalson4dc35072002-08-20 03:56:52 +0000782 * See the \link flac_metadata_level0 C layer equivalent \endlink
783 * for more.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000784 *
785 * \{
786 */
787
Josh Coalson4dc35072002-08-20 03:56:52 +0000788 //! See FLAC__metadata_get_streaminfo().
Josh Coalson55bc5872002-10-16 22:18:32 +0000789 FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo);
Josh Coalsonfb74f102002-05-22 05:33:29 +0000790
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000791 /* \} */
792
Josh Coalsonb2b53582002-05-31 06:20:50 +0000793
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000794 /** \defgroup flacpp_metadata_level1 FLAC++/metadata.h: metadata level 1 interface
795 * \ingroup flacpp_metadata
796 *
Josh Coalson4dc35072002-08-20 03:56:52 +0000797 * \brief
798 * Level 1 metadata iterator.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000799 *
Josh Coalson4dc35072002-08-20 03:56:52 +0000800 * The flow through the iterator in the C++ layer is similar
801 * to the C layer:
802 * - Create a SimpleIterator instance
803 * - Check SimpleIterator::is_valid()
804 * - Call SimpleIterator::init() and check the return
805 * - Traverse and/or edit. Edits are written to file
806 * immediately.
807 * - Destroy the SimpleIterator instance
808 *
809 * The ownership of pointers in the C++ layer follows that in
810 * the C layer, i.e.
811 * - The objects returned by get_block() are yours to
812 * modify, but changes are not reflected in the FLAC file
813 * until you call set_block(). The objects are also
814 * yours to delete; they are not automatically deleted
815 * when passed to set_block() or insert_block_after().
816 *
817 * See the \link flac_metadata_level1 C layer equivalent \endlink
818 * for more.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000819 *
820 * \{
821 */
822
Josh Coalson402da702002-08-21 03:40:11 +0000823 /** This class is a wrapper around the FLAC__metadata_simple_iterator
824 * structures and methods; see ::FLAC__Metadata_SimpleIterator.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000825 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000826 class FLACPP_API SimpleIterator {
Josh Coalsonfb74f102002-05-22 05:33:29 +0000827 public:
Josh Coalson55bc5872002-10-16 22:18:32 +0000828 class FLACPP_API Status {
Josh Coalsonfb74f102002-05-22 05:33:29 +0000829 public:
Josh Coalsoncc682512002-06-08 04:53:42 +0000830 inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { }
831 inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; }
832 inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; }
Josh Coalsonfb74f102002-05-22 05:33:29 +0000833 protected:
Josh Coalsoncc682512002-06-08 04:53:42 +0000834 ::FLAC__Metadata_SimpleIteratorStatus status_;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000835 };
836
837 SimpleIterator();
838 virtual ~SimpleIterator();
839
Josh Coalson3ac66932002-08-30 05:41:31 +0000840 bool init(const char *filename, bool read_only, bool preserve_file_stats);
Josh Coalsonfb74f102002-05-22 05:33:29 +0000841
842 bool is_valid() const;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000843 Status status();
844 bool is_writable() const;
845
846 bool next();
847 bool prev();
848
Josh Coalsoncc682512002-06-08 04:53:42 +0000849 ::FLAC__MetadataType get_block_type() const;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000850 Prototype *get_block();
851 bool set_block(Prototype *block, bool use_padding = true);
852 bool insert_block_after(Prototype *block, bool use_padding = true);
853 bool delete_block(bool use_padding = true);
854
855 protected:
Josh Coalsoncc682512002-06-08 04:53:42 +0000856 ::FLAC__Metadata_SimpleIterator *iterator_;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000857 void clear();
858 };
859
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000860 /* \} */
861
Josh Coalsonb2b53582002-05-31 06:20:50 +0000862
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000863 /** \defgroup flacpp_metadata_level2 FLAC++/metadata.h: metadata level 2 interface
864 * \ingroup flacpp_metadata
865 *
Josh Coalson4dc35072002-08-20 03:56:52 +0000866 * \brief
867 * Level 2 metadata iterator.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000868 *
Josh Coalson4dc35072002-08-20 03:56:52 +0000869 * The flow through the iterator in the C++ layer is similar
870 * to the C layer:
871 * - Create a Chain instance
872 * - Check Chain::is_valid()
873 * - Call Chain::read() and check the return
874 * - Traverse and/or edit with an Iterator or with
875 * Chain::merge_padding() or Chain::sort_padding()
876 * - Write changes back to FLAC file with Chain::write()
877 * - Destroy the Chain instance
878 *
Josh Coalson8b9a4772002-12-28 07:03:26 +0000879 * The ownership of pointers in the C++ layer is slightly
880 * different than in the C layer, i.e.
881 * - The objects returned by Iterator::get_block() are NOT
882 * owned by the iterator and should be deleted by the
883 * caller when finished, BUT, when you modify the block,
884 * it will directly edit what's in the chain and you do
885 * not need to call Iterator::set_block(). However the
886 * changes will not be reflected in the FLAC file until
887 * the chain is written with Chain::write().
Josh Coalson4dc35072002-08-20 03:56:52 +0000888 * - When you pass an object to Iterator::set_block(),
889 * Iterator::insert_block_before(), or
890 * Iterator::insert_block_after(), the iterator takes
Josh Coalson8b9a4772002-12-28 07:03:26 +0000891 * ownership of the block and it will be deleted by the
Josh Coalson4dc35072002-08-20 03:56:52 +0000892 * chain.
893 *
894 * See the \link flac_metadata_level2 C layer equivalent \endlink
895 * for more.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000896 *
897 * \{
898 */
899
Josh Coalson402da702002-08-21 03:40:11 +0000900 /** This class is a wrapper around the FLAC__metadata_chain
901 * structures and methods; see ::FLAC__Metadata_Chain.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000902 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000903 class FLACPP_API Chain {
Josh Coalsonfb74f102002-05-22 05:33:29 +0000904 public:
Josh Coalson55bc5872002-10-16 22:18:32 +0000905 class FLACPP_API Status {
Josh Coalsonfb74f102002-05-22 05:33:29 +0000906 public:
Josh Coalsoncc682512002-06-08 04:53:42 +0000907 inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { }
908 inline operator ::FLAC__Metadata_ChainStatus() const { return status_; }
909 inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; }
Josh Coalsonfb74f102002-05-22 05:33:29 +0000910 protected:
Josh Coalsoncc682512002-06-08 04:53:42 +0000911 ::FLAC__Metadata_ChainStatus status_;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000912 };
913
914 Chain();
915 virtual ~Chain();
916
917 friend class Iterator;
918
919 bool is_valid() const;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000920 Status status();
921
922 bool read(const char *filename);
Josh Coalsondeab4622004-07-15 16:22:43 +0000923 bool read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks);
924
925 bool check_if_tempfile_needed(bool use_padding);
926
Josh Coalsonfb74f102002-05-22 05:33:29 +0000927 bool write(bool use_padding = true, bool preserve_file_stats = false);
Josh Coalsondeab4622004-07-15 16:22:43 +0000928 bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks);
929 bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, ::FLAC__IOHandle temp_handle, ::FLAC__IOCallbacks temp_callbacks);
Josh Coalsonfb74f102002-05-22 05:33:29 +0000930
931 void merge_padding();
932 void sort_padding();
933
934 protected:
Josh Coalsoncc682512002-06-08 04:53:42 +0000935 ::FLAC__Metadata_Chain *chain_;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000936 virtual void clear();
937 };
938
Josh Coalson402da702002-08-21 03:40:11 +0000939 /** This class is a wrapper around the FLAC__metadata_iterator
940 * structures and methods; see ::FLAC__Metadata_Iterator.
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000941 */
Josh Coalson55bc5872002-10-16 22:18:32 +0000942 class FLACPP_API Iterator {
Josh Coalsonfb74f102002-05-22 05:33:29 +0000943 public:
944 Iterator();
945 virtual ~Iterator();
946
947 bool is_valid() const;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000948
Josh Coalson999be3b2002-06-10 04:42:35 +0000949 void init(Chain &chain);
Josh Coalsonfb74f102002-05-22 05:33:29 +0000950
951 bool next();
952 bool prev();
953
Josh Coalsoncc682512002-06-08 04:53:42 +0000954 ::FLAC__MetadataType get_block_type() const;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000955 Prototype *get_block();
956 bool set_block(Prototype *block);
957 bool delete_block(bool replace_with_padding);
958 bool insert_block_before(Prototype *block);
959 bool insert_block_after(Prototype *block);
960
961 protected:
Josh Coalsoncc682512002-06-08 04:53:42 +0000962 ::FLAC__Metadata_Iterator *iterator_;
Josh Coalsonfb74f102002-05-22 05:33:29 +0000963 virtual void clear();
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000964 };
965
Josh Coalsonf6efd9c2002-07-27 04:59:54 +0000966 /* \} */
967
Josh Coalsonfda98fb2002-05-17 06:33:39 +0000968 };
969};
970
971#endif