AvogadroLibs 2.1.0-20261111
Loading...
Searching...
No Matches
VariantMap Class Reference

The VariantMap class provides a map between string keys and variant values.

#include <avogadro/core/variantmap.h>

Public Types

using iterator = std::map<std::string, Variant>::iterator
using const_iterator = std::map<std::string, Variant>::const_iterator

Public Member Functions

 VariantMap ()=default
 VariantMap (const VariantMap &other)=default
VariantMap & operator= (const VariantMap &other)=default
 VariantMap (VariantMap &&other)=default
VariantMap & operator= (VariantMap &&other)=default
 ~VariantMap ()=default
size_t size () const
bool isEmpty () const
std::vector< std::string > names () const
void setValue (const std::string &name, const Variant &v)
Variant value (const std::string &name) const
bool hasValue (const std::string &name) const
void remove (const std::string &name)
void clear ()
iterator begin ()
const_iterator begin () const
const_iterator constBegin () const
iterator end ()
const_iterator end () const
const_iterator constEnd () const

Constructor & Destructor Documentation

◆ VariantMap() [1/2]

VariantMap ( )
default

Creates a new variant map object.

◆ VariantMap() [2/2]

VariantMap ( VariantMap && other)
default

Move operations are declared explicitly: the defaulted destructor below would otherwise suppress them, and moving a molecule would silently fall back to copying the whole map.

◆ ~VariantMap()

~VariantMap ( )
default

Destroys the variant map.

Member Function Documentation

◆ size()

size_t size ( ) const

Returns the size of the variant map.

◆ isEmpty()

bool isEmpty ( ) const

Returns true if the variant map is empty (i.e. size() == 0).

◆ names()

std::vector< std::string > names ( ) const

Returns the names of the entries in the map.

◆ setValue()

void setValue ( const std::string & name,
const Variant & v )

Sets the value of name to v.

◆ value()

Variant value ( const std::string & name) const

Returns the value for name. If name is not found a null variant is returned.

◆ hasValue()

bool hasValue ( const std::string & name) const

Returns true if the key exists in the map.

◆ remove()

void remove ( const std::string & name)

Removes the entry for name from the map. Nothing happens if there is no such entry.

◆ clear()

void clear ( )

Clears the map.

◆ begin() [1/2]

iterator begin ( )

Return an iterator pointing to the beginning of the map.

◆ begin() [2/2]

const_iterator begin ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ constBegin()

const_iterator constBegin ( ) const

Return a const_iterator pointing to the beginning of the map.

◆ end() [1/2]

iterator end ( )

Return an iterator pointing to the end of the map.

◆ end() [2/2]

const_iterator end ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ constEnd()

const_iterator constEnd ( ) const

Return a const_iterator pointing to the end of the map.


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