51Degrees Common C/C++  4.1

A shared functionality library that is used by 51Degrees products

properties.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 
110 #ifndef FIFTYONE_DEGREES_PROPERTIES_H_INCLUDED
111 #define FIFTYONE_DEGREES_PROPERTIES_H_INCLUDED
112 
113 #include <stdint.h>
114 #ifdef _MSC_FULL_VER
115 #include <string.h>
116 #else
117 #include <strings.h>
118 #define _stricmp strcasecmp
119 #define _strnicmp strncasecmp
120 #endif
121 #include "string.h"
122 #include "list.h"
123 #include "data.h"
124 #include "collection.h"
125 #include "array.h"
126 
127 #ifdef __cplusplus
128 #define EXTERNAL extern "C"
129 #else
130 #define EXTERNAL
131 #endif
132 
134 typedef struct fiftyone_degrees_property_available_t {
135  uint32_t propertyIndex;
139 
141 
142 
145 
150 EXTERNAL typedef struct fiftyone_degrees_properties_required_t {
151  const char **array;
154  int count;
155  const char *string;
161 
170 typedef fiftyoneDegreesString*(*fiftyoneDegreesPropertiesGetMethod)(
171  void *state,
172  uint32_t index,
174 
181 
199  void *state,
200  fiftyoneDegreesPropertiesGetMethod getPropertyMethod);
201 
210  const char *propertyName);
211 
222  const char *propertyName);
223 
233  int requiredPropertyIndex);
234 
242 EXTERNAL fiftyoneDegreesString*
245  int requiredPropertyIndex);
246 
252 EXTERNAL void fiftyoneDegreesPropertiesFree(
254 
259 #endif
EXTERNAL int fiftyoneDegreesPropertiesGetPropertyIndexFromName(fiftyoneDegreesPropertiesAvailable *available, const char *propertyName)
Gets the index of the property in the source data structure from the name.
Definition: properties.c:439
const char ** array
Array of required properties or NULL if all properties are required.
Definition: properties.h:151
EXTERNAL int fiftyoneDegreesPropertiesGetPropertyIndexFromRequiredIndex(fiftyoneDegreesPropertiesAvailable *available, int requiredPropertyIndex)
Maps the required property index to the index in the source data structure.
Definition: properties.c:407
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
uint32_t propertyIndex
Index of the property in the collection of all properties.
Definition: properties.h:135
EXTERNAL fiftyoneDegreesPropertiesRequired fiftyoneDegreesPropertiesDefault
The default properties required to make all possible properties available.
Definition: properties.h:180
EXTERNAL void fiftyoneDegreesPropertiesFree(fiftyoneDegreesPropertiesAvailable *available)
Frees the memory and resources used by the properties results previously created using the fiftyoneDe...
Definition: properties.c:460
String structure containing its value and size.
Definition: string.h:80
EXTERNAL int fiftyoneDegreesPropertiesGetRequiredPropertyIndexFromName(fiftyoneDegreesPropertiesAvailable *available, const char *propertyName)
Gets the required property index in the list of all required properties from the name.
Definition: properties.c:417
EXTERNAL fiftyoneDegreesPropertiesAvailable * fiftyoneDegreesPropertiesCreate(fiftyoneDegreesPropertiesRequired *properties, void *state, fiftyoneDegreesPropertiesGetMethod getPropertyMethod)
Creates a properties result instance for use with future property operations.
Definition: properties.c:359
fiftyoneDegreesCollectionItem name
Name of the property from strings.
Definition: properties.h:137
EXTERNAL fiftyoneDegreesString * fiftyoneDegreesPropertiesGetNameFromRequiredIndex(fiftyoneDegreesPropertiesAvailable *available, int requiredPropertyIndex)
Gets the name as a string from the required property index.
Definition: properties.c:454
fiftyoneDegreesString *(* fiftyoneDegreesPropertiesGetMethod)(void *state, uint32_t index, fiftyoneDegreesCollectionItem *item)
Returns a string for the property at the index provided or NULL if there is no property available at ...
Definition: properties.h:170
Array of items of type fiftyoneDegreesPropertyAvailable used to easily access and track the size of t...
Definition: properties.h:140
Used to access the property item quickly without the need to search.
Definition: properties.h:134
fiftyoneDegreesPropertiesAvailable * existing
A pointer to an existing set of property names from another instance.
Definition: properties.h:157
Defines a set of properties which are required by a caller.
Definition: properties.h:150
int count
Number of properties in array.
Definition: properties.h:154
#define FIFTYONE_DEGREES_ARRAY_TYPE(t, m)
Simple array structure definition macro used for generic types.
Definition: array.h:41
const char * string
Separated list of required properties or NULL if all properties are required.
Definition: properties.h:155