51Degrees Common C/C++  4.1

A shared functionality library that is used by 51Degrees products

profile.h

1 /* *********************************************************************
2  * This Source Code Form is copyright of 51 Degrees Mobile Experts Limited.
3  * Copyright 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4  * Caversham, Reading, Berkshire, United Kingdom RG4 7BY
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0.
8  *
9  * If a copy of the MPL was not distributed with this file, You can obtain
10  * one at http://mozilla.org/MPL/2.0/.
11  *
12  * This Source Code Form is "Incompatible With Secondary Licenses", as
13  * defined by the Mozilla Public License, v. 2.0.
14 * ******************************************************************** */
15 
16 #ifndef FIFTYONE_DEGREES_PROFILE_H_INCLUDED
17 #define FIFTYONE_DEGREES_PROFILE_H_INCLUDED
18 
59 #include <stdint.h>
60 #ifdef _MSC_VER
61 #include <windows.h>
62 #endif
63 #include "data.h"
64 #include "exceptions.h"
65 #include "collection.h"
66 #include "string.h"
67 #include "component.h"
68 #include "property.h"
69 #include "value.h"
70 
71 #ifdef __cplusplus
72 #define EXTERNAL extern "C"
73 #else
74 #define EXTERNAL
75 #endif
76 
81 #pragma pack(push, 1)
82 typedef struct fiftyoneDegrees_profile_t {
83  const byte componentIndex;
85  const uint32_t profileId;
86  const uint32_t valueCount;
87  const uint32_t signatureCount;
90 #pragma pack(pop)
91 
98 #pragma pack(push, 4)
99 typedef struct fiftyoneDegrees_profile_offset_t {
100  const uint32_t profileId;
101  const uint32_t offset;
103 #pragma pack(pop)
104 
113  void *state,
115 
126  fiftyoneDegreesCollection *components,
127  fiftyoneDegreesProfile *profile,
129  fiftyoneDegreesException *exception);
130 
144  fiftyoneDegreesCollection *profileOffsets,
145  fiftyoneDegreesCollection *profiles,
146  const uint32_t profileId,
148  fiftyoneDegreesException *exception);
149 
165  fiftyoneDegreesCollection *profileOffsets,
166  fiftyoneDegreesCollection *profiles,
167  uint32_t index,
169  fiftyoneDegreesException *exception);
170 
171 #ifndef FIFTYONE_DEGREES_MEMORY_ONLY
172 
184  const fiftyoneDegreesCollectionFile *file,
185  uint32_t offset,
186  fiftyoneDegreesData *data,
187  fiftyoneDegreesException *exception);
188 #endif
189 
204  fiftyoneDegreesProfile *profile,
205  fiftyoneDegreesProperty *property,
206  void *state,
208  fiftyoneDegreesException *exception);
209 
229  fiftyoneDegreesCollection *strings,
230  fiftyoneDegreesCollection *properties,
232  fiftyoneDegreesCollection *profiles,
233  fiftyoneDegreesCollection *profileOffsets,
234  const char *propertyName,
235  const char* valueName,
236  void *state,
238  fiftyoneDegreesException *exception);
239 
251  fiftyoneDegreesCollection *profileOffsets,
252  const uint32_t profileId,
253  uint32_t *profileOffset,
254  fiftyoneDegreesException *exception);
255 
260 #endif
A component of a data set.
Definition: component.h:63
const byte componentIndex
The index of the component the profile relates to.
Definition: profile.h:83
const uint32_t profileId
The unique Id of the profile.
Definition: profile.h:100
EXTERNAL fiftyoneDegreesProfile * fiftyoneDegreesProfileGetByProfileId(fiftyoneDegreesCollection *profileOffsets, fiftyoneDegreesCollection *profiles, const uint32_t profileId, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets the profile associated with the profileId or NULL if there is no corresponding profile.
Definition: profile.c:178
Used to store a handle to the underlying item that could be used to release the item when it's finish...
Definition: collection.h:302
Structure containing the unique id of the profile, and the offset needed to retrieve the actual profi...
Definition: profile.h:99
Type of collection where the collection is streamed from file.
Definition: collection.h:437
EXTERNAL 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.
Definition: profile.c:273
Data structure used for reusing memory which may have been allocated in a previous operation.
Definition: data.h:99
const uint32_t offset
Offset to the profile in the profiles structure.
Definition: profile.h:101
Property structure containing all the meta data relating to a property.
Definition: property.h:75
EXTERNAL fiftyoneDegreesComponent * fiftyoneDegreesProfileGetComponent(fiftyoneDegreesCollection *components, fiftyoneDegreesProfile *profile, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets the Component associated with the property.
Definition: profile.c:166
const uint32_t valueCount
The number of values within the profile.
Definition: profile.h:86
const uint32_t signatureCount
The number of signatures containing this profile.
Definition: profile.h:87
uint32_t * fiftyoneDegreesProfileGetOffsetForProfileId(fiftyoneDegreesCollection *profileOffsets, const 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 ...
Definition: profile.c:140
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition: exceptions.h:109
EXTERNAL fiftyoneDegreesProfile * fiftyoneDegreesProfileGetByIndex(fiftyoneDegreesCollection *profileOffsets, fiftyoneDegreesCollection *profiles, uint32_t index, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets a pointer to the profile at the index provided.
Definition: profile.c:200
void * fiftyoneDegreesProfileReadFromFile(const fiftyoneDegreesCollectionFile *file, uint32_t offset, fiftyoneDegreesData *data, fiftyoneDegreesException *exception)
Read a profile from the file collection provided and store in the data pointer.
Definition: profile.c:230
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:112
Encapsulates a profile stored within a data set.
Definition: profile.h:82
const uint32_t profileId
Unique id of the profile.
Definition: profile.h:85
All the shared methods and fields required by file, memory and cached collections.
Definition: collection.h:400
EXTERNAL uint32_t fiftyoneDegreesProfileIterateValuesForProperty(fiftyoneDegreesCollection *values, fiftyoneDegreesProfile *profile, fiftyoneDegreesProperty *property, void *state, fiftyoneDegreesProfileIterateMethod callback, fiftyoneDegreesException *exception)
Iterate over all values contained in the profile which relate to the specified property,...
Definition: profile.c:248