Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 1 | /* libFLAC++ - Free Lossless Audio Codec library |
| 2 | * Copyright (C) 2002 Josh Coalson |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Library General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Library General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Library General Public |
| 15 | * License along with this library; if not, write to the |
| 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 17 | * Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifndef FLACPP__METADATA_H |
| 21 | #define FLACPP__METADATA_H |
| 22 | |
| 23 | #include "FLAC/metadata.h" |
| 24 | |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 25 | // =============================================================== |
| 26 | // |
| 27 | // Full documentation for the metadata interface can be found |
| 28 | // in the C layer in include/FLAC/metadata.h |
| 29 | // |
| 30 | // =============================================================== |
| 31 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 32 | /** \file include/FLAC++/metadata.h |
| 33 | * |
| 34 | * \brief |
| 35 | * This module provides classes for creating and manipulating FLAC |
| 36 | * metadata blocks in memory, and three progressively more powerful |
| 37 | * interfaces for traversing and editing metadata in FLAC files. |
| 38 | * |
| 39 | * See the detailed documentation for each interface in the |
| 40 | * \link flacpp_metadata metadata \endlink module. |
| 41 | */ |
| 42 | |
| 43 | /** \defgroup flacpp_metadata FLAC++/metadata.h: metadata interfaces |
| 44 | * \ingroup flacpp |
| 45 | * |
| 46 | * \brief |
| 47 | * This module provides classes for creating and manipulating FLAC |
| 48 | * metadata blocks in memory, and three progressively more powerful |
| 49 | * interfaces for traversing and editing metadata in FLAC files. |
| 50 | * |
| 51 | * The behavior closely mimics the C layer interface; be sure to read |
| 52 | * the detailed description of the |
| 53 | * \link flac_metadata C metadata module \endlink. |
| 54 | */ |
| 55 | |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 56 | |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 57 | namespace FLAC { |
| 58 | namespace Metadata { |
| 59 | |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 60 | // ============================================================ |
| 61 | // |
| 62 | // Metadata objects |
| 63 | // |
| 64 | // ============================================================ |
| 65 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 66 | /** \defgroup flacpp_metadata_object FLAC++/metadata.h: metadata object classes |
| 67 | * \ingroup flacpp_metadata |
| 68 | * |
| 69 | * This module contains classes representing FLAC metadata |
| 70 | * blocks in memory. |
| 71 | * |
| 72 | * The behavior closely mimics the C layer interface; be |
| 73 | * sure to read the detailed description of the |
| 74 | * \link flac_metadata_object C metadata object module \endlink. |
| 75 | * |
| 76 | * Any time a metadata object is constructed or assigned, you |
| 77 | * should check is_valid() to make sure the underlying |
| 78 | * ::FLAC__StreamMetadata object was able to be created. |
| 79 | * |
| 80 | * \warning |
| 81 | * When the get_*() methods of any metadata object method |
| 82 | * return you a const pointer, DO NOT disobey and write into it. |
| 83 | * Always use the set_*() methods. |
| 84 | * |
| 85 | * \{ |
| 86 | */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 87 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 88 | /** Base class for all metadata block types. |
| 89 | */ |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 90 | class Prototype { |
| 91 | protected: |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 92 | //@{ |
| 93 | /** Constructs a copy of the given object. This form |
| 94 | * always performs a deep copy. |
| 95 | */ |
| 96 | Prototype(const Prototype &); |
| 97 | Prototype(const ::FLAC__StreamMetadata &); |
| 98 | Prototype(const ::FLAC__StreamMetadata *); |
| 99 | //@} |
Josh Coalson | 8396175 | 2002-07-09 06:12:59 +0000 | [diff] [blame] | 100 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 101 | /** Constructs an object with copy control. When \a copy |
| 102 | * is \c true, behaves identically to |
| 103 | * FLAC::Metadata::Prototype::Prototype(const ::FLAC__StreamMetadata *object). |
| 104 | * When \a copy is \c false, the instance takes ownership of |
| 105 | * the pointer and the ::FLAC__StreamMetadata object will |
| 106 | * be freed by the destructor. |
| 107 | * |
| 108 | * \assert |
| 109 | * \code object != NULL \endcode |
| 110 | */ |
Josh Coalson | 8396175 | 2002-07-09 06:12:59 +0000 | [diff] [blame] | 111 | Prototype(::FLAC__StreamMetadata *object, bool copy); |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 112 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 113 | //@{ |
| 114 | /** Assign from another object. Always performs a deep copy. */ |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 115 | void operator=(const Prototype &); |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 116 | void operator=(const ::FLAC__StreamMetadata &); |
| 117 | void operator=(const ::FLAC__StreamMetadata *); |
| 118 | //@} |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 119 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 120 | /** Deletes the underlying ::FLAC__StreamMetadata object. |
| 121 | */ |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 122 | virtual void clear(); |
| 123 | |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 124 | ::FLAC__StreamMetadata *object_; |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 125 | public: |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 126 | /** Deletes the underlying ::FLAC__StreamMetadata object. |
| 127 | */ |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 128 | virtual ~Prototype(); |
| 129 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 130 | //@{ |
| 131 | /** Check for equality, performing a deep compare by following pointers. */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 132 | inline bool operator==(const Prototype &) const; |
| 133 | inline bool operator==(const ::FLAC__StreamMetadata &) const; |
| 134 | inline bool operator==(const ::FLAC__StreamMetadata *) const; |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 135 | //@} |
| 136 | |
| 137 | //@{ |
| 138 | /** Check for inequality, performing a deep compare by following pointers. */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 139 | inline bool operator!=(const Prototype &) const; |
| 140 | inline bool operator!=(const ::FLAC__StreamMetadata &) const; |
| 141 | inline bool operator!=(const ::FLAC__StreamMetadata *) const; |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 142 | //@} |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 143 | |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 144 | friend class SimpleIterator; |
| 145 | friend class Iterator; |
| 146 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 147 | /** Returns \c true if the object was correctly constructed |
| 148 | * (i.e. the underlying ::FLAC__StreamMetadata object was |
| 149 | * properly allocated), else \c false. |
| 150 | */ |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 151 | inline bool is_valid() const; |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 152 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 153 | /** Returns \c true if this block is the last block in a |
| 154 | * stream, else \c false. |
| 155 | * |
| 156 | * \assert |
| 157 | * \code is_valid() \endcode |
| 158 | */ |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 159 | bool get_is_last() const; |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 160 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 161 | /** Returns the type of the block. |
| 162 | * |
| 163 | * \assert |
| 164 | * \code is_valid() \endcode |
| 165 | */ |
| 166 | ::FLAC__MetadataType get_type() const; |
| 167 | |
| 168 | /** Returns the stream length of the metadata block. |
| 169 | * |
| 170 | * \note |
| 171 | * The length does not include the metadata block header, |
| 172 | * per spec. |
| 173 | * |
| 174 | * \assert |
| 175 | * \code is_valid() \endcode |
| 176 | */ |
| 177 | unsigned get_length() const; |
| 178 | |
| 179 | /** Sets the "is_last" flag for the block. When using the iterators |
| 180 | * it is not necessary to set this flag; they will do it for you. |
| 181 | * |
| 182 | * \assert |
| 183 | * \code is_valid() \endcode |
| 184 | */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 185 | void set_is_last(bool); |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 186 | private: |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 187 | /** Private and undefined so you can't use it. */ |
| 188 | Prototype(); |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 189 | |
| 190 | // These are used only by Iterator |
| 191 | bool is_reference_; |
| 192 | inline void set_reference(bool x) { is_reference_ = x; } |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 193 | }; |
| 194 | |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 195 | inline bool Prototype::operator==(const Prototype &object) const |
Josh Coalson | d57c8d3 | 2002-06-11 06:15:28 +0000 | [diff] [blame] | 196 | { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); } |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 197 | |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 198 | inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const |
Josh Coalson | d57c8d3 | 2002-06-11 06:15:28 +0000 | [diff] [blame] | 199 | { return (bool)::FLAC__metadata_object_is_equal(object_, &object); } |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 200 | |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 201 | inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const |
Josh Coalson | d57c8d3 | 2002-06-11 06:15:28 +0000 | [diff] [blame] | 202 | { return (bool)::FLAC__metadata_object_is_equal(object_, object); } |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 203 | |
| 204 | inline bool Prototype::operator!=(const Prototype &object) const |
| 205 | { return !operator==(object); } |
| 206 | |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 207 | inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 208 | { return !operator==(object); } |
| 209 | |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 210 | inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 211 | { return !operator==(object); } |
| 212 | |
| 213 | inline bool Prototype::is_valid() const |
| 214 | { return 0 != object_; } |
| 215 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 216 | /** Create a deep copy of an object and return it. */ |
| 217 | Prototype *clone(const Prototype *); |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 218 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 219 | |
| 220 | /** STREAMINFO metadata block. |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 221 | * See <A HREF="../format.html#metadata_block_streaminfo">format specification</A>. |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 222 | */ |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 223 | class StreamInfo : public Prototype { |
| 224 | public: |
| 225 | StreamInfo(); |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 226 | |
| 227 | //@{ |
| 228 | /** Constructs a copy of the given object. This form |
| 229 | * always performs a deep copy. |
| 230 | */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 231 | inline StreamInfo(const StreamInfo &object): Prototype(object) { } |
| 232 | inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 233 | inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 234 | //@} |
| 235 | |
| 236 | /** Constructs an object with copy control. See |
| 237 | * Prototype(::FLAC__StreamMetadata *object, bool copy). |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 238 | */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 239 | inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 240 | |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 241 | ~StreamInfo(); |
| 242 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 243 | //@{ |
| 244 | /** Assign from another object. Always performs a deep copy. */ |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 245 | inline void operator=(const StreamInfo &object) { Prototype::operator=(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 246 | inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); } |
| 247 | inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); } |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 248 | //@} |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 249 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 250 | //@{ |
| 251 | /** Check for equality, performing a deep compare by following pointers. */ |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 252 | inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 253 | inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } |
| 254 | inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 255 | //@} |
| 256 | |
| 257 | //@{ |
| 258 | /** Check for inequality, performing a deep compare by following pointers. */ |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 259 | inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 260 | inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } |
| 261 | inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 262 | //@} |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 263 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 264 | //@{ |
| 265 | /** See <A HREF="../format.html#metadata_block_streaminfo">format specification</A>. */ |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 266 | unsigned get_min_blocksize() const; |
| 267 | unsigned get_max_blocksize() const; |
| 268 | unsigned get_min_framesize() const; |
| 269 | unsigned get_max_framesize() const; |
| 270 | unsigned get_sample_rate() const; |
| 271 | unsigned get_channels() const; |
| 272 | unsigned get_bits_per_sample() const; |
| 273 | FLAC__uint64 get_total_samples() const; |
| 274 | const FLAC__byte *get_md5sum() const; |
| 275 | |
| 276 | void set_min_blocksize(unsigned value); |
| 277 | void set_max_blocksize(unsigned value); |
| 278 | void set_min_framesize(unsigned value); |
| 279 | void set_max_framesize(unsigned value); |
| 280 | void set_sample_rate(unsigned value); |
| 281 | void set_channels(unsigned value); |
| 282 | void set_bits_per_sample(unsigned value); |
| 283 | void set_total_samples(FLAC__uint64 value); |
| 284 | void set_md5sum(const FLAC__byte value[16]); |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 285 | //@} |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 286 | }; |
| 287 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 288 | /** PADDING metadata block. |
| 289 | * See <A HREF="../format.html#metadata_block_padding">format specification</A>. |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 290 | */ |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 291 | class Padding : public Prototype { |
| 292 | public: |
| 293 | Padding(); |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 294 | |
| 295 | //@{ |
| 296 | /** Constructs a copy of the given object. This form |
| 297 | * always performs a deep copy. |
| 298 | */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 299 | inline Padding(const Padding &object): Prototype(object) { } |
| 300 | inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 301 | inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 302 | //@} |
| 303 | |
| 304 | /** Constructs an object with copy control. See |
| 305 | * Prototype(::FLAC__StreamMetadata *object, bool copy). |
| 306 | */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 307 | inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 308 | |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 309 | ~Padding(); |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 310 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 311 | //@{ |
| 312 | /** Assign from another object. Always performs a deep copy. */ |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 313 | inline void operator=(const Padding &object) { Prototype::operator=(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 314 | inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); } |
| 315 | inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 316 | //@} |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 317 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 318 | //@{ |
| 319 | /** Check for equality, performing a deep compare by following pointers. */ |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 320 | inline bool operator==(const Padding &object) const { return Prototype::operator==(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 321 | inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } |
| 322 | inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 323 | //@} |
| 324 | |
| 325 | //@{ |
| 326 | /** Check for inequality, performing a deep compare by following pointers. */ |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 327 | inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 328 | inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } |
| 329 | inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 330 | //@} |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 331 | |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 332 | void set_length(unsigned length); |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 333 | }; |
| 334 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 335 | /** APPLICATION metadata block. |
| 336 | * See <A HREF="../format.html#metadata_block_application">format specification</A>. |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 337 | */ |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 338 | class Application : public Prototype { |
| 339 | public: |
| 340 | Application(); |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 341 | // |
| 342 | //@{ |
| 343 | /** Constructs a copy of the given object. This form |
| 344 | * always performs a deep copy. |
| 345 | */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 346 | inline Application(const Application &object): Prototype(object) { } |
| 347 | inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 348 | inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 349 | //@} |
| 350 | |
| 351 | /** Constructs an object with copy control. See |
| 352 | * Prototype(::FLAC__StreamMetadata *object, bool copy). |
| 353 | */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 354 | inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 355 | |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 356 | ~Application(); |
| 357 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 358 | //@{ |
| 359 | /** Assign from another object. Always performs a deep copy. */ |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 360 | inline void operator=(const Application &object) { Prototype::operator=(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 361 | inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); } |
| 362 | inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 363 | //@} |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 364 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 365 | //@{ |
| 366 | /** Check for equality, performing a deep compare by following pointers. */ |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 367 | inline bool operator==(const Application &object) const { return Prototype::operator==(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 368 | inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } |
| 369 | inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 370 | //@} |
| 371 | |
| 372 | //@{ |
| 373 | /** Check for inequality, performing a deep compare by following pointers. */ |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 374 | inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 375 | inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } |
| 376 | inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 377 | //@} |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 378 | |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 379 | const FLAC__byte *get_id() const; |
| 380 | const FLAC__byte *get_data() const; |
| 381 | |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 382 | void set_id(const FLAC__byte value[4]); |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 383 | //! This form always copies \a data |
| 384 | bool set_data(const FLAC__byte *data, unsigned length); |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 385 | bool set_data(FLAC__byte *data, unsigned length, bool copy); |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 386 | }; |
| 387 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 388 | /** SEEKTABLE metadata block. |
| 389 | * See <A HREF="../format.html#metadata_block_seektable">format specification</A>. |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 390 | */ |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 391 | class SeekTable : public Prototype { |
| 392 | public: |
| 393 | SeekTable(); |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 394 | |
| 395 | //@{ |
| 396 | /** Constructs a copy of the given object. This form |
| 397 | * always performs a deep copy. |
| 398 | */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 399 | inline SeekTable(const SeekTable &object): Prototype(object) { } |
| 400 | inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 401 | inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 402 | //@} |
| 403 | |
| 404 | /** Constructs an object with copy control. See |
| 405 | * Prototype(::FLAC__StreamMetadata *object, bool copy). |
| 406 | */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 407 | inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 408 | |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 409 | ~SeekTable(); |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 410 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 411 | //@{ |
| 412 | /** Assign from another object. Always performs a deep copy. */ |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 413 | inline void operator=(const SeekTable &object) { Prototype::operator=(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 414 | inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); } |
| 415 | inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 416 | //@} |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 417 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 418 | //@{ |
| 419 | /** Check for equality, performing a deep compare by following pointers. */ |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 420 | inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 421 | inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } |
| 422 | inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 423 | //@} |
| 424 | |
| 425 | //@{ |
| 426 | /** Check for inequality, performing a deep compare by following pointers. */ |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 427 | inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 428 | inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } |
| 429 | inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 430 | //@} |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 431 | |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 432 | unsigned get_num_points() const; |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 433 | ::FLAC__StreamMetadata_SeekPoint get_point(unsigned index) const; |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 434 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 435 | //! See FLAC__metadata_object_seektable_set_point() |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 436 | void set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point); |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 437 | |
| 438 | //! See FLAC__metadata_object_seektable_insert_point() |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 439 | bool insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point); |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 440 | |
| 441 | //! See FLAC__metadata_object_seektable_delete_point() |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 442 | bool delete_point(unsigned index); |
Josh Coalson | 28e08d8 | 2002-06-05 05:56:41 +0000 | [diff] [blame] | 443 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 444 | //! See FLAC__metadata_object_seektable_is_legal() |
Josh Coalson | 28e08d8 | 2002-06-05 05:56:41 +0000 | [diff] [blame] | 445 | bool is_legal() const; |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 446 | }; |
| 447 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 448 | /** VORBIS_COMMENT metadata block. |
| 449 | * See <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>. |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 450 | */ |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 451 | class VorbisComment : public Prototype { |
| 452 | public: |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 453 | /** Convenience class for encapsulating Vorbis comment |
| 454 | * entries. An entry is a vendor string or a comment |
| 455 | * field. In the case of a vendor string, the field |
| 456 | * name is undefined; only the field value is relevant. |
| 457 | * |
| 458 | * A \a field as used in the methods refers to an |
| 459 | * entire 'NAME=VALUE' string; the string is not null- |
| 460 | * terminated and a length field is required since the |
| 461 | * string may contain embedded nulls. |
| 462 | * |
| 463 | * A \a field_name is what is on the left side of the |
| 464 | * first '=' in the \a field. By definition it is ASCII |
| 465 | * and so is null-terminated and does not require a |
| 466 | * length to describe it. \a field_name is undefined |
| 467 | * for a vendor string entry. |
| 468 | * |
| 469 | * A \a field_value is what is on the right side of the |
| 470 | * first '=' in the \a field. By definition, this may |
| 471 | * contain embedded nulls and so a \a field_value_length |
| 472 | * is requires to describe it. |
| 473 | * |
| 474 | * Always check is_valid() after the constructor or operator= |
| 475 | * to make sure memory was properly allocated. |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 476 | */ |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 477 | class Entry { |
| 478 | public: |
| 479 | Entry(); |
| 480 | Entry(const char *field, unsigned field_length); |
| 481 | Entry(const char *field_name, const char *field_value, unsigned field_value_length); |
| 482 | Entry(const Entry &entry); |
| 483 | void operator=(const Entry &entry); |
| 484 | |
| 485 | virtual ~Entry(); |
| 486 | |
| 487 | virtual bool is_valid() const; |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 488 | |
| 489 | unsigned get_field_length() const; |
| 490 | unsigned get_field_name_length() const; |
| 491 | unsigned get_field_value_length() const; |
| 492 | |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 493 | ::FLAC__StreamMetadata_VorbisComment_Entry get_entry() const; |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 494 | const char *get_field() const; |
| 495 | const char *get_field_name() const; |
| 496 | const char *get_field_value() const; |
| 497 | |
| 498 | bool set_field(const char *field, unsigned field_length); |
| 499 | bool set_field_name(const char *field_name); |
| 500 | bool set_field_value(const char *field_value, unsigned field_value_length); |
| 501 | protected: |
| 502 | bool is_valid_; |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 503 | ::FLAC__StreamMetadata_VorbisComment_Entry entry_; |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 504 | char *field_name_; |
| 505 | unsigned field_name_length_; |
| 506 | char *field_value_; |
| 507 | unsigned field_value_length_; |
| 508 | private: |
| 509 | void zero(); |
| 510 | void clear(); |
| 511 | void clear_entry(); |
| 512 | void clear_field_name(); |
| 513 | void clear_field_value(); |
| 514 | void construct(const char *field, unsigned field_length); |
| 515 | void construct(const char *field_name, const char *field_value, unsigned field_value_length); |
| 516 | void compose_field(); |
| 517 | void parse_field(); |
| 518 | }; |
| 519 | |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 520 | VorbisComment(); |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 521 | |
| 522 | //@{ |
| 523 | /** Constructs a copy of the given object. This form |
| 524 | * always performs a deep copy. |
| 525 | */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 526 | inline VorbisComment(const VorbisComment &object): Prototype(object) { } |
| 527 | inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { } |
| 528 | inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 529 | //@} |
| 530 | |
| 531 | /** Constructs an object with copy control. See |
| 532 | * Prototype(::FLAC__StreamMetadata *object, bool copy). |
| 533 | */ |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 534 | inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 535 | |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 536 | ~VorbisComment(); |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 537 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 538 | //@{ |
| 539 | /** Assign from another object. Always performs a deep copy. */ |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 540 | inline void operator=(const VorbisComment &object) { Prototype::operator=(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 541 | inline void operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); } |
| 542 | inline void operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 543 | //@} |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 544 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 545 | //@{ |
| 546 | /** Check for equality, performing a deep compare by following pointers. */ |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 547 | inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 548 | inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); } |
| 549 | inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 550 | //@} |
| 551 | |
| 552 | //@{ |
| 553 | /** Check for inequality, performing a deep compare by following pointers. */ |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 554 | inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); } |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 555 | inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); } |
| 556 | inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); } |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 557 | //@} |
Josh Coalson | 57ba6f4 | 2002-06-07 05:27:37 +0000 | [diff] [blame] | 558 | |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 559 | unsigned get_num_comments() const; |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 560 | 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] | 561 | Entry get_comment(unsigned index) const; |
| 562 | |
Josh Coalson | 87977ba | 2002-08-20 07:09:33 +0000 | [diff] [blame^] | 563 | //! See FLAC__metadata_object_vorbiscomment_set_vendor_string() |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 564 | //! \note Only the Entry's field name will be used. |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 565 | bool set_vendor_string(const Entry &entry); // only the Entry's field name will be used |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 566 | |
Josh Coalson | 87977ba | 2002-08-20 07:09:33 +0000 | [diff] [blame^] | 567 | //! See FLAC__metadata_object_vorbiscomment_set_comment() |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 568 | bool set_comment(unsigned index, const Entry &entry); |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 569 | |
Josh Coalson | 87977ba | 2002-08-20 07:09:33 +0000 | [diff] [blame^] | 570 | //! See FLAC__metadata_object_vorbiscomment_insert_comment() |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 571 | bool insert_comment(unsigned index, const Entry &entry); |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 572 | |
Josh Coalson | 87977ba | 2002-08-20 07:09:33 +0000 | [diff] [blame^] | 573 | //! See FLAC__metadata_object_vorbiscomment_delete_comment() |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 574 | bool delete_comment(unsigned index); |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 575 | }; |
| 576 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 577 | /* \} */ |
| 578 | |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 579 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 580 | /** \defgroup flacpp_metadata_level0 FLAC++/metadata.h: metadata level 0 interface |
| 581 | * \ingroup flacpp_metadata |
| 582 | * |
| 583 | * \brief |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 584 | * Level 0 metadata iterator. |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 585 | * |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 586 | * See the \link flac_metadata_level0 C layer equivalent \endlink |
| 587 | * for more. |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 588 | * |
| 589 | * \{ |
| 590 | */ |
| 591 | |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 592 | //! See FLAC__metadata_get_streaminfo(). |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 593 | bool get_streaminfo(const char *filename, StreamInfo &streaminfo); |
| 594 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 595 | /* \} */ |
| 596 | |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 597 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 598 | /** \defgroup flacpp_metadata_level1 FLAC++/metadata.h: metadata level 1 interface |
| 599 | * \ingroup flacpp_metadata |
| 600 | * |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 601 | * \brief |
| 602 | * Level 1 metadata iterator. |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 603 | * |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 604 | * The flow through the iterator in the C++ layer is similar |
| 605 | * to the C layer: |
| 606 | * - Create a SimpleIterator instance |
| 607 | * - Check SimpleIterator::is_valid() |
| 608 | * - Call SimpleIterator::init() and check the return |
| 609 | * - Traverse and/or edit. Edits are written to file |
| 610 | * immediately. |
| 611 | * - Destroy the SimpleIterator instance |
| 612 | * |
| 613 | * The ownership of pointers in the C++ layer follows that in |
| 614 | * the C layer, i.e. |
| 615 | * - The objects returned by get_block() are yours to |
| 616 | * modify, but changes are not reflected in the FLAC file |
| 617 | * until you call set_block(). The objects are also |
| 618 | * yours to delete; they are not automatically deleted |
| 619 | * when passed to set_block() or insert_block_after(). |
| 620 | * |
| 621 | * See the \link flac_metadata_level1 C layer equivalent \endlink |
| 622 | * for more. |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 623 | * |
| 624 | * \{ |
| 625 | */ |
| 626 | |
| 627 | /** XXX class SimpleIterator |
| 628 | */ |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 629 | class SimpleIterator { |
| 630 | public: |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 631 | /** XXX class SimpleIterator::Status |
| 632 | */ |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 633 | class Status { |
| 634 | public: |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 635 | inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { } |
| 636 | inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; } |
| 637 | inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; } |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 638 | protected: |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 639 | ::FLAC__Metadata_SimpleIteratorStatus status_; |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 640 | }; |
| 641 | |
| 642 | SimpleIterator(); |
| 643 | virtual ~SimpleIterator(); |
| 644 | |
| 645 | bool init(const char *filename, bool preserve_file_stats = false); |
| 646 | |
| 647 | bool is_valid() const; |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 648 | Status status(); |
| 649 | bool is_writable() const; |
| 650 | |
| 651 | bool next(); |
| 652 | bool prev(); |
| 653 | |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 654 | ::FLAC__MetadataType get_block_type() const; |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 655 | Prototype *get_block(); |
| 656 | bool set_block(Prototype *block, bool use_padding = true); |
| 657 | bool insert_block_after(Prototype *block, bool use_padding = true); |
| 658 | bool delete_block(bool use_padding = true); |
| 659 | |
| 660 | protected: |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 661 | ::FLAC__Metadata_SimpleIterator *iterator_; |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 662 | void clear(); |
| 663 | }; |
| 664 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 665 | /* \} */ |
| 666 | |
Josh Coalson | b2b5358 | 2002-05-31 06:20:50 +0000 | [diff] [blame] | 667 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 668 | /** \defgroup flacpp_metadata_level2 FLAC++/metadata.h: metadata level 2 interface |
| 669 | * \ingroup flacpp_metadata |
| 670 | * |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 671 | * \brief |
| 672 | * Level 2 metadata iterator. |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 673 | * |
Josh Coalson | 4dc3507 | 2002-08-20 03:56:52 +0000 | [diff] [blame] | 674 | * The flow through the iterator in the C++ layer is similar |
| 675 | * to the C layer: |
| 676 | * - Create a Chain instance |
| 677 | * - Check Chain::is_valid() |
| 678 | * - Call Chain::read() and check the return |
| 679 | * - Traverse and/or edit with an Iterator or with |
| 680 | * Chain::merge_padding() or Chain::sort_padding() |
| 681 | * - Write changes back to FLAC file with Chain::write() |
| 682 | * - Destroy the Chain instance |
| 683 | * |
| 684 | * The ownership of pointers in the C++ layer follows that in |
| 685 | * the C layer, i.e. |
| 686 | * - The objects returned by Iterator::get_block() are |
| 687 | * owned by the iterator and should not be deleted. |
| 688 | * When you modify the block, you are directly editing |
| 689 | * what's in the chain and do not need to call |
| 690 | * Iterator::set_block(). However the changes will not |
| 691 | * be reflected in the FLAC file until the chain is |
| 692 | * written with Chain::write(). |
| 693 | * - When you pass an object to Iterator::set_block(), |
| 694 | * Iterator::insert_block_before(), or |
| 695 | * Iterator::insert_block_after(), the iterator takes |
| 696 | * ownership of the block and it will be deleted with the |
| 697 | * chain. |
| 698 | * |
| 699 | * See the \link flac_metadata_level2 C layer equivalent \endlink |
| 700 | * for more. |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 701 | * |
| 702 | * \{ |
| 703 | */ |
| 704 | |
| 705 | /** XXX class Chain |
| 706 | */ |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 707 | class Chain { |
| 708 | public: |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 709 | /** XXX class Chain::Status |
| 710 | */ |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 711 | class Status { |
| 712 | public: |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 713 | inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { } |
| 714 | inline operator ::FLAC__Metadata_ChainStatus() const { return status_; } |
| 715 | inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; } |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 716 | protected: |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 717 | ::FLAC__Metadata_ChainStatus status_; |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 718 | }; |
| 719 | |
| 720 | Chain(); |
| 721 | virtual ~Chain(); |
| 722 | |
| 723 | friend class Iterator; |
| 724 | |
| 725 | bool is_valid() const; |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 726 | Status status(); |
| 727 | |
| 728 | bool read(const char *filename); |
| 729 | bool write(bool use_padding = true, bool preserve_file_stats = false); |
| 730 | |
| 731 | void merge_padding(); |
| 732 | void sort_padding(); |
| 733 | |
| 734 | protected: |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 735 | ::FLAC__Metadata_Chain *chain_; |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 736 | virtual void clear(); |
| 737 | }; |
| 738 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 739 | /** XXX class Iterator |
| 740 | */ |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 741 | class Iterator { |
| 742 | public: |
| 743 | Iterator(); |
| 744 | virtual ~Iterator(); |
| 745 | |
| 746 | bool is_valid() const; |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 747 | |
Josh Coalson | 999be3b | 2002-06-10 04:42:35 +0000 | [diff] [blame] | 748 | void init(Chain &chain); |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 749 | |
| 750 | bool next(); |
| 751 | bool prev(); |
| 752 | |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 753 | ::FLAC__MetadataType get_block_type() const; |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 754 | Prototype *get_block(); |
| 755 | bool set_block(Prototype *block); |
| 756 | bool delete_block(bool replace_with_padding); |
| 757 | bool insert_block_before(Prototype *block); |
| 758 | bool insert_block_after(Prototype *block); |
| 759 | |
| 760 | protected: |
Josh Coalson | cc68251 | 2002-06-08 04:53:42 +0000 | [diff] [blame] | 761 | ::FLAC__Metadata_Iterator *iterator_; |
Josh Coalson | fb74f10 | 2002-05-22 05:33:29 +0000 | [diff] [blame] | 762 | virtual void clear(); |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 763 | }; |
| 764 | |
Josh Coalson | f6efd9c | 2002-07-27 04:59:54 +0000 | [diff] [blame] | 765 | /* \} */ |
| 766 | |
Josh Coalson | fda98fb | 2002-05-17 06:33:39 +0000 | [diff] [blame] | 767 | }; |
| 768 | }; |
| 769 | |
| 770 | #endif |