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

profile.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_PROFILE_H_INCLUDED
24#define FIFTYONE_DEGREES_PROFILE_H_INCLUDED
25
26#ifdef FIFTYONE_DEGREES_IPI_SYMBOLS
27#include "ipiSymbols.h"
28#endif
29
69
70#include <stdint.h>
71#ifdef _MSC_VER
72#pragma warning (push)
73#pragma warning (disable: 5105)
74#include <windows.h>
75#pragma warning (default: 5105)
76#pragma warning (pop)
77#endif
78#include "data.h"
79#include "exceptions.h"
80#include "collection.h"
81#include "string.h"
82#include "component.h"
83#include "property.h"
84#include "value.h"
85#include "common.h"
86#include "indices.h"
87
88typedef
89#ifdef FIFTYONE_DEGREES_REDUCED_FILE
90// In a reduced size data file, there is no profile id, and the value count
91// is written as 2 bytes.
92uint16_t
93#else
94// Full size data file contains a profile id, and 32 bit value count.
95uint32_t
96#endif
98
103#pragma pack(push, 1)
104typedef struct fiftyoneDegrees_profile_t {
105 const byte componentIndex;
107#ifndef FIFTYONE_DEGREES_REDUCED_FILE
108 // In a reduced size data file, there is no profile id.
109 // Full size data file contains a profile id.
110 const uint32_t profileId;
111#endif
114#pragma pack(pop)
115
122#pragma pack(push, 4)
123typedef struct fiftyoneDegrees_profile_offset_t {
124#ifndef FIFTYONE_DEGREES_REDUCED_FILE
125 const uint32_t profileId;
126#endif
127 const uint32_t offset;
129#pragma pack(pop)
130
137typedef uint32_t (*fiftyoneDegreesProfileOffsetValueExtractor)(const void *rawProfileOffset);
138
145uint32_t fiftyoneDegreesProfileOffsetToPureOffset(const void *rawProfileOffset);
146
154uint32_t fiftyoneDegreesProfileOffsetAsPureOffset(const void *rawProfileOffset);
155
164 void *state,
166
175 void* state,
176 uint32_t valueIndex);
177
183#ifndef FIFTYONE_DEGREES_MEMORY_ONLY
185 const void *initial,
186 fiftyoneDegreesException * const exception);
187#else
188#define fiftyoneDegreesProfileGetFinalSize NULL
189#endif
190
204 fiftyoneDegreesCollection *profileOffsets,
206 uint32_t profileId,
208 fiftyoneDegreesException *exception);
209
225 fiftyoneDegreesCollection *profileOffsets,
227 uint32_t index,
229 fiftyoneDegreesException *exception);
230
231#ifndef FIFTYONE_DEGREES_MEMORY_ONLY
232
247 fiftyoneDegreesException *exception);
248#endif
249
263 const fiftyoneDegreesCollection *values,
264 const fiftyoneDegreesProfile *profile,
265 const fiftyoneDegreesProperty *property,
266 void *state,
268 fiftyoneDegreesException *exception);
269
285 const fiftyoneDegreesCollection* values,
287 uint32_t availablePropertyIndex,
288 const fiftyoneDegreesProfile* profile,
289 const fiftyoneDegreesProperty* property,
290 void* state,
292 fiftyoneDegreesException* exception);
293
315 fiftyoneDegreesCollection *properties,
316 fiftyoneDegreesCollection *propertyTypes,
319 fiftyoneDegreesCollection *profileOffsets,
320 const char *propertyName,
321 const char* valueName,
322 void *state,
324 fiftyoneDegreesException *exception);
325
348 fiftyoneDegreesCollection *properties,
349 fiftyoneDegreesCollection *propertyTypes,
352 const fiftyoneDegreesCollection *profileOffsets,
354 const char *propertyName,
355 const char* valueName,
356 void *state,
358 fiftyoneDegreesException *exception);
359
380 fiftyoneDegreesCollection *properties,
383 fiftyoneDegreesCollection *profileOffsets,
384 const char *propertyName,
385 const char* valueName,
386 void *state,
388 fiftyoneDegreesException *exception);
389
401 fiftyoneDegreesCollection *profileOffsets,
402 uint32_t profileId,
403 uint32_t *profileOffset,
404 fiftyoneDegreesException *exception);
405
419 fiftyoneDegreesCollection *profileOffsets,
421 uint32_t profileId,
422 fiftyoneDegreesCollectionItem *outProfileItem,
423 fiftyoneDegreesException *exception);
424
437 fiftyoneDegreesProfile* profile,
440 void* state,
442 fiftyoneDegreesException* exception);
443
447
448#endif
fiftyoneDegreesProfile * fiftyoneDegreesProfileGetByIndex(fiftyoneDegreesCollection *profileOffsets, fiftyoneDegreesCollection *profiles, uint32_t index, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets a pointer to the profile at the index provided.
uint32_t fiftyoneDegreesProfileIterateProfilesForPropertyWithTypeAndValueAndOffsetExtractor(fiftyoneDegreesCollection *strings, fiftyoneDegreesCollection *properties, fiftyoneDegreesCollection *propertyTypes, fiftyoneDegreesCollection *values, fiftyoneDegreesCollection *profiles, const fiftyoneDegreesCollection *profileOffsets, fiftyoneDegreesProfileOffsetValueExtractor offsetValueExtractor, const char *propertyName, const char *valueName, void *state, fiftyoneDegreesProfileIterateMethod callback, fiftyoneDegreesException *exception)
Iterate all profiles which contain the specified value, calling the callback method for each.
uint32_t fiftyoneDegreesProfileIterateValueIndexes(fiftyoneDegreesProfile *profile, fiftyoneDegreesPropertiesAvailable *available, fiftyoneDegreesCollection *values, void *state, fiftyoneDegreesProfileIterateValueIndexesMethod callback, fiftyoneDegreesException *exception)
Calls the callback for every value index available for the profile.
uint32_t fiftyoneDegreesProfileIterateProfilesForPropertyWithTypeAndValue(fiftyoneDegreesCollection *strings, fiftyoneDegreesCollection *properties, fiftyoneDegreesCollection *propertyTypes, fiftyoneDegreesCollection *values, fiftyoneDegreesCollection *profiles, fiftyoneDegreesCollection *profileOffsets, const char *propertyName, const char *valueName, void *state, fiftyoneDegreesProfileIterateMethod callback, fiftyoneDegreesException *exception)
Iterate all profiles which contain the specified value, calling the callback method for each.
uint32_t fiftyoneDegreesProfileValuesCountType
Type for fiftyoneDegreesProfile::valueCount.
Definition profile.h:97
bool(* fiftyoneDegreesProfileIterateMethod)(void *state, fiftyoneDegreesCollectionItem *item)
Definition of a callback function which is passed an item of a type determined by the iteration metho...
Definition profile.h:163
uint32_t fiftyoneDegreesProfileGetFinalSize(const void *initial, fiftyoneDegreesException *const exception)
Gets size of Profile with trailing values.
uint32_t fiftyoneDegreesProfileOffsetAsPureOffset(const void *rawProfileOffset)
Function that extracts "pure" profile offset from a value (that starts with a "pure" profile offset) ...
bool(* fiftyoneDegreesProfileIterateValueIndexesMethod)(void *state, uint32_t valueIndex)
Definition of a callback function which is passed the next values index for the profile.
Definition profile.h:174
uint32_t fiftyoneDegreesProfileOffsetToPureOffset(const void *rawProfileOffset)
Function that extracts "pure" profile offset from a fiftyoneDegreesProfileOffset.
uint32_t fiftyoneDegreesProfileIterateProfilesForPropertyAndValue(fiftyoneDegreesCollection *strings, fiftyoneDegreesCollection *properties, fiftyoneDegreesCollection *values, fiftyoneDegreesCollection *profiles, fiftyoneDegreesCollection *profileOffsets, const char *propertyName, const char *valueName, void *state, fiftyoneDegreesProfileIterateMethod callback, fiftyoneDegreesException *exception)
Iterate all profiles which contain the specified value, calling the callback method for each.
uint32_t * fiftyoneDegreesProfileGetOffsetForProfileId(fiftyoneDegreesCollection *profileOffsets, uint32_t profileId, uint32_t *profileOffset, fiftyoneDegreesException *exception)
Gets the offset in the profiles collection for the profile with the profileId or NULL if there is no ...
fiftyoneDegreesProfile * fiftyoneDegreesProfileGetByProfileIdIndirect(fiftyoneDegreesCollection *profileOffsets, fiftyoneDegreesCollection *profiles, uint32_t profileId, fiftyoneDegreesCollectionItem *outProfileItem, fiftyoneDegreesException *exception)
Gets the profile from the profiles collection with the profileId or NULL if there is no corresponding...
void * fiftyoneDegreesProfileReadFromFile(const fiftyoneDegreesCollectionFile *file, const fiftyoneDegreesCollectionKey *key, fiftyoneDegreesData *data, fiftyoneDegreesException *exception)
Read a profile from the file collection provided and store in the data pointer.
uint32_t fiftyoneDegreesProfileIterateValuesForProperty(const fiftyoneDegreesCollection *values, const fiftyoneDegreesProfile *profile, const fiftyoneDegreesProperty *property, void *state, fiftyoneDegreesProfileIterateMethod callback, fiftyoneDegreesException *exception)
Iterate over all values contained in the profile which relate to the specified property,...
uint32_t(* fiftyoneDegreesProfileOffsetValueExtractor)(const void *rawProfileOffset)
Function that extracts "pure" profile offset from a value inside profileOffsets collection.
Definition profile.h:137
uint32_t fiftyoneDegreesProfileIterateValuesForPropertyWithIndex(const fiftyoneDegreesCollection *values, fiftyoneDegreesIndicesPropertyProfile *index, uint32_t availablePropertyIndex, const fiftyoneDegreesProfile *profile, const fiftyoneDegreesProperty *property, void *state, fiftyoneDegreesProfileIterateMethod callback, fiftyoneDegreesException *exception)
Iterate over all values contained in the profile which relate to the specified property and profile,...
fiftyoneDegreesProfile * fiftyoneDegreesProfileGetByProfileId(fiftyoneDegreesCollection *profileOffsets, fiftyoneDegreesCollection *profiles, uint32_t profileId, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets the profile associated with the profileId or NULL if there is no corresponding profile.
fiftyoneDegreesPropertyAvailableArray fiftyoneDegreesPropertiesAvailable
Array of properties which are available in a data set.
Definition properties.h:223
Type of collection where the collection is streamed from file.
Definition collection.h:456
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
Explains to a collection (or cache) what the consumer is looking for.
Definition collectionKey.h:76
Data structure used for reusing memory which may have been allocated in a previous operation.
Definition data.h:105
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition exceptions.h:115
Maps the profile index and the property index to the first value index of the profile for the propert...
Definition indices.h:121
Encapsulates a profile stored within a data set.
Definition profile.h:104
const fiftyoneDegreesProfileValuesCountType valueCount
The number of values within the profile.
Definition profile.h:112
const byte componentIndex
The index of the component the profile relates to.
Definition profile.h:105
const uint32_t profileId
Unique id of the profile.
Definition profile.h:110
Structure containing the unique id of the profile, and the offset needed to retrieve the actual profi...
Definition profile.h:123
const uint32_t offset
Offset to the profile in the profiles structure.
Definition profile.h:127
const uint32_t profileId
The unique Id of the profile.
Definition profile.h:125
Property structure containing all the meta data relating to a property.
Definition property.h:75