libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
Metadata Class Reference

Key-value metadata container using typed Variant values. More...

#include <metadata.h>

Public Types

enum  ID {
  Invalid , Timecode , Gamma , Title ,
  Copyright , Software , Artist , Comment ,
  Date , Album , License , TrackNumber ,
  Genre , EnableBWF , Description , Originator ,
  OriginatorReference , OriginationDateTime , FrameRate , UMID ,
  CodingHistory , CompressionLevel , EnableVBR , VBRQuality ,
  CompressedSize , EndOfStream
}
 
using Ptr = SharedPtr< Metadata >
 Shared pointer type for Metadata.
 

Public Member Functions

 Metadata ()=default
 Constructs an empty Metadata object.
 
template<typename T >
void set (ID id, const T &value)
 Sets a metadata value for the given ID.
 
const Variantget (ID id) const
 Returns the Variant value for the given ID.
 
bool contains (ID id) const
 Returns true if the given ID has been set.
 
void remove (ID id)
 Removes the entry for the given ID.
 
void clear ()
 Removes all metadata entries.
 
size_t size () const
 Returns the number of metadata entries.
 
bool isEmpty () const
 Returns true if no metadata entries are stored.
 
template<typename Func >
void forEach (Func &&func) const
 Iterates over all metadata entries, invoking a callback for each.
 
StringList dump () const
 Returns a human-readable dump of all metadata entries.
 
bool operator== (const Metadata &other) const
 Returns true if both Metadata objects contain the same entries.
 
JsonObject toJson () const
 Serializes this Metadata to a JSON object.
 

Static Public Member Functions

static const StringidToString (ID id)
 Converts a metadata ID to its string name.
 
static ID stringToID (const String &val)
 Converts a string name to a metadata ID.
 
static Metadata fromJson (const JsonObject &json, Error *err=nullptr)
 Deserializes a Metadata object from a JSON object.
 

Detailed Description

Key-value metadata container using typed Variant values.

Stores metadata entries keyed by a well-known ID enum. Each value is stored as a Variant, supporting types such as String, int, double, bool, Timecode, and Rational. Supports JSON serialization

Example
meta.set(Metadata::Title, String("My Video"));
meta.set(Metadata::FrameRate, Rational<int>(24, 1));
String title = meta.value(Metadata::Title).get<String>();
bool has = meta.isSet(Metadata::Copyright); // false
Dynamic array container wrapping std::vector.
Definition list.h:40
bool set(size_t index, const T &val)
Sets an item in the list by index.
Definition list.h:541
Key-value metadata container using typed Variant values.
Definition metadata.h:68
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
and deserialization. When shared ownership is needed, use Metadata::Ptr.

Member Enumeration Documentation

◆ ID

Enumerator
CompressedSize 

Internal: allocation hint for compressed pixel formats. Use Image::compressedSize() instead.

EndOfStream 

Signals end-of-stream to downstream nodes.

Member Function Documentation

◆ contains()

bool Metadata::contains ( ID  id) const
inline

Returns true if the given ID has been set.

Parameters
idThe metadata key.
Returns
true if the key exists.

◆ dump()

StringList Metadata::dump ( ) const

Returns a human-readable dump of all metadata entries.

Returns
A StringList with one entry per metadata key-value pair.

◆ forEach()

template<typename Func >
void Metadata::forEach ( Func &&  func) const
inline

Iterates over all metadata entries, invoking a callback for each.

Template Parameters
FuncCallable type with signature void(ID, const Variant &).
Parameters
funcThe callback to invoke for each entry.

◆ fromJson()

static Metadata Metadata::fromJson ( const JsonObject json,
Error err = nullptr 
)
static

Deserializes a Metadata object from a JSON object.

Parameters
jsonThe source JSON object.
errOptional error output.
Returns
The deserialized Metadata.

◆ get()

const Variant & Metadata::get ( ID  id) const
inline

Returns the Variant value for the given ID.

Parameters
idThe metadata key.
Returns
A const reference to the Variant value.

◆ idToString()

static const String & Metadata::idToString ( ID  id)
static

Converts a metadata ID to its string name.

Parameters
idThe metadata ID.
Returns
A const reference to the name string.

◆ isEmpty()

bool Metadata::isEmpty ( ) const
inline

Returns true if no metadata entries are stored.

Returns
true if empty.

◆ operator==()

bool Metadata::operator== ( const Metadata other) const
inline

Returns true if both Metadata objects contain the same entries.

Parameters
otherThe Metadata to compare against.
Returns
true if equal.

◆ remove()

void Metadata::remove ( ID  id)
inline

Removes the entry for the given ID.

Parameters
idThe metadata key to remove.

◆ set()

template<typename T >
void Metadata::set ( ID  id,
const T value 
)
inline

Sets a metadata value for the given ID.

Template Parameters
TThe value type.
Parameters
idThe metadata key.
valueThe value to store.

◆ size()

size_t Metadata::size ( ) const
inline

Returns the number of metadata entries.

Returns
The entry count.

◆ stringToID()

static ID Metadata::stringToID ( const String val)
static

Converts a string name to a metadata ID.

Parameters
valThe name string.
Returns
The corresponding ID, or Invalid if not found.

◆ toJson()

JsonObject Metadata::toJson ( ) const
inline

Serializes this Metadata to a JSON object.

Returns
A JsonObject containing all metadata entries.

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