annotate src/flac-1.2.1/include/FLAC++/metadata.h @ 23:619f715526df sv_v2.1

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