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