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 "memory.h"
31#include "storedBinaryValue.h"
32#include "string.h"
33#include "string_pp.hpp"
34
35
36using namespace FiftyoneDegrees;
37
38namespace FiftyoneDegrees {
39 namespace Common {
40 FIFTYONE_DEGREES_COMMON_CXX_BEGIN
46 protected:
47
52
62 static string getString(
63 fiftyoneDegreesCollection *stringsCollection,
64 uint32_t offset) {
66 string result;
68 fiftyoneDegreesDataReset(&item.data);
69 const fiftyoneDegreesStoredBinaryValue * const value =
70 fiftyoneDegreesStoredBinaryValueGet(
71 stringsCollection,
72 offset,
73 FIFTYONE_DEGREES_PROPERTY_VALUE_TYPE_STRING,
74 &item,
75 exception);
77 if (value != nullptr) {
78 char buffer[FIFTYONE_DEGREES_REASONABLE_WKT_STRING_LENGTH];
79 // A string has no decimal places.
80 char * const text = fiftyoneDegreesStoredBinaryValueToText(
81 value,
82 FIFTYONE_DEGREES_PROPERTY_VALUE_TYPE_STRING,
83 0,
84 buffer,
85 sizeof(buffer),
86 exception);
88 stringsCollection,
89 &item);
90 result = takeText(text, buffer, exception);
91 }
92 return result;
93 }
94
104 static string takeText(
105 char *text,
106 const char *buffer,
107 fiftyoneDegreesException *exception) {
108 string result;
109 if (text != nullptr) {
110 result = text;
111 if (text != buffer) {
113 }
114 }
116 return result;
117 }
118
122 };
123 FIFTYONE_DEGREES_COMMON_CXX_END
124 }
125}
126
127#endif
Meta data builder class contains static helper methods used when building meta data instances.
Definition EntityMetaDataBuilder.hpp:45
static string takeText(char *text, const char *buffer, fiftyoneDegreesException *exception)
Get a copy of the text a C function wrote into the buffer provided or into memory it allocated,...
Definition EntityMetaDataBuilder.hpp:104
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:62
#define FIFTYONE_DEGREES_COLLECTION_RELEASE(c, i)
Collection release macro used to release a collection item.
Definition collection.h:273
#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
EXTERNAL_VAR void(* fiftyoneDegreesFree)(void *__ptr)
Pointer to the method used to free memory.
Definition memory.h:206
Shared classes.
Definition Collection.hpp:31
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:410
Used to store a handle to the underlying item that could be used to release the item when it's finish...
Definition collection.h:317
fiftyoneDegreesData data
Item data including allocated memory.
Definition collection.h:318
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition exceptions.h:115
"Packed" value that can be present inside "strings" of dataset.
Definition storedBinaryValue.h:85