\r\n

51Degrees Device Detection C/C++  4.5

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 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_PROFILE_H_INCLUDED
24 #define FIFTYONE_DEGREES_PROFILE_H_INCLUDED
25 
66 #include <stdint.h>
67 #ifdef _MSC_VER
68 #pragma warning (push)
69 #pragma warning (disable: 5105)
70 #include <windows.h>
71 #pragma warning (default: 5105)
72 #pragma warning (pop)
73 #endif
74 #include "data.h"
75 #include "exceptions.h"
76 #include "collection.h"
77 #include "string.h"
78 #include "component.h"
79 #include "property.h"
80 #include "value.h"
81 #include "common.h"
82 #include "indices.h"
83 
88 #pragma pack(push, 1)
89 typedef struct fiftyoneDegrees_profile_t {
90  const byte componentIndex;
92  const uint32_t profileId;
93  const uint32_t valueCount;
95 #pragma pack(pop)
96 
103 #pragma pack(push, 4)
104 typedef struct fiftyoneDegrees_profile_offset_t {
105  const uint32_t profileId;
106  const uint32_t offset;
108 #pragma pack(pop)
109 
116 typedef uint32_t (*fiftyoneDegreesProfileOffsetValueExtractor)(const void *rawProfileOffset);
117 
124 uint32_t fiftyoneDegreesProfileOffsetToPureOffset(const void *rawProfileOffset);
125 
133 uint32_t fiftyoneDegreesProfileOffsetAsPureOffset(const void *rawProfileOffset);
134 
143  void *state,
145 
154  void* state,
155  uint32_t valueIndex);
156 
162 #ifndef FIFTYONE_DEGREES_MEMORY_ONLY
163 EXTERNAL uint32_t fiftyoneDegreesProfileGetFinalSize(
164  const void *initial,
165  fiftyoneDegreesException * const exception);
166 #else
167 #define fiftyoneDegreesProfileGetFinalSize NULL
168 #endif
169 
183  fiftyoneDegreesCollection *profileOffsets,
184  fiftyoneDegreesCollection *profiles,
185  uint32_t profileId,
187  fiftyoneDegreesException *exception);
188 
204  fiftyoneDegreesCollection *profileOffsets,
205  fiftyoneDegreesCollection *profiles,
206  uint32_t index,
208  fiftyoneDegreesException *exception);
209 
210 #ifndef FIFTYONE_DEGREES_MEMORY_ONLY
211 
223  const fiftyoneDegreesCollectionFile *file,
224  const fiftyoneDegreesCollectionKey *key,
225  fiftyoneDegreesData *data,
226  fiftyoneDegreesException *exception);
227 #endif
228 
242  const fiftyoneDegreesCollection *values,
243  const fiftyoneDegreesProfile *profile,
244  const fiftyoneDegreesProperty *property,
245  void *state,
247  fiftyoneDegreesException *exception);
248 
264  const fiftyoneDegreesCollection* values,
266  uint32_t availablePropertyIndex,
267  const fiftyoneDegreesProfile* profile,
268  const fiftyoneDegreesProperty* property,
269  void* state,
271  fiftyoneDegreesException* exception);
272 
293  fiftyoneDegreesCollection *strings,
294  fiftyoneDegreesCollection *properties,
295  fiftyoneDegreesCollection *propertyTypes,
297  fiftyoneDegreesCollection *profiles,
298  fiftyoneDegreesCollection *profileOffsets,
299  const char *propertyName,
300  const char* valueName,
301  void *state,
303  fiftyoneDegreesException *exception);
304 
326  fiftyoneDegreesCollection *strings,
327  fiftyoneDegreesCollection *properties,
328  fiftyoneDegreesCollection *propertyTypes,
330  fiftyoneDegreesCollection *profiles,
331  const fiftyoneDegreesCollection *profileOffsets,
332  fiftyoneDegreesProfileOffsetValueExtractor offsetValueExtractor,
333  const char *propertyName,
334  const char* valueName,
335  void *state,
337  fiftyoneDegreesException *exception);
338 
358  fiftyoneDegreesCollection *strings,
359  fiftyoneDegreesCollection *properties,
361  fiftyoneDegreesCollection *profiles,
362  fiftyoneDegreesCollection *profileOffsets,
363  const char *propertyName,
364  const char* valueName,
365  void *state,
367  fiftyoneDegreesException *exception);
368 
380  fiftyoneDegreesCollection *profileOffsets,
381  uint32_t profileId,
382  uint32_t *profileOffset,
383  fiftyoneDegreesException *exception);
384 
398  fiftyoneDegreesCollection *profileOffsets,
399  fiftyoneDegreesCollection *profiles,
400  uint32_t profileId,
401  fiftyoneDegreesCollectionItem *outProfileItem,
402  fiftyoneDegreesException *exception);
403 
416  fiftyoneDegreesProfile* profile,
419  void* state,
421  fiftyoneDegreesException* exception);
422 
427 #endif
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,...
const byte componentIndex
The index of the component the profile relates to.
Definition: profile.h:90
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:153
const uint32_t profileId
The unique Id of the profile.
Definition: profile.h:105
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.
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.
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
Structure containing the unique id of the profile, and the offset needed to retrieve the actual profi...
Definition: profile.h:104
Type of collection where the collection is streamed from file.
Definition: collection.h:438
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 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.
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 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.
Data structure used for reusing memory which may have been allocated in a previous operation.
Definition: data.h:101
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 fiftyoneDegreesProfileOffsetToPureOffset(const void *rawProfileOffset)
Function that extracts "pure" profile offset from a fiftyoneDegreesProfileOffset.
const uint32_t offset
Offset to the profile in the profiles structure.
Definition: profile.h:106
uint32_t fiftyoneDegreesProfileGetFinalSize(const void *initial, fiftyoneDegreesException *const exception)
Gets size of Profile with trailing values.
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 ...
Array of items of type fiftyoneDegreesPropertyAvailable used to easily access and track the size of t...
Definition: properties.h:165
Property structure containing all the meta data relating to a property.
Definition: property.h:71
Maps the profile index and the property index to the first value index of the profile for the propert...
Definition: indices.h:109
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...
const uint32_t valueCount
The number of values within the profile.
Definition: profile.h:93
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition: exceptions.h:111
uint32_t fiftyoneDegreesProfileOffsetAsPureOffset(const void *rawProfileOffset)
Function that extracts "pure" profile offset from a value (that starts with a "pure" profile offset) ...
uint32_t(* fiftyoneDegreesProfileOffsetValueExtractor)(const void *rawProfileOffset)
Function that extracts "pure" profile offset from a value inside profileOffsets collection.
Definition: profile.h:116
Explains to a collection (or cache) what the consumer is looking for.
Definition: collectionKey.h:72
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:142
Encapsulates a profile stored within a data set.
Definition: profile.h:89
const uint32_t profileId
Unique id of the profile.
Definition: profile.h:92
All the shared methods and fields required by file, memory and cached collections.
Definition: collection.h:402
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.