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

FiftyoneDegrees::DeviceDetection::ResultsDeviceDetection Class Referenceabstract

Detailed Description

Encapsulates the results of a device detection engine's processing.

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

Additional get methods are included on top of the base methods to return device detection specific metrics.

Results instances should only be created by an Engine.

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

// Iterate over all User-Agent indexes
for (int i = 0; i < results->getUserAgents(); i++) {
// Get the matched substrings of the User-Agent
string matchedUserAgent = results->getUserAgent(i);
// Do something with the string
// ...
}
// Get the device id for the device
string deviceId = results->getDeviceId();
// Delete the results
delete results;
virtual string getDeviceId() const =0
Returns the unique device id if the Id property was included in the required list of properties when ...
ResultsDeviceDetection(fiftyoneDegreesResultsDeviceDetection *results, shared_ptr< fiftyoneDegreesResourceManager > manager)
Create a new instance of Results from the results structure provided.
Device Detection specific classes.
Definition ComponentMetaDataBuilderHash.hpp:34

Inheritance diagram for FiftyoneDegrees::DeviceDetection::ResultsDeviceDetection:

[legend]

Collaboration diagram for FiftyoneDegrees::DeviceDetection::ResultsDeviceDetection:

[legend]

Public Member Functions

Constructor

 ResultsDeviceDetection (fiftyoneDegreesResultsDeviceDetection *results, shared_ptr< fiftyoneDegreesResourceManager > manager)
 Create a new instance of Results from the results structure provided.

Metric Getters

virtual string getDeviceId () const =0
 Returns the unique device id if the Id property was included in the required list of properties when the Provider was constructed.
virtual int getUserAgents () const =0
 Returns the number of different User-Agents that were used in the results.
virtual string getUserAgent (int resultIndex) const =0
 Returns relevant parts of the User-Agent which most closely matched the target User-Agent if the ConfigDeviceDetection::setUpdateMatchedUserAgent flag was set to true in the configuration.

Public Member Functions inherited from FiftyoneDegrees::Common::ResultsBase

 ResultsBase (fiftyoneDegreesResultsBase *results, shared_ptr< fiftyoneDegreesResourceManager > manager)
 Create a new instance of Results from the results structure provided.
virtual ~ResultsBase ()
 Free any memory associated with the results and release any resource handles.
int getAvailableProperties () const
 Get the number of required property indexes, which is the number of names the engine was created with, including any the data file lacks.
bool containsProperty (const string &propertyName) const
 Get whether or not this results instance contains a value for the requested property.
vector< string > getProperties () const
 Get the names of the properties the data set has, in ascending order.
string getPropertyName (int requiredPropertyIndex) const
 Get the name of the property at the required property index, or an empty string if there is no property at the index.
Value< vector< string > > getValues (const char *propertyName)
 Get a vector with all values associated with the required property name.
Value< vector< string > > getValues (const string &propertyName)
 Get a vector with all values associated with the required property name.
Value< vector< string > > getValues (const string *propertyName)
 Get a vector with all values associated with the required property name.
Value< vector< string > > getValues (int requiredPropertyIndex)
 Get a vector with all values associated with the required property index.
Value< string > getValueAsString (const char *propertyName)
 Get a string representation of the value associated with the required property name.
Value< string > getValueAsString (const string &propertyName)
 Get a string representation of the value associated with the required property name.
Value< string > getValueAsString (const string *propertyName)
 Get a string representation of the value associated with the required property name.
virtual Value< string > getValueAsString (int requiredPropertyIndex)
 Get a string representation of the value associated with the required property index.
Value< bool > getValueAsBool (const char *propertyName)
 Get a boolean representation of the value associated with the required property name.
Value< bool > getValueAsBool (const string &propertyName)
 Get a boolean representation of the value associated with the required property name.
Value< bool > getValueAsBool (const string *propertyName)
 Get a boolean representation of the value associated with the required property name.
virtual Value< bool > getValueAsBool (int requiredPropertyIndex)
 Get a boolean representation of the value associated with the required property index.
Value< int > getValueAsInteger (const char *propertyName)
 Get an integer representation of the value associated with the required property name.
Value< int > getValueAsInteger (const string &propertyName)
 Get an integer representation of the value associated with the required property name.
Value< int > getValueAsInteger (const string *propertyName)
 Get an integer representation of the value associated with the required property name.
virtual Value< int > getValueAsInteger (int requiredPropertyIndex)
 Get an integer representation of the value associated with the required property index.
Value< double > getValueAsDouble (const char *propertyName)
 Get a double representation of the value associated with the required property name.
Value< double > getValueAsDouble (const string &propertyName)
 Get a double representation of the value associated with the required property name.
Value< double > getValueAsDouble (const string *propertyName)
 Get a double representation of the value associated with the required property name.
virtual Value< double > getValueAsDouble (int requiredPropertyIndex)
 Get a double representation of the value associated with the required property index.
Value< bool > getValueAsStrictBool (const char *propertyName)
 Get the value as a boolean only if its text is "True" or "False".
Value< bool > getValueAsStrictBool (const string &propertyName)
 Get the value as a boolean only if its text is "True" or "False".
Value< bool > getValueAsStrictBool (int requiredPropertyIndex)
 Get the value as a boolean only if its text is "True" or "False".
Value< int > getValueAsStrictInteger (const char *propertyName)
 Get the value as an integer only if all of its text is a whole number an int can hold.
Value< int > getValueAsStrictInteger (const string &propertyName)
 Get the value as an integer only if all of its text is a whole number an int can hold.
Value< int > getValueAsStrictInteger (int requiredPropertyIndex)
 Get the value as an integer only if all of its text is a whole number an int can hold.
Value< double > getValueAsStrictDouble (const char *propertyName)
 Get the value as a double only if all of its text is a finite number.
Value< double > getValueAsStrictDouble (const string &propertyName)
 Get the value as a double only if all of its text is a finite number.
Value< double > getValueAsStrictDouble (int requiredPropertyIndex)
 Get the value as a double only if all of its text is a finite number.

Friends

class ::EngineDeviceDetectionTests

Additional Inherited Members

Protected Member Functions inherited from FiftyoneDegrees::Common::ResultsBase

int getRequiredPropertyIndex (const char *propertyName)
 Get the required property index of the property name provided.
int allowedRequiredPropertyIndex (int requiredPropertyIndex) const
 Get the index a read by required property index uses, which is the index given when the engine named its properties.
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.
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.
virtual const char * getNoValueMessageInternal (fiftyoneDegreesResultsNoValueReason reason)=0
 Get the message explaining the reason for missing values.
virtual fiftyoneDegreesResultsNoValueReason getNoValueReasonInternal (int requiredPropertyIndex)=0
 Get the reason for values not being available.

Protected Attributes inherited from FiftyoneDegrees::Common::ResultsBase

fiftyoneDegreesPropertiesAvailable * available
 Pointer to the underlying available properties structure.

Constructor & Destructor Documentation

◆ ResultsDeviceDetection()

FiftyoneDegrees::DeviceDetection::ResultsDeviceDetection::ResultsDeviceDetection ( fiftyoneDegreesResultsDeviceDetection * 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
resultspointer to the underlying results structure
managershared 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

◆ getDeviceId()

virtual string FiftyoneDegrees::DeviceDetection::ResultsDeviceDetection::getDeviceId ( ) const
pure virtual

Returns the unique device id if the Id property was included in the required list of properties when the Provider was constructed.

Returns
profile ids separated with a '-' character

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

◆ getUserAgent()

virtual string FiftyoneDegrees::DeviceDetection::ResultsDeviceDetection::getUserAgent ( int resultIndex) const
pure virtual

Returns relevant parts of the User-Agent which most closely matched the target User-Agent if the ConfigDeviceDetection::setUpdateMatchedUserAgent flag was set to true in the configuration.

Returns
string set to the HTTP header value matched

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

◆ getUserAgents()

virtual int FiftyoneDegrees::DeviceDetection::ResultsDeviceDetection::getUserAgents ( ) const
pure virtual

Returns the number of different User-Agents that were used in the results.

Returns
the number of User-Agents available to query with getUserAgent

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


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