51Degrees Device Detection C/C++  4.1

A device detection library that is used natively or by 51Degrees products

FiftyoneDegrees::Common::ResultsBase Class Reference abstract

Detailed Description

Encapsulates the results of an engine's processing.

The class is constructed using an instance of a C fiftyoneDegreesResultsBase structure which is then referenced to return associated values and metrics. Any memory used by the results is freed by the extending class.

Values contained in a results instance can be returned as a string, or as a type specified by the method used to fetch the value. For example, the getValueAsBool(int) method returns a value as a bool instead of a string representation.

The key used to get the value for a property can be either the name of the property, or the index of the property in the required properties structure.

Results instances should only be created by a Engine.

Usage Example

using namespace FiftyoneDegrees::Common;
ResultsBase *results;
// Iterate over all property indexes
for (int i = 0; i < results->getAvailableProperties(); i++) {
// Get the value for the property as a string
string value = *results->getValueAsString(i);
// Do something with the value
// ...
}
// Or get a value using the name of the property
string value = *results->getValueAsString("name of a property");
// Delete the results
delete results;

Inheritance diagram for FiftyoneDegrees::Common::ResultsBase:

[legend]

Collaboration diagram for FiftyoneDegrees::Common::ResultsBase:

[legend]

Public Member Functions

Constructors and Destructors

 ResultsBase (fiftyoneDegreesResultsBase *results, shared_ptr< fiftyoneDegreesResourceManager > manager)
Create a new instance of Results from the results structure provided. More...
virtual  ~ResultsBase ()
Free any memory associated with the results and release any resource handles.

Available Properties

int  getAvailableProperties ()
Get the number of available properties contained in the Results instance. More...
bool  containsProperty (const string &propertyName)
Get whether or not this results instance contains a value for the requested property. More...
vector< string >  getProperties ()
Get the names of the properties which are available in the Results instance. More...
string  getPropertyName (int requiredPropertyIndex)
Get the name of the property at the require property index, or an empty string if the required property index is invalid. More...

Value Getters

Value< vector< string > >  getValues (const char *propertyName)
Get a vector with all values associated with the required property name. More...
Value< vector< string > >  getValues (const string &propertyName)
Get a vector with all values associated with the required property name. More...
Value< vector< string > >  getValues (const string *propertyName)
Get a vector with all values associated with the required property name. More...
Value< vector< string > >  getValues (int requiredPropertyIndex)
Get a vector with all values associated with the required property index. More...
Value< string >  getValueAsString (const char *propertyName)
Get a string representation of the value associated with the required property name. More...
Value< string >  getValueAsString (const string &propertyName)
Get a string representation of the value associated with the required property name. More...
Value< string >  getValueAsString (const string *propertyName)
Get a string representation of the value associated with the required property name. More...
Value< string >  getValueAsString (int requiredPropertyIndex)
Get a string representation of the value associated with the required property index. More...
Value< bool >  getValueAsBool (const char *propertyName)
Get a boolean representation of the value associated with the required property name. More...
Value< bool >  getValueAsBool (const string &propertyName)
Get a boolean representation of the value associated with the required property name. More...
Value< bool >  getValueAsBool (const string *propertyName)
Get a boolean representation of the value associated with the required property name. More...
Value< bool >  getValueAsBool (int requiredPropertyIndex)
Get a boolean representation of the value associated with the required property index. More...
Value< int >  getValueAsInteger (const char *propertyName)
Get an integer representation of the value associated with the required property name. More...
Value< int >  getValueAsInteger (const string &propertyName)
Get an integer representation of the value associated with the required property name. More...
Value< int >  getValueAsInteger (const string *propertyName)
Get an integer representation of the value associated with the required property name. More...
Value< int >  getValueAsInteger (int requiredPropertyIndex)
Get an integer representation of the value associated with the required property index. More...
Value< double >  getValueAsDouble (const char *propertyName)
Get a double representation of the value associated with the required property name. More...
Value< double >  getValueAsDouble (const string &propertyName)
Get a double representation of the value associated with the required property name. More...
Value< double >  getValueAsDouble (const string *propertyName)
Get a double representation of the value associated with the required property name. More...
Value< double >  getValueAsDouble (int requiredPropertyIndex)
Get a double representation of the value associated with the required property index. More...

Protected Member Functions

int  getRequiredPropertyIndex (const char *propertyName)
Get the index in the available properties for the property name provided. More...
virtual void  getValuesInternal (int requiredPropertyIndex, vector< string > &values)=0
Get the values for the index in required properties and add them to the values vector supplied. More...
virtual bool  hasValuesInternal (int requiredPropertyIndex)=0
Get whether or not there are valid values available for the property identified by its index in the required properties. More...
virtual const char *  getNoValueMessageInternal (fiftyoneDegreesResultsNoValueReason reason)=0
Get the message explaining the reason for missing values. More...
virtual fiftyoneDegreesResultsNoValueReason  getNoValueReasonInternal (int requiredPropertyIndex)=0
Get the reason for values not being available. More...

Protected Attributes

fiftyoneDegreesPropertiesAvailable *  available
Pointer to the underlying available properties structure. More...

Constructor & Destructor Documentation

◆ ResultsBase()

FiftyoneDegrees::Common::ResultsBase::ResultsBase ( fiftyoneDegreesResultsBase *   results,
shared_ptr< fiftyoneDegreesResourceManager >   manager  
)

Create a new instance of Results from the results structure provided.

This method should only be called from inside an engine's process method.

Parameters
results - pointer to the underlying results structure
manager - shared pointer to the manager which manages the data set used to create the results. This is needed for thread-safe operation, see local variable description for more info.

Member Function Documentation

◆ containsProperty()

bool FiftyoneDegrees::Common::ResultsBase::containsProperty ( const string &   propertyName )

Get whether or not this results instance contains a value for the requested property.

Parameters
propertyName - name of the property to check for
Returns
true if there is a value for the requested property

◆ getAvailableProperties()

int FiftyoneDegrees::Common::ResultsBase::getAvailableProperties ( )

Get the number of available properties contained in the Results instance.

Returns
the number of available properties

◆ getNoValueMessageInternal()

virtual const char* FiftyoneDegrees::Common::ResultsBase::getNoValueMessageInternal ( fiftyoneDegreesResultsNoValueReason   reason )
protected pure virtual

Get the message explaining the reason for missing values.

This can differ slightly between APIs, so the implementation of this is left up to the extending class. This is used when populating a Value instance to return.

Parameters
reason - the enum indicating the reason no values are available
Returns
string explaining the reason in more detail

Implemented in FiftyoneDegrees::DeviceDetection::Hash::ResultsHash.

◆ getNoValueReasonInternal()

virtual fiftyoneDegreesResultsNoValueReason FiftyoneDegrees::Common::ResultsBase::getNoValueReasonInternal ( int   requiredPropertyIndex )
protected pure virtual

Get the reason for values not being available.

This is implemented by the extending class and is called when the hasValuesInternal method returns false.

Parameters
requiredPropertyIndex - index in the available properties
Returns
enum indicating the reason for values not being available

Implemented in FiftyoneDegrees::DeviceDetection::Hash::ResultsHash.

◆ getProperties()

vector<string> FiftyoneDegrees::Common::ResultsBase::getProperties ( )

Get the names of the properties which are available in the Results instance.

The index of the property in the vector indicates its index in the Results instance, so a name's index can be used to fetch its corresponding value via a get method.

Returns
vector containing the names of all available properties

◆ getPropertyName()

string FiftyoneDegrees::Common::ResultsBase::getPropertyName ( int   requiredPropertyIndex )

Get the name of the property at the require property index, or an empty string if the required property index is invalid.

Parameters
requiredPropertyIndex - of the property name required
Returns
the name of the property, or an empty string if not valid

◆ getRequiredPropertyIndex()

int FiftyoneDegrees::Common::ResultsBase::getRequiredPropertyIndex ( const char *   propertyName )
protected

Get the index in the available properties for the property name provided.

Returns
0 based index or -1 if not found

◆ getValueAsBool() [1/4]

Value<bool> FiftyoneDegrees::Common::ResultsBase::getValueAsBool ( const char *   propertyName )

Get a boolean representation of the value associated with the required property name.

If the property name is not valid then false is returned.

Parameters
propertyName - string containing the property name
Returns
a boolean representation of the value for the property
Examples
Hash/StronglyTyped.cpp.

◆ getValueAsBool() [2/4]

Value<bool> FiftyoneDegrees::Common::ResultsBase::getValueAsBool ( const string &   propertyName )

Get a boolean representation of the value associated with the required property name.

If the property name is not valid then false is returned.

Parameters
propertyName - string containing the property name
Returns
a boolean representation of the value for the property

◆ getValueAsBool() [3/4]

Value<bool> FiftyoneDegrees::Common::ResultsBase::getValueAsBool ( const string *   propertyName )

Get a boolean representation of the value associated with the required property name.

If the property name is not valid then false is returned.

Parameters
propertyName - string containing the property name
Returns
a boolean representation of the value for the property

◆ getValueAsBool() [4/4]

Value<bool> FiftyoneDegrees::Common::ResultsBase::getValueAsBool ( int   requiredPropertyIndex )

Get a boolean representation of the value associated with the required property index.

If the property index is not valid then false is returned.

Parameters
requiredPropertyIndex - in the required properties
Returns
a boolean representation of the value for the property

◆ getValueAsDouble() [1/4]

Value<double> FiftyoneDegrees::Common::ResultsBase::getValueAsDouble ( const char *   propertyName )

Get a double representation of the value associated with the required property name.

If the property name is not valid then 0 is returned. Using a property which returns non-numeric characters will result in unexpected behavior.

Parameters
propertyName - string containing the property name
Returns
a double representation of the value for the property

◆ getValueAsDouble() [2/4]

Value<double> FiftyoneDegrees::Common::ResultsBase::getValueAsDouble ( const string &   propertyName )

Get a double representation of the value associated with the required property name.

If the property name is not valid then 0 is returned. Using a property which returns non-numeric characters will result in unexpected behavior.

Parameters
propertyName - string containing the property name
Returns
a double representation of the value for the property

◆ getValueAsDouble() [3/4]

Value<double> FiftyoneDegrees::Common::ResultsBase::getValueAsDouble ( const string *   propertyName )

Get a double representation of the value associated with the required property name.

If the property name is not valid then 0 is returned. Using a property which returns non-numeric characters will result in unexpected behavior.

Parameters
propertyName - string containing the property name
Returns
a double representation of the value for the property

◆ getValueAsDouble() [2/4]

Value<double> FiftyoneDegrees::Common::ResultsBase::getValueAsDouble ( const string &   propertyName )

Get a double representation of the value associated with the required property name.

If the property name is not valid then 0 is returned. Using a property which returns non-numeric characters will result in unexpected behavior.

Parameters
propertyName - string containing the property name
Returns
a double representation of the value for the property

◆ getValueAsDouble() [3/4]

Value<double> FiftyoneDegrees::Common::ResultsBase::getValueAsDouble ( const string *   propertyName )

Get a double representation of the value associated with the required property name.

If the property name is not valid then 0 is returned. Using a property which returns non-numeric characters will result in unexpected behavior.

Parameters
propertyName - string containing the property name
Returns
a double representation of the value for the property

◆ getValueAsDouble() [4/4]

Value<double> FiftyoneDegrees::Common::ResultsBase::getValueAsDouble ( int   requiredPropertyIndex )

Get a double representation of the value associated with the required property index.

If the property index is not valid then 0 is returned. Using a property which returns non-numeric characters will result in unexpected behavior.

Parameters
requiredPropertyIndex - in the required properties
Returns
a double representation of the value for the property

◆ getValueAsInteger() [1/4]

Value<int> FiftyoneDegrees::Common::ResultsBase::getValueAsInteger ( const char *   propertyName )

Get an integer representation of the value associated with the required property name.

If the property name is not valid then 0 is returned. Using a property which returns non-numeric characters will result in unexpected behavior.

Parameters
propertyName - string containing the property name
Returns
an integer representation of the value for the property

◆ getValueAsInteger() [2/4]

Value<int> FiftyoneDegrees::Common::ResultsBase::getValueAsInteger ( const string &   propertyName )

Get an integer representation of the value associated with the required property name.

If the property name is not valid then 0 is returned. Using a property which returns non-numeric characters will result in unexpected behavior.

Parameters
propertyName - string containing the property name
Returns
an integer representation of the value for the property

◆ getValueAsInteger() [3/4]

Value<int> FiftyoneDegrees::Common::ResultsBase::getValueAsInteger ( const string *   propertyName )

Get an integer representation of the value associated with the required property name.

If the property name is not valid then 0 is returned. Using a property which returns non-numeric characters will result in unexpected behavior.

Parameters
propertyName - string containing the property name
Returns
an integer representation of the value for the property

◆ getValueAsInteger() [4/4]

Value<int> FiftyoneDegrees::Common::ResultsBase::getValueAsInteger ( int   requiredPropertyIndex )

Get an integer representation of the value associated with the required property index.

If the property index is not valid then 0 is returned. Using a property which returns non-numeric characters will result in unexpected behavior.

Parameters
requiredPropertyIndex - in the required properties
Returns
an integer representation of the value for the property

◆ getValueAsString() [1/4]

Value<string> FiftyoneDegrees::Common::ResultsBase::getValueAsString ( const char *   propertyName )

Get a string representation of the value associated with the required property name.

If the property name is not valid an empty string is returned. If the property relates to a list with more than one value then values are separated by '|' characters.

Parameters
propertyName - string containing the property name
Returns
a string representation of the value for the property
Examples
Hash/GettingStarted.cpp, and Hash/MatchMetrics.cpp.

◆ getValueAsString() [2/4]

Value<string> FiftyoneDegrees::Common::ResultsBase::getValueAsString ( const string &   propertyName )

Get a string representation of the value associated with the required property name.

If the property name is not valid an empty string is returned. If the property relates to a list with more than one value then values are separated by '|' characters.

Parameters
propertyName - string containing the property name
Returns
a string representation of the value for the property

◆ getValueAsString() [3/4]

Value<string> FiftyoneDegrees::Common::ResultsBase::getValueAsString ( const string *   propertyName )

Get a string representation of the value associated with the required property name.

If the property name is not valid an empty string is returned. If the property relates to a list with more than one value then values are separated by '|' characters.

Parameters
propertyName - string containing the property name
Returns
a string representation of the value for the property

◆ getValueAsString() [4/4]

Value<string> FiftyoneDegrees::Common::ResultsBase::getValueAsString ( int   requiredPropertyIndex )

Get a string representation of the value associated with the required property index.

If the index is not valid an empty string is returned. If the property relates to a list with more than one value then values are separated by '|' characters.

Parameters
requiredPropertyIndex - of the property required
Returns
a string representation of the value for the property or an empty string

◆ getValues() [1/4]

Value<vector<string> > FiftyoneDegrees::Common::ResultsBase::getValues ( const char *   propertyName )

Get a vector with all values associated with the required property name.

If the name is not valid an empty vector is returned.

Parameters
propertyName - pointer to a string containing the property name
Returns
a vector of values for the property

◆ getValues() [2/4]

Value<vector<string> > FiftyoneDegrees::Common::ResultsBase::getValues ( const string &   propertyName )

Get a vector with all values associated with the required property name.

If the name is not valid an empty vector is returned.

Parameters
propertyName - pointer to a string containing the property name
Returns
a vector of values for the property

◆ getValues() [3/4]

Value<vector<string> > FiftyoneDegrees::Common::ResultsBase::getValues ( const string *   propertyName )

Get a vector with all values associated with the required property name.

If the name is not valid an empty vector is returned.

Parameters
propertyName - pointer to a string containing the property name
Returns
a vector of values for the property

◆ getValues() [4/4]

Value<vector<string> > FiftyoneDegrees::Common::ResultsBase::getValues ( int   requiredPropertyIndex )

Get a vector with all values associated with the required property index.

If the index is not valid an empty vector is returned.

Parameters
requiredPropertyIndex - of the property required
Returns
a vector of values for the property

◆ getValuesInternal()

virtual void FiftyoneDegrees::Common::ResultsBase::getValuesInternal ( int   requiredPropertyIndex,
vector< string > &   values  
)
protected pure virtual

Get the values for the index in required properties and add them to the values vector supplied.

This is implemented by extending classes.

Parameters
requiredPropertyIndex - index in the available properties
values - vector to populate with the values for the property

Implemented in FiftyoneDegrees::DeviceDetection::Hash::ResultsHash.

◆ hasValuesInternal()

virtual bool FiftyoneDegrees::Common::ResultsBase::hasValuesInternal ( int   requiredPropertyIndex )
protected pure virtual

Get whether or not there are valid values available for the property identified by its index in the required properties.

This is implemented by extending classes, and used when populating a Value instance to return.

Parameters
requiredPropertyIndex - index in the available properties
Returns
true if there are values available for the property

Implemented in FiftyoneDegrees::DeviceDetection::Hash::ResultsHash.

Field Documentation


The documentation for this class was generated from the following file:
  • /home/vsts/work/1/s/apis/device-detection-cxx/src/common-cxx/ResultsBase.hpp