summaryrefslogtreecommitdiff
path: root/src/libFLAC++/metadata.cpp
diff options
context:
space:
mode:
authorJosh Coalson <jcoalson@users.sourceforce.net>2002-11-16 06:30:30 +0000
committerJosh Coalson <jcoalson@users.sourceforce.net>2002-11-16 06:30:30 +0000
commit863dbf3bcb193bc39ad43ee4951c4c897f4ab3b6 (patch)
tree016cae2567faccc21a34a970503b22fc39d95143 /src/libFLAC++/metadata.cpp
parentd639455a26140e26ed6ceb93c04aab1db16e2d45 (diff)
downloadflac-863dbf3bcb193bc39ad43ee4951c4c897f4ab3b6.tar.gz
add CueSheet object wrapper
Diffstat (limited to 'src/libFLAC++/metadata.cpp')
-rw-r--r--src/libFLAC++/metadata.cpp135
1 files changed, 135 insertions, 0 deletions
diff --git a/src/libFLAC++/metadata.cpp b/src/libFLAC++/metadata.cpp
index 36c79a34..2b71fa04 100644
--- a/src/libFLAC++/metadata.cpp
+++ b/src/libFLAC++/metadata.cpp
@@ -48,6 +48,9 @@ namespace FLAC {
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
ret = new VorbisComment(object, /*copy=*/false);
break;
+ case FLAC__METADATA_TYPE_CUESHEET:
+ ret = new CueSheet(object, /*copy=*/false);
+ break;
default:
FLAC__ASSERT(0);
break;
@@ -739,6 +742,138 @@ namespace FLAC {
}
+ //
+ // CueSheet::Track
+ //
+
+ CueSheet::Track::Track():
+ object_(::FLAC__metadata_object_cuesheet_track_new())
+ { }
+
+ CueSheet::Track::Track(const ::FLAC__StreamMetadata_CueSheet_Track *track):
+ object_(::FLAC__metadata_object_cuesheet_track_clone(track))
+ { }
+
+ CueSheet::Track::Track(const Track &track):
+ object_(::FLAC__metadata_object_cuesheet_track_clone(track.object_))
+ { }
+
+ void CueSheet::Track::operator=(const Track &track)
+ {
+ object_ = ::FLAC__metadata_object_cuesheet_track_clone(track.object_);
+ }
+
+ CueSheet::Track::~Track()
+ {
+ if(0 != object_)
+ delete object_;
+ }
+
+ bool CueSheet::Track::is_valid() const
+ {
+ return(0 != object_);
+ }
+
+ ::FLAC__StreamMetadata_CueSheet_Index CueSheet::Track::get_index(unsigned i) const
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(i < object_->num_indices);
+ return object_->indices[i];
+ }
+
+ void CueSheet::Track::set_isrc(char value[12])
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(0 != value);
+ memcpy(object_->isrc, value, 12);
+ object_->isrc[12] = '\0';
+ }
+
+ void CueSheet::Track::set_type(unsigned value)
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(value <= 1);
+ object_->type = value;
+ }
+
+ void CueSheet::Track::set_index(unsigned i, const ::FLAC__StreamMetadata_CueSheet_Index &index)
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(i < object_->num_indices);
+ object_->indices[i] = index;
+ }
+
+
+ //
+ // CueSheet
+ //
+
+ CueSheet::CueSheet():
+ Prototype(FLAC__metadata_object_new(FLAC__METADATA_TYPE_CUESHEET), /*copy=*/false)
+ { }
+
+ CueSheet::~CueSheet()
+ { }
+
+ unsigned CueSheet::get_num_tracks() const
+ {
+ FLAC__ASSERT(is_valid());
+ return object_->data.cue_sheet.num_tracks;
+ }
+
+ CueSheet::Track CueSheet::get_track(unsigned i) const
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(i < object_->data.cue_sheet.num_tracks);
+ return Track(object_->data.cue_sheet.tracks + i);
+ }
+
+ bool CueSheet::insert_index(unsigned track_num, unsigned index_num, const ::FLAC__StreamMetadata_CueSheet_Index &index)
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks);
+ FLAC__ASSERT(index_num <= object_->data.cue_sheet.tracks[track_num].num_indices);
+ return (bool)::FLAC__metadata_object_cuesheet_track_insert_index(object_, track_num, index_num, index);
+ }
+
+ bool CueSheet::delete_index(unsigned track_num, unsigned index_num)
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(track_num < object_->data.cue_sheet.num_tracks);
+ FLAC__ASSERT(index_num < object_->data.cue_sheet.tracks[track_num].num_indices);
+ return (bool)::FLAC__metadata_object_cuesheet_track_delete_index(object_, track_num, index_num);
+ }
+
+ bool CueSheet::set_track(unsigned i, const CueSheet::Track &track)
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(i < object_->data.cue_sheet.num_tracks);
+ // We can safely const_cast since copy=true
+ return (bool)::FLAC__metadata_object_cuesheet_set_track(object_, i, const_cast< ::FLAC__StreamMetadata_CueSheet_Track*>(track.get_track()), /*copy=*/true);
+ }
+
+ bool CueSheet::insert_track(unsigned i, const CueSheet::Track &track)
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(i <= object_->data.cue_sheet.num_tracks);
+ // We can safely const_cast since copy=true
+ return (bool)::FLAC__metadata_object_cuesheet_insert_track(object_, i, const_cast< ::FLAC__StreamMetadata_CueSheet_Track*>(track.get_track()), /*copy=*/true);
+ }
+
+ bool CueSheet::delete_track(unsigned i)
+ {
+ FLAC__ASSERT(is_valid());
+ FLAC__ASSERT(i < object_->data.cue_sheet.num_tracks);
+ return (bool)::FLAC__metadata_object_cuesheet_delete_track(object_, i);
+ }
+
+ bool CueSheet::is_legal(bool check_cd_da_subset, const char **violation) const
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_object_cuesheet_is_legal(object_, check_cd_da_subset, violation);
+ }
+
+
// ============================================================
//
// Level 0