kDB: Knowledge DataBase
Loading...
Searching...
No Matches
knowCore::ValueHash Class Reference

#include <ValueHash.h>

Classes

struct  Private
 

Public Member Functions

template<typename _T_ , typename... _TOther_>
 ValueHash (const QString &_key, const _T_ &_t, const _TOther_ &...)
 
 ValueHash (const QHash< QString, Value > &_value)
 
 ValueHash (const ValueHash &_list)
 
 ValueHash (ValueHash &&_list)
 
ValueHash operator= (const ValueHash &_list)
 
int size () const
 
QStringList keys () const
 
Value value (const QString &_key) const
 
template<typename _T_ >
cres_qresult< _T_ > value (const QString &_key) const
 
template<typename _T_ >
cres_qresult< _T_ > value (const QString &_key, const _T_ &_default) const
 
bool contains (const QString &_key) const
 
bool contains (const QString &_key, const knowCore::Uri &_datatype) const
 
template<typename _T_ >
bool contains (const QString &_key) const
 
cres_qresult< void > ensureContains (const QString &_key, const knowCore::Uri &_datatype) const
 
template<typename _T_ >
cres_qresult< void > ensureContains (const QString &_key) const
 
template<typename _T_ >
cres_qresult< QHash< QString, _T_ > > hash () const
 
QHash< QString, Valuehash () const
 
template<typename _T_ >
cres_qresult< QMap< QString, _T_ > > map () const
 
QMap< QString, Valuemap () const
 
template<typename _T_ >
cres_qresult< QList< _T_ > > values () const
 
QList< Valuevalues () const
 
bool operator== (const ValueHash &_rhs) const
 
bool operator!= (const ValueHash &_rhs) const
 
bool operator== (const QHash< QString, Value > &_rhs) const
 
cres_qresult< QByteArray > md5 () const
 
cres_qresult< QJsonValue > toJsonValue (const SerialisationContexts &_contexts) const
 
cres_qresult< QCborValue > toCborValue (const SerialisationContexts &_contexts) const
 
cres_qresult< QString > printable () const
 
QVariantHash toVariantHash () const
 
QVariantMap toVariantMap () const
 
QVariant toVariant () const
 
cres_qresult< void > checkContainsOnly (const Uri &_uri) const
 
template<typename _T_ >
cres_qresult< void > checkContainsOnly () const
 
 operator Value () const
 
template<typename _T_ >
ValueHashinsert (const QString &_key, const _T_ &_value)
 
template<typename _T_ , typename... _TOther_>
ValueHashinsert (const QString &_key, const _T_ &_value, const QString &_key_n, const _TOther_ &... _other)
 
ValueHashinsert (const QString &_key, const knowCore::Value &_value)
 
cres_qresult< void > insert (const QString &_key, const QVariant &_value)
 
cres_qresult< void > insert (const QVariantHash &_value)
 
ValueHashinsert (const knowCore::ValueHash &_value)
 
cres_qresult< void > insert (const QVariantMap &_value)
 
cres_qresult< void > insert (const QJsonObject &_value)
 
ValueHashremove (const QString &_key)
 
void clear ()
 
template<typename _T_ , typename... _TOther_>
 ValueHash (const QString &_key, const _T_ &_t, const _TOther_ &... _other)
 

Static Public Member Functions

static cres_qresult< ValueHashfromVariantMap (const QVariantMap &_map)
 
static cres_qresult< ValueHashfromVariantHash (const QVariantHash &_map)
 
static cres_qresult< ValueHashparseVariantMap (const QVariantMap &_value)
 
static cres_qresult< ValueHashfromJsonValue (const QJsonValue &_value, const DeserialisationContexts &_contexts)
 
static cres_qresult< ValueHashfromCborValue (const QCborValue &_value, const DeserialisationContexts &_contexts)
 

Detailed Description

Represent a (key, value) where key are strings for integration with knowCore::Value.

Member Function Documentation

◆ checkContainsOnly()

cres_qresult< void > ValueHash::checkContainsOnly ( const Uri & _uri) const

Check that the list only contains value of type _uri. It returns success if that is true. It returns a failure with an error message in case a value has a different type in the list.

◆ clear()

void ValueHash::clear ( )

Clear the hash.

◆ contains() [1/3]

bool ValueHash::contains ( const QString & _key) const
Returns
if the value is contained in the hash.

◆ contains() [2/3]

template<typename _T_ >
bool knowCore::ValueHash::contains ( const QString & _key) const
Returns
if the value is contained in the hash and is of type _T_.

◆ contains() [3/3]

bool ValueHash::contains ( const QString & _key,
const knowCore::Uri & _datatype ) const
Returns
if the value is contained in the hash and has the given _datatype.

◆ ensureContains() [1/2]

template<typename _T_ >
cres_qresult< void > knowCore::ValueHash::ensureContains ( const QString & _key) const
Returns
if the value is contained in the hash and is of type _T_.

◆ ensureContains() [2/2]

cres_qresult< void > ValueHash::ensureContains ( const QString & _key,
const knowCore::Uri & _datatype ) const
Returns
if the value is contained in the hash and has the given _datatype.

◆ hash() [1/2]

template<typename _T_ >
cres_qresult< QHash< QString, _T_ > > knowCore::ValueHash::hash ( ) const
inline
Returns
attempt to return as a hash of a specific type
  • T if they are convertible to
  • T

◆ hash() [2/2]

QHash< QString, Value > ValueHash::hash ( ) const
Returns
the underlying QHash<QString, Value>

◆ insert() [1/8]

ValueHash & ValueHash::insert ( const knowCore::ValueHash & _value)

Merge a QVariantHash into the hash.

◆ insert() [2/8]

cres_qresult< void > ValueHash::insert ( const QJsonObject & _value)

Attempt to insert the content of a QJsonObject to the hash.

◆ insert() [3/8]

template<typename _T_ >
ValueHash & knowCore::ValueHash::insert ( const QString & _key,
const _T_ & _value )
inline

Add a value to the hash with the given key.

◆ insert() [4/8]

template<typename _T_ , typename... _TOther_>
ValueHash & knowCore::ValueHash::insert ( const QString & _key,
const _T_ & _value,
const QString & _key_n,
const _TOther_ &... _other )
inline

Add a set of keys/values to the hash.

◆ insert() [5/8]

ValueHash & ValueHash::insert ( const QString & _key,
const knowCore::Value & _value )

Add a value to the hash with the given key.

◆ insert() [6/8]

cres_qresult< void > ValueHash::insert ( const QString & _key,
const QVariant & _value )

Add a value from variant. This can potentially trigger a failure that is detected at create.

◆ insert() [7/8]

cres_qresult< void > ValueHash::insert ( const QVariantHash & _value)

Merge a QVariantHash into the hash.

◆ insert() [8/8]

cres_qresult< void > ValueHash::insert ( const QVariantMap & _value)

Merge a QVariantMap into the hash.

◆ keys()

QStringList ValueHash::keys ( ) const
Returns
the list of keys

◆ map() [1/2]

template<typename _T_ >
cres_qresult< QMap< QString, _T_ > > knowCore::ValueHash::map ( ) const
inline
Returns
attempt to return as a map of a specific type
  • T if they are convertible to
  • T

◆ map() [2/2]

QMap< QString, Value > knowCore::ValueHash::map ( ) const
inline
Returns
convert the underlying hash into a QMap<QString, Value>

◆ operator Value()

knowCore::ValueHash::operator Value ( ) const
inline

Allow direct casting to Value.

◆ remove()

ValueHash & ValueHash::remove ( const QString & _key)

Remove the _key.

◆ size()

int ValueHash::size ( ) const
Returns
the number of elements in the hash

◆ toVariantHash()

QVariantHash ValueHash::toVariantHash ( ) const
Returns
a variant hash representation

◆ toVariantMap()

QVariantMap ValueHash::toVariantMap ( ) const
Returns
a variant map representation

◆ value() [1/3]

Value ValueHash::value ( const QString & _key) const
Returns
the value for the given
  • _key or an empty value

◆ value() [2/3]

template<typename _T_ >
cres_qresult< _T_ > knowCore::ValueHash::value ( const QString & _key) const
inline
Returns
attempt to return the value for the given
  • _key if convertible to
  • T

◆ value() [3/3]

template<typename _T_ >
cres_qresult< _T_ > knowCore::ValueHash::value ( const QString & _key,
const _T_ & _default ) const
inline
Returns
attempt to return the value for the given
  • _key if convertible to
  • T

◆ values() [1/2]

template<typename _T_ >
cres_qresult< QList< _T_ > > knowCore::ValueHash::values ( ) const
Returns
attempt to return the values if they are convertible to
  • T

◆ values() [2/2]

QList< Value > knowCore::ValueHash::values ( ) const
inline
Returns
return the list of values

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