FLAC  1.3.1
metadata.h
Go to the documentation of this file.
1 /* libFLAC++ - Free Lossless Audio Codec library
2  * Copyright (C) 2002-2009 Josh Coalson
3  * Copyright (C) 2011-2014 Xiph.Org Foundation
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * - Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * - Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * - Neither the name of the Xiph.org Foundation nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef FLACPP__METADATA_H
34 #define FLACPP__METADATA_H
35 
36 #include "export.h"
37 
38 #include "FLAC/metadata.h"
39 
40 // ===============================================================
41 //
42 // Full documentation for the metadata interface can be found
43 // in the C layer in include/FLAC/metadata.h
44 //
45 // ===============================================================
46 
75 namespace FLAC {
76  namespace Metadata {
77 
78  // ============================================================
79  //
80  // Metadata objects
81  //
82  // ============================================================
83 
109  class FLACPP_API Prototype {
110  protected:
112 
115  Prototype(const Prototype &);
116  Prototype(const ::FLAC__StreamMetadata &);
117  Prototype(const ::FLAC__StreamMetadata *);
119 
130  Prototype(::FLAC__StreamMetadata *object, bool copy);
131 
133 
134  Prototype &operator=(const Prototype &);
135  Prototype &operator=(const ::FLAC__StreamMetadata &);
136  Prototype &operator=(const ::FLAC__StreamMetadata *);
138 
142  Prototype &assign_object(::FLAC__StreamMetadata *object, bool copy);
143 
146  virtual void clear();
147 
148  ::FLAC__StreamMetadata *object_;
149  public:
152  virtual ~Prototype();
153 
155 
157  inline bool operator==(const Prototype &) const;
158  inline bool operator==(const ::FLAC__StreamMetadata &) const;
159  inline bool operator==(const ::FLAC__StreamMetadata *) const;
161 
163 
164  inline bool operator!=(const Prototype &) const;
165  inline bool operator!=(const ::FLAC__StreamMetadata &) const;
166  inline bool operator!=(const ::FLAC__StreamMetadata *) const;
168 
169  friend class SimpleIterator;
170  friend class Iterator;
171 
176  inline bool is_valid() const;
177 
184  bool get_is_last() const;
185 
191  ::FLAC__MetadataType get_type() const;
192 
202  unsigned get_length() const;
203 
210  void set_is_last(bool);
211 
219  inline operator const ::FLAC__StreamMetadata *() const;
220  private:
222  Prototype();
223 
224  // These are used only by Iterator
225  bool is_reference_;
226  inline void set_reference(bool x) { is_reference_ = x; }
227  };
228 
229 #ifdef _MSC_VER
230 // warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning)
231 #pragma warning ( disable : 4800 )
232 #endif
233 
234  inline bool Prototype::operator==(const Prototype &object) const
235  { return (bool)::FLAC__metadata_object_is_equal(object_, object.object_); }
236 
237  inline bool Prototype::operator==(const ::FLAC__StreamMetadata &object) const
238  { return (bool)::FLAC__metadata_object_is_equal(object_, &object); }
239 
240  inline bool Prototype::operator==(const ::FLAC__StreamMetadata *object) const
241  { return (bool)::FLAC__metadata_object_is_equal(object_, object); }
242 
243 #ifdef _MSC_VER
244 #pragma warning ( default : 4800 )
245 #endif
246 
247  inline bool Prototype::operator!=(const Prototype &object) const
248  { return !operator==(object); }
249 
250  inline bool Prototype::operator!=(const ::FLAC__StreamMetadata &object) const
251  { return !operator==(object); }
252 
253  inline bool Prototype::operator!=(const ::FLAC__StreamMetadata *object) const
254  { return !operator==(object); }
255 
256  inline bool Prototype::is_valid() const
257  { return 0 != object_; }
258 
259  inline Prototype::operator const ::FLAC__StreamMetadata *() const
260  { return object_; }
261 
263  FLACPP_API Prototype *clone(const Prototype *);
264 
265 
270  class FLACPP_API StreamInfo : public Prototype {
271  public:
272  StreamInfo();
273 
275 
278  inline StreamInfo(const StreamInfo &object): Prototype(object) { }
279  inline StreamInfo(const ::FLAC__StreamMetadata &object): Prototype(object) { }
280  inline StreamInfo(const ::FLAC__StreamMetadata *object): Prototype(object) { }
282 
286  inline StreamInfo(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
287 
288  ~StreamInfo();
289 
291 
292  inline StreamInfo &operator=(const StreamInfo &object) { Prototype::operator=(object); return *this; }
293  inline StreamInfo &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
294  inline StreamInfo &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
296 
300  inline StreamInfo &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
301 
303 
304  inline bool operator==(const StreamInfo &object) const { return Prototype::operator==(object); }
305  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
306  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
308 
310 
311  inline bool operator!=(const StreamInfo &object) const { return Prototype::operator!=(object); }
312  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
313  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
315 
317 
318  unsigned get_min_blocksize() const;
319  unsigned get_max_blocksize() const;
320  unsigned get_min_framesize() const;
321  unsigned get_max_framesize() const;
322  unsigned get_sample_rate() const;
323  unsigned get_channels() const;
324  unsigned get_bits_per_sample() const;
325  FLAC__uint64 get_total_samples() const;
326  const FLAC__byte *get_md5sum() const;
327 
328  void set_min_blocksize(unsigned value);
329  void set_max_blocksize(unsigned value);
330  void set_min_framesize(unsigned value);
331  void set_max_framesize(unsigned value);
332  void set_sample_rate(unsigned value);
333  void set_channels(unsigned value);
334  void set_bits_per_sample(unsigned value);
335  void set_total_samples(FLAC__uint64 value);
336  void set_md5sum(const FLAC__byte value[16]);
338  };
339 
344  class FLACPP_API Padding : public Prototype {
345  public:
346  Padding();
347 
349 
352  inline Padding(const Padding &object): Prototype(object) { }
353  inline Padding(const ::FLAC__StreamMetadata &object): Prototype(object) { }
354  inline Padding(const ::FLAC__StreamMetadata *object): Prototype(object) { }
356 
360  inline Padding(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
361 
364  Padding(unsigned length);
365 
366  ~Padding();
367 
369 
370  inline Padding &operator=(const Padding &object) { Prototype::operator=(object); return *this; }
371  inline Padding &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
372  inline Padding &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
374 
378  inline Padding &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
379 
381 
382  inline bool operator==(const Padding &object) const { return Prototype::operator==(object); }
383  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
384  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
386 
388 
389  inline bool operator!=(const Padding &object) const { return Prototype::operator!=(object); }
390  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
391  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
393 
396  void set_length(unsigned length);
397  };
398 
403  class FLACPP_API Application : public Prototype {
404  public:
405  Application();
406  //
408 
411  inline Application(const Application &object): Prototype(object) { }
412  inline Application(const ::FLAC__StreamMetadata &object): Prototype(object) { }
413  inline Application(const ::FLAC__StreamMetadata *object): Prototype(object) { }
415 
419  inline Application(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
420 
421  ~Application();
422 
424 
425  inline Application &operator=(const Application &object) { Prototype::operator=(object); return *this; }
426  inline Application &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
427  inline Application &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
429 
433  inline Application &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
434 
436 
437  inline bool operator==(const Application &object) const { return Prototype::operator==(object); }
438  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
439  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
441 
443 
444  inline bool operator!=(const Application &object) const { return Prototype::operator!=(object); }
445  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
446  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
448 
449  const FLAC__byte *get_id() const;
450  const FLAC__byte *get_data() const;
451 
452  void set_id(const FLAC__byte value[4]);
454  bool set_data(const FLAC__byte *data, unsigned length);
455  bool set_data(FLAC__byte *data, unsigned length, bool copy);
456  };
457 
462  class FLACPP_API SeekTable : public Prototype {
463  public:
464  SeekTable();
465 
467 
470  inline SeekTable(const SeekTable &object): Prototype(object) { }
471  inline SeekTable(const ::FLAC__StreamMetadata &object): Prototype(object) { }
472  inline SeekTable(const ::FLAC__StreamMetadata *object): Prototype(object) { }
474 
478  inline SeekTable(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
479 
480  ~SeekTable();
481 
483 
484  inline SeekTable &operator=(const SeekTable &object) { Prototype::operator=(object); return *this; }
485  inline SeekTable &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
486  inline SeekTable &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
488 
492  inline SeekTable &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
493 
495 
496  inline bool operator==(const SeekTable &object) const { return Prototype::operator==(object); }
497  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
498  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
500 
502 
503  inline bool operator!=(const SeekTable &object) const { return Prototype::operator!=(object); }
504  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
505  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
507 
508  unsigned get_num_points() const;
509  ::FLAC__StreamMetadata_SeekPoint get_point(unsigned index) const;
510 
512  bool resize_points(unsigned new_num_points);
513 
515  void set_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
516 
518  bool insert_point(unsigned index, const ::FLAC__StreamMetadata_SeekPoint &point);
519 
521  bool delete_point(unsigned index);
522 
524  bool is_legal() const;
525 
527  bool template_append_placeholders(unsigned num);
528 
530  bool template_append_point(FLAC__uint64 sample_number);
531 
533  bool template_append_points(FLAC__uint64 sample_numbers[], unsigned num);
534 
536  bool template_append_spaced_points(unsigned num, FLAC__uint64 total_samples);
537 
539  bool template_append_spaced_points_by_samples(unsigned samples, FLAC__uint64 total_samples);
540 
542  bool template_sort(bool compact);
543  };
544 
549  class FLACPP_API VorbisComment : public Prototype {
550  public:
580  class FLACPP_API Entry {
581  public:
582  Entry();
583 
584  Entry(const char *field, unsigned field_length);
585  Entry(const char *field); // assumes \a field is NUL-terminated
586 
587  Entry(const char *field_name, const char *field_value, unsigned field_value_length);
588  Entry(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated
589 
590  Entry(const Entry &entry);
591 
592  Entry &operator=(const Entry &entry);
593 
594  virtual ~Entry();
595 
596  virtual bool is_valid() const;
597 
598  unsigned get_field_length() const;
599  unsigned get_field_name_length() const;
600  unsigned get_field_value_length() const;
601 
603  const char *get_field() const;
604  const char *get_field_name() const;
605  const char *get_field_value() const;
606 
607  bool set_field(const char *field, unsigned field_length);
608  bool set_field(const char *field); // assumes \a field is NUL-terminated
609  bool set_field_name(const char *field_name);
610  bool set_field_value(const char *field_value, unsigned field_value_length);
611  bool set_field_value(const char *field_value); // assumes \a field_value is NUL-terminated
612  protected:
613  bool is_valid_;
615  char *field_name_;
616  unsigned field_name_length_;
617  char *field_value_;
618  unsigned field_value_length_;
619  private:
620  void zero();
621  void clear();
622  void clear_entry();
623  void clear_field_name();
624  void clear_field_value();
625  void construct(const char *field, unsigned field_length);
626  void construct(const char *field); // assumes \a field is NUL-terminated
627  void construct(const char *field_name, const char *field_value, unsigned field_value_length);
628  void construct(const char *field_name, const char *field_value); // assumes \a field_value is NUL-terminated
629  void compose_field();
630  void parse_field();
631  };
632 
633  VorbisComment();
634 
636 
639  inline VorbisComment(const VorbisComment &object): Prototype(object) { }
640  inline VorbisComment(const ::FLAC__StreamMetadata &object): Prototype(object) { }
641  inline VorbisComment(const ::FLAC__StreamMetadata *object): Prototype(object) { }
643 
647  inline VorbisComment(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
648 
649  ~VorbisComment();
650 
652 
653  inline VorbisComment &operator=(const VorbisComment &object) { Prototype::operator=(object); return *this; }
654  inline VorbisComment &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
655  inline VorbisComment &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
657 
661  inline VorbisComment &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
662 
664 
665  inline bool operator==(const VorbisComment &object) const { return Prototype::operator==(object); }
666  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
667  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
669 
671 
672  inline bool operator!=(const VorbisComment &object) const { return Prototype::operator!=(object); }
673  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
674  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
676 
677  unsigned get_num_comments() const;
678  const FLAC__byte *get_vendor_string() const; // NUL-terminated UTF-8 string
679  Entry get_comment(unsigned index) const;
680 
682  bool set_vendor_string(const FLAC__byte *string); // NUL-terminated UTF-8 string
683 
685  bool resize_comments(unsigned new_num_comments);
686 
688  bool set_comment(unsigned index, const Entry &entry);
689 
691  bool insert_comment(unsigned index, const Entry &entry);
692 
694  bool append_comment(const Entry &entry);
695 
697  bool replace_comment(const Entry &entry, bool all);
698 
700  bool delete_comment(unsigned index);
701 
703  int find_entry_from(unsigned offset, const char *field_name);
704 
706  int remove_entry_matching(const char *field_name);
707 
709  int remove_entries_matching(const char *field_name);
710  };
711 
716  class FLACPP_API CueSheet : public Prototype {
717  public:
724  class FLACPP_API Track {
725  protected:
727  public:
728  Track();
729  Track(const ::FLAC__StreamMetadata_CueSheet_Track *track);
730  Track(const Track &track);
731  Track &operator=(const Track &track);
732 
733  virtual ~Track();
734 
735  virtual bool is_valid() const;
736 
737 
738  inline FLAC__uint64 get_offset() const { return object_->offset; }
739  inline FLAC__byte get_number() const { return object_->number; }
740  inline const char *get_isrc() const { return object_->isrc; }
741  inline unsigned get_type() const { return object_->type; }
742  inline bool get_pre_emphasis() const { return object_->pre_emphasis; }
743 
744  inline FLAC__byte get_num_indices() const { return object_->num_indices; }
745  ::FLAC__StreamMetadata_CueSheet_Index get_index(unsigned i) const;
746 
747  inline const ::FLAC__StreamMetadata_CueSheet_Track *get_track() const { return object_; }
748 
749  inline void set_offset(FLAC__uint64 value) { object_->offset = value; }
750  inline void set_number(FLAC__byte value) { object_->number = value; }
751  void set_isrc(const char value[12]);
752  void set_type(unsigned value);
753  inline void set_pre_emphasis(bool value) { object_->pre_emphasis = value? 1 : 0; }
754 
755  void set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index);
756  //@@@ It's awkward but to insert/delete index points
757  //@@@ you must use the routines in the CueSheet class.
758  };
759 
760  CueSheet();
761 
763 
766  inline CueSheet(const CueSheet &object): Prototype(object) { }
767  inline CueSheet(const ::FLAC__StreamMetadata &object): Prototype(object) { }
768  inline CueSheet(const ::FLAC__StreamMetadata *object): Prototype(object) { }
770 
774  inline CueSheet(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
775 
776  ~CueSheet();
777 
779 
780  inline CueSheet &operator=(const CueSheet &object) { Prototype::operator=(object); return *this; }
781  inline CueSheet &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
782  inline CueSheet &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
784 
788  inline CueSheet &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
789 
791 
792  inline bool operator==(const CueSheet &object) const { return Prototype::operator==(object); }
793  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
794  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
796 
798 
799  inline bool operator!=(const CueSheet &object) const { return Prototype::operator!=(object); }
800  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
801  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
803 
804  const char *get_media_catalog_number() const;
805  FLAC__uint64 get_lead_in() const;
806  bool get_is_cd() const;
807 
808  unsigned get_num_tracks() const;
809  Track get_track(unsigned i) const;
810 
811  void set_media_catalog_number(const char value[128]);
812  void set_lead_in(FLAC__uint64 value);
813  void set_is_cd(bool value);
814 
815  void set_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
816 
818  bool resize_indices(unsigned track_num, unsigned new_num_indices);
819 
821  bool insert_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index);
822 
824  bool insert_blank_index(unsigned track_num, unsigned index_num);
825 
827  bool delete_index(unsigned track_num, unsigned index_num);
828 
830  bool resize_tracks(unsigned new_num_tracks);
831 
833  bool set_track(unsigned i, const Track &track);
834 
836  bool insert_track(unsigned i, const Track &track);
837 
839  bool insert_blank_track(unsigned i);
840 
842  bool delete_track(unsigned i);
843 
845  bool is_legal(bool check_cd_da_subset = false, const char **violation = 0) const;
846 
848  FLAC__uint32 calculate_cddb_id() const;
849  };
850 
855  class FLACPP_API Picture : public Prototype {
856  public:
857  Picture();
858 
860 
863  inline Picture(const Picture &object): Prototype(object) { }
864  inline Picture(const ::FLAC__StreamMetadata &object): Prototype(object) { }
865  inline Picture(const ::FLAC__StreamMetadata *object): Prototype(object) { }
867 
871  inline Picture(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
872 
873  ~Picture();
874 
876 
877  inline Picture &operator=(const Picture &object) { Prototype::operator=(object); return *this; }
878  inline Picture &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
879  inline Picture &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
881 
885  inline Picture &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
886 
888 
889  inline bool operator==(const Picture &object) const { return Prototype::operator==(object); }
890  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
891  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
893 
895 
896  inline bool operator!=(const Picture &object) const { return Prototype::operator!=(object); }
897  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
898  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
900 
901  ::FLAC__StreamMetadata_Picture_Type get_type() const;
902  const char *get_mime_type() const; // NUL-terminated printable ASCII string
903  const FLAC__byte *get_description() const; // NUL-terminated UTF-8 string
904  FLAC__uint32 get_width() const;
905  FLAC__uint32 get_height() const;
906  FLAC__uint32 get_depth() const;
907  FLAC__uint32 get_colors() const;
908  FLAC__uint32 get_data_length() const;
909  const FLAC__byte *get_data() const;
910 
911  void set_type(::FLAC__StreamMetadata_Picture_Type type);
912 
914  bool set_mime_type(const char *string); // NUL-terminated printable ASCII string
915 
917  bool set_description(const FLAC__byte *string); // NUL-terminated UTF-8 string
918 
919  void set_width(FLAC__uint32 value) const;
920  void set_height(FLAC__uint32 value) const;
921  void set_depth(FLAC__uint32 value) const;
922  void set_colors(FLAC__uint32 value) const;
923 
925  bool set_data(const FLAC__byte *data, FLAC__uint32 data_length);
926 
928  bool is_legal(const char **violation);
929  };
930 
937  class FLACPP_API Unknown : public Prototype {
938  public:
939  Unknown();
940  //
942 
945  inline Unknown(const Unknown &object): Prototype(object) { }
946  inline Unknown(const ::FLAC__StreamMetadata &object): Prototype(object) { }
947  inline Unknown(const ::FLAC__StreamMetadata *object): Prototype(object) { }
949 
953  inline Unknown(::FLAC__StreamMetadata *object, bool copy): Prototype(object, copy) { }
954 
955  ~Unknown();
956 
958 
959  inline Unknown &operator=(const Unknown &object) { Prototype::operator=(object); return *this; }
960  inline Unknown &operator=(const ::FLAC__StreamMetadata &object) { Prototype::operator=(object); return *this; }
961  inline Unknown &operator=(const ::FLAC__StreamMetadata *object) { Prototype::operator=(object); return *this; }
963 
967  inline Unknown &assign(::FLAC__StreamMetadata *object, bool copy) { Prototype::assign_object(object, copy); return *this; }
968 
970 
971  inline bool operator==(const Unknown &object) const { return Prototype::operator==(object); }
972  inline bool operator==(const ::FLAC__StreamMetadata &object) const { return Prototype::operator==(object); }
973  inline bool operator==(const ::FLAC__StreamMetadata *object) const { return Prototype::operator==(object); }
975 
977 
978  inline bool operator!=(const Unknown &object) const { return Prototype::operator!=(object); }
979  inline bool operator!=(const ::FLAC__StreamMetadata &object) const { return Prototype::operator!=(object); }
980  inline bool operator!=(const ::FLAC__StreamMetadata *object) const { return Prototype::operator!=(object); }
982 
983  const FLAC__byte *get_data() const;
984 
986  bool set_data(const FLAC__byte *data, unsigned length);
987  bool set_data(FLAC__byte *data, unsigned length, bool copy);
988  };
989 
990  /* \} */
991 
992 
1005  FLACPP_API bool get_streaminfo(const char *filename, StreamInfo &streaminfo);
1006 
1007  FLACPP_API bool get_tags(const char *filename, VorbisComment *&tags);
1008  FLACPP_API bool get_tags(const char *filename, VorbisComment &tags);
1009 
1010  FLACPP_API bool get_cuesheet(const char *filename, CueSheet *&cuesheet);
1011  FLACPP_API bool get_cuesheet(const char *filename, CueSheet &cuesheet);
1012 
1013  FLACPP_API bool get_picture(const char *filename, Picture *&picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors);
1014  FLACPP_API bool get_picture(const char *filename, Picture &picture, ::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors);
1015 
1016  /* \} */
1017 
1018 
1053  class FLACPP_API SimpleIterator {
1054  public:
1057  class FLACPP_API Status {
1058  public:
1059  inline Status(::FLAC__Metadata_SimpleIteratorStatus status): status_(status) { }
1060  inline operator ::FLAC__Metadata_SimpleIteratorStatus() const { return status_; }
1061  inline const char *as_cstring() const { return ::FLAC__Metadata_SimpleIteratorStatusString[status_]; }
1062  protected:
1064  };
1065 
1066  SimpleIterator();
1067  virtual ~SimpleIterator();
1068 
1069  bool is_valid() const;
1070 
1071  bool init(const char *filename, bool read_only, bool preserve_file_stats);
1072 
1073  Status status();
1074  bool is_writable() const;
1075 
1076  bool next();
1077  bool prev();
1078  bool is_last() const;
1079 
1080  off_t get_block_offset() const;
1081  ::FLAC__MetadataType get_block_type() const;
1082  unsigned get_block_length() const;
1083  bool get_application_id(FLAC__byte *id);
1084  Prototype *get_block();
1085  bool set_block(Prototype *block, bool use_padding = true);
1086  bool insert_block_after(Prototype *block, bool use_padding = true);
1087  bool delete_block(bool use_padding = true);
1088 
1089  protected:
1091  void clear();
1092 
1093  private: // Do not use.
1095  SimpleIterator&operator=(const SimpleIterator&);
1096  };
1097 
1098  /* \} */
1099 
1100 
1143  class FLACPP_API Chain {
1144  public:
1147  class FLACPP_API Status {
1148  public:
1149  inline Status(::FLAC__Metadata_ChainStatus status): status_(status) { }
1150  inline operator ::FLAC__Metadata_ChainStatus() const { return status_; }
1151  inline const char *as_cstring() const { return ::FLAC__Metadata_ChainStatusString[status_]; }
1152  protected:
1154  };
1155 
1156  Chain();
1157  virtual ~Chain();
1158 
1159  friend class Iterator;
1160 
1161  bool is_valid() const;
1162 
1163  Status status();
1164 
1165  bool read(const char *filename, bool is_ogg = false);
1166  bool read(FLAC__IOHandle handle, FLAC__IOCallbacks callbacks, bool is_ogg = false);
1167 
1168  bool check_if_tempfile_needed(bool use_padding);
1169 
1170  bool write(bool use_padding = true, bool preserve_file_stats = false);
1171  bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks);
1172  bool write(bool use_padding, ::FLAC__IOHandle handle, ::FLAC__IOCallbacks callbacks, ::FLAC__IOHandle temp_handle, ::FLAC__IOCallbacks temp_callbacks);
1173 
1174  void merge_padding();
1175  void sort_padding();
1176 
1177  protected:
1178  ::FLAC__Metadata_Chain *chain_;
1179  virtual void clear();
1180 
1181  private: // Do not use.
1182  Chain(const Chain&);
1183  Chain&operator=(const Chain&);
1184  };
1185 
1191  class FLACPP_API Iterator {
1192  public:
1193  Iterator();
1194  virtual ~Iterator();
1195 
1196  bool is_valid() const;
1197 
1198 
1199  void init(Chain &chain);
1200 
1201  bool next();
1202  bool prev();
1203 
1204  ::FLAC__MetadataType get_block_type() const;
1205  Prototype *get_block();
1206  bool set_block(Prototype *block);
1207  bool delete_block(bool replace_with_padding);
1208  bool insert_block_before(Prototype *block);
1209  bool insert_block_after(Prototype *block);
1210 
1211  protected:
1212  ::FLAC__Metadata_Iterator *iterator_;
1213  virtual void clear();
1214 
1215  private: // Do not use.
1216  Iterator(const Iterator&);
1217  Iterator&operator=(const Iterator&);
1218  };
1219 
1220  /* \} */
1221 
1222  }
1223 }
1224 
1225 #endif
FLAC__byte number
Definition: format.h:670
bool operator!=(const Application &object) const
Definition: metadata.h:444
bool operator==(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:973
Application & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:433
CueSheet(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:768
StreamInfo(const StreamInfo &object)
Definition: metadata.h:278
unsigned pre_emphasis
Definition: format.h:679
bool operator!=(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:445
bool operator==(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:439
Definition: metadata.h:855
VorbisComment(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:640
Prototype & operator=(const Prototype &)
bool operator==(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:890
Application(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:412
Definition: metadata.h:1053
CueSheet & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:788
bool get_cuesheet(const char *filename, CueSheet &cuesheet)
See FLAC__metadata_get_cuesheet().
StreamInfo & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:300
bool operator!=(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:801
bool operator!=(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:504
bool operator!=(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:898
Padding & operator=(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:371
bool get_tags(const char *filename, VorbisComment &tags)
See FLAC__metadata_get_tags().
Definition: decoder.h:78
bool operator!=(const CueSheet &object) const
Definition: metadata.h:799
bool operator!=(const VorbisComment &object) const
Definition: metadata.h:672
This module provides functions for creating and manipulating FLAC metadata blocks in memory...
CueSheet & operator=(const CueSheet &object)
Definition: metadata.h:780
bool operator!=(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:446
Unknown & operator=(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:961
Definition: callback.h:170
Picture(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:871
Definition: metadata.h:344
const char *const FLAC__Metadata_SimpleIteratorStatusString[]
Unknown(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:947
Padding & operator=(const Padding &object)
Definition: metadata.h:370
VorbisComment(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:647
StreamInfo & operator=(const StreamInfo &object)
Definition: metadata.h:292
bool operator==(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:794
Picture & operator=(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:878
StreamInfo(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:286
VorbisComment(const VorbisComment &object)
Definition: metadata.h:639
bool operator!=(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:391
bool operator!=(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:673
bool operator!=(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:979
Unknown(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:953
bool operator!=(const Unknown &object) const
Definition: metadata.h:978
bool operator==(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:438
Application & operator=(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:426
SeekTable & operator=(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:485
unsigned type
Definition: format.h:676
bool operator!=(const SeekTable &object) const
Definition: metadata.h:503
StreamInfo(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:279
Definition: format.h:666
Padding & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:378
Padding & operator=(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:372
StreamInfo & operator=(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:294
Picture & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:885
bool operator==(const Unknown &object) const
Definition: metadata.h:971
Prototype * clone(const Prototype *)
Definition: format.h:647
Unknown(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:946
bool operator!=(const StreamInfo &object) const
Definition: metadata.h:311
Picture & operator=(const Picture &object)
Definition: metadata.h:877
FLAC__bool FLAC__metadata_object_is_equal(const FLAC__StreamMetadata *block1, const FLAC__StreamMetadata *block2)
Unknown & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:967
CueSheet & operator=(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:782
Definition: metadata.h:549
Prototype & assign_object(::FLAC__StreamMetadata *object, bool copy)
bool operator==(const CueSheet &object) const
Definition: metadata.h:792
Definition: metadata.h:1143
SeekTable & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:492
bool operator!=(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:390
CueSheet(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:767
FLAC__byte num_indices
Definition: format.h:682
Padding(const Padding &object)
Definition: metadata.h:352
Picture & operator=(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:879
bool operator!=(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:980
StreamInfo & operator=(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:293
This module contains #defines and symbols for exporting function calls, and providing version informa...
bool operator!=(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:312
Unknown(const Unknown &object)
Definition: metadata.h:945
struct FLAC__Metadata_Chain FLAC__Metadata_Chain
Definition: metadata.h:714
Definition: format.h:834
Application & operator=(const Application &object)
Definition: metadata.h:425
bool get_streaminfo(const char *filename, StreamInfo &streaminfo)
See FLAC__metadata_get_streaminfo().
Padding(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:353
Definition: metadata.h:580
SeekTable(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:471
bool operator==(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:972
Definition: metadata.h:1147
const char *const FLAC__Metadata_ChainStatusString[]
bool operator==(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:667
VorbisComment(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:641
Application(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:419
Definition: metadata.h:1057
bool operator==(const Padding &object) const
Definition: metadata.h:382
bool operator==(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:306
bool operator==(const Picture &object) const
Definition: metadata.h:889
CueSheet(const CueSheet &object)
Definition: metadata.h:766
Application(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:413
bool is_valid() const
Definition: metadata.h:256
Definition: metadata.h:270
StreamInfo(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:280
FLAC__MetadataType
Definition: format.h:489
struct FLAC__Metadata_Iterator FLAC__Metadata_Iterator
Definition: metadata.h:719
bool operator==(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:498
Picture(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:865
Definition: format.h:624
VorbisComment & assign(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:661
bool operator==(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:497
Picture(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:864
SeekTable(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:472
Picture(const Picture &object)
Definition: metadata.h:863
Definition: metadata.h:724
bool operator!=(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:313
void * FLAC__IOHandle
Definition: callback.h:89
CueSheet(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:774
char isrc[13]
Definition: format.h:673
SeekTable(const SeekTable &object)
Definition: metadata.h:470
FLAC__StreamMetadata_Picture_Type
Definition: format.h:732
struct FLAC__Metadata_SimpleIterator FLAC__Metadata_SimpleIterator
Definition: metadata.h:303
bool operator!=(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:674
bool operator==(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:384
VorbisComment & operator=(const VorbisComment &object)
Definition: metadata.h:653
bool operator==(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:891
bool operator==(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:793
bool operator!=(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:800
Definition: metadata.h:716
bool operator!=(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:897
bool operator!=(const Prototype &) const
Definition: metadata.h:247
FLAC__uint64 offset
Definition: format.h:667
Definition: metadata.h:1191
bool operator==(const VorbisComment &object) const
Definition: metadata.h:665
Definition: metadata.h:109
bool operator==(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:305
Padding(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:360
Unknown & operator=(const Unknown &object)
Definition: metadata.h:959
VorbisComment & operator=(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:655
Padding(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:354
Application(const Application &object)
Definition: metadata.h:411
SeekTable & operator=(const SeekTable &object)
Definition: metadata.h:484
CueSheet & operator=(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:781
FLAC__Metadata_SimpleIteratorStatus
Definition: metadata.h:309
Definition: metadata.h:462
bool operator==(const Application &object) const
Definition: metadata.h:437
Unknown & operator=(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:960
bool operator==(const StreamInfo &object) const
Definition: metadata.h:304
bool operator==(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:383
Definition: metadata.h:937
Application & operator=(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:427
Definition: format.h:574
bool operator!=(const Picture &object) const
Definition: metadata.h:896
VorbisComment & operator=(const ::FLAC__StreamMetadata &object)
Definition: metadata.h:654
FLAC__Metadata_ChainStatus
Definition: metadata.h:721
Definition: metadata.h:403
bool operator!=(const Padding &object) const
Definition: metadata.h:389
SeekTable & operator=(const ::FLAC__StreamMetadata *object)
Definition: metadata.h:486
bool operator!=(const ::FLAC__StreamMetadata *object) const
Definition: metadata.h:505
bool operator==(const Prototype &) const
Definition: metadata.h:234
bool get_picture(const char *filename, Picture &picture,::FLAC__StreamMetadata_Picture_Type type, const char *mime_type, const FLAC__byte *description, unsigned max_width, unsigned max_height, unsigned max_depth, unsigned max_colors)
See FLAC__metadata_get_picture().
SeekTable(::FLAC__StreamMetadata *object, bool copy)
Definition: metadata.h:478
bool operator==(const SeekTable &object) const
Definition: metadata.h:496
bool operator==(const ::FLAC__StreamMetadata &object) const
Definition: metadata.h:666