\r\n

51Degrees Device Detection C/C++  4.5

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

storedBinaryValue.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_STORED_BINARY_VALUE_H_INCLUDED
24 #define FIFTYONE_DEGREES_STORED_BINARY_VALUE_H_INCLUDED
25 
35 #include <stdint.h>
36 #include <ctype.h>
37 #include "exceptions.h"
38 #include "collection.h"
39 #include "float.h"
40 #include "common.h"
41 #include "ip.h"
42 #include "propertyValueType.h"
43 #include "string.h"
44 
70 #pragma pack(push, 1)
71 typedef struct fiftyone_degrees_var_length_byte_array_t {
72  int16_t size;
73  unsigned char firstByte;
75 #pragma pack(pop)
76 
80 #pragma pack(push, 1)
81 typedef union fiftyone_degrees_stored_binary_value_t {
85  int32_t intValue;
86  int16_t shortValue;
87  byte byteValue;
89 #pragma pack(pop)
90 
91 #ifndef FIFTYONE_DEGREES_MEMORY_ONLY
92 
106  const fiftyoneDegreesCollectionFile *file,
107  const fiftyoneDegreesCollectionKey *key,
108  fiftyoneDegreesData *data,
109  fiftyoneDegreesException *exception);
110 
111 #endif
112 
124  const fiftyoneDegreesCollection *strings,
125  uint32_t offset,
126  fiftyoneDegreesPropertyValueType storedValueType,
128  fiftyoneDegreesException *exception);
129 
142  fiftyoneDegreesPropertyValueType storedValueType,
143  const char *target,
144  fiftyoneDegreesStringBuilder *tempBuilder,
145  fiftyoneDegreesException *exception);
146 
157  fiftyoneDegreesPropertyValueType storedValueType,
158  int defaultValue);
159 
170  fiftyoneDegreesPropertyValueType storedValueType,
171  double defaultValue);
172 
183  fiftyoneDegreesPropertyValueType storedValueType,
184  bool defaultValue);
185 
190 #endif
void * fiftyoneDegreesStoredBinaryValueRead(const fiftyoneDegreesCollectionFile *file, const fiftyoneDegreesCollectionKey *key, fiftyoneDegreesData *data, fiftyoneDegreesException *exception)
Reads a binary value from the source file at the offset within the string structure.
String buffer for building strings with memory checks.
Definition: stringBuilder.h:82
fiftyoneDegreesString stringValue
String value (ASCII or UTF-8)
Definition: storedBinaryValue.h:82
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
byte byteValue
Single byte value.
Definition: storedBinaryValue.h:87
int16_t shortValue
Short value.
Definition: storedBinaryValue.h:86
Type of collection where the collection is streamed from file.
Definition: collection.h:438
Definition: storedBinaryValue.h:71
int fiftyoneDegreesStoredBinaryValueCompareWithString(const fiftyoneDegreesStoredBinaryValue *value, fiftyoneDegreesPropertyValueType storedValueType, const char *target, fiftyoneDegreesStringBuilder *tempBuilder, fiftyoneDegreesException *exception)
Function to compare the current binary value to the target string value using the text format.
Definition: string.h:93
Data structure used for reusing memory which may have been allocated in a previous operation.
Definition: data.h:101
bool fiftyoneDegreesStoredBinaryValueToBoolOrDefault(const fiftyoneDegreesStoredBinaryValue *value, fiftyoneDegreesPropertyValueType storedValueType, bool defaultValue)
Function to convert the binary value to bool when possible.
double fiftyoneDegreesStoredBinaryValueToDoubleOrDefault(const fiftyoneDegreesStoredBinaryValue *value, fiftyoneDegreesPropertyValueType storedValueType, double defaultValue)
Function to convert the binary value to double when possible.
int fiftyoneDegreesStoredBinaryValueToIntOrDefault(const fiftyoneDegreesStoredBinaryValue *value, fiftyoneDegreesPropertyValueType storedValueType, int defaultValue)
Function to convert the binary value to int when possible.
Struture that represents 51Degrees implementation, which encapsulate an array of 4 bytes.
Definition: float.h:111
fiftyoneDegreesVarLengthByteArray byteArrayValue
Byte array value (e.g.
Definition: storedBinaryValue.h:83
fiftyoneDegreesFloat floatValue
single precision floating point value
Definition: storedBinaryValue.h:84
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition: exceptions.h:111
Explains to a collection (or cache) what the consumer is looking for.
Definition: collectionKey.h:72
int32_t intValue
Integer value.
Definition: storedBinaryValue.h:85
All the shared methods and fields required by file, memory and cached collections.
Definition: collection.h:402
int16_t size
Size of the byte array in memory (starting from 'firstByte')
Definition: storedBinaryValue.h:72
"Packed" value that can be present inside "strings" of dataset.
Definition: storedBinaryValue.h:81
const fiftyoneDegreesStoredBinaryValue * fiftyoneDegreesStoredBinaryValueGet(const fiftyoneDegreesCollection *strings, uint32_t offset, fiftyoneDegreesPropertyValueType storedValueType, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets the binary value at the required offset from the collection provided.
unsigned char firstByte
The first byte of the array.
Definition: storedBinaryValue.h:73