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