51Degrees Common C/C++  4.1

A shared functionality library that is used by 51Degrees products

ResultsBase.hpp

1 /* *********************************************************************
2  * This Source Code Form 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 Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0.
8  *
9  * If a copy of the MPL was not distributed with this file, You can obtain
10  * one at http://mozilla.org/MPL/2.0/.
11  *
12  * This Source Code Form is "Incompatible With Secondary Licenses", as
13  * defined by the Mozilla Public License, v. 2.0.
14  * ********************************************************************* */
15 
16 #ifndef FIFTYONE_DEGREES_RESULTS_BASE_HPP
17 #define FIFTYONE_DEGREES_RESULTS_BASE_HPP
18 
19 #include <string>
20 #include <vector>
21 #include <memory>
22 #include <sstream>
23 #include "Exceptions.hpp"
24 #include "Value.hpp"
25 #include "RequiredPropertiesConfig.hpp"
26 #include "results.h"
27 #include "resource.h"
28 
29 using namespace std;
30 
31 namespace FiftyoneDegrees {
32  namespace Common {
74  class ResultsBase {
75  public:
95  shared_ptr<fiftyoneDegreesResourceManager> manager);
96 
101  virtual ~ResultsBase();
102 
114  int getAvailableProperties();
115 
122  bool containsProperty(const string &propertyName);
123 
131  vector<string> getProperties();
132 
140  string getPropertyName(int requiredPropertyIndex);
141 
156  Value<vector<string>> getValues(const char *propertyName);
157 
166  Value<vector<string>> getValues(const string &propertyName);
167 
176  Value<vector<string>> getValues(const string *propertyName);
177 
185  Value<vector<string>> getValues(int requiredPropertyIndex);
186 
195  Value<string> getValueAsString(const char *propertyName);
196 
205  Value<string> getValueAsString(const string &propertyName);
206 
215  Value<string> getValueAsString(const string *propertyName);
216 
226  Value<string> getValueAsString(int requiredPropertyIndex);
227 
235  Value<bool> getValueAsBool(const char *propertyName);
236 
244  Value<bool> getValueAsBool(const string &propertyName);
245 
253  Value<bool> getValueAsBool(const string *propertyName);
254 
262  Value<bool> getValueAsBool(int requiredPropertyIndex);
263 
272  Value<int> getValueAsInteger(const char *propertyName);
273 
282  Value<int> getValueAsInteger(const string &propertyName);
283 
292  Value<int> getValueAsInteger(const string *propertyName);
293 
302  Value<int> getValueAsInteger(int requiredPropertyIndex);
303 
312  Value<double> getValueAsDouble(const char *propertyName);
313 
322  Value<double> getValueAsDouble(const string &propertyName);
323 
332  Value<double> getValueAsDouble(const string *propertyName);
333 
342  Value<double> getValueAsDouble(int requiredPropertyIndex);
343 
348  protected:
351 
357  int getRequiredPropertyIndex(const char *propertyName);
358 
367  virtual void getValuesInternal(
368  int requiredPropertyIndex,
369  vector<string> &values) = 0;
370 
379  virtual bool hasValuesInternal(int requiredPropertyIndex) = 0;
380 
390  virtual const char* getNoValueMessageInternal(
392 
401  virtual fiftyoneDegreesResultsNoValueReason getNoValueReasonInternal(
402  int requiredPropertyIndex) = 0;
403 
404  private:
413  shared_ptr<fiftyoneDegreesResourceManager> manager;
414  };
415  }
416 }
417 
418 #endif
Encapsulates a value returned an instance of ResultsBase for a specified property.
Definition: Value.hpp:68
fiftyoneDegreesPropertiesAvailable * available
Pointer to the underlying available properties structure.
Definition: ResultsBase.hpp:350
51Degrees base namespace.
Definition: Collection.hpp:24
Array of items of type fiftyoneDegreesPropertyAvailable used to easily access and track the size of t...
Definition: properties.h:140
fiftyoneDegreesResultsNoValueReason
Enum containing reasons which cause a value to not be present or valid.
Definition: results.h:54
Encapsulates the results of an engine's processing.
Definition: ResultsBase.hpp:74
Base results structure which any processing results should extend.
Definition: results.h:88