annotate src/flac-1.2.1/include/FLAC++/metadata.h @ 124:e3d5853d5918

Current stable PortAudio source
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 18 Oct 2016 13:11:05 +0100
parents 98c1576536ae
children
rev   line source
cannam@86 1 /* libFLAC++ - Free Lossless Audio Codec library
cannam@86 2 * Copyright (C) 2002,2003,2004,2005,2006,2007 Josh Coalson
cannam@86 3 *
cannam@86 4 * Redistribution and use in source and binary forms, with or without
cannam@86 5 * modification, are permitted provided that the following conditions
cannam@86 6 * are met:
cannam@86 7 *
cannam@86 8 * - Redistributions of source code must retain the above copyright
cannam@86 9 * notice, this list of conditions and the following disclaimer.
cannam@86 10 *
cannam@86 11 * - Redistributions in binary form must reproduce the above copyright
cannam@86 12 * notice, this list of conditions and the following disclaimer in the
cannam@86 13 * documentation and/or other materials provided with the distribution.
cannam@86 14 *
cannam@86 15 * - Neither the name of the Xiph.org Foundation nor the names of its
cannam@86 16 * contributors may be used to endorse or promote products derived from
cannam@86 17 * this software without specific prior written permission.
cannam@86 18 *
cannam@86 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
cannam@86 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
cannam@86 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
cannam@86 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
cannam@86 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
cannam@86 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
cannam@86 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
cannam@86 26 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
cannam@86 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
cannam@86 28 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
cannam@86 29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cannam@86 30 */
cannam@86 31
cannam@86 32 #ifndef FLACPP__METADATA_H
cannam@86 33 #define FLACPP__METADATA_H
cannam@86 34
cannam@86 35 #include "export.h"
cannam@86 36
cannam@86 37 #include "FLAC/metadata.h"
cannam@86 38
cannam@86 39 // ===============================================================
cannam@86 40 //
cannam@86 41 // Full documentation for the metadata interface can be found
cannam@86 42 // in the C layer in include/FLAC/metadata.h
cannam@86 43 //
cannam@86 44 // ===============================================================
cannam@86 45
cannam@86 46 /** \file include/FLAC++/metadata.h
cannam@86 47 *
cannam@86 48 * \brief
cannam@86 49 * This module provides classes for creating and manipulating FLAC
cannam@86 50 * metadata blocks in memory, and three progressively more powerful
cannam@86 51 * interfaces for traversing and editing metadata in FLAC files.
cannam@86 52 *
cannam@86 53 * See the detailed documentation for each interface in the
cannam@86 54 * \link flacpp_metadata metadata \endlink module.
cannam@86 55 */
cannam@86 56
cannam@86 57 /** \defgroup flacpp_metadata FLAC++/metadata.h: metadata interfaces
cannam@86 58 * \ingroup flacpp
cannam@86 59 *
cannam@86 60 * \brief
cannam@86 61 * This module provides classes for creating and manipulating FLAC
cannam@86 62 * metadata blocks in memory, and three progressively more powerful
cannam@86 63 * interfaces for traversing and editing metadata in FLAC files.
cannam@86 64 *
cannam@86 65 * The behavior closely mimics the C layer interface; be sure to read
cannam@86 66 * the detailed description of the
cannam@86 67 * \link flac_metadata C metadata module \endlink. Note that like the
cannam@86 68 * C layer, currently only the Chain interface (level 2) supports Ogg
cannam@86 69 * FLAC files, and it is read-only i.e. no writing back changed
cannam@86 70 * metadata to file.
cannam@86 71 */
cannam@86 72
cannam@86 73
cannam@86 74 namespace FLAC {
cannam@86 75 namespace Metadata {
cannam@86 76
cannam@86 77 // ============================================================
cannam@86 78 //
cannam@86 79 // Metadata objects
cannam@86 80 //
cannam@86 81 // ============================================================
cannam@86 82
cannam@86 83 /** \defgroup flacpp_metadata_object FLAC++/metadata.h: metadata object classes
cannam@86 84 * \ingroup flacpp_metadata
cannam@86 85 *
cannam@86 86 * This module contains classes representing FLAC metadata
cannam@86 87 * blocks in memory.
cannam@86 88 *
cannam@86 89 * The behavior closely mimics the C layer interface; be
cannam@86 90 * sure to read the detailed description of the
cannam@86 91 * \link flac_metadata_object C metadata object module \endlink.
cannam@86 92 *
cannam@86 93 * Any time a metadata object is constructed or assigned, you
cannam@86 94 * should check is_valid() to make sure the underlying
cannam@86 95 * ::FLAC__StreamMetadata object was able to be created.
cannam@86 96 *
cannam@86 97 * \warning
cannam@86 98 * When the get_*() methods of any metadata object method
cannam@86 99 * return you a const pointer, DO NOT disobey and write into it.
cannam@86 100 * Always use the set_*() methods.
cannam@86 101 *
cannam@86 102 * \{
cannam@86 103 */
cannam@86 104
cannam@86 105 /** Base class for all metadata block types.
cannam@86 106 * See the \link flacpp_metadata_object overview \endlink for more.
cannam@86 107 */
cannam@86 108 class FLACPP_API Prototype {
cannam@86 109 protected:
cannam@86 110 //@{
cannam@86 111 /** Constructs a copy of the given object. This form
cannam@86 112 * always performs a deep copy.
cannam@86 113 */
cannam@86 114 Prototype(const Prototype &);
cannam@86 115 Prototype(const ::FLAC__StreamMetadata &);
cannam@86 116 Prototype(const ::FLAC__StreamMetadata *);
cannam@86 117 //@}
cannam@86 118
cannam@86 119 /** Constructs an object with copy control. When \a copy
cannam@86 120 * is \c true, behaves identically to
cannam@86 121 * FLAC::Metadata::Prototype::Prototype(const ::FLAC__StreamMetadata *object).
cannam@86 122 * When \a copy is \c false, the instance takes ownership of
cannam@86 123 * the pointer and the ::FLAC__StreamMetadata object will
cannam@86 124 * be freed by the destructor.
cannam@86 125 *
cannam@86 126 * \assert
cannam@86 127 * \code object != NULL \endcode
cannam@86 128 */
cannam@86 129 Prototype(::FLAC__StreamMetadata *object, bool copy);
cannam@86 130
cannam@86 131 //@{
cannam@86 132 /** Assign from another object. Always performs a deep copy. */
cannam@86 133 Prototype &operator=(const Prototype &);
cannam@86 134 Prototype &operator=(const ::FLAC__StreamMetadata &);
cannam@86 135 Prototype &operator=(const ::FLAC__StreamMetadata *);
cannam@86 136 //@}
cannam@86 137
cannam@86 138 /** Assigns an object with copy control. See
cannam@86 139 * Prototype(::FLAC__StreamMetadata *object, bool copy).
cannam@86 140 */
cannam@86 141 Prototype &assign_object(::FLAC__StreamMetadata *object, bool copy);
cannam@86 142
cannam@86 143 /** Deletes the underlying ::FLAC__StreamMetadata object.
cannam@86 144 */
cannam@86 145 virtual void clear();
cannam@86 146
cannam@86 147 ::FLAC__StreamMetadata *object_;
cannam@86 148 public:
cannam@86 149 /** Deletes the underlying ::FLAC__StreamMetadata object.
cannam@86 150 */
cannam@86 151 virtual ~Prototype();
cannam@86 152
cannam@86 153 //@{
cannam@86 154 /** Check for equality, performing a deep compare by following pointers.
cannam@86 155 */
cannam@86 156 inline bool operator==(const Prototype &) const;
cannam@86 157 inline bool operator==(const ::FLAC__StreamMetadata &) const;
cannam@86 158 inline bool operator==(const ::FLAC__StreamMetadata *) const;
cannam@86 159 //@}
cannam@86 160
cannam@86 161 //@{
cannam@86 162 /** Check for inequality, performing a deep compare by following pointers. */
cannam@86 163 inline bool operator!=(const Prototype &) const;
cannam@86 164 inline bool operator!=(const ::FLAC__StreamMetadata &) const;
cannam@86 165 inline bool operator!=(const ::FLAC__StreamMetadata *) const;
cannam@86 166 //@}
cannam@86 167
cannam@86 168 friend class SimpleIterator;
cannam@86 169 friend class Iterator;
cannam@86 170
cannam@86 171 /** Returns \c true if the object was correctly constructed
cannam@86 172 * (i.e. the underlying ::FLAC__StreamMetadata object was
cannam@86 173 * properly allocated), else \c false.
cannam@86 174 */
cannam@86 175 inline bool is_valid() const;
cannam@86 176
cannam@86 177 /** Returns \c true if this block is the last block in a
cannam@86 178 * stream, else \c false.
cannam@86 179 *
cannam@86 180 * \assert
cannam@86 181 * \code is_valid() \endcode
cannam@86 182 */
cannam@86 183 bool get_is_last() const;
cannam@86 184
cannam@86 185 /** Returns the type of the block.
cannam@86 186 *
cannam@86 187 * \assert
cannam@86 188 * \code is_valid() \endcode
cannam@86 189 */
cannam@86 190 ::FLAC__MetadataType get_type() const;
cannam@86 191
cannam@86 192 /** Returns the stream length of the metadata block.
cannam@86 193 *
cannam@86 194 * \note
cannam@86 195 * The length does not include the metadata block header,
cannam@86 196 * per spec.
cannam@86 197 *
cannam@86 198 * \assert
cannam@86 199 * \code is_valid() \endcode
cannam@86 200 */
cannam@86 201 unsigned get_length() const;
cannam@86 202
cannam@86 203 /** Sets the "is_last" flag for the block. When using the iterators
cannam@86 204 * it is not necessary to set this flag; they will do it for you.
cannam@86 205 *
cannam@86 206 * \assert
cannam@86 207 * \code is_valid() \endcode
cannam@86 208 */
cannam@86 209 void set_is_last(bool);
cannam@86 210
cannam@86 211 /** Returns a pointer to the underlying ::FLAC__StreamMetadata
cannam@86 212 * object. This can be useful for plugging any holes between
cannam@86 213 * the C++ and C interfaces.
cannam@86 214 *
cannam@86 215 * \assert
cannam@86 216 * \code is_valid() \endcode
cannam@86 217 */
cannam@86 218 inline operator const ::FLAC__StreamMetadata *() const;
cannam@86 219 private:
cannam@86 220 /** Private and undefined so you can't use it. */
cannam@86 221 Prototype();
cannam@86 222
cannam@86 223 // These are used only by Iterator
cannam@86 224 bool is_reference_;
cannam@86 225 inline void set_reference(bool x) { is_reference_ = x; }
cannam@86 226 };
cannam@86 227
cannam@86 228 #ifdef _MSC_VER
cannam@86 229 // warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning)
cannam@86 230 #pragma warning ( disable : 4800 )
cannam@86 231 #endif
cannam@86 232
cannam@86 233 inline bool Prototype::operator==(const Prototype &object) const
cannam@86 234 { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); }
cannam@86 235
cannam@86 236 inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const
cannam@86 237 { return (bool)::FLAC__metadata_object_is_equal(object_, &object); }
cannam@86 238
cannam@86 239 inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const
cannam@86 240 { return (bool)::FLAC__metadata_object_is_equal(object_, object); }
cannam@86 241
cannam@86 242 #ifdef _MSC_VER
cannam@86 243 // @@@ how to re-enable? the following doesn't work
cannam@86 244 // #pragma warning ( enable : 4800 )
cannam@86 245 #endif
cannam@86 246
cannam@86 247 inline bool Prototype::operator!=(const Prototype &object) const
cannam@86 248 { return !operator==(object); }
cannam@86 249
cannam@86 250 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const
cannam@86 251 { return !operator==(object); }
cannam@86 252
cannam@86 253 inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const
cannam@86 254 { return !operator==(object); }
cannam@86 255
cannam@86 256 inline bool Prototype::is_valid() const
cannam@86 257 { return 0 != object_; }
cannam@86 258
cannam@86 259 inline Prototype::operator const ::FLAC__StreamMetadata *() const
cannam@86 260 { return object_; }
cannam@86 261
cannam@86 262 /** Create a deep copy of an object and return it. */
cannam@86 263 FLACPP_API Prototype *clone(const Prototype *);
cannam@86 264
cannam@86 265
cannam@86 266 /** STREAMINFO metadata block.
cannam@86 267 * See the \link flacpp_metadata_object overview \endlink for more,
cannam@86 268 * and the <A HREF="../format.html#metadata_block_streaminfo">format specification</A>.
cannam@86 269 */
cannam@86 270 class FLACPP_API StreamInfo : public Prototype {
cannam@86 271 public:
cannam@86 272 StreamInfo();
cannam@86 273
cannam@86 274 //@{
cannam@86 275 /** Constructs a copy of the given object. This form
cannam@86 276 * always performs a deep copy.
cannam@86 277 */
cannam@86 278 inline StreamInfo(const StreamInfo &object): Prototype(object) { }
cannam@86 279 inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { }
cannam@86 280 inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { }
cannam@86 281 //@}
cannam@86 282
cannam@86 283 /** Constructs an object with copy control. See
cannam@86 284 * Prototype(::FLAC__StreamMetadata *object, bool copy).
cannam@86 285 */
cannam@86 286 inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
cannam@86 287
cannam@86 288 ~StreamInfo();
cannam@86 289
cannam@86 290 //@{
cannam@86 291 /** Assign from another object. Always performs a deep copy. */
cannam@86 292 inline StreamInfo &operator=(const StreamInfo &object) { Prototype::operator=(object); return *this; }
cannam@86 293 inline StreamInfo &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
cannam@86 294 inline StreamInfo &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
cannam@86 295 //@}
cannam@86 296
cannam@86 297 /** Assigns an object with copy control. See
cannam@86 298 * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
cannam@86 299 */
cannam@86 300 inline StreamInfo &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
cannam@86 301
cannam@86 302 //@{
cannam@86 303 /** Check for equality, performing a deep compare by following pointers. */
cannam@86 304 inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); }
cannam@86 305 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
cannam@86 306 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
cannam@86 307 //@}
cannam@86 308
cannam@86 309 //@{
cannam@86 310 /** Check for inequality, performing a deep compare by following pointers. */
cannam@86 311 inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); }
cannam@86 312 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
cannam@86 313 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
cannam@86 314 //@}
cannam@86 315
cannam@86 316 //@{
cannam@86 317 /** See <A HREF="../format.html#metadata_block_streaminfo">format specification</A>. */
cannam@86 318 unsigned get_min_blocksize() const;
cannam@86 319 unsigned get_max_blocksize() const;
cannam@86 320 unsigned get_min_framesize() const;
cannam@86 321 unsigned get_max_framesize() const;
cannam@86 322 unsigned get_sample_rate() const;
cannam@86 323 unsigned get_channels() const;
cannam@86 324 unsigned get_bits_per_sample() const;
cannam@86 325 FLAC__uint64 get_total_samples() const;
cannam@86 326 const FLAC__byte *get_md5sum() const;
cannam@86 327
cannam@86 328 void set_min_blocksize(unsigned value);
cannam@86 329 void set_max_blocksize(unsigned value);
cannam@86 330 void set_min_framesize(unsigned value);
cannam@86 331 void set_max_framesize(unsigned value);
cannam@86 332 void set_sample_rate(unsigned value);
cannam@86 333 void set_channels(unsigned value);
cannam@86 334 void set_bits_per_sample(unsigned value);
cannam@86 335 void set_total_samples(FLAC__uint64 value);
cannam@86 336 void set_md5sum(const FLAC__byte value[16]);
cannam@86 337 //@}
cannam@86 338 };
cannam@86 339
cannam@86 340 /** PADDING metadata block.
cannam@86 341 * See the \link flacpp_metadata_object overview \endlink for more,
cannam@86 342 * and the <A HREF="../format.html#metadata_block_padding">format specification</A>.
cannam@86 343 */
cannam@86 344 class FLACPP_API Padding : public Prototype {
cannam@86 345 public:
cannam@86 346 Padding();
cannam@86 347
cannam@86 348 //@{
cannam@86 349 /** Constructs a copy of the given object. This form
cannam@86 350 * always performs a deep copy.
cannam@86 351 */
cannam@86 352 inline Padding(const Padding &object): Prototype(object) { }
cannam@86 353 inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { }
cannam@86 354 inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { }
cannam@86 355 //@}
cannam@86 356
cannam@86 357 /** Constructs an object with copy control. See
cannam@86 358 * Prototype(::FLAC__StreamMetadata *object, bool copy).
cannam@86 359 */
cannam@86 360 inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
cannam@86 361
cannam@86 362 ~Padding();
cannam@86 363
cannam@86 364 //@{
cannam@86 365 /** Assign from another object. Always performs a deep copy. */
cannam@86 366 inline Padding &operator=(const Padding &object) { Prototype::operator=(object); return *this; }
cannam@86 367 inline Padding &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
cannam@86 368 inline Padding &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
cannam@86 369 //@}
cannam@86 370
cannam@86 371 /** Assigns an object with copy control. See
cannam@86 372 * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
cannam@86 373 */
cannam@86 374 inline Padding &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
cannam@86 375
cannam@86 376 //@{
cannam@86 377 /** Check for equality, performing a deep compare by following pointers. */
cannam@86 378 inline bool operator==(const Padding &object) const { return Prototype::operator==(object); }
cannam@86 379 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
cannam@86 380 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
cannam@86 381 //@}
cannam@86 382
cannam@86 383 //@{
cannam@86 384 /** Check for inequality, performing a deep compare by following pointers. */
cannam@86 385 inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); }
cannam@86 386 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
cannam@86 387 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
cannam@86 388 //@}
cannam@86 389
cannam@86 390 void set_length(unsigned length);
cannam@86 391 };
cannam@86 392
cannam@86 393 /** APPLICATION metadata block.
cannam@86 394 * See the \link flacpp_metadata_object overview \endlink for more,
cannam@86 395 * and the <A HREF="../format.html#metadata_block_application">format specification</A>.
cannam@86 396 */
cannam@86 397 class FLACPP_API Application : public Prototype {
cannam@86 398 public:
cannam@86 399 Application();
cannam@86 400 //
cannam@86 401 //@{
cannam@86 402 /** Constructs a copy of the given object. This form
cannam@86 403 * always performs a deep copy.
cannam@86 404 */
cannam@86 405 inline Application(const Application &object): Prototype(object) { }
cannam@86 406 inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { }
cannam@86 407 inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { }
cannam@86 408 //@}
cannam@86 409
cannam@86 410 /** Constructs an object with copy control. See
cannam@86 411 * Prototype(::FLAC__StreamMetadata *object, bool copy).
cannam@86 412 */
cannam@86 413 inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
cannam@86 414
cannam@86 415 ~Application();
cannam@86 416
cannam@86 417 //@{
cannam@86 418 /** Assign from another object. Always performs a deep copy. */
cannam@86 419 inline Application &operator=(const Application &object) { Prototype::operator=(object); return *this; }
cannam@86 420 inline Application &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
cannam@86 421 inline Application &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
cannam@86 422 //@}
cannam@86 423
cannam@86 424 /** Assigns an object with copy control. See
cannam@86 425 * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
cannam@86 426 */
cannam@86 427 inline Application &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
cannam@86 428
cannam@86 429 //@{
cannam@86 430 /** Check for equality, performing a deep compare by following pointers. */
cannam@86 431 inline bool operator==(const Application &object) const { return Prototype::operator==(object); }
cannam@86 432 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
cannam@86 433 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
cannam@86 434 //@}
cannam@86 435
cannam@86 436 //@{
cannam@86 437 /** Check for inequality, performing a deep compare by following pointers. */
cannam@86 438 inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); }
cannam@86 439 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
cannam@86 440 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
cannam@86 441 //@}
cannam@86 442
cannam@86 443 const FLAC__byte *get_id() const;
cannam@86 444 const FLAC__byte *get_data() const;
cannam@86 445
cannam@86 446 void set_id(const FLAC__byte value[4]);
cannam@86 447 //! This form always copies \a data
cannam@86 448 bool set_data(const FLAC__byte *data, unsigned length);
cannam@86 449 bool set_data(FLAC__byte *data, unsigned length, bool copy);
cannam@86 450 };
cannam@86 451
cannam@86 452 /** SEEKTABLE metadata block.
cannam@86 453 * See the \link flacpp_metadata_object overview \endlink for more,
cannam@86 454 * and the <A HREF="../format.html#metadata_block_seektable">format specification</A>.
cannam@86 455 */
cannam@86 456 class FLACPP_API SeekTable : public Prototype {
cannam@86 457 public:
cannam@86 458 SeekTable();
cannam@86 459
cannam@86 460 //@{
cannam@86 461 /** Constructs a copy of the given object. This form
cannam@86 462 * always performs a deep copy.
cannam@86 463 */
cannam@86 464 inline SeekTable(const SeekTable &object): Prototype(object) { }
cannam@86 465 inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { }
cannam@86 466 inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { }
cannam@86 467 //@}
cannam@86 468
cannam@86 469 /** Constructs an object with copy control. See
cannam@86 470 * Prototype(::FLAC__StreamMetadata *object, bool copy).
cannam@86 471 */
cannam@86 472 inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
cannam@86 473
cannam@86 474 ~SeekTable();
cannam@86 475
cannam@86 476 //@{
cannam@86 477 /** Assign from another object. Always performs a deep copy. */
cannam@86 478 inline SeekTable &operator=(const SeekTable &object) { Prototype::operator=(object); return *this; }
cannam@86 479 inline SeekTable &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
cannam@86 480 inline SeekTable &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
cannam@86 481 //@}
cannam@86 482
cannam@86 483 /** Assigns an object with copy control. See
cannam@86 484 * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
cannam@86 485 */
cannam@86 486 inline SeekTable &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
cannam@86 487
cannam@86 488 //@{
cannam@86 489 /** Check for equality, performing a deep compare by following pointers. */
cannam@86 490 inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); }
cannam@86 491 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
cannam@86 492 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
cannam@86 493 //@}
cannam@86 494
cannam@86 495 //@{
cannam@86 496 /** Check for inequality, performing a deep compare by following pointers. */
cannam@86 497 inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); }
cannam@86 498 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
cannam@86 499 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
cannam@86 500 //@}
cannam@86 501
cannam@86 502 unsigned get_num_points() const;
cannam@86 503 ::FLAC__StreamMetadata_SeekPoint get_point(unsigned index) const;
cannam@86 504
cannam@86 505 //! See FLAC__metadata_object_seektable_set_point()
cannam@86 506 void set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
cannam@86 507
cannam@86 508 //! See FLAC__metadata_object_seektable_insert_point()
cannam@86 509 bool insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
cannam@86 510
cannam@86 511 //! See FLAC__metadata_object_seektable_delete_point()
cannam@86 512 bool delete_point(unsigned index);
cannam@86 513
cannam@86 514 //! See FLAC__metadata_object_seektable_is_legal()
cannam@86 515 bool is_legal() const;
cannam@86 516 };
cannam@86 517
cannam@86 518 /** VORBIS_COMMENT metadata block.
cannam@86 519 * See the \link flacpp_metadata_object overview \endlink for more,
cannam@86 520 * and the <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>.
cannam@86 521 */
cannam@86 522 class FLACPP_API VorbisComment : public Prototype {
cannam@86 523 public:
cannam@86 524 /** Convenience class for encapsulating Vorbis comment
cannam@86 525 * entries. An entry is a vendor string or a comment
cannam@86 526 * field. In the case of a vendor string, the field
cannam@86 527 * name is undefined; only the field value is relevant.
cannam@86 528 *
cannam@86 529 * A \a field as used in the methods refers to an
cannam@86 530 * entire 'NAME=VALUE' string; for convenience the
cannam@86 531 * string is NUL-terminated. A length field is
cannam@86 532 * required in the unlikely event that the value
cannam@86 533 * contains contain embedded NULs.
cannam@86 534 *
cannam@86 535 * A \a field_name is what is on the left side of the
cannam@86 536 * first '=' in the \a field. By definition it is ASCII
cannam@86 537 * and so is NUL-terminated and does not require a
cannam@86 538 * length to describe it. \a field_name is undefined
cannam@86 539 * for a vendor string entry.
cannam@86 540 *
cannam@86 541 * A \a field_value is what is on the right side of the
cannam@86 542 * first '=' in the \a field. By definition, this may
cannam@86 543 * contain embedded NULs and so a \a field_value_length
cannam@86 544 * is required to describe it. However in practice,
cannam@86 545 * embedded NULs are not known to be used, so it is
cannam@86 546 * generally safe to treat field values as NUL-
cannam@86 547 * terminated UTF-8 strings.
cannam@86 548 *
cannam@86 549 * Always check is_valid() after the constructor or operator=
cannam@86 550 * to make sure memory was properly allocated and that the
cannam@86 551 * Entry conforms to the Vorbis comment specification.
cannam@86 552 */
cannam@86 553 class FLACPP_API Entry {
cannam@86 554 public:
cannam@86 555 Entry();
cannam@86 556
cannam@86 557 Entry(const char *field, unsigned field_length);
cannam@86 558 Entry(const char *field); // assumes \a field is NUL-terminated
cannam@86 559
cannam@86 560 Entry(const char *field_name, const char *field_value, unsigned field_value_length);
cannam@86 561 Entry(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated
cannam@86 562
cannam@86 563 Entry(const Entry &entry);
cannam@86 564
cannam@86 565 Entry &operator=(const Entry &entry);
cannam@86 566
cannam@86 567 virtual ~Entry();
cannam@86 568
cannam@86 569 virtual bool is_valid() const; ///< Returns \c true iff object was properly constructed.
cannam@86 570
cannam@86 571 unsigned get_field_length() const;
cannam@86 572 unsigned get_field_name_length() const;
cannam@86 573 unsigned get_field_value_length() const;
cannam@86 574
cannam@86 575 ::FLAC__StreamMetadata_VorbisComment_Entry get_entry() const;
cannam@86 576 const char *get_field() const;
cannam@86 577 const char *get_field_name() const;
cannam@86 578 const char *get_field_value() const;
cannam@86 579
cannam@86 580 bool set_field(const char *field, unsigned field_length);
cannam@86 581 bool set_field(const char *field); // assumes \a field is NUL-terminated
cannam@86 582 bool set_field_name(const char *field_name);
cannam@86 583 bool set_field_value(const char *field_value, unsigned field_value_length);
cannam@86 584 bool set_field_value(const char *field_value); // assumes \a field_value is NUL-terminated
cannam@86 585 protected:
cannam@86 586 bool is_valid_;
cannam@86 587 ::FLAC__StreamMetadata_VorbisComment_Entry entry_;
cannam@86 588 char *field_name_;
cannam@86 589 unsigned field_name_length_;
cannam@86 590 char *field_value_;
cannam@86 591 unsigned field_value_length_;
cannam@86 592 private:
cannam@86 593 void zero();
cannam@86 594 void clear();
cannam@86 595 void clear_entry();
cannam@86 596 void clear_field_name();
cannam@86 597 void clear_field_value();
cannam@86 598 void construct(const char *field, unsigned field_length);
cannam@86 599 void construct(const char *field); // assumes \a field is NUL-terminated
cannam@86 600 void construct(const char *field_name, const char *field_value, unsigned field_value_length);
cannam@86 601 void construct(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated
cannam@86 602 void compose_field();
cannam@86 603 void parse_field();
cannam@86 604 };
cannam@86 605
cannam@86 606 VorbisComment();
cannam@86 607
cannam@86 608 //@{
cannam@86 609 /** Constructs a copy of the given object. This form
cannam@86 610 * always performs a deep copy.
cannam@86 611 */
cannam@86 612 inline VorbisComment(const VorbisComment &object): Prototype(object) { }
cannam@86 613 inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { }
cannam@86 614 inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { }
cannam@86 615 //@}
cannam@86 616
cannam@86 617 /** Constructs an object with copy control. See
cannam@86 618 * Prototype(::FLAC__StreamMetadata *object, bool copy).
cannam@86 619 */
cannam@86 620 inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
cannam@86 621
cannam@86 622 ~VorbisComment();
cannam@86 623
cannam@86 624 //@{
cannam@86 625 /** Assign from another object. Always performs a deep copy. */
cannam@86 626 inline VorbisComment &operator=(const VorbisComment &object) { Prototype::operator=(object); return *this; }
cannam@86 627 inline VorbisComment &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
cannam@86 628 inline VorbisComment &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
cannam@86 629 //@}
cannam@86 630
cannam@86 631 /** Assigns an object with copy control. See
cannam@86 632 * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
cannam@86 633 */
cannam@86 634 inline VorbisComment &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
cannam@86 635
cannam@86 636 //@{
cannam@86 637 /** Check for equality, performing a deep compare by following pointers. */
cannam@86 638 inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); }
cannam@86 639 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
cannam@86 640 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
cannam@86 641 //@}
cannam@86 642
cannam@86 643 //@{
cannam@86 644 /** Check for inequality, performing a deep compare by following pointers. */
cannam@86 645 inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); }
cannam@86 646 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
cannam@86 647 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
cannam@86 648 //@}
cannam@86 649
cannam@86 650 unsigned get_num_comments() const;
cannam@86 651 const FLAC__byte *get_vendor_string() const; // NUL-terminated UTF-8 string
cannam@86 652 Entry get_comment(unsigned index) const;
cannam@86 653
cannam@86 654 //! See FLAC__metadata_object_vorbiscomment_set_vendor_string()
cannam@86 655 bool set_vendor_string(const FLAC__byte *string); // NUL-terminated UTF-8 string
cannam@86 656
cannam@86 657 //! See FLAC__metadata_object_vorbiscomment_set_comment()
cannam@86 658 bool set_comment(unsigned index, const Entry &entry);
cannam@86 659
cannam@86 660 //! See FLAC__metadata_object_vorbiscomment_insert_comment()
cannam@86 661 bool insert_comment(unsigned index, const Entry &entry);
cannam@86 662
cannam@86 663 //! See FLAC__metadata_object_vorbiscomment_append_comment()
cannam@86 664 bool append_comment(const Entry &entry);
cannam@86 665
cannam@86 666 //! See FLAC__metadata_object_vorbiscomment_delete_comment()
cannam@86 667 bool delete_comment(unsigned index);
cannam@86 668 };
cannam@86 669
cannam@86 670 /** CUESHEET metadata block.
cannam@86 671 * See the \link flacpp_metadata_object overview \endlink for more,
cannam@86 672 * and the <A HREF="../format.html#metadata_block_cuesheet">format specification</A>.
cannam@86 673 */
cannam@86 674 class FLACPP_API CueSheet : public Prototype {
cannam@86 675 public:
cannam@86 676 /** Convenience class for encapsulating a cue sheet
cannam@86 677 * track.
cannam@86 678 *
cannam@86 679 * Always check is_valid() after the constructor or operator=
cannam@86 680 * to make sure memory was properly allocated.
cannam@86 681 */
cannam@86 682 class FLACPP_API Track {
cannam@86 683 protected:
cannam@86 684 ::FLAC__StreamMetadata_CueSheet_Track *object_;
cannam@86 685 public:
cannam@86 686 Track();
cannam@86 687 Track(const ::FLAC__StreamMetadata_CueSheet_Track *track);
cannam@86 688 Track(const Track &track);
cannam@86 689 Track &operator=(const Track &track);
cannam@86 690
cannam@86 691 virtual ~Track();
cannam@86 692
cannam@86 693 virtual bool is_valid() const; ///< Returns \c true iff object was properly constructed.
cannam@86 694
cannam@86 695
cannam@86 696 inline FLAC__uint64 get_offset() const { return object_->offset; }
cannam@86 697 inline FLAC__byte get_number() const { return object_->number; }
cannam@86 698 inline const char *get_isrc() const { return object_->isrc; }
cannam@86 699 inline unsigned get_type() const { return object_->type; }
cannam@86 700 inline bool get_pre_emphasis() const { return object_->pre_emphasis; }
cannam@86 701
cannam@86 702 inline FLAC__byte get_num_indices() const { return object_->num_indices; }
cannam@86 703 ::FLAC__StreamMetadata_CueSheet_Index get_index(unsigned i) const;
cannam@86 704
cannam@86 705 inline const ::FLAC__StreamMetadata_CueSheet_Track *get_track() const { return object_; }
cannam@86 706
cannam@86 707 inline void set_offset(FLAC__uint64 value) { object_->offset = value; }
cannam@86 708 inline void set_number(FLAC__byte value) { object_->number = value; }
cannam@86 709 void set_isrc(const char value[12]);
cannam@86 710 void set_type(unsigned value);
cannam@86 711 inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; }
cannam@86 712
cannam@86 713 void set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index);
cannam@86 714 //@@@ It's awkward but to insert/delete index points
cannam@86 715 //@@@ you must use the routines in the CueSheet class.
cannam@86 716 };
cannam@86 717
cannam@86 718 CueSheet();
cannam@86 719
cannam@86 720 //@{
cannam@86 721 /** Constructs a copy of the given object. This form
cannam@86 722 * always performs a deep copy.
cannam@86 723 */
cannam@86 724 inline CueSheet(const CueSheet &object): Prototype(object) { }
cannam@86 725 inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { }
cannam@86 726 inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { }
cannam@86 727 //@}
cannam@86 728
cannam@86 729 /** Constructs an object with copy control. See
cannam@86 730 * Prototype(::FLAC__StreamMetadata *object, bool copy).
cannam@86 731 */
cannam@86 732 inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
cannam@86 733
cannam@86 734 ~CueSheet();
cannam@86 735
cannam@86 736 //@{
cannam@86 737 /** Assign from another object. Always performs a deep copy. */
cannam@86 738 inline CueSheet &operator=(const CueSheet &object) { Prototype::operator=(object); return *this; }
cannam@86 739 inline CueSheet &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
cannam@86 740 inline CueSheet &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
cannam@86 741 //@}
cannam@86 742
cannam@86 743 /** Assigns an object with copy control. See
cannam@86 744 * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
cannam@86 745 */
cannam@86 746 inline CueSheet &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
cannam@86 747
cannam@86 748 //@{
cannam@86 749 /** Check for equality, performing a deep compare by following pointers. */
cannam@86 750 inline bool operator==(const CueSheet &object) const { return Prototype::operator==(object); }
cannam@86 751 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
cannam@86 752 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
cannam@86 753 //@}
cannam@86 754
cannam@86 755 //@{
cannam@86 756 /** Check for inequality, performing a deep compare by following pointers. */
cannam@86 757 inline bool operator!=(const CueSheet &object) const { return Prototype::operator!=(object); }
cannam@86 758 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
cannam@86 759 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
cannam@86 760 //@}
cannam@86 761
cannam@86 762 const char *get_media_catalog_number() const;
cannam@86 763 FLAC__uint64 get_lead_in() const;
cannam@86 764 bool get_is_cd() const;
cannam@86 765
cannam@86 766 unsigned get_num_tracks() const;
cannam@86 767 Track get_track(unsigned i) const;
cannam@86 768
cannam@86 769 void set_media_catalog_number(const char value[128]);
cannam@86 770 void set_lead_in(FLAC__uint64 value);
cannam@86 771 void set_is_cd(bool value);
cannam@86 772
cannam@86 773 void set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
cannam@86 774
cannam@86 775 //! See FLAC__metadata_object_cuesheet_track_insert_index()
cannam@86 776 bool insert_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
cannam@86 777
cannam@86 778 //! See FLAC__metadata_object_cuesheet_track_delete_index()
cannam@86 779 bool delete_index(unsigned track_num, unsigned index_num);
cannam@86 780
cannam@86 781 //! See FLAC__metadata_object_cuesheet_set_track()
cannam@86 782 bool set_track(unsigned i, const Track &track);
cannam@86 783
cannam@86 784 //! See FLAC__metadata_object_cuesheet_insert_track()
cannam@86 785 bool insert_track(unsigned i, const Track &track);
cannam@86 786
cannam@86 787 //! See FLAC__metadata_object_cuesheet_delete_track()
cannam@86 788 bool delete_track(unsigned i);
cannam@86 789
cannam@86 790 //! See FLAC__metadata_object_cuesheet_is_legal()
cannam@86 791 bool is_legal(bool check_cd_da_subset = false, const char **violation = 0) const;
cannam@86 792
cannam@86 793 //! See FLAC__metadata_object_cuesheet_calculate_cddb_id()
cannam@86 794 FLAC__uint32 calculate_cddb_id() const;
cannam@86 795 };
cannam@86 796
cannam@86 797 /** PICTURE metadata block.
cannam@86 798 * See the \link flacpp_metadata_object overview \endlink for more,
cannam@86 799 * and the <A HREF="../format.html#metadata_block_picture">format specification</A>.
cannam@86 800 */
cannam@86 801 class FLACPP_API Picture : public Prototype {
cannam@86 802 public:
cannam@86 803 Picture();
cannam@86 804
cannam@86 805 //@{
cannam@86 806 /** Constructs a copy of the given object. This form
cannam@86 807 * always performs a deep copy.
cannam@86 808 */
cannam@86 809 inline Picture(const Picture &object): Prototype(object) { }
cannam@86 810 inline Picture(const ::FLAC__StreamMetadata &object): Prototype(object) { }
cannam@86 811 inline Picture(const ::FLAC__StreamMetadata *object): Prototype(object) { }
cannam@86 812 //@}
cannam@86 813
cannam@86 814 /** Constructs an object with copy control. See
cannam@86 815 * Prototype(::FLAC__StreamMetadata *object, bool copy).
cannam@86 816 */
cannam@86 817 inline Picture(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
cannam@86 818
cannam@86 819 ~Picture();
cannam@86 820
cannam@86 821 //@{
cannam@86 822 /** Assign from another object. Always performs a deep copy. */
cannam@86 823 inline Picture &operator=(const Picture &object) { Prototype::operator=(object); return *this; }
cannam@86 824 inline Picture &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
cannam@86 825 inline Picture &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
cannam@86 826 //@}
cannam@86 827
cannam@86 828 /** Assigns an object with copy control. See
cannam@86 829 * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
cannam@86 830 */
cannam@86 831 inline Picture &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
cannam@86 832
cannam@86 833 //@{
cannam@86 834 /** Check for equality, performing a deep compare by following pointers. */
cannam@86 835 inline bool operator==(const Picture &object) const { return Prototype::operator==(object); }
cannam@86 836 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
cannam@86 837 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
cannam@86 838 //@}
cannam@86 839
cannam@86 840 //@{
cannam@86 841 /** Check for inequality, performing a deep compare by following pointers. */
cannam@86 842 inline bool operator!=(const Picture &object) const { return Prototype::operator!=(object); }
cannam@86 843 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
cannam@86 844 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
cannam@86 845 //@}
cannam@86 846
cannam@86 847 ::FLAC__StreamMetadata_Picture_Type get_type() const;
cannam@86 848 const char *get_mime_type() const; // NUL-terminated printable ASCII string
cannam@86 849 const FLAC__byte *get_description() const; // NUL-terminated UTF-8 string
cannam@86 850 FLAC__uint32 get_width() const;
cannam@86 851 FLAC__uint32 get_height() const;
cannam@86 852 FLAC__uint32 get_depth() const;
cannam@86 853 FLAC__uint32 get_colors() const; ///< a return value of \c 0 means true-color, i.e. 2^depth colors
cannam@86 854 FLAC__uint32 get_data_length() const;
cannam@86 855 const FLAC__byte *get_data() const;
cannam@86 856
cannam@86 857 void set_type(::FLAC__StreamMetadata_Picture_Type type);
cannam@86 858
cannam@86 859 //! See FLAC__metadata_object_picture_set_mime_type()
cannam@86 860 bool set_mime_type(const char *string); // NUL-terminated printable ASCII string
cannam@86 861
cannam@86 862 //! See FLAC__metadata_object_picture_set_description()
cannam@86 863 bool set_description(const FLAC__byte *string); // NUL-terminated UTF-8 string
cannam@86 864
cannam@86 865 void set_width(FLAC__uint32 value) const;
cannam@86 866 void set_height(FLAC__uint32 value) const;
cannam@86 867 void set_depth(FLAC__uint32 value) const;
cannam@86 868 void set_colors(FLAC__uint32 value) const; ///< a value of \c 0 means true-color, i.e. 2^depth colors
cannam@86 869
cannam@86 870 //! See FLAC__metadata_object_picture_set_data()
cannam@86 871 bool set_data(const FLAC__byte *data, FLAC__uint32 data_length);
cannam@86 872 };
cannam@86 873
cannam@86 874 /** Opaque metadata block for storing unknown types.
cannam@86 875 * This should not be used unless you know what you are doing;
cannam@86 876 * it is currently used only internally to support forward
cannam@86 877 * compatibility of metadata blocks.
cannam@86 878 * See the \link flacpp_metadata_object overview \endlink for more,
cannam@86 879 */
cannam@86 880 class FLACPP_API Unknown : public Prototype {
cannam@86 881 public:
cannam@86 882 Unknown();
cannam@86 883 //
cannam@86 884 //@{
cannam@86 885 /** Constructs a copy of the given object. This form
cannam@86 886 * always performs a deep copy.
cannam@86 887 */
cannam@86 888 inline Unknown(const Unknown &object): Prototype(object) { }
cannam@86 889 inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { }
cannam@86 890 inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { }
cannam@86 891 //@}
cannam@86 892
cannam@86 893 /** Constructs an object with copy control. See
cannam@86 894 * Prototype(::FLAC__StreamMetadata *object, bool copy).
cannam@86 895 */
cannam@86 896 inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
cannam@86 897
cannam@86 898 ~Unknown();
cannam@86 899
cannam@86 900 //@{
cannam@86 901 /** Assign from another object. Always performs a deep copy. */
cannam@86 902 inline Unknown &operator=(const Unknown &object) { Prototype::operator=(object); return *this; }
cannam@86 903 inline Unknown &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
cannam@86 904 inline Unknown &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
cannam@86 905 //@}
cannam@86 906
cannam@86 907 /** Assigns an object with copy control. See
cannam@86 908 * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy).
cannam@86 909 */
cannam@86 910 inline Unknown &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
cannam@86 911
cannam@86 912 //@{
cannam@86 913 /** Check for equality, performing a deep compare by following pointers. */
cannam@86 914 inline bool operator==(const Unknown &object) const { return Prototype::operator==(object); }
cannam@86 915 inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
cannam@86 916 inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
cannam@86 917 //@}
cannam@86 918
cannam@86 919 //@{
cannam@86 920 /** Check for inequality, performing a deep compare by following pointers. */
cannam@86 921 inline bool operator!=(const Unknown &object) const { return Prototype::operator!=(object); }
cannam@86 922 inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
cannam@86 923 inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
cannam@86 924 //@}
cannam@86 925
cannam@86 926 const FLAC__byte *get_data() const;
cannam@86 927
cannam@86 928 //! This form always copies \a data
cannam@86 929 bool set_data(const FLAC__byte *data, unsigned length);
cannam@86 930 bool set_data(FLAC__byte *data, unsigned length, bool copy);
cannam@86 931 };
cannam@86 932
cannam@86 933 /* \} */
cannam@86 934
cannam@86 935
cannam@86 936 /** \defgroup flacpp_metadata_level0 FLAC++/metadata.h: metadata level 0 interface
cannam@86 937 * \ingroup flacpp_metadata
cannam@86 938 *
cannam@86 939 * \brief
cannam@86 940 * Level 0 metadata iterators.
cannam@86 941 *
cannam@86 942 * See the \link flac_metadata_level0 C layer equivalent \endlink
cannam@86 943 * for more.
cannam@86 944 *
cannam@86 945 * \{
cannam@86 946 */
cannam@86 947
cannam@86 948 FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo); ///< See FLAC__metadata_get_streaminfo().
cannam@86 949
cannam@86 950 FLACPP_API bool get_tags(const char *filename, VorbisComment *&tags); ///< See FLAC__metadata_get_tags().
cannam@86 951 FLACPP_API bool get_tags(const char *filename, VorbisComment &tags); ///< See FLAC__metadata_get_tags().
cannam@86 952
cannam@86 953 FLACPP_API bool get_cuesheet(const char *filename, CueSheet *&cuesheet); ///< See FLAC__metadata_get_cuesheet().
cannam@86 954 FLACPP_API bool get_cuesheet(const char *filename, CueSheet &cuesheet); ///< See FLAC__metadata_get_cuesheet().
cannam@86 955
cannam@86 956 FLACPP_API bool get_picture(const char *filename, Picture *&picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors); ///< See FLAC__metadata_get_picture().
cannam@86 957 FLACPP_API bool get_picture(const char *filename, Picture &picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors); ///< See FLAC__metadata_get_picture().
cannam@86 958
cannam@86 959 /* \} */
cannam@86 960
cannam@86 961
cannam@86 962 /** \defgroup flacpp_metadata_level1 FLAC++/metadata.h: metadata level 1 interface
cannam@86 963 * \ingroup flacpp_metadata
cannam@86 964 *
cannam@86 965 * \brief
cannam@86 966 * Level 1 metadata iterator.
cannam@86 967 *
cannam@86 968 * The flow through the iterator in the C++ layer is similar
cannam@86 969 * to the C layer:
cannam@86 970 * - Create a SimpleIterator instance
cannam@86 971 * - Check SimpleIterator::is_valid()
cannam@86 972 * - Call SimpleIterator::init() and check the return
cannam@86 973 * - Traverse and/or edit. Edits are written to file
cannam@86 974 * immediately.
cannam@86 975 * - Destroy the SimpleIterator instance
cannam@86 976 *
cannam@86 977 * The ownership of pointers in the C++ layer follows that in
cannam@86 978 * the C layer, i.e.
cannam@86 979 * - The objects returned by get_block() are yours to
cannam@86 980 * modify, but changes are not reflected in the FLAC file
cannam@86 981 * until you call set_block(). The objects are also
cannam@86 982 * yours to delete; they are not automatically deleted
cannam@86 983 * when passed to set_block() or insert_block_after().
cannam@86 984 *
cannam@86 985 * See the \link flac_metadata_level1 C layer equivalent \endlink
cannam@86 986 * for more.
cannam@86 987 *
cannam@86 988 * \{
cannam@86 989 */
cannam@86 990
cannam@86 991 /** This class is a wrapper around the FLAC__metadata_simple_iterator
cannam@86 992 * structures and methods; see the
cannam@86 993 * \link flacpp_metadata_level1 usage guide \endlink and
cannam@86 994 * ::FLAC__Metadata_SimpleIterator.
cannam@86 995 */
cannam@86 996 class FLACPP_API SimpleIterator {
cannam@86 997 public:
cannam@86 998 /** This class is a wrapper around FLAC__Metadata_SimpleIteratorStatus.
cannam@86 999 */
cannam@86 1000 class FLACPP_API Status {
cannam@86 1001 public:
cannam@86 1002 inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { }
cannam@86 1003 inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; }
cannam@86 1004 inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; }
cannam@86 1005 protected:
cannam@86 1006 ::FLAC__Metadata_SimpleIteratorStatus status_;
cannam@86 1007 };
cannam@86 1008
cannam@86 1009 SimpleIterator();
cannam@86 1010 virtual ~SimpleIterator();
cannam@86 1011
cannam@86 1012 bool is_valid() const; ///< Returns \c true iff object was properly constructed.
cannam@86 1013
cannam@86 1014 bool init(const char *filename, bool read_only, bool preserve_file_stats); ///< See FLAC__metadata_simple_iterator_init().
cannam@86 1015
cannam@86 1016 Status status(); ///< See FLAC__metadata_simple_iterator_status().
cannam@86 1017 bool is_writable() const; ///< See FLAC__metadata_simple_iterator_is_writable().
cannam@86 1018
cannam@86 1019 bool next(); ///< See FLAC__metadata_simple_iterator_next().
cannam@86 1020 bool prev(); ///< See FLAC__metadata_simple_iterator_prev().
cannam@86 1021 bool is_last() const; ///< See FLAC__metadata_simple_iterator_is_last().
cannam@86 1022
cannam@86 1023 off_t get_block_offset() const; ///< See FLAC__metadata_simple_iterator_get_block_offset().
cannam@86 1024 ::FLAC__MetadataType get_block_type() const; ///< See FLAC__metadata_simple_iterator_get_block_type().
cannam@86 1025 unsigned get_block_length() const; ///< See FLAC__metadata_simple_iterator_get_block_length().
cannam@86 1026 bool get_application_id(FLAC__byte *id); ///< See FLAC__metadata_simple_iterator_get_application_id().
cannam@86 1027 Prototype *get_block(); ///< See FLAC__metadata_simple_iterator_get_block().
cannam@86 1028 bool set_block(Prototype *block, bool use_padding = true); ///< See FLAC__metadata_simple_iterator_set_block().
cannam@86 1029 bool insert_block_after(Prototype *block, bool use_padding = true); ///< See FLAC__metadata_simple_iterator_insert_block_after().
cannam@86 1030 bool delete_block(bool use_padding = true); ///< See FLAC__metadata_simple_iterator_delete_block().
cannam@86 1031
cannam@86 1032 protected:
cannam@86 1033 ::FLAC__Metadata_SimpleIterator *iterator_;
cannam@86 1034 void clear();
cannam@86 1035 };
cannam@86 1036
cannam@86 1037 /* \} */
cannam@86 1038
cannam@86 1039
cannam@86 1040 /** \defgroup flacpp_metadata_level2 FLAC++/metadata.h: metadata level 2 interface
cannam@86 1041 * \ingroup flacpp_metadata
cannam@86 1042 *
cannam@86 1043 * \brief
cannam@86 1044 * Level 2 metadata iterator.
cannam@86 1045 *
cannam@86 1046 * The flow through the iterator in the C++ layer is similar
cannam@86 1047 * to the C layer:
cannam@86 1048 * - Create a Chain instance
cannam@86 1049 * - Check Chain::is_valid()
cannam@86 1050 * - Call Chain::read() and check the return
cannam@86 1051 * - Traverse and/or edit with an Iterator or with
cannam@86 1052 * Chain::merge_padding() or Chain::sort_padding()
cannam@86 1053 * - Write changes back to FLAC file with Chain::write()
cannam@86 1054 * - Destroy the Chain instance
cannam@86 1055 *
cannam@86 1056 * The ownership of pointers in the C++ layer is slightly
cannam@86 1057 * different than in the C layer, i.e.
cannam@86 1058 * - The objects returned by Iterator::get_block() are NOT
cannam@86 1059 * owned by the iterator and should be deleted by the
cannam@86 1060 * caller when finished, BUT, when you modify the block,
cannam@86 1061 * it will directly edit what's in the chain and you do
cannam@86 1062 * not need to call Iterator::set_block(). However the
cannam@86 1063 * changes will not be reflected in the FLAC file until
cannam@86 1064 * the chain is written with Chain::write().
cannam@86 1065 * - When you pass an object to Iterator::set_block(),
cannam@86 1066 * Iterator::insert_block_before(), or
cannam@86 1067 * Iterator::insert_block_after(), the iterator takes
cannam@86 1068 * ownership of the block and it will be deleted by the
cannam@86 1069 * chain.
cannam@86 1070 *
cannam@86 1071 * See the \link flac_metadata_level2 C layer equivalent \endlink
cannam@86 1072 * for more.
cannam@86 1073 *
cannam@86 1074 * \{
cannam@86 1075 */
cannam@86 1076
cannam@86 1077 /** This class is a wrapper around the FLAC__metadata_chain
cannam@86 1078 * structures and methods; see the
cannam@86 1079 * \link flacpp_metadata_level2 usage guide \endlink and
cannam@86 1080 * ::FLAC__Metadata_Chain.
cannam@86 1081 */
cannam@86 1082 class FLACPP_API Chain {
cannam@86 1083 public:
cannam@86 1084 /** This class is a wrapper around FLAC__Metadata_ChainStatus.
cannam@86 1085 */
cannam@86 1086 class FLACPP_API Status {
cannam@86 1087 public:
cannam@86 1088 inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { }
cannam@86 1089 inline operator ::FLAC__Metadata_ChainStatus() const { return status_; }
cannam@86 1090 inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; }
cannam@86 1091 protected:
cannam@86 1092 ::FLAC__Metadata_ChainStatus status_;
cannam@86 1093 };
cannam@86 1094
cannam@86 1095 Chain();
cannam@86 1096 virtual ~Chain();
cannam@86 1097
cannam@86 1098 friend class Iterator;
cannam@86 1099
cannam@86 1100 bool is_valid() const; ///< Returns \c true iff object was properly constructed.
cannam@86 1101
cannam@86 1102 Status status(); ///< See FLAC__metadata_chain_status().
cannam@86 1103
cannam@86 1104 bool read(const char *filename, bool is_ogg = false); ///< See FLAC__metadata_chain_read(), FLAC__metadata_chain_read_ogg().
cannam@86 1105 bool read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, bool is_ogg = false); ///< See FLAC__metadata_chain_read_with_callbacks(), FLAC__metadata_chain_read_ogg_with_callbacks().
cannam@86 1106
cannam@86 1107 bool check_if_tempfile_needed(bool use_padding); ///< See FLAC__metadata_chain_check_if_tempfile_needed().
cannam@86 1108
cannam@86 1109 bool write(bool use_padding = true, bool preserve_file_stats = false); ///< See FLAC__metadata_chain_write().
cannam@86 1110 bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks); ///< See FLAC__metadata_chain_write_with_callbacks().
cannam@86 1111 bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, ::FLAC__IOHandle temp_handle, ::FLAC__IOCallbacks temp_callbacks); ///< See FLAC__metadata_chain_write_with_callbacks_and_tempfile().
cannam@86 1112
cannam@86 1113 void merge_padding(); ///< See FLAC__metadata_chain_merge_padding().
cannam@86 1114 void sort_padding(); ///< See FLAC__metadata_chain_sort_padding().
cannam@86 1115
cannam@86 1116 protected:
cannam@86 1117 ::FLAC__Metadata_Chain *chain_;
cannam@86 1118 virtual void clear();
cannam@86 1119 };
cannam@86 1120
cannam@86 1121 /** This class is a wrapper around the FLAC__metadata_iterator
cannam@86 1122 * structures and methods; see the
cannam@86 1123 * \link flacpp_metadata_level2 usage guide \endlink and
cannam@86 1124 * ::FLAC__Metadata_Iterator.
cannam@86 1125 */
cannam@86 1126 class FLACPP_API Iterator {
cannam@86 1127 public:
cannam@86 1128 Iterator();
cannam@86 1129 virtual ~Iterator();
cannam@86 1130
cannam@86 1131 bool is_valid() const; ///< Returns \c true iff object was properly constructed.
cannam@86 1132
cannam@86 1133
cannam@86 1134 void init(Chain &chain); ///< See FLAC__metadata_iterator_init().
cannam@86 1135
cannam@86 1136 bool next(); ///< See FLAC__metadata_iterator_next().
cannam@86 1137 bool prev(); ///< See FLAC__metadata_iterator_prev().
cannam@86 1138
cannam@86 1139 ::FLAC__MetadataType get_block_type() const; ///< See FLAC__metadata_iterator_get_block_type().
cannam@86 1140 Prototype *get_block(); ///< See FLAC__metadata_iterator_get_block().
cannam@86 1141 bool set_block(Prototype *block); ///< See FLAC__metadata_iterator_set_block().
cannam@86 1142 bool delete_block(bool replace_with_padding); ///< See FLAC__metadata_iterator_delete_block().
cannam@86 1143 bool insert_block_before(Prototype *block); ///< See FLAC__metadata_iterator_insert_block_before().
cannam@86 1144 bool insert_block_after(Prototype *block); ///< See FLAC__metadata_iterator_insert_block_after().
cannam@86 1145
cannam@86 1146 protected:
cannam@86 1147 ::FLAC__Metadata_Iterator *iterator_;
cannam@86 1148 virtual void clear();
cannam@86 1149 };
cannam@86 1150
cannam@86 1151 /* \} */
cannam@86 1152
cannam@86 1153 }
cannam@86 1154 }
cannam@86 1155
cannam@86 1156 #endif