51Degrees Device Detection C/C++  4.1

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 2019 51 Degrees Mobile Experts Limited, 5 Charlotte Close,
4  * Caversham, Reading, Berkshire, United Kingdom RG4 7BY.
5  *
6  * This Original Work is licensed under the European Union Public Licence (EUPL)
7  * 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 
71 #ifdef __cplusplus
72 #define EXTERNAL extern "C"
73 #else
74 #define EXTERNAL
75 #endif
76 
82 #define FIFTYONE_DEGREES_STRING(s) \
83  (const char*)(s == NULL ? NULL : &((fiftyoneDegreesString*)s)->value)
84 
86 #pragma pack(push, 2)
87 typedef struct fiftyone_degrees_string_t {
88  int16_t size;
89  char value;
91 #pragma pack(pop)
92 
93 #ifndef FIFTYONE_DEGREES_MEMORY_ONLY
94 
105 EXTERNAL void* fiftyoneDegreesStringRead(
106  const fiftyoneDegreesCollectionFile *file,
107  uint32_t offset,
108  fiftyoneDegreesData *data,
109  fiftyoneDegreesException *exception);
110 
111 #endif
112 
123  fiftyoneDegreesCollection *strings,
124  uint32_t offset,
126  fiftyoneDegreesException *exception);
127 
136  char const *a,
137  char const *b,
138  size_t length);
139 
146 EXTERNAL int fiftyoneDegreesStringCompare(char *a, char *b);
147 
152 #endif
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:444
int fiftyoneDegreesStringCompareLength(char const *a, char const *b, size_t length)
Case insensitively compare two strings up to the length requested.
String structure containing its value and size.
Definition: string.h:87
Data structure used for reusing memory which may have been allocated in a previous operation.
Definition: data.h:106
int fiftyoneDegreesStringCompare(char *a, char *b)
Case insensitively compare two strings.
int16_t size
Size of the string in memory.
Definition: string.h:88
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition: exceptions.h:116
fiftyoneDegreesString * fiftyoneDegreesStringGet(fiftyoneDegreesCollection *strings, uint32_t offset, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets the string at the required offset from the collection provided.
All the shared methods and fields required by file, memory and cached collections.
Definition: collection.h:407
void * fiftyoneDegreesStringRead(const fiftyoneDegreesCollectionFile *file, uint32_t offset, fiftyoneDegreesData *data, fiftyoneDegreesException *exception)
Reads a string from the source file at the offset within the string structure.
char value
The first character of the string.
Definition: string.h:89