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