\r\n

51Degrees Device Detection C/C++  4.5

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

EntityMetaDataBuilder.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_ENTITY_META_DATA_BUILDER_HPP
24 #define FIFTYONE_DEGREES_ENTITY_META_DATA_BUILDER_HPP
25 
26 #include <string>
27 #include "Exceptions.hpp"
28 #include "collection.h"
29 #include "constants.h"
30 #include "storedBinaryValue.h"
31 #include "string.h"
32 #include "string_pp.hpp"
33 
34 
35 using namespace FiftyoneDegrees;
36 
37 namespace FiftyoneDegrees {
38  namespace Common {
44  protected:
45 
60  static string getString(
61  fiftyoneDegreesCollection *stringsCollection,
62  uint32_t offset) {
63  return getValue(
64  stringsCollection,
65  offset,
66  FIFTYONE_DEGREES_PROPERTY_VALUE_TYPE_STRING); // legacy contract
67  }
68 
79  static string getValue(
80  fiftyoneDegreesCollection *stringsCollection,
81  uint32_t offset,
82  fiftyoneDegreesPropertyValueType storedValueType) {
84  string result;
88  stringsCollection,
89  offset,
90  storedValueType,
91  &item,
92  exception);
94  if (binaryValue != nullptr) {
95  std::stringstream stream;
97  binaryValue,
98  storedValueType,
99  stream,
100  FIFTYONE_DEGREES_MAX_DOUBLE_DECIMAL_PLACES,
101  exception);
103  result.append(stream.str());
104  }
106  stringsCollection,
107  &item);
108  return result;
109  }
110 
114  };
115  }
116 }
117 
118 #endif
#define FIFTYONE_DEGREES_EXCEPTION_CREATE
Macro used to create an exception.
Definition: exceptions.h:196
Used to store a handle to the underlying item that could be used to release the item when it's finish...
Definition: collection.h:309
Meta data builder class contains static helper methods used when building meta data instances.
Definition: EntityMetaDataBuilder.hpp:43
A C++ wrapper class for transform.h conversion routines.
Definition: ComponentMetaDataBuilderHash.hpp:33
#define FIFTYONE_DEGREES_EXCEPTION_THROW
Macro to print to standard error a message if an exception is set.
Definition: exceptions.h:172
void writeStoredBinaryValueToStringStream(const fiftyoneDegreesStoredBinaryValue *binaryValue, fiftyoneDegreesPropertyValueType valueType, std::stringstream &stream, uint8_t decimalPlaces, fiftyoneDegreesException *exception)
Converts stored binary value to text and pushes into a string stream.
static string getValue(fiftyoneDegreesCollection *stringsCollection, uint32_t offset, fiftyoneDegreesPropertyValueType storedValueType)
Get a copy of a binary value (as string) from the strings collection at the offset provided.
Definition: EntityMetaDataBuilder.hpp:79
static string getString(fiftyoneDegreesCollection *stringsCollection, uint32_t offset)
Get a copy of a string from the strings collection at the offset provided.
Definition: EntityMetaDataBuilder.hpp:60
void fiftyoneDegreesDataReset(fiftyoneDegreesData *data)
Resets the data structure ready for a new operation.
All the shared methods and fields required by file, memory and cached collections.
Definition: collection.h:402
fiftyoneDegreesData data
Item data including allocated memory.
Definition: collection.h:310
"Packed" value that can be present inside "strings" of dataset.
Definition: storedBinaryValue.h:81
const fiftyoneDegreesStoredBinaryValue * fiftyoneDegreesStoredBinaryValueGet(const fiftyoneDegreesCollection *strings, uint32_t offset, fiftyoneDegreesPropertyValueType storedValueType, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets the binary value at the required offset from the collection provided.
#define FIFTYONE_DEGREES_COLLECTION_RELEASE(c, i)
Collection release macro used to release a collection item.
Definition: collection.h:268