diff --git a/doc/html/changelog.html b/doc/html/changelog.html
index 5598647f..fb949d7d 100644
--- a/doc/html/changelog.html
+++ b/doc/html/changelog.html
@@ -118,13 +118,17 @@
libFLAC:
- - (none)
+ - Added FLAC__metadata_simple_iterator_is_last()
+ - Added FLAC__metadata_simple_iterator_get_block_offset()
+ - Added FLAC__metadata_simple_iterator_get_block_length()
libFLAC++:
- - (none)
+ - Added FLAC::Metadata::SimpleIterator::is_last()
+ - Added FLAC::Metadata::SimpleIterator::get_block_offset()
+ - Added FLAC::Metadata::SimpleIterator::get_block_length()
diff --git a/include/FLAC++/metadata.h b/include/FLAC++/metadata.h
index e2ba5c5d..abe2defa 100644
--- a/include/FLAC++/metadata.h
+++ b/include/FLAC++/metadata.h
@@ -1018,8 +1018,11 @@ namespace FLAC {
bool next(); ///< See FLAC__metadata_simple_iterator_next().
bool prev(); ///< See FLAC__metadata_simple_iterator_prev().
+ bool is_last() const; ///< See FLAC__metadata_simple_iterator_is_last().
+ off_t get_block_offset() const; ///< See FLAC__metadata_simple_iterator_get_block_offset().
::FLAC__MetadataType get_block_type() const; ///< See FLAC__metadata_simple_iterator_get_block_type().
+ unsigned get_block_length() const; ///< See FLAC__metadata_simple_iterator_get_block_length().
Prototype *get_block(); ///< See FLAC__metadata_simple_iterator_get_block().
bool set_block(Prototype *block, bool use_padding = true); ///< See FLAC__metadata_simple_iterator_set_block().
bool insert_block_after(Prototype *block, bool use_padding = true); ///< See FLAC__metadata_simple_iterator_insert_block_after().
diff --git a/include/FLAC/metadata.h b/include/FLAC/metadata.h
index 0f21dec2..6ee8036f 100644
--- a/include/FLAC/metadata.h
+++ b/include/FLAC/metadata.h
@@ -443,6 +443,38 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next(FLAC__Metadata_SimpleIte
*/
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIterator *iterator);
+/*@@@@add to tests*/
+/** Returns a flag telling if the current metadata block is the last.
+ *
+ * \param iterator A pointer to an existing initialized iterator.
+ * \assert
+ * \code iterator != NULL \endcode
+ * \a iterator has been successfully initialized with
+ * FLAC__metadata_simple_iterator_init()
+ * \retval FLAC__bool
+ * \c true if the current metadata block is the last in the file,
+ * else \c false.
+ */
+FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_last(const FLAC__Metadata_SimpleIterator *iterator);
+
+/*@@@@add to tests*/
+/** Get the offset of the metadata block at the current position. This
+ * avoids reading the actual block data which can save time for large
+ * blocks.
+ *
+ * \param iterator A pointer to an existing initialized iterator.
+ * \assert
+ * \code iterator != NULL \endcode
+ * \a iterator has been successfully initialized with
+ * FLAC__metadata_simple_iterator_init()
+ * \retval off_t
+ * The offset of the metadata block at the current iterator position.
+ * This is the byte offset relative to the beginning of the file of
+ * the current metadata block's header.
+ */
+
+FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset(const FLAC__Metadata_SimpleIterator *iterator);
+
/** Get the type of the metadata block at the current position. This
* avoids reading the actual block data which can save time for large
* blocks.
@@ -458,6 +490,25 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIte
FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator);
+/*@@@@add to tests*/
+/** Get the length of the metadata block at the current position. This
+ * avoids reading the actual block data which can save time for large
+ * blocks.
+ *
+ * \param iterator A pointer to an existing initialized iterator.
+ * \assert
+ * \code iterator != NULL \endcode
+ * \a iterator has been successfully initialized with
+ * FLAC__metadata_simple_iterator_init()
+ * \retval unsigned
+ * The length of the metadata block at the current iterator position.
+ * The is same length as that in the
+ * metadata block header,
+ * i.e. the length of the metadata body that follows the header.
+ */
+
+FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator);
+
/** Get the metadata block at the current position. You can modify the
* block but must use FLAC__metadata_simple_iterator_set_block() to
* write it back to the FLAC file.
diff --git a/src/libFLAC++/metadata.cpp b/src/libFLAC++/metadata.cpp
index 314f3595..f5e5ebc2 100644
--- a/src/libFLAC++/metadata.cpp
+++ b/src/libFLAC++/metadata.cpp
@@ -1336,12 +1336,33 @@ namespace FLAC {
return (bool)::FLAC__metadata_simple_iterator_prev(iterator_);
}
+ //@@@@ add to tests
+ bool SimpleIterator::is_last() const
+ {
+ FLAC__ASSERT(is_valid());
+ return (bool)::FLAC__metadata_simple_iterator_is_last(iterator_);
+ }
+
+ //@@@@ add to tests
+ off_t SimpleIterator::get_block_offset() const
+ {
+ FLAC__ASSERT(is_valid());
+ return ::FLAC__metadata_simple_iterator_get_block_offset(iterator_);
+ }
+
::FLAC__MetadataType SimpleIterator::get_block_type() const
{
FLAC__ASSERT(is_valid());
return ::FLAC__metadata_simple_iterator_get_block_type(iterator_);
}
+ //@@@@ add to tests
+ unsigned SimpleIterator::get_block_length() const
+ {
+ FLAC__ASSERT(is_valid());
+ return ::FLAC__metadata_simple_iterator_get_block_length(iterator_);
+ }
+
Prototype *SimpleIterator::get_block()
{
FLAC__ASSERT(is_valid());
diff --git a/src/libFLAC/metadata_iterators.c b/src/libFLAC/metadata_iterators.c
index 7a9ca7c0..8272844d 100644
--- a/src/libFLAC/metadata_iterators.c
+++ b/src/libFLAC/metadata_iterators.c
@@ -577,6 +577,22 @@ FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIte
return true;
}
+FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_last(const FLAC__Metadata_SimpleIterator *iterator)
+{
+ FLAC__ASSERT(0 != iterator);
+ FLAC__ASSERT(0 != iterator->file);
+
+ return iterator->is_last;
+}
+
+FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset(const FLAC__Metadata_SimpleIterator *iterator)
+{
+ FLAC__ASSERT(0 != iterator);
+ FLAC__ASSERT(0 != iterator->file);
+
+ return iterator->offset[iterator->depth];
+}
+
FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator)
{
FLAC__ASSERT(0 != iterator);
@@ -585,6 +601,14 @@ FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const
return iterator->type;
}
+FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length(const FLAC__Metadata_SimpleIterator *iterator)
+{
+ FLAC__ASSERT(0 != iterator);
+ FLAC__ASSERT(0 != iterator->file);
+
+ return iterator->length;
+}
+
FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Metadata_SimpleIterator *iterator)
{
FLAC__StreamMetadata *block = FLAC__metadata_object_new(iterator->type);