QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
Public Member Functions | Protected Attributes | List of all members
QgsObjectCustomProperties Class Reference

Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML in. More...

#include <qgsobjectcustomproperties.h>

Public Member Functions

 QgsObjectCustomProperties ()=default
 Constructor for QgsObjectCustomProperties. More...
 
bool contains (const QString &key) const
 Returns true if the properties contains a key with the specified name. More...
 
QStringList keys () const
 Returns a list of all stored keys. More...
 
void readXml (const QDomNode &parentNode, const QString &keyStartsWith=QString())
 Read store contents from an XML node. More...
 
void remove (const QString &key)
 Removes a key (entry) from the store. More...
 
void setValue (const QString &key, const QVariant &value)
 Add an entry to the store with the specified key. More...
 
QVariant value (const QString &key, const QVariant &defaultValue=QVariant()) const
 Returns the value for the given key. More...
 
void writeXml (QDomNode &parentNode, QDomDocument &doc) const
 Writes the store contents to an XML node. More...
 

Protected Attributes

QMap< QString, QVariant > mMap
 

Detailed Description

Simple key-value store (keys = strings, values = variants) that supports loading/saving to/from XML in.

<customproperties> 

element.

Since
QGIS 2.4

Definition at line 35 of file qgsobjectcustomproperties.h.

Constructor & Destructor Documentation

◆ QgsObjectCustomProperties()

QgsObjectCustomProperties::QgsObjectCustomProperties ( )
default

Constructor for QgsObjectCustomProperties.

Member Function Documentation

◆ contains()

bool QgsObjectCustomProperties::contains ( const QString &  key) const

Returns true if the properties contains a key with the specified name.

Since
QGIS 3.14

Definition at line 46 of file qgsobjectcustomproperties.cpp.

◆ keys()

QStringList QgsObjectCustomProperties::keys ( ) const

Returns a list of all stored keys.

Definition at line 26 of file qgsobjectcustomproperties.cpp.

◆ readXml()

void QgsObjectCustomProperties::readXml ( const QDomNode &  parentNode,
const QString &  keyStartsWith = QString() 
)

Read store contents from an XML node.

Parameters
parentNodenode to read from
keyStartsWithreads only properties starting with the specified string (or all if the string is empty)
See also
writeXml()

Definition at line 51 of file qgsobjectcustomproperties.cpp.

◆ remove()

void QgsObjectCustomProperties::remove ( const QString &  key)

Removes a key (entry) from the store.

Definition at line 41 of file qgsobjectcustomproperties.cpp.

◆ setValue()

void QgsObjectCustomProperties::setValue ( const QString &  key,
const QVariant &  value 
)

Add an entry to the store with the specified key.

If an entry with the same key exists already, it will be overwritten.

Definition at line 31 of file qgsobjectcustomproperties.cpp.

◆ value()

QVariant QgsObjectCustomProperties::value ( const QString &  key,
const QVariant &  defaultValue = QVariant() 
) const

Returns the value for the given key.

If the key is not present in the properties, the defaultValue will be returned.

Definition at line 36 of file qgsobjectcustomproperties.cpp.

◆ writeXml()

void QgsObjectCustomProperties::writeXml ( QDomNode &  parentNode,
QDomDocument &  doc 
) const

Writes the store contents to an XML node.

See also
readXml()

Definition at line 130 of file qgsobjectcustomproperties.cpp.

Member Data Documentation

◆ mMap

QMap<QString, QVariant> QgsObjectCustomProperties::mMap
protected

Definition at line 92 of file qgsobjectcustomproperties.h.


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