PIP 5.5.3
Platform-Independent Primitives
Classes | Public Member Functions | List of all members
PIPropertyStorage Class Reference

This class provides key-value properties storage. More...

#include <pipropertystorage.h>

Classes

class  Property
 PIPropertyStorage element. More...
 

Public Member Functions

 PIPropertyStorage ()
 Contructs an empty PIPropertyStorage.
 
 PIPropertyStorage (const PIVector< Property > &pl)
 Contructs PIPropertyStorage with "pl" properties.
 
 PIPropertyStorage (PIVector< Property > &&o)
 Contructs PIPropertyStorage from another "o".
 
int length () const
 Returns properties count.
 
int size () const
 Returns properties count.
 
bool isEmpty () const
 Returns if no properties.
 
bool isNotEmpty () const
 Returns if properties.
 
Propertyfront ()
 Returns first property.
 
const Propertyfront () const
 Returns first property as const.
 
Propertyback ()
 Returns last property.
 
const Propertyback () const
 Returns last property as const.
 
void removeAt (int i)
 Remove property at index "i".
 
void clear ()
 Remove all properties.
 
PIPropertyStorage copy () const
 Returns copy of this PIPropertyStorage.
 
int propertiesCount () const
 Returns properties count.
 
PIVector< Property > & properties ()
 Returns properties as PIVector.
 
const PIVector< Property > & properties () const
 Returns properties as const PIVector.
 
bool isPropertyExists (const PIString &name) const
 Returns if properties with name "name" exists.
 
void clearProperties ()
 Remove all properties.
 
bool addProperty (const Property &p)
 Add property if name isn't present in storage, otherwrise update existing property with same name. More...
 
bool addProperty (const PIString &_name, const PIVariant &_def_value, const PIString &_comment=PIString(), int _flags=0)
 Add property if name isn't present in storage, otherwrise update existing property with same name. More...
 
bool removeProperty (const PIString &name)
 Remove property with name "name", returns if property removed.
 
int removePropertiesByFlag (int flag)
 Remove all properties with flag "flag" set, returns removed properties count. More...
 
void updateProperties (const PIVector< Property > &properties, int flag_ignore=0)
 Merge other "properties" into this. More...
 
Property propertyByName (const PIString &name) const
 Returns property with name "name" or default-constructed PIPropertyStorage::Property.
 
PIVariant propertyValueByName (const PIString &name) const
 Returns property value with name "name" or invalid PIVariant.
 
bool setPropertyValue (const PIString &name, const PIVariant &value)
 Set value of property with name "name" to "value", returns if property exists.
 
bool setPropertyComment (const PIString &name, const PIString &comment)
 Set comment of property with name "name" to "comment", returns if property exists.
 
bool setPropertyFlags (const PIString &name, int flags)
 Set flags of property with name "name" to "flags", returns if property exists.
 
PIPropertyStorageoperator<< (const PIPropertyStorage::Property &p)
 Add property "p".
 
PIPropertyStorageoperator<< (const PIVector< Property > &p)
 Add properties "p".
 
PIPropertyStorageoperator<< (const PIPropertyStorage &p)
 Add properties "p".
 
Propertyoperator[] (int i)
 Returns property with index "i".
 
const Propertyoperator[] (int i) const
 Returns property with index "i" as const.
 
Propertyoperator[] (const PIString &name)
 Returns property with name "name".
 
const Property operator[] (const PIString &name) const
 Returns property with name "name" as const.
 

Detailed Description

This class provides key-value properties storage.

Synopsis

Key-value storage, based on PIVector with PIPropertyStorage::Property elements. Each element in vector contains unique name. You can access property by name with propertyValueByName() or propertyByName(). You can add or replace property by addProperty(const Property&) or addProperty(const PIString&, const PIVariant&, const PIString&, int).

Example:

Member Function Documentation

◆ addProperty() [1/2]

bool PIPropertyStorage::addProperty ( const Property p)

Add property if name isn't present in storage, otherwrise update existing property with same name.

Returns "true" if new property added, else if update existing property return "false"

◆ addProperty() [2/2]

bool PIPropertyStorage::addProperty ( const PIString _name,
const PIVariant _def_value,
const PIString _comment = PIString(),
int  _flags = 0 
)

Add property if name isn't present in storage, otherwrise update existing property with same name.

Returns "true" if new property added, else if update existing property return "false"

◆ removePropertiesByFlag()

int PIPropertyStorage::removePropertiesByFlag ( int  flag)

Remove all properties with flag "flag" set, returns removed properties count.

"flag" checked as bitfield

◆ updateProperties()

void PIPropertyStorage::updateProperties ( const PIVector< Property > &  properties,
int  flag_ignore = 0 
)

Merge other "properties" into this.

"flag_ignore" is bitfield to ignore property in merge process