add FLAC__metadata_simple_iterator_get_block_offset(), FLAC__metadata_simple_iterator...
authorJosh Coalson <jcoalson@users.sourceforce.net>
Tue, 14 Aug 2007 00:34:50 +0000 (00:34 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Tue, 14 Aug 2007 00:34:50 +0000 (00:34 +0000)
doc/html/changelog.html
include/FLAC++/metadata.h
include/FLAC/metadata.h
src/libFLAC++/metadata.cpp
src/libFLAC/metadata_iterators.c

index 5598647..fb949d7 100644 (file)
                                        <li>
                                                libFLAC:
                                                <ul>
-                                                       <li>(none)</li>
+                                                       <li><b>Added</b> FLAC__metadata_simple_iterator_is_last()</li>
+                                                       <li><b>Added</b> FLAC__metadata_simple_iterator_get_block_offset()</li>
+                                                       <li><b>Added</b> FLAC__metadata_simple_iterator_get_block_length()</li>
                                                </ul>
                                        </li>
                                        <li>
                                                libFLAC++:
                                                <ul>
-                                                       <li>(none)</li>
+                                                       <li><b>Added</b> FLAC::Metadata::SimpleIterator::is_last()</li>
+                                                       <li><b>Added</b> FLAC::Metadata::SimpleIterator::get_block_offset()</li>
+                                                       <li><b>Added</b> FLAC::Metadata::SimpleIterator::get_block_length()</li>
                                                </ul>
                                        </li>
                                </ul>
index e2ba5c5..abe2def 100644 (file)
@@ -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().
index 0f21dec..6ee8036 100644 (file)
@@ -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
+ *    <a href="http://flac.sourceforge.net/format.html#metadata_block_header">metadata block header</a>,
+ *    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.
index 314f359..f5e5ebc 100644 (file)
@@ -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());
index 7a9ca7c..8272844 100644 (file)
@@ -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);