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

value.h

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_PROPERTY_VALUE_H_INCLUDED
24#define FIFTYONE_DEGREES_PROPERTY_VALUE_H_INCLUDED
25
26#ifdef FIFTYONE_DEGREES_IPI_SYMBOLS
27#include "ipiSymbols.h"
28#endif
29
57
58#include <stdint.h>
59#ifdef _MSC_VER
60#pragma warning (push)
61#pragma warning (disable: 5105)
62#include <windows.h>
63#pragma warning (default: 5105)
64#pragma warning (pop)
65#endif
66#include "data.h"
67#include "exceptions.h"
68#include "collection.h"
69#include "storedBinaryValue.h"
70#include "property.h"
71#include "profile.h"
72#include "common.h"
73
80#define FIFTYONE_DEGREES_VALUE_IS_MASKED(v) \
81 ((((uint32_t)((v)->urlOffsetOrWeight)) & 0xFFFF0000u) == 0xFF000000u)
82
84#pragma pack(push, 2)
85typedef struct fiftyoneDegrees_value_t {
86 const int16_t propertyIndex;
87 const int32_t nameOffset;
89#ifndef FIFTYONE_DEGREES_REDUCED_FILE
90 // Descriptions are not included in reduced size data files.
91 const int32_t descriptionOffset;
93#endif
94 const int32_t urlOffsetOrWeight;
101#pragma pack(pop)
102
116 const fiftyoneDegreesCollection *strings,
117 const fiftyoneDegreesValue *value,
118 fiftyoneDegreesPropertyValueType storedValueType,
120 fiftyoneDegreesException *exception);
121
134 const fiftyoneDegreesCollection *strings,
135 const fiftyoneDegreesValue *value,
137 fiftyoneDegreesException *exception);
138
152 const fiftyoneDegreesCollection *strings,
153 const fiftyoneDegreesValue *value,
155 fiftyoneDegreesException *exception);
156
171 const fiftyoneDegreesCollection *strings,
172 const fiftyoneDegreesValue *value,
174 fiftyoneDegreesException *exception);
175
186 const fiftyoneDegreesCollection *values,
187 uint32_t valueIndex,
189 fiftyoneDegreesException *exception);
190
204 const fiftyoneDegreesCollection *values,
205 const fiftyoneDegreesCollection *strings,
206 const fiftyoneDegreesProperty *property,
207 fiftyoneDegreesPropertyValueType storedValueType,
208 const char *valueName,
210 fiftyoneDegreesException *exception);
211
224 const fiftyoneDegreesCollection *values,
225 const fiftyoneDegreesCollection *strings,
226 const fiftyoneDegreesProperty *property,
227 const char *valueName,
229 fiftyoneDegreesException *exception);
230
243 const fiftyoneDegreesCollection *values,
244 const fiftyoneDegreesCollection *strings,
245 const fiftyoneDegreesProperty *property,
246 fiftyoneDegreesPropertyValueType storedValueType,
247 const char *valueName,
248 fiftyoneDegreesException *exception);
249
263 fiftyoneDegreesProperty *property,
264 const char *valueName,
265 fiftyoneDegreesException *exception);
266
276 const fiftyoneDegreesValue *value);
277
288 const fiftyoneDegreesValue *value);
289
293
294#endif
bool fiftyoneDegreesValueIsWeighted(const fiftyoneDegreesValue *value)
Returns true if the value carries a masked weight.
const fiftyoneDegreesValue * fiftyoneDegreesValueGetByName(const fiftyoneDegreesCollection *values, const fiftyoneDegreesCollection *strings, const fiftyoneDegreesProperty *property, const char *valueName, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Get the value for the requested name from the collection provided.
const fiftyoneDegreesString * fiftyoneDegreesValueGetDescription(const fiftyoneDegreesCollection *strings, const fiftyoneDegreesValue *value, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Returns the string description of the value using the item provided.
uint16_t fiftyoneDegreesValueGetWeight(const fiftyoneDegreesValue *value)
Gets the weight from a Value record as a uint16_t (0–65535), or 0 if the value is not weighted.
const fiftyoneDegreesString * fiftyoneDegreesValueGetUrl(const fiftyoneDegreesCollection *strings, const fiftyoneDegreesValue *value, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Returns the string URL of the value using the item provided.
const fiftyoneDegreesString * fiftyoneDegreesValueGetName(const fiftyoneDegreesCollection *strings, const fiftyoneDegreesValue *value, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Returns the string name of the value using the item provided.
long fiftyoneDegreesValueGetIndexByName(fiftyoneDegreesCollection *values, fiftyoneDegreesCollection *strings, fiftyoneDegreesProperty *property, const char *valueName, fiftyoneDegreesException *exception)
Get index of the value for the requested name from the collection provided.
long fiftyoneDegreesValueGetIndexByNameAndType(const fiftyoneDegreesCollection *values, const fiftyoneDegreesCollection *strings, const fiftyoneDegreesProperty *property, fiftyoneDegreesPropertyValueType storedValueType, const char *valueName, fiftyoneDegreesException *exception)
Get index of the value for the requested name from the collection provided.
const fiftyoneDegreesValue * fiftyoneDegreesValueGet(const fiftyoneDegreesCollection *values, uint32_t valueIndex, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets the value for the requested index from the collection provided.
const fiftyoneDegreesStoredBinaryValue * fiftyoneDegreesValueGetContent(const fiftyoneDegreesCollection *strings, const fiftyoneDegreesValue *value, fiftyoneDegreesPropertyValueType storedValueType, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Returns the contents of the value using the item provided.
const fiftyoneDegreesValue * fiftyoneDegreesValueGetByNameAndType(const fiftyoneDegreesCollection *values, const fiftyoneDegreesCollection *strings, const fiftyoneDegreesProperty *property, fiftyoneDegreesPropertyValueType storedValueType, const char *valueName, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Get the value for the requested name from the collection provided.
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
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition exceptions.h:115
Property structure containing all the meta data relating to a property.
Definition property.h:75
Definition string.h:97
Value structure containing meta data relating to the value.
Definition value.h:85
const int32_t urlOffsetOrWeight
The offset in the strings structure to the value URL, or a masked weight if upper 2 bytes == 0xFF00 (...
Definition value.h:94
const int16_t propertyIndex
Index of the property the value relates to.
Definition value.h:86
const int32_t nameOffset
The offset in the strings structure to the value name.
Definition value.h:87
const int32_t descriptionOffset
The offset in the strings structure to the value description.
Definition value.h:91
"Packed" value that can be present inside "strings" of dataset.
Definition storedBinaryValue.h:85