annotate win32-mingw/include/FLAC++/metadata.h @ 30:553a5f65ef64

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