openPMD-api
 
Loading...
Searching...
No Matches
openPMD::Attribute Class Reference
Inheritance diagram for openPMD::Attribute:
openPMD::auxiliary::Variant< Datatype OPENPMD_FOREACH_DATATYPE(OPENPMD_ENUMERATE_TYPES)>

Classes

struct  from_any_tag
 

Public Member Functions

 Attribute (from_any_tag, std::any val)
 
template<typename U>
get () const
 Retrieve a stored specific Attribute and cast if convertible.
 
template<typename U>
std::optional< U > getOptional () const
 Retrieve a stored specific Attribute and cast if convertible.
 
template<typename U>
auto get_impl () const -> std::variant< U, std::runtime_error >
 
- Public Member Functions inherited from openPMD::auxiliary::Variant< Datatype OPENPMD_FOREACH_DATATYPE(OPENPMD_ENUMERATE_TYPES)>
 Variant (from_basic_type_tag, U)
 
 Variant (from_any_tag, std::any)
 
 Variant (U u)
 Construct a lightweight wrapper around a generic object that indicates the concrete datatype of the specific object stored.
 
U const & get () const
 Retrieve a stored specific object of known datatype with ensured type-safety.
 
variant_t const & getVariant () const
 Retrieve the stored generic object.
 
std::any const & getAny () const
 
size_t index () const
 Retrieve the index of the alternative that is currently been held.
 
U const & get () const
 
 Variant (from_basic_type_tag, U)
 
 Variant (from_any_tag, std::any)
 
 Variant (U u)
 Construct a lightweight wrapper around a generic object that indicates the concrete datatype of the specific object stored.
 
U const & get () const
 Retrieve a stored specific object of known datatype with ensured type-safety.
 
U const & get () const
 
variant_t const & getVariant () const
 Retrieve the stored generic object.
 
std::any const & getAny () const
 
size_t index () const
 Retrieve the index of the alternative that is currently been held.
 

Static Public Attributes

static constexpr from_any_tag from_any = from_any_tag{}
 
- Static Public Attributes inherited from openPMD::auxiliary::Variant< Datatype OPENPMD_FOREACH_DATATYPE(OPENPMD_ENUMERATE_TYPES)>
static constexpr from_basic_type_tag from_basic_type
 
static constexpr from_any_tag from_any
 
static constexpr from_basic_type_tag from_basic_type
 
static constexpr from_any_tag from_any
 

Additional Inherited Members

- Public Attributes inherited from openPMD::auxiliary::Variant< Datatype OPENPMD_FOREACH_DATATYPE(OPENPMD_ENUMERATE_TYPES)>
Datatype OPENPMD_FOREACH_DATATYPE dtype
 
Datatype OPENPMD_FOREACH_DATATYPE dtype
 

Member Function Documentation

◆ get()

template<typename U>
U openPMD::Attribute::get ( ) const

Retrieve a stored specific Attribute and cast if convertible.

Note
This performs a static_cast and might introduce precision loss if requested. Check dtype explicitly beforehand if needed.
Exceptions
std::runtime_errorif stored object is not static castable to U.
Template Parameters
UType of the object to be casted to.
Returns
Copy of the retrieved object, casted to type U.

◆ getOptional()

template<typename U>
std::optional< U > openPMD::Attribute::getOptional ( ) const

Retrieve a stored specific Attribute and cast if convertible.

Like Attribute::get<>(), but returns an empty std::optional if no conversion is possible instead of throwing an exception.

Note
This performs a static_cast and might introduce precision loss if requested. Check dtype explicitly beforehand if needed.
Template Parameters
UType of the object to be casted to.
Returns
Copy of the retrieved object, casted to type U. An empty std::optional if no conversion is possible.

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