51Degrees Device Detection C/C++  4.1

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 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4  * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
5  *
6  * This Original Work is licensed under the European Union Public Licence (EUPL)
7  * 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 namespace std;
37 
38 namespace FiftyoneDegrees {
39  namespace Common {
81  class ResultsBase {
82  public:
100  ResultsBase(
102  shared_ptr<fiftyoneDegreesResourceManager> manager);
103 
108  virtual ~ResultsBase();
109 
121  int getAvailableProperties();
122 
129  bool containsProperty(const string &propertyName);
130 
138  vector<string> getProperties();
139 
147  string getPropertyName(int requiredPropertyIndex);
148 
163  Value<vector<string>> getValues(const char *propertyName);
164 
173  Value<vector<string>> getValues(const string &propertyName);
174 
183  Value<vector<string>> getValues(const string *propertyName);
184 
192  Value<vector<string>> getValues(int requiredPropertyIndex);
193 
202  Value<string> getValueAsString(const char *propertyName);
203 
212  Value<string> getValueAsString(const string &propertyName);
213 
222  Value<string> getValueAsString(const string *propertyName);
223 
233  Value<string> getValueAsString(int requiredPropertyIndex);
234 
242  Value<bool> getValueAsBool(const char *propertyName);
243 
251  Value<bool> getValueAsBool(const string &propertyName);
252 
260  Value<bool> getValueAsBool(const string *propertyName);
261 
269  Value<bool> getValueAsBool(int requiredPropertyIndex);
270 
279  Value<int> getValueAsInteger(const char *propertyName);
280 
289  Value<int> getValueAsInteger(const string &propertyName);
290 
299  Value<int> getValueAsInteger(const string *propertyName);
300 
309  Value<int> getValueAsInteger(int requiredPropertyIndex);
310 
319  Value<double> getValueAsDouble(const char *propertyName);
320 
329  Value<double> getValueAsDouble(const string &propertyName);
330 
339  Value<double> getValueAsDouble(const string *propertyName);
340 
349  Value<double> getValueAsDouble(int requiredPropertyIndex);
350 
355  protected:
358 
364  int getRequiredPropertyIndex(const char *propertyName);
365 
374  virtual void getValuesInternal(
375  int requiredPropertyIndex,
376  vector<string> &values) = 0;
377 
386  virtual bool hasValuesInternal(int requiredPropertyIndex) = 0;
387 
397  virtual const char* getNoValueMessageInternal(
399 
408  virtual fiftyoneDegreesResultsNoValueReason getNoValueReasonInternal(
409  int requiredPropertyIndex) = 0;
410 
411  private:
420  shared_ptr<fiftyoneDegreesResourceManager> manager;
421  };
422  }
423 }
424 
425 #endif
Encapsulates a value returned an instance of ResultsBase for a specified property.
Definition: Value.hpp:75
fiftyoneDegreesPropertiesAvailable * available
Pointer to the underlying available properties structure.
Definition: ResultsBase.hpp:357
51Degrees base namespace.
Definition: ComponentMetaDataBuilderHash.hpp:34
Array of items of type fiftyoneDegreesPropertyAvailable used to easily access and track the size of t...
Definition: properties.h:170
fiftyoneDegreesResultsNoValueReason
Enum containing reasons which cause a value to not be present or valid.
Definition: results.h:61
Encapsulates the results of an engine's processing.
Definition: ResultsBase.hpp:81
Base results structure which any processing results should extend.
Definition: results.h:99