\r\n

51Degrees Device Detection C/C++  4.5

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

string.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_STRING_H_INCLUDED
24 #define FIFTYONE_DEGREES_STRING_H_INCLUDED
25 
66 #include <stdint.h>
67 #include <ctype.h>
68 #include "exceptions.h"
69 #include "collection.h"
70 #include "float.h"
71 #include "common.h"
72 #include "ip.h"
73 #include "propertyValueType.h"
74 
80 #define FIFTYONE_DEGREES_STRING(s) \
81  (const char*)(s == NULL ? NULL : &((fiftyoneDegreesString*)s)->value)
82 
92 #pragma pack(push, 1)
93 typedef struct fiftyone_degrees_string_t {
94  int16_t size;
95  char value;
97 #pragma pack(pop)
98 
104 #ifndef FIFTYONE_DEGREES_MEMORY_ONLY
105 EXTERNAL uint32_t fiftyoneDegreesStringGetFinalSize(
106  const void *initial,
107  fiftyoneDegreesException *exception);
108 #else
109 #define fiftyoneDegreesStringGetFinalSize NULL
110 #endif
111 
112 
113 #ifndef FIFTYONE_DEGREES_MEMORY_ONLY
114 
124 EXTERNAL void* fiftyoneDegreesStringRead(
125  const fiftyoneDegreesCollectionFile *file,
126  const fiftyoneDegreesCollectionKey *key,
127  fiftyoneDegreesData *data,
128  fiftyoneDegreesException *exception);
129 
130 #endif
131 
142  const fiftyoneDegreesCollection *strings,
143  uint32_t offset,
145  fiftyoneDegreesException *exception);
146 
155  char const *a,
156  char const *b,
157  size_t length);
158 
165 EXTERNAL int fiftyoneDegreesStringCompare(const char *a, const char *b);
166 
174 EXTERNAL const char *fiftyoneDegreesStringSubString(const char *a, const char *b);
175 
180 #include "stringBuilder.h"
181 
182 #endif
const char * fiftyoneDegreesStringSubString(const char *a, const char *b)
Case insensitively searching a first occurrence of a substring.
int fiftyoneDegreesStringCompare(const char *a, const char *b)
Case insensitively compare two strings.
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
Type of collection where the collection is streamed from file.
Definition: collection.h:438
int fiftyoneDegreesStringCompareLength(char const *a, char const *b, size_t length)
Case insensitively compare two strings up to the length requested.
const fiftyoneDegreesString * fiftyoneDegreesStringGet(const fiftyoneDegreesCollection *strings, uint32_t offset, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets the string at the required offset from the collection provided.
Definition: string.h:93
void * fiftyoneDegreesStringRead(const fiftyoneDegreesCollectionFile *file, const fiftyoneDegreesCollectionKey *key, fiftyoneDegreesData *data, fiftyoneDegreesException *exception)
Reads a string from the source file at the offset within the string structure.
Data structure used for reusing memory which may have been allocated in a previous operation.
Definition: data.h:101
int16_t size
Size of the string in memory (starting from 'value')
Definition: string.h:94
uint32_t fiftyoneDegreesStringGetFinalSize(const void *initial, fiftyoneDegreesException *exception)
Gets size of String with trailing characters.
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
All the shared methods and fields required by file, memory and cached collections.
Definition: collection.h:402
char value
The first character of the string.
Definition: string.h:95