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 2026 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
35using namespace FiftyoneDegrees;
36
37namespace FiftyoneDegrees {
38 namespace Common {
39 FIFTYONE_DEGREES_COMMON_CXX_BEGIN
45 protected:
46
51
61 static string getString(
62 fiftyoneDegreesCollection *stringsCollection,
63 uint32_t offset) {
64 return getValue(
65 stringsCollection,
66 offset,
67 FIFTYONE_DEGREES_PROPERTY_VALUE_TYPE_STRING); // legacy contract
68 }
69
80 static string getValue(
81 fiftyoneDegreesCollection *stringsCollection,
82 uint32_t offset,
83 fiftyoneDegreesPropertyValueType storedValueType) {
85 string result;
87 fiftyoneDegreesDataReset(&item.data);
88 const fiftyoneDegreesStoredBinaryValue * const binaryValue = fiftyoneDegreesStoredBinaryValueGet(
89 stringsCollection,
90 offset,
91 storedValueType,
92 &item,
93 exception);
95 if (binaryValue != nullptr) {
96 std::stringstream stream;
98 binaryValue,
99 storedValueType,
100 stream,
101 FIFTYONE_DEGREES_MAX_DOUBLE_DECIMAL_PLACES,
102 exception);
104 result.append(stream.str());
105 }
107 stringsCollection,
108 &item);
109 return result;
110 }
111
115 };
116 FIFTYONE_DEGREES_COMMON_CXX_END
117 }
118}
119
120#endif
Meta data builder class contains static helper methods used when building meta data instances.
Definition EntityMetaDataBuilder.hpp:44
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:80
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:61
#define FIFTYONE_DEGREES_COLLECTION_RELEASE(c, i)
Collection release macro used to release a collection item.
Definition collection.h:272
#define FIFTYONE_DEGREES_EXCEPTION_THROW
Macro to print to standard error a message if an exception is set.
Definition exceptions.h:176
#define FIFTYONE_DEGREES_EXCEPTION_CREATE
Macro used to create an exception.
Definition exceptions.h:200
Shared classes.
Definition Collection.hpp:31
FIFTYONE_DEGREES_COMMON_CXX_BEGIN 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.
A C++ wrapper class for transform.h conversion routines.
Definition ComponentMetaDataBuilderHash.hpp:33
All the shared methods and fields required by file, memory and cached collections.
Definition collection.h:408
Used to store a handle to the underlying item that could be used to release the item when it's finish...
Definition collection.h:315
fiftyoneDegreesData data
Item data including allocated memory.
Definition collection.h:316
"Packed" value that can be present inside "strings" of dataset.
Definition storedBinaryValue.h:85