Chris@2: /* libFLAC++ - Free Lossless Audio Codec library Chris@2: * Copyright (C) 2002,2003,2004,2005,2006,2007 Josh Coalson Chris@2: * Chris@2: * Redistribution and use in source and binary forms, with or without Chris@2: * modification, are permitted provided that the following conditions Chris@2: * are met: Chris@2: * Chris@2: * - Redistributions of source code must retain the above copyright Chris@2: * notice, this list of conditions and the following disclaimer. Chris@2: * Chris@2: * - Redistributions in binary form must reproduce the above copyright Chris@2: * notice, this list of conditions and the following disclaimer in the Chris@2: * documentation and/or other materials provided with the distribution. Chris@2: * Chris@2: * - Neither the name of the Xiph.org Foundation nor the names of its Chris@2: * contributors may be used to endorse or promote products derived from Chris@2: * this software without specific prior written permission. Chris@2: * Chris@2: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS Chris@2: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT Chris@2: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR Chris@2: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR Chris@2: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, Chris@2: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, Chris@2: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR Chris@2: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF Chris@2: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING Chris@2: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS Chris@2: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Chris@2: */ Chris@2: Chris@2: #ifndef FLACPP__METADATA_H Chris@2: #define FLACPP__METADATA_H Chris@2: Chris@2: #include "export.h" Chris@2: Chris@2: #include "FLAC/metadata.h" Chris@2: Chris@2: // =============================================================== Chris@2: // Chris@2: // Full documentation for the metadata interface can be found Chris@2: // in the C layer in include/FLAC/metadata.h Chris@2: // Chris@2: // =============================================================== Chris@2: Chris@2: /** \file include/FLAC++/metadata.h Chris@2: * Chris@2: * \brief Chris@2: * This module provides classes for creating and manipulating FLAC Chris@2: * metadata blocks in memory, and three progressively more powerful Chris@2: * interfaces for traversing and editing metadata in FLAC files. Chris@2: * Chris@2: * See the detailed documentation for each interface in the Chris@2: * \link flacpp_metadata metadata \endlink module. Chris@2: */ Chris@2: Chris@2: /** \defgroup flacpp_metadata FLAC++/metadata.h: metadata interfaces Chris@2: * \ingroup flacpp Chris@2: * Chris@2: * \brief Chris@2: * This module provides classes for creating and manipulating FLAC Chris@2: * metadata blocks in memory, and three progressively more powerful Chris@2: * interfaces for traversing and editing metadata in FLAC files. Chris@2: * Chris@2: * The behavior closely mimics the C layer interface; be sure to read Chris@2: * the detailed description of the Chris@2: * \link flac_metadata C metadata module \endlink. Note that like the Chris@2: * C layer, currently only the Chain interface (level 2) supports Ogg Chris@2: * FLAC files, and it is read-only i.e. no writing back changed Chris@2: * metadata to file. Chris@2: */ Chris@2: Chris@2: Chris@2: namespace FLAC { Chris@2: namespace Metadata { Chris@2: Chris@2: // ============================================================ Chris@2: // Chris@2: // Metadata objects Chris@2: // Chris@2: // ============================================================ Chris@2: Chris@2: /** \defgroup flacpp_metadata_object FLAC++/metadata.h: metadata object classes Chris@2: * \ingroup flacpp_metadata Chris@2: * Chris@2: * This module contains classes representing FLAC metadata Chris@2: * blocks in memory. Chris@2: * Chris@2: * The behavior closely mimics the C layer interface; be Chris@2: * sure to read the detailed description of the Chris@2: * \link flac_metadata_object C metadata object module \endlink. Chris@2: * Chris@2: * Any time a metadata object is constructed or assigned, you Chris@2: * should check is_valid() to make sure the underlying Chris@2: * ::FLAC__StreamMetadata object was able to be created. Chris@2: * Chris@2: * \warning Chris@2: * When the get_*() methods of any metadata object method Chris@2: * return you a const pointer, DO NOT disobey and write into it. Chris@2: * Always use the set_*() methods. Chris@2: * Chris@2: * \{ Chris@2: */ Chris@2: Chris@2: /** Base class for all metadata block types. Chris@2: * See the \link flacpp_metadata_object overview \endlink for more. Chris@2: */ Chris@2: class FLACPP_API Prototype { Chris@2: protected: Chris@2: //@{ Chris@2: /** Constructs a copy of the given object. This form Chris@2: * always performs a deep copy. Chris@2: */ Chris@2: Prototype(const Prototype &); Chris@2: Prototype(const ::FLAC__StreamMetadata &); Chris@2: Prototype(const ::FLAC__StreamMetadata *); Chris@2: //@} Chris@2: Chris@2: /** Constructs an object with copy control. When \a copy Chris@2: * is \c true, behaves identically to Chris@2: * FLAC::Metadata::Prototype::Prototype(const ::FLAC__StreamMetadata *object). Chris@2: * When \a copy is \c false, the instance takes ownership of Chris@2: * the pointer and the ::FLAC__StreamMetadata object will Chris@2: * be freed by the destructor. Chris@2: * Chris@2: * \assert Chris@2: * \code object != NULL \endcode Chris@2: */ Chris@2: Prototype(::FLAC__StreamMetadata *object, bool copy); Chris@2: Chris@2: //@{ Chris@2: /** Assign from another object. Always performs a deep copy. */ Chris@2: Prototype &operator=(const Prototype &); Chris@2: Prototype &operator=(const ::FLAC__StreamMetadata &); Chris@2: Prototype &operator=(const ::FLAC__StreamMetadata *); Chris@2: //@} Chris@2: Chris@2: /** Assigns an object with copy control. See Chris@2: * Prototype(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: Prototype &assign_object(::FLAC__StreamMetadata *object, bool copy); Chris@2: Chris@2: /** Deletes the underlying ::FLAC__StreamMetadata object. Chris@2: */ Chris@2: virtual void clear(); Chris@2: Chris@2: ::FLAC__StreamMetadata *object_; Chris@2: public: Chris@2: /** Deletes the underlying ::FLAC__StreamMetadata object. Chris@2: */ Chris@2: virtual ~Prototype(); Chris@2: Chris@2: //@{ Chris@2: /** Check for equality, performing a deep compare by following pointers. Chris@2: */ Chris@2: inline bool operator==(const Prototype &) const; Chris@2: inline bool operator==(const ::FLAC__StreamMetadata &) const; Chris@2: inline bool operator==(const ::FLAC__StreamMetadata *) const; Chris@2: //@} Chris@2: Chris@2: //@{ Chris@2: /** Check for inequality, performing a deep compare by following pointers. */ Chris@2: inline bool operator!=(const Prototype &) const; Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata &) const; Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata *) const; Chris@2: //@} Chris@2: Chris@2: friend class SimpleIterator; Chris@2: friend class Iterator; Chris@2: Chris@2: /** Returns \c true if the object was correctly constructed Chris@2: * (i.e. the underlying ::FLAC__StreamMetadata object was Chris@2: * properly allocated), else \c false. Chris@2: */ Chris@2: inline bool is_valid() const; Chris@2: Chris@2: /** Returns \c true if this block is the last block in a Chris@2: * stream, else \c false. Chris@2: * Chris@2: * \assert Chris@2: * \code is_valid() \endcode Chris@2: */ Chris@2: bool get_is_last() const; Chris@2: Chris@2: /** Returns the type of the block. Chris@2: * Chris@2: * \assert Chris@2: * \code is_valid() \endcode Chris@2: */ Chris@2: ::FLAC__MetadataType get_type() const; Chris@2: Chris@2: /** Returns the stream length of the metadata block. Chris@2: * Chris@2: * \note Chris@2: * The length does not include the metadata block header, Chris@2: * per spec. Chris@2: * Chris@2: * \assert Chris@2: * \code is_valid() \endcode Chris@2: */ Chris@2: unsigned get_length() const; Chris@2: Chris@2: /** Sets the "is_last" flag for the block. When using the iterators Chris@2: * it is not necessary to set this flag; they will do it for you. Chris@2: * Chris@2: * \assert Chris@2: * \code is_valid() \endcode Chris@2: */ Chris@2: void set_is_last(bool); Chris@2: Chris@2: /** Returns a pointer to the underlying ::FLAC__StreamMetadata Chris@2: * object. This can be useful for plugging any holes between Chris@2: * the C++ and C interfaces. Chris@2: * Chris@2: * \assert Chris@2: * \code is_valid() \endcode Chris@2: */ Chris@2: inline operator const ::FLAC__StreamMetadata *() const; Chris@2: private: Chris@2: /** Private and undefined so you can't use it. */ Chris@2: Prototype(); Chris@2: Chris@2: // These are used only by Iterator Chris@2: bool is_reference_; Chris@2: inline void set_reference(bool x) { is_reference_ = x; } Chris@2: }; Chris@2: Chris@2: #ifdef _MSC_VER Chris@2: // warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning) Chris@2: #pragma warning ( disable : 4800 ) Chris@2: #endif Chris@2: Chris@2: inline bool Prototype::operator==(const Prototype &object) const Chris@2: { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); } Chris@2: Chris@2: inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const Chris@2: { return (bool)::FLAC__metadata_object_is_equal(object_, &object); } Chris@2: Chris@2: inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const Chris@2: { return (bool)::FLAC__metadata_object_is_equal(object_, object); } Chris@2: Chris@2: #ifdef _MSC_VER Chris@2: // @@@ how to re-enable? the following doesn't work Chris@2: // #pragma warning ( enable : 4800 ) Chris@2: #endif Chris@2: Chris@2: inline bool Prototype::operator!=(const Prototype &object) const Chris@2: { return !operator==(object); } Chris@2: Chris@2: inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const Chris@2: { return !operator==(object); } Chris@2: Chris@2: inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const Chris@2: { return !operator==(object); } Chris@2: Chris@2: inline bool Prototype::is_valid() const Chris@2: { return 0 != object_; } Chris@2: Chris@2: inline Prototype::operator const ::FLAC__StreamMetadata *() const Chris@2: { return object_; } Chris@2: Chris@2: /** Create a deep copy of an object and return it. */ Chris@2: FLACPP_API Prototype *clone(const Prototype *); Chris@2: Chris@2: Chris@2: /** STREAMINFO metadata block. Chris@2: * See the \link flacpp_metadata_object overview \endlink for more, Chris@2: * and the format specification. Chris@2: */ Chris@2: class FLACPP_API StreamInfo : public Prototype { Chris@2: public: Chris@2: StreamInfo(); Chris@2: Chris@2: //@{ Chris@2: /** Constructs a copy of the given object. This form Chris@2: * always performs a deep copy. Chris@2: */ Chris@2: inline StreamInfo(const StreamInfo &object): Prototype(object) { } Chris@2: inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@2: inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@2: //@} Chris@2: Chris@2: /** Constructs an object with copy control. See Chris@2: * Prototype(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@2: Chris@2: ~StreamInfo(); Chris@2: Chris@2: //@{ Chris@2: /** Assign from another object. Always performs a deep copy. */ Chris@2: inline StreamInfo &operator=(const StreamInfo &object) { Prototype::operator=(object); return *this; } Chris@2: inline StreamInfo &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@2: inline StreamInfo &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@2: //@} Chris@2: Chris@2: /** Assigns an object with copy control. See Chris@2: * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline StreamInfo &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@2: Chris@2: //@{ Chris@2: /** Check for equality, performing a deep compare by following pointers. */ Chris@2: inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@2: //@} Chris@2: Chris@2: //@{ Chris@2: /** Check for inequality, performing a deep compare by following pointers. */ Chris@2: inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@2: //@} Chris@2: Chris@2: //@{ Chris@2: /** See format specification. */ Chris@2: unsigned get_min_blocksize() const; Chris@2: unsigned get_max_blocksize() const; Chris@2: unsigned get_min_framesize() const; Chris@2: unsigned get_max_framesize() const; Chris@2: unsigned get_sample_rate() const; Chris@2: unsigned get_channels() const; Chris@2: unsigned get_bits_per_sample() const; Chris@2: FLAC__uint64 get_total_samples() const; Chris@2: const FLAC__byte *get_md5sum() const; Chris@2: Chris@2: void set_min_blocksize(unsigned value); Chris@2: void set_max_blocksize(unsigned value); Chris@2: void set_min_framesize(unsigned value); Chris@2: void set_max_framesize(unsigned value); Chris@2: void set_sample_rate(unsigned value); Chris@2: void set_channels(unsigned value); Chris@2: void set_bits_per_sample(unsigned value); Chris@2: void set_total_samples(FLAC__uint64 value); Chris@2: void set_md5sum(const FLAC__byte value[16]); Chris@2: //@} Chris@2: }; Chris@2: Chris@2: /** PADDING metadata block. Chris@2: * See the \link flacpp_metadata_object overview \endlink for more, Chris@2: * and the format specification. Chris@2: */ Chris@2: class FLACPP_API Padding : public Prototype { Chris@2: public: Chris@2: Padding(); Chris@2: Chris@2: //@{ Chris@2: /** Constructs a copy of the given object. This form Chris@2: * always performs a deep copy. Chris@2: */ Chris@2: inline Padding(const Padding &object): Prototype(object) { } Chris@2: inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@2: inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@2: //@} Chris@2: Chris@2: /** Constructs an object with copy control. See Chris@2: * Prototype(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@2: Chris@2: ~Padding(); Chris@2: Chris@2: //@{ Chris@2: /** Assign from another object. Always performs a deep copy. */ Chris@2: inline Padding &operator=(const Padding &object) { Prototype::operator=(object); return *this; } Chris@2: inline Padding &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@2: inline Padding &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@2: //@} Chris@2: Chris@2: /** Assigns an object with copy control. See Chris@2: * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline Padding &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@2: Chris@2: //@{ Chris@2: /** Check for equality, performing a deep compare by following pointers. */ Chris@2: inline bool operator==(const Padding &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@2: //@} Chris@2: Chris@2: //@{ Chris@2: /** Check for inequality, performing a deep compare by following pointers. */ Chris@2: inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@2: //@} Chris@2: Chris@2: void set_length(unsigned length); Chris@2: }; Chris@2: Chris@2: /** APPLICATION metadata block. Chris@2: * See the \link flacpp_metadata_object overview \endlink for more, Chris@2: * and the format specification. Chris@2: */ Chris@2: class FLACPP_API Application : public Prototype { Chris@2: public: Chris@2: Application(); Chris@2: // Chris@2: //@{ Chris@2: /** Constructs a copy of the given object. This form Chris@2: * always performs a deep copy. Chris@2: */ Chris@2: inline Application(const Application &object): Prototype(object) { } Chris@2: inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@2: inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@2: //@} Chris@2: Chris@2: /** Constructs an object with copy control. See Chris@2: * Prototype(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@2: Chris@2: ~Application(); Chris@2: Chris@2: //@{ Chris@2: /** Assign from another object. Always performs a deep copy. */ Chris@2: inline Application &operator=(const Application &object) { Prototype::operator=(object); return *this; } Chris@2: inline Application &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@2: inline Application &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@2: //@} Chris@2: Chris@2: /** Assigns an object with copy control. See Chris@2: * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline Application &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@2: Chris@2: //@{ Chris@2: /** Check for equality, performing a deep compare by following pointers. */ Chris@2: inline bool operator==(const Application &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@2: //@} Chris@2: Chris@2: //@{ Chris@2: /** Check for inequality, performing a deep compare by following pointers. */ Chris@2: inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@2: //@} Chris@2: Chris@2: const FLAC__byte *get_id() const; Chris@2: const FLAC__byte *get_data() const; Chris@2: Chris@2: void set_id(const FLAC__byte value[4]); Chris@2: //! This form always copies \a data Chris@2: bool set_data(const FLAC__byte *data, unsigned length); Chris@2: bool set_data(FLAC__byte *data, unsigned length, bool copy); Chris@2: }; Chris@2: Chris@2: /** SEEKTABLE metadata block. Chris@2: * See the \link flacpp_metadata_object overview \endlink for more, Chris@2: * and the format specification. Chris@2: */ Chris@2: class FLACPP_API SeekTable : public Prototype { Chris@2: public: Chris@2: SeekTable(); Chris@2: Chris@2: //@{ Chris@2: /** Constructs a copy of the given object. This form Chris@2: * always performs a deep copy. Chris@2: */ Chris@2: inline SeekTable(const SeekTable &object): Prototype(object) { } Chris@2: inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@2: inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@2: //@} Chris@2: Chris@2: /** Constructs an object with copy control. See Chris@2: * Prototype(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@2: Chris@2: ~SeekTable(); Chris@2: Chris@2: //@{ Chris@2: /** Assign from another object. Always performs a deep copy. */ Chris@2: inline SeekTable &operator=(const SeekTable &object) { Prototype::operator=(object); return *this; } Chris@2: inline SeekTable &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@2: inline SeekTable &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@2: //@} Chris@2: Chris@2: /** Assigns an object with copy control. See Chris@2: * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline SeekTable &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@2: Chris@2: //@{ Chris@2: /** Check for equality, performing a deep compare by following pointers. */ Chris@2: inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@2: //@} Chris@2: Chris@2: //@{ Chris@2: /** Check for inequality, performing a deep compare by following pointers. */ Chris@2: inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@2: //@} Chris@2: Chris@2: unsigned get_num_points() const; Chris@2: ::FLAC__StreamMetadata_SeekPoint get_point(unsigned index) const; Chris@2: Chris@2: //! See FLAC__metadata_object_seektable_set_point() Chris@2: void set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point); Chris@2: Chris@2: //! See FLAC__metadata_object_seektable_insert_point() Chris@2: bool insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point); Chris@2: Chris@2: //! See FLAC__metadata_object_seektable_delete_point() Chris@2: bool delete_point(unsigned index); Chris@2: Chris@2: //! See FLAC__metadata_object_seektable_is_legal() Chris@2: bool is_legal() const; Chris@2: }; Chris@2: Chris@2: /** VORBIS_COMMENT metadata block. Chris@2: * See the \link flacpp_metadata_object overview \endlink for more, Chris@2: * and the format specification. Chris@2: */ Chris@2: class FLACPP_API VorbisComment : public Prototype { Chris@2: public: Chris@2: /** Convenience class for encapsulating Vorbis comment Chris@2: * entries. An entry is a vendor string or a comment Chris@2: * field. In the case of a vendor string, the field Chris@2: * name is undefined; only the field value is relevant. Chris@2: * Chris@2: * A \a field as used in the methods refers to an Chris@2: * entire 'NAME=VALUE' string; for convenience the Chris@2: * string is NUL-terminated. A length field is Chris@2: * required in the unlikely event that the value Chris@2: * contains contain embedded NULs. Chris@2: * Chris@2: * A \a field_name is what is on the left side of the Chris@2: * first '=' in the \a field. By definition it is ASCII Chris@2: * and so is NUL-terminated and does not require a Chris@2: * length to describe it. \a field_name is undefined Chris@2: * for a vendor string entry. Chris@2: * Chris@2: * A \a field_value is what is on the right side of the Chris@2: * first '=' in the \a field. By definition, this may Chris@2: * contain embedded NULs and so a \a field_value_length Chris@2: * is required to describe it. However in practice, Chris@2: * embedded NULs are not known to be used, so it is Chris@2: * generally safe to treat field values as NUL- Chris@2: * terminated UTF-8 strings. Chris@2: * Chris@2: * Always check is_valid() after the constructor or operator= Chris@2: * to make sure memory was properly allocated and that the Chris@2: * Entry conforms to the Vorbis comment specification. Chris@2: */ Chris@2: class FLACPP_API Entry { Chris@2: public: Chris@2: Entry(); Chris@2: Chris@2: Entry(const char *field, unsigned field_length); Chris@2: Entry(const char *field); // assumes \a field is NUL-terminated Chris@2: Chris@2: Entry(const char *field_name, const char *field_value, unsigned field_value_length); Chris@2: Entry(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated Chris@2: Chris@2: Entry(const Entry &entry); Chris@2: Chris@2: Entry &operator=(const Entry &entry); Chris@2: Chris@2: virtual ~Entry(); Chris@2: Chris@2: virtual bool is_valid() const; ///< Returns \c true iff object was properly constructed. Chris@2: Chris@2: unsigned get_field_length() const; Chris@2: unsigned get_field_name_length() const; Chris@2: unsigned get_field_value_length() const; Chris@2: Chris@2: ::FLAC__StreamMetadata_VorbisComment_Entry get_entry() const; Chris@2: const char *get_field() const; Chris@2: const char *get_field_name() const; Chris@2: const char *get_field_value() const; Chris@2: Chris@2: bool set_field(const char *field, unsigned field_length); Chris@2: bool set_field(const char *field); // assumes \a field is NUL-terminated Chris@2: bool set_field_name(const char *field_name); Chris@2: bool set_field_value(const char *field_value, unsigned field_value_length); Chris@2: bool set_field_value(const char *field_value); // assumes \a field_value is NUL-terminated Chris@2: protected: Chris@2: bool is_valid_; Chris@2: ::FLAC__StreamMetadata_VorbisComment_Entry entry_; Chris@2: char *field_name_; Chris@2: unsigned field_name_length_; Chris@2: char *field_value_; Chris@2: unsigned field_value_length_; Chris@2: private: Chris@2: void zero(); Chris@2: void clear(); Chris@2: void clear_entry(); Chris@2: void clear_field_name(); Chris@2: void clear_field_value(); Chris@2: void construct(const char *field, unsigned field_length); Chris@2: void construct(const char *field); // assumes \a field is NUL-terminated Chris@2: void construct(const char *field_name, const char *field_value, unsigned field_value_length); Chris@2: void construct(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated Chris@2: void compose_field(); Chris@2: void parse_field(); Chris@2: }; Chris@2: Chris@2: VorbisComment(); Chris@2: Chris@2: //@{ Chris@2: /** Constructs a copy of the given object. This form Chris@2: * always performs a deep copy. Chris@2: */ Chris@2: inline VorbisComment(const VorbisComment &object): Prototype(object) { } Chris@2: inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@2: inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@2: //@} Chris@2: Chris@2: /** Constructs an object with copy control. See Chris@2: * Prototype(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@2: Chris@2: ~VorbisComment(); Chris@2: Chris@2: //@{ Chris@2: /** Assign from another object. Always performs a deep copy. */ Chris@2: inline VorbisComment &operator=(const VorbisComment &object) { Prototype::operator=(object); return *this; } Chris@2: inline VorbisComment &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@2: inline VorbisComment &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@2: //@} Chris@2: Chris@2: /** Assigns an object with copy control. See Chris@2: * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline VorbisComment &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@2: Chris@2: //@{ Chris@2: /** Check for equality, performing a deep compare by following pointers. */ Chris@2: inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@2: //@} Chris@2: Chris@2: //@{ Chris@2: /** Check for inequality, performing a deep compare by following pointers. */ Chris@2: inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@2: //@} Chris@2: Chris@2: unsigned get_num_comments() const; Chris@2: const FLAC__byte *get_vendor_string() const; // NUL-terminated UTF-8 string Chris@2: Entry get_comment(unsigned index) const; Chris@2: Chris@2: //! See FLAC__metadata_object_vorbiscomment_set_vendor_string() Chris@2: bool set_vendor_string(const FLAC__byte *string); // NUL-terminated UTF-8 string Chris@2: Chris@2: //! See FLAC__metadata_object_vorbiscomment_set_comment() Chris@2: bool set_comment(unsigned index, const Entry &entry); Chris@2: Chris@2: //! See FLAC__metadata_object_vorbiscomment_insert_comment() Chris@2: bool insert_comment(unsigned index, const Entry &entry); Chris@2: Chris@2: //! See FLAC__metadata_object_vorbiscomment_append_comment() Chris@2: bool append_comment(const Entry &entry); Chris@2: Chris@2: //! See FLAC__metadata_object_vorbiscomment_delete_comment() Chris@2: bool delete_comment(unsigned index); Chris@2: }; Chris@2: Chris@2: /** CUESHEET metadata block. Chris@2: * See the \link flacpp_metadata_object overview \endlink for more, Chris@2: * and the format specification. Chris@2: */ Chris@2: class FLACPP_API CueSheet : public Prototype { Chris@2: public: Chris@2: /** Convenience class for encapsulating a cue sheet Chris@2: * track. Chris@2: * Chris@2: * Always check is_valid() after the constructor or operator= Chris@2: * to make sure memory was properly allocated. Chris@2: */ Chris@2: class FLACPP_API Track { Chris@2: protected: Chris@2: ::FLAC__StreamMetadata_CueSheet_Track *object_; Chris@2: public: Chris@2: Track(); Chris@2: Track(const ::FLAC__StreamMetadata_CueSheet_Track *track); Chris@2: Track(const Track &track); Chris@2: Track &operator=(const Track &track); Chris@2: Chris@2: virtual ~Track(); Chris@2: Chris@2: virtual bool is_valid() const; ///< Returns \c true iff object was properly constructed. Chris@2: Chris@2: Chris@2: inline FLAC__uint64 get_offset() const { return object_->offset; } Chris@2: inline FLAC__byte get_number() const { return object_->number; } Chris@2: inline const char *get_isrc() const { return object_->isrc; } Chris@2: inline unsigned get_type() const { return object_->type; } Chris@2: inline bool get_pre_emphasis() const { return object_->pre_emphasis; } Chris@2: Chris@2: inline FLAC__byte get_num_indices() const { return object_->num_indices; } Chris@2: ::FLAC__StreamMetadata_CueSheet_Index get_index(unsigned i) const; Chris@2: Chris@2: inline const ::FLAC__StreamMetadata_CueSheet_Track *get_track() const { return object_; } Chris@2: Chris@2: inline void set_offset(FLAC__uint64 value) { object_->offset = value; } Chris@2: inline void set_number(FLAC__byte value) { object_->number = value; } Chris@2: void set_isrc(const char value[12]); Chris@2: void set_type(unsigned value); Chris@2: inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; } Chris@2: Chris@2: void set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index); Chris@2: //@@@ It's awkward but to insert/delete index points Chris@2: //@@@ you must use the routines in the CueSheet class. Chris@2: }; Chris@2: Chris@2: CueSheet(); Chris@2: Chris@2: //@{ Chris@2: /** Constructs a copy of the given object. This form Chris@2: * always performs a deep copy. Chris@2: */ Chris@2: inline CueSheet(const CueSheet &object): Prototype(object) { } Chris@2: inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@2: inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@2: //@} Chris@2: Chris@2: /** Constructs an object with copy control. See Chris@2: * Prototype(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@2: Chris@2: ~CueSheet(); Chris@2: Chris@2: //@{ Chris@2: /** Assign from another object. Always performs a deep copy. */ Chris@2: inline CueSheet &operator=(const CueSheet &object) { Prototype::operator=(object); return *this; } Chris@2: inline CueSheet &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@2: inline CueSheet &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@2: //@} Chris@2: Chris@2: /** Assigns an object with copy control. See Chris@2: * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline CueSheet &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@2: Chris@2: //@{ Chris@2: /** Check for equality, performing a deep compare by following pointers. */ Chris@2: inline bool operator==(const CueSheet &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@2: //@} Chris@2: Chris@2: //@{ Chris@2: /** Check for inequality, performing a deep compare by following pointers. */ Chris@2: inline bool operator!=(const CueSheet &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@2: //@} Chris@2: Chris@2: const char *get_media_catalog_number() const; Chris@2: FLAC__uint64 get_lead_in() const; Chris@2: bool get_is_cd() const; Chris@2: Chris@2: unsigned get_num_tracks() const; Chris@2: Track get_track(unsigned i) const; Chris@2: Chris@2: void set_media_catalog_number(const char value[128]); Chris@2: void set_lead_in(FLAC__uint64 value); Chris@2: void set_is_cd(bool value); Chris@2: Chris@2: void set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index); Chris@2: Chris@2: //! See FLAC__metadata_object_cuesheet_track_insert_index() Chris@2: bool insert_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index); Chris@2: Chris@2: //! See FLAC__metadata_object_cuesheet_track_delete_index() Chris@2: bool delete_index(unsigned track_num, unsigned index_num); Chris@2: Chris@2: //! See FLAC__metadata_object_cuesheet_set_track() Chris@2: bool set_track(unsigned i, const Track &track); Chris@2: Chris@2: //! See FLAC__metadata_object_cuesheet_insert_track() Chris@2: bool insert_track(unsigned i, const Track &track); Chris@2: Chris@2: //! See FLAC__metadata_object_cuesheet_delete_track() Chris@2: bool delete_track(unsigned i); Chris@2: Chris@2: //! See FLAC__metadata_object_cuesheet_is_legal() Chris@2: bool is_legal(bool check_cd_da_subset = false, const char **violation = 0) const; Chris@2: Chris@2: //! See FLAC__metadata_object_cuesheet_calculate_cddb_id() Chris@2: FLAC__uint32 calculate_cddb_id() const; Chris@2: }; Chris@2: Chris@2: /** PICTURE metadata block. Chris@2: * See the \link flacpp_metadata_object overview \endlink for more, Chris@2: * and the format specification. Chris@2: */ Chris@2: class FLACPP_API Picture : public Prototype { Chris@2: public: Chris@2: Picture(); Chris@2: Chris@2: //@{ Chris@2: /** Constructs a copy of the given object. This form Chris@2: * always performs a deep copy. Chris@2: */ Chris@2: inline Picture(const Picture &object): Prototype(object) { } Chris@2: inline Picture(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@2: inline Picture(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@2: //@} Chris@2: Chris@2: /** Constructs an object with copy control. See Chris@2: * Prototype(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline Picture(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@2: Chris@2: ~Picture(); Chris@2: Chris@2: //@{ Chris@2: /** Assign from another object. Always performs a deep copy. */ Chris@2: inline Picture &operator=(const Picture &object) { Prototype::operator=(object); return *this; } Chris@2: inline Picture &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@2: inline Picture &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@2: //@} Chris@2: Chris@2: /** Assigns an object with copy control. See Chris@2: * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline Picture &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@2: Chris@2: //@{ Chris@2: /** Check for equality, performing a deep compare by following pointers. */ Chris@2: inline bool operator==(const Picture &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@2: //@} Chris@2: Chris@2: //@{ Chris@2: /** Check for inequality, performing a deep compare by following pointers. */ Chris@2: inline bool operator!=(const Picture &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@2: //@} Chris@2: Chris@2: ::FLAC__StreamMetadata_Picture_Type get_type() const; Chris@2: const char *get_mime_type() const; // NUL-terminated printable ASCII string Chris@2: const FLAC__byte *get_description() const; // NUL-terminated UTF-8 string Chris@2: FLAC__uint32 get_width() const; Chris@2: FLAC__uint32 get_height() const; Chris@2: FLAC__uint32 get_depth() const; Chris@2: FLAC__uint32 get_colors() const; ///< a return value of \c 0 means true-color, i.e. 2^depth colors Chris@2: FLAC__uint32 get_data_length() const; Chris@2: const FLAC__byte *get_data() const; Chris@2: Chris@2: void set_type(::FLAC__StreamMetadata_Picture_Type type); Chris@2: Chris@2: //! See FLAC__metadata_object_picture_set_mime_type() Chris@2: bool set_mime_type(const char *string); // NUL-terminated printable ASCII string Chris@2: Chris@2: //! See FLAC__metadata_object_picture_set_description() Chris@2: bool set_description(const FLAC__byte *string); // NUL-terminated UTF-8 string Chris@2: Chris@2: void set_width(FLAC__uint32 value) const; Chris@2: void set_height(FLAC__uint32 value) const; Chris@2: void set_depth(FLAC__uint32 value) const; Chris@2: void set_colors(FLAC__uint32 value) const; ///< a value of \c 0 means true-color, i.e. 2^depth colors Chris@2: Chris@2: //! See FLAC__metadata_object_picture_set_data() Chris@2: bool set_data(const FLAC__byte *data, FLAC__uint32 data_length); Chris@2: }; Chris@2: Chris@2: /** Opaque metadata block for storing unknown types. Chris@2: * This should not be used unless you know what you are doing; Chris@2: * it is currently used only internally to support forward Chris@2: * compatibility of metadata blocks. Chris@2: * See the \link flacpp_metadata_object overview \endlink for more, Chris@2: */ Chris@2: class FLACPP_API Unknown : public Prototype { Chris@2: public: Chris@2: Unknown(); Chris@2: // Chris@2: //@{ Chris@2: /** Constructs a copy of the given object. This form Chris@2: * always performs a deep copy. Chris@2: */ Chris@2: inline Unknown(const Unknown &object): Prototype(object) { } Chris@2: inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { } Chris@2: inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { } Chris@2: //@} Chris@2: Chris@2: /** Constructs an object with copy control. See Chris@2: * Prototype(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } Chris@2: Chris@2: ~Unknown(); Chris@2: Chris@2: //@{ Chris@2: /** Assign from another object. Always performs a deep copy. */ Chris@2: inline Unknown &operator=(const Unknown &object) { Prototype::operator=(object); return *this; } Chris@2: inline Unknown &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; } Chris@2: inline Unknown &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; } Chris@2: //@} Chris@2: Chris@2: /** Assigns an object with copy control. See Chris@2: * Prototype::assign_object(::FLAC__StreamMetadata *object, bool copy). Chris@2: */ Chris@2: inline Unknown &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; } Chris@2: Chris@2: //@{ Chris@2: /** Check for equality, performing a deep compare by following pointers. */ Chris@2: inline bool operator==(const Unknown &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } Chris@2: inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } Chris@2: //@} Chris@2: Chris@2: //@{ Chris@2: /** Check for inequality, performing a deep compare by following pointers. */ Chris@2: inline bool operator!=(const Unknown &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } Chris@2: inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } Chris@2: //@} Chris@2: Chris@2: const FLAC__byte *get_data() const; Chris@2: Chris@2: //! This form always copies \a data Chris@2: bool set_data(const FLAC__byte *data, unsigned length); Chris@2: bool set_data(FLAC__byte *data, unsigned length, bool copy); Chris@2: }; Chris@2: Chris@2: /* \} */ Chris@2: Chris@2: Chris@2: /** \defgroup flacpp_metadata_level0 FLAC++/metadata.h: metadata level 0 interface Chris@2: * \ingroup flacpp_metadata Chris@2: * Chris@2: * \brief Chris@2: * Level 0 metadata iterators. Chris@2: * Chris@2: * See the \link flac_metadata_level0 C layer equivalent \endlink Chris@2: * for more. Chris@2: * Chris@2: * \{ Chris@2: */ Chris@2: Chris@2: FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo); ///< See FLAC__metadata_get_streaminfo(). Chris@2: Chris@2: FLACPP_API bool get_tags(const char *filename, VorbisComment *&tags); ///< See FLAC__metadata_get_tags(). Chris@2: FLACPP_API bool get_tags(const char *filename, VorbisComment &tags); ///< See FLAC__metadata_get_tags(). Chris@2: Chris@2: FLACPP_API bool get_cuesheet(const char *filename, CueSheet *&cuesheet); ///< See FLAC__metadata_get_cuesheet(). Chris@2: FLACPP_API bool get_cuesheet(const char *filename, CueSheet &cuesheet); ///< See FLAC__metadata_get_cuesheet(). Chris@2: Chris@2: 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@2: 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@2: Chris@2: /* \} */ Chris@2: Chris@2: Chris@2: /** \defgroup flacpp_metadata_level1 FLAC++/metadata.h: metadata level 1 interface Chris@2: * \ingroup flacpp_metadata Chris@2: * Chris@2: * \brief Chris@2: * Level 1 metadata iterator. Chris@2: * Chris@2: * The flow through the iterator in the C++ layer is similar Chris@2: * to the C layer: Chris@2: * - Create a SimpleIterator instance Chris@2: * - Check SimpleIterator::is_valid() Chris@2: * - Call SimpleIterator::init() and check the return Chris@2: * - Traverse and/or edit. Edits are written to file Chris@2: * immediately. Chris@2: * - Destroy the SimpleIterator instance Chris@2: * Chris@2: * The ownership of pointers in the C++ layer follows that in Chris@2: * the C layer, i.e. Chris@2: * - The objects returned by get_block() are yours to Chris@2: * modify, but changes are not reflected in the FLAC file Chris@2: * until you call set_block(). The objects are also Chris@2: * yours to delete; they are not automatically deleted Chris@2: * when passed to set_block() or insert_block_after(). Chris@2: * Chris@2: * See the \link flac_metadata_level1 C layer equivalent \endlink Chris@2: * for more. Chris@2: * Chris@2: * \{ Chris@2: */ Chris@2: Chris@2: /** This class is a wrapper around the FLAC__metadata_simple_iterator Chris@2: * structures and methods; see the Chris@2: * \link flacpp_metadata_level1 usage guide \endlink and Chris@2: * ::FLAC__Metadata_SimpleIterator. Chris@2: */ Chris@2: class FLACPP_API SimpleIterator { Chris@2: public: Chris@2: /** This class is a wrapper around FLAC__Metadata_SimpleIteratorStatus. Chris@2: */ Chris@2: class FLACPP_API Status { Chris@2: public: Chris@2: inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { } Chris@2: inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; } Chris@2: inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; } Chris@2: protected: Chris@2: ::FLAC__Metadata_SimpleIteratorStatus status_; Chris@2: }; Chris@2: Chris@2: SimpleIterator(); Chris@2: virtual ~SimpleIterator(); Chris@2: Chris@2: bool is_valid() const; ///< Returns \c true iff object was properly constructed. Chris@2: Chris@2: bool init(const char *filename, bool read_only, bool preserve_file_stats); ///< See FLAC__metadata_simple_iterator_init(). Chris@2: Chris@2: Status status(); ///< See FLAC__metadata_simple_iterator_status(). Chris@2: bool is_writable() const; ///< See FLAC__metadata_simple_iterator_is_writable(). Chris@2: Chris@2: bool next(); ///< See FLAC__metadata_simple_iterator_next(). Chris@2: bool prev(); ///< See FLAC__metadata_simple_iterator_prev(). Chris@2: bool is_last() const; ///< See FLAC__metadata_simple_iterator_is_last(). Chris@2: Chris@2: off_t get_block_offset() const; ///< See FLAC__metadata_simple_iterator_get_block_offset(). Chris@2: ::FLAC__MetadataType get_block_type() const; ///< See FLAC__metadata_simple_iterator_get_block_type(). Chris@2: unsigned get_block_length() const; ///< See FLAC__metadata_simple_iterator_get_block_length(). Chris@2: bool get_application_id(FLAC__byte *id); ///< See FLAC__metadata_simple_iterator_get_application_id(). Chris@2: Prototype *get_block(); ///< See FLAC__metadata_simple_iterator_get_block(). Chris@2: bool set_block(Prototype *block, bool use_padding = true); ///< See FLAC__metadata_simple_iterator_set_block(). Chris@2: bool insert_block_after(Prototype *block, bool use_padding = true); ///< See FLAC__metadata_simple_iterator_insert_block_after(). Chris@2: bool delete_block(bool use_padding = true); ///< See FLAC__metadata_simple_iterator_delete_block(). Chris@2: Chris@2: protected: Chris@2: ::FLAC__Metadata_SimpleIterator *iterator_; Chris@2: void clear(); Chris@2: }; Chris@2: Chris@2: /* \} */ Chris@2: Chris@2: Chris@2: /** \defgroup flacpp_metadata_level2 FLAC++/metadata.h: metadata level 2 interface Chris@2: * \ingroup flacpp_metadata Chris@2: * Chris@2: * \brief Chris@2: * Level 2 metadata iterator. Chris@2: * Chris@2: * The flow through the iterator in the C++ layer is similar Chris@2: * to the C layer: Chris@2: * - Create a Chain instance Chris@2: * - Check Chain::is_valid() Chris@2: * - Call Chain::read() and check the return Chris@2: * - Traverse and/or edit with an Iterator or with Chris@2: * Chain::merge_padding() or Chain::sort_padding() Chris@2: * - Write changes back to FLAC file with Chain::write() Chris@2: * - Destroy the Chain instance Chris@2: * Chris@2: * The ownership of pointers in the C++ layer is slightly Chris@2: * different than in the C layer, i.e. Chris@2: * - The objects returned by Iterator::get_block() are NOT Chris@2: * owned by the iterator and should be deleted by the Chris@2: * caller when finished, BUT, when you modify the block, Chris@2: * it will directly edit what's in the chain and you do Chris@2: * not need to call Iterator::set_block(). However the Chris@2: * changes will not be reflected in the FLAC file until Chris@2: * the chain is written with Chain::write(). Chris@2: * - When you pass an object to Iterator::set_block(), Chris@2: * Iterator::insert_block_before(), or Chris@2: * Iterator::insert_block_after(), the iterator takes Chris@2: * ownership of the block and it will be deleted by the Chris@2: * chain. Chris@2: * Chris@2: * See the \link flac_metadata_level2 C layer equivalent \endlink Chris@2: * for more. Chris@2: * Chris@2: * \{ Chris@2: */ Chris@2: Chris@2: /** This class is a wrapper around the FLAC__metadata_chain Chris@2: * structures and methods; see the Chris@2: * \link flacpp_metadata_level2 usage guide \endlink and Chris@2: * ::FLAC__Metadata_Chain. Chris@2: */ Chris@2: class FLACPP_API Chain { Chris@2: public: Chris@2: /** This class is a wrapper around FLAC__Metadata_ChainStatus. Chris@2: */ Chris@2: class FLACPP_API Status { Chris@2: public: Chris@2: inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { } Chris@2: inline operator ::FLAC__Metadata_ChainStatus() const { return status_; } Chris@2: inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; } Chris@2: protected: Chris@2: ::FLAC__Metadata_ChainStatus status_; Chris@2: }; Chris@2: Chris@2: Chain(); Chris@2: virtual ~Chain(); Chris@2: Chris@2: friend class Iterator; Chris@2: Chris@2: bool is_valid() const; ///< Returns \c true iff object was properly constructed. Chris@2: Chris@2: Status status(); ///< See FLAC__metadata_chain_status(). Chris@2: Chris@2: bool read(const char *filename, bool is_ogg = false); ///< See FLAC__metadata_chain_read(), FLAC__metadata_chain_read_ogg(). Chris@2: 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@2: Chris@2: bool check_if_tempfile_needed(bool use_padding); ///< See FLAC__metadata_chain_check_if_tempfile_needed(). Chris@2: Chris@2: bool write(bool use_padding = true, bool preserve_file_stats = false); ///< See FLAC__metadata_chain_write(). Chris@2: bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks); ///< See FLAC__metadata_chain_write_with_callbacks(). Chris@2: 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@2: Chris@2: void merge_padding(); ///< See FLAC__metadata_chain_merge_padding(). Chris@2: void sort_padding(); ///< See FLAC__metadata_chain_sort_padding(). Chris@2: Chris@2: protected: Chris@2: ::FLAC__Metadata_Chain *chain_; Chris@2: virtual void clear(); Chris@2: }; Chris@2: Chris@2: /** This class is a wrapper around the FLAC__metadata_iterator Chris@2: * structures and methods; see the Chris@2: * \link flacpp_metadata_level2 usage guide \endlink and Chris@2: * ::FLAC__Metadata_Iterator. Chris@2: */ Chris@2: class FLACPP_API Iterator { Chris@2: public: Chris@2: Iterator(); Chris@2: virtual ~Iterator(); Chris@2: Chris@2: bool is_valid() const; ///< Returns \c true iff object was properly constructed. Chris@2: Chris@2: Chris@2: void init(Chain &chain); ///< See FLAC__metadata_iterator_init(). Chris@2: Chris@2: bool next(); ///< See FLAC__metadata_iterator_next(). Chris@2: bool prev(); ///< See FLAC__metadata_iterator_prev(). Chris@2: Chris@2: ::FLAC__MetadataType get_block_type() const; ///< See FLAC__metadata_iterator_get_block_type(). Chris@2: Prototype *get_block(); ///< See FLAC__metadata_iterator_get_block(). Chris@2: bool set_block(Prototype *block); ///< See FLAC__metadata_iterator_set_block(). Chris@2: bool delete_block(bool replace_with_padding); ///< See FLAC__metadata_iterator_delete_block(). Chris@2: bool insert_block_before(Prototype *block); ///< See FLAC__metadata_iterator_insert_block_before(). Chris@2: bool insert_block_after(Prototype *block); ///< See FLAC__metadata_iterator_insert_block_after(). Chris@2: Chris@2: protected: Chris@2: ::FLAC__Metadata_Iterator *iterator_; Chris@2: virtual void clear(); Chris@2: }; Chris@2: Chris@2: /* \} */ Chris@2: Chris@2: } Chris@2: } Chris@2: Chris@2: #endif