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