SoundFontInfoLib  2.21.6
Library for parsing and rendering SF2 files
SF2::IO::ChunkItems< T > Class Template Reference

Container of SF2 entities. More...

#include <ChunkItems.hpp>

Inherits SF2::IO::ChunkItemsSupport.

Public Types

using ItemType = T
 
using ItemCollection = std::vector< ItemType >
 
using const_iterator = typename std::vector< ItemType >::const_iterator
 
using ItemRefCollection = std::vector< std::reference_wrapper< ItemType const > >
 

Public Member Functions

 ChunkItems ()
 Constructor for an empty collection. More...
 
 ChunkItems (const ChunkList &source)
 Constructor that loads items from the file. More...
 
size_t size () const
 Get the number of items in this collection. More...
 
bool empty () const
 Determine if collection is empty. More...
 
const ItemTypeoperator[] (size_t index) const
 Obtain a (read-only) reference to an entity in the collection. More...
 
ItemRefCollection slice (size_t first, size_t count) const
 Obtain a read-only slice of the original collection. More...
 
const_iterator begin () const
 Obtain iterator to the start of the collection. More...
 
const_iterator end () const
 Obtain iterator at the end of the collection. More...
 
void dump (const std::string &indent) const
 Utility to dump out the contents of the collection. More...
 

Static Public Attributes

static constexpr size_t itemSize = T::size
 Definition of the size in bytes of each item in the collection. More...
 

Friends

class File
 

Detailed Description

template<typename T>
class SF2::IO::ChunkItems< T >

Container of SF2 entities.

All SF2 containers are homogenous (all entities in the container have the same type). Compared to the ChunkType type, this class holds actual values from an SF2 file while the former just knows where in the file to find the values.

Like most of the IO namespace, instances of this class are essentially immutable.

  • T is the entity type to hold in this container

Member Typedef Documentation

◆ const_iterator

template<typename T >
using SF2::IO::ChunkItems< T >::const_iterator = typename std::vector<ItemType>::const_iterator

◆ ItemCollection

template<typename T >
using SF2::IO::ChunkItems< T >::ItemCollection = std::vector<ItemType>

◆ ItemRefCollection

template<typename T >
using SF2::IO::ChunkItems< T >::ItemRefCollection = std::vector<std::reference_wrapper<ItemType const> >

◆ ItemType

template<typename T >
using SF2::IO::ChunkItems< T >::ItemType = T

Constructor & Destructor Documentation

◆ ChunkItems() [1/2]

template<typename T >
SF2::IO::ChunkItems< T >::ChunkItems ( )
inline

Constructor for an empty collection.

◆ ChunkItems() [2/2]

template<typename T >
SF2::IO::ChunkItems< T >::ChunkItems ( const ChunkList source)
inlineexplicit

Constructor that loads items from the file.

Parameters
sourcedefines where to load and how many items to load

Member Function Documentation

◆ begin()

template<typename T >
const_iterator SF2::IO::ChunkItems< T >::begin ( ) const
inline

Obtain iterator to the start of the collection.

Returns
iterator to start of the collection

Referenced by SF2::IO::ChunkItems< T >::dump().

◆ dump()

template<typename T >
void SF2::IO::ChunkItems< T >::dump ( const std::string &  indent) const
inline

Utility to dump out the contents of the collection.

Parameters
indentthe prefix to use for all output

References SF2::IO::ChunkItems< T >::begin(), SF2::IO::ChunkItemsSupport::beginDump(), SF2::IO::ChunkItems< T >::end(), and SF2::IO::ChunkItems< T >::size().

Referenced by SF2::IO::File::dump().

◆ empty()

template<typename T >
bool SF2::IO::ChunkItems< T >::empty ( ) const
inline

Determine if collection is empty.

Returns
true if so

◆ end()

template<typename T >
const_iterator SF2::IO::ChunkItems< T >::end ( ) const
inline

Obtain iterator at the end of the collection.

Returns
iterator at the end of the collection

Referenced by SF2::IO::ChunkItems< T >::dump().

◆ operator[]()

template<typename T >
const ItemType& SF2::IO::ChunkItems< T >::operator[] ( size_t  index) const
inline

Obtain a (read-only) reference to an entity in the collection.

Parameters
indexthe entity to fetch
Returns
entity reference

◆ size()

template<typename T >
size_t SF2::IO::ChunkItems< T >::size ( ) const
inline

Get the number of items in this collection.

Returns
collection count

Referenced by SF2::IO::ChunkItems< T >::dump(), and SF2::IO::ChunkItems< T >::slice().

◆ slice()

template<typename T >
ItemRefCollection SF2::IO::ChunkItems< T >::slice ( size_t  first,
size_t  count 
) const
inline

Obtain a read-only slice of the original collection.

Parameters
firstthe index of the first item to include in the collection
countthe number of items to have in the slice
Returns
the sliced references

References SF2::IO::ChunkItems< T >::size().

Friends And Related Function Documentation

◆ File

template<typename T >
friend class File
friend

Member Data Documentation

◆ itemSize

template<typename T >
constexpr size_t SF2::IO::ChunkItems< T >::itemSize = T::size
staticconstexpr

Definition of the size in bytes of each item in the collection.


The documentation for this class was generated from the following file: