Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
unity::scopes::SearchMetadata Class Referencefinal

Metadata passed with search requests. More...

#include <unity/scopes/SearchMetadata.h>

Public Member Functions

 SearchMetadata (std::string const &locale, std::string const &form_factor)
 Create SearchMetadata with given locale and form factor. More...
 
 SearchMetadata (int cardinality, std::string const &locale, std::string const &form_factor)
 Create SearchMetadata with given cardinality, locale and form factor. More...
 
std::string locale () const
 Get the locale string. More...
 
std::string form_factor () const
 Get the form factor string. More...
 
void set_cardinality (int cardinality)
 Set cardinality. More...
 
int cardinality () const
 Get cardinality. More...
 
void set_hint (std::string const &key, Variant const &value)
 Sets a hint. More...
 
VariantMap hints () const
 Get all hints. More...
 
bool contains_hint (std::string const &key) const
 Check if this SearchMetadata has a hint. More...
 
Variantoperator[] (std::string const &key)
 Returns a reference to a hint. More...
 
Variant const & operator[] (std::string const &key) const
 Returns a const reference to a hint. More...
 
Copy and assignment

Copy and assignment operators (move and non-move versions) have the usual value semantics.

 SearchMetadata (SearchMetadata const &other)
 
 SearchMetadata (SearchMetadata &&)
 
SearchMetadataoperator= (SearchMetadata const &other)
 
SearchMetadataoperator= (SearchMetadata &&)
 

Detailed Description

Metadata passed with search requests.

Constructor & Destructor Documentation

unity::scopes::SearchMetadata::SearchMetadata ( std::string const &  locale,
std::string const &  form_factor 
)

Create SearchMetadata with given locale and form factor.

Parameters
localelocale string, eg. en_EN
form_factorform factor name, e.g. phone, desktop, phone-version etc.
unity::scopes::SearchMetadata::SearchMetadata ( int  cardinality,
std::string const &  locale,
std::string const &  form_factor 
)

Create SearchMetadata with given cardinality, locale and form factor.

Parameters
cardinalitymaximum number of search results
localelocale string, eg. en_EN
form_factorform factor name, e.g. phone, desktop, phone-version etc.

Member Function Documentation

int unity::scopes::SearchMetadata::cardinality ( ) const

Get cardinality.

Returns
The maxmium number of search results, or 0 for no limit.
bool unity::scopes::SearchMetadata::contains_hint ( std::string const &  key) const

Check if this SearchMetadata has a hint.

Parameters
keyThe hint name.
Returns
True if the hint is set.
std::string unity::scopes::SearchMetadata::form_factor ( ) const

Get the form factor string.

Returns
The form factor string
VariantMap unity::scopes::SearchMetadata::hints ( ) const

Get all hints.

Returns
Hints dictionary.
std::string unity::scopes::SearchMetadata::locale ( ) const

Get the locale string.

Returns
The locale string
Variant & unity::scopes::SearchMetadata::operator[] ( std::string const &  key)

Returns a reference to a hint.

This method can be used to read or set hints. Setting a value of an existing hint overwrites its previous value. Referencing a non-existing hint automatically creates it with a default value of Variant::Type::Null.

Parameters
keyThe name of the hint.
Returns
A reference to the hint.
Variant const & unity::scopes::SearchMetadata::operator[] ( std::string const &  key) const

Returns a const reference to a hint.

This method can be used for read-only access to hints. Referencing a non-existing hint throws unity::InvalidArgumentException.

Parameters
keyThe name of the hint.
Returns
A const reference to the hint.
Exceptions
unity::LogicExceptionif no hint with the given name exists.
void unity::scopes::SearchMetadata::set_cardinality ( int  cardinality)

Set cardinality.

Parameters
cardinalityThe maximum number of search results.
void unity::scopes::SearchMetadata::set_hint ( std::string const &  key,
Variant const &  value 
)

Sets a hint.

Parameters
keyThe name of the hint.
valueHint value

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