\r\n

51Degrees Device Detection C/C++  4.4

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

ResultsBase.hpp

1 /* *********************************************************************
2  * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3  * Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
4  * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
5  *
6  * This Original Work is licensed under the European Union Public Licence
7  * (EUPL) v.1.2 and is subject to its terms as set out below.
8  *
9  * If a copy of the EUPL was not distributed with this file, You can obtain
10  * one at https://opensource.org/licenses/EUPL-1.2.
11  *
12  * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
13  * amended by the European Commission) shall be deemed incompatible for
14  * the purposes of the Work and the provisions of the compatibility
15  * clause in Article 5 of the EUPL shall not apply.
16  *
17  * If using the Work as, or as part of, a network application, by
18  * including the attribution notice(s) required under Article 5 of the EUPL
19  * in the end user terms of the application under an appropriate heading,
20  * such notice(s) shall fulfill the requirements of that article.
21  * ********************************************************************* */
22 
23 #ifndef FIFTYONE_DEGREES_RESULTS_BASE_HPP
24 #define FIFTYONE_DEGREES_RESULTS_BASE_HPP
25 
26 #include <string>
27 #include <vector>
28 #include <memory>
29 #include <sstream>
30 #include "Exceptions.hpp"
31 #include "Value.hpp"
32 #include "RequiredPropertiesConfig.hpp"
33 #include "results.h"
34 #include "resource.h"
35 
36 using std::shared_ptr;
37 using std::stringstream;
38 
39 namespace FiftyoneDegrees {
40  namespace Common {
82  class ResultsBase {
83  public:
101  ResultsBase(
103  shared_ptr<fiftyoneDegreesResourceManager> manager);
104 
109  virtual ~ResultsBase();
110 
122  int getAvailableProperties() const;
123 
130  bool containsProperty(const string &propertyName) const;
131 
139  vector<string> getProperties() const;
140 
148  string getPropertyName(int requiredPropertyIndex) const;
149 
164  Value<vector<string>> getValues(const char *propertyName);
165 
174  Value<vector<string>> getValues(const string &propertyName);
175 
184  Value<vector<string>> getValues(const string *propertyName);
185 
193  Value<vector<string>> getValues(int requiredPropertyIndex);
194 
203  Value<string> getValueAsString(const char *propertyName);
204 
213  Value<string> getValueAsString(const string &propertyName);
214 
223  Value<string> getValueAsString(const string *propertyName);
224 
234  virtual Value<string> getValueAsString(int requiredPropertyIndex);
235 
243  Value<bool> getValueAsBool(const char *propertyName);
244 
252  Value<bool> getValueAsBool(const string &propertyName);
253 
261  Value<bool> getValueAsBool(const string *propertyName);
262 
270  virtual Value<bool> getValueAsBool(int requiredPropertyIndex);
271 
280  Value<int> getValueAsInteger(const char *propertyName);
281 
290  Value<int> getValueAsInteger(const string &propertyName);
291 
300  Value<int> getValueAsInteger(const string *propertyName);
301 
310  virtual Value<int> getValueAsInteger(int requiredPropertyIndex);
311 
320  Value<double> getValueAsDouble(const char *propertyName);
321 
330  Value<double> getValueAsDouble(const string &propertyName);
331 
340  Value<double> getValueAsDouble(const string *propertyName);
341 
350  virtual Value<double> getValueAsDouble(int requiredPropertyIndex);
351 
356  protected:
359 
365  int getRequiredPropertyIndex(const char *propertyName);
366 
375  virtual void getValuesInternal(
376  int requiredPropertyIndex,
377  vector<string> &values) = 0;
378 
387  virtual bool hasValuesInternal(int requiredPropertyIndex) = 0;
388 
398  virtual const char* getNoValueMessageInternal(
400 
410  int requiredPropertyIndex) = 0;
411 
412  private:
421  shared_ptr<fiftyoneDegreesResourceManager> manager;
422  };
423  }
424 }
425 
426 #endif
Encapsulates a value returned an instance of ResultsBase for a specified property.
Definition: Value.hpp:74
virtual bool hasValuesInternal(int requiredPropertyIndex)=0
Get whether or not there are valid values available for the property identified by its index in the r...
fiftyoneDegreesPropertiesAvailable * available
Pointer to the underlying available properties structure.
Definition: ResultsBase.hpp:358
Value< double > getValueAsDouble(const char *propertyName)
Get a double representation of the value associated with the required property name.
Value< int > getValueAsInteger(const char *propertyName)
Get an integer representation of the value associated with the required property name.
virtual ~ResultsBase()
Free any memory associated with the results and release any resource handles.
int getAvailableProperties() const
Get the number of available properties contained in the Results instance.
51Degrees base namespace.
Definition: ComponentMetaDataBuilderHash.hpp:33
Value< vector< string > > getValues(const char *propertyName)
Get a vector with all values associated with the required property name.
Value< bool > getValueAsBool(const char *propertyName)
Get a boolean representation of the value associated with the required property name.
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.
Value< string > getValueAsString(const char *propertyName)
Get a string representation of the value associated with the required property name.
string getPropertyName(int requiredPropertyIndex) const
Get the name of the property at the require property index, or an empty string if the required proper...
ResultsBase(fiftyoneDegreesResultsBase *results, shared_ptr< fiftyoneDegreesResourceManager > manager)
Create a new instance of Results from the results structure provided.
int getRequiredPropertyIndex(const char *propertyName)
Get the index in the available properties for the property name provided.
virtual fiftyoneDegreesResultsNoValueReason getNoValueReasonInternal(int requiredPropertyIndex)=0
Get the reason for values not being available.
Array of items of type fiftyoneDegreesPropertyAvailable used to easily access and track the size of t...
Definition: properties.h:165
fiftyoneDegreesResultsNoValueReason
Enum containing reasons which cause a value to not be present or valid.
Definition: results.h:56
vector< string > getProperties() const
Get the names of the properties which are available in the Results instance.
bool containsProperty(const string &propertyName) const
Get whether or not this results instance contains a value for the requested property.
Encapsulates the results of an engine's processing.
Definition: ResultsBase.hpp:82
Base results structure which any processing results should extend.
Definition: results.h:94
virtual const char * getNoValueMessageInternal(fiftyoneDegreesResultsNoValueReason reason)=0
Get the message explaining the reason for missing values.