51Degrees Common C/C++  4.1

A shared functionality library that is used by 51Degrees products

string.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_STRING_H_INCLUDED
17 #define FIFTYONE_DEGREES_STRING_H_INCLUDED
18 
59 #include <stdint.h>
60 #include <ctype.h>
61 #include "exceptions.h"
62 #include "collection.h"
63 
64 #ifdef __cplusplus
65 #define EXTERNAL extern "C"
66 #else
67 #define EXTERNAL
68 #endif
69 
75 #define FIFTYONE_DEGREES_STRING(s) \
76  (const char*)(s == NULL ? NULL : &((fiftyoneDegreesString*)s)->value)
77 
79 #pragma pack(push, 2)
80 typedef struct fiftyone_degrees_string_t {
81  int16_t size;
82  char value;
84 #pragma pack(pop)
85 
86 #ifndef FIFTYONE_DEGREES_MEMORY_ONLY
87 
98 EXTERNAL void* fiftyoneDegreesStringRead(
100  uint32_t offset,
101  fiftyoneDegreesData *data,
102  fiftyoneDegreesException *exception);
103 
104 #endif
105 
116  fiftyoneDegreesCollection *strings,
117  uint32_t offset,
119  fiftyoneDegreesException *exception);
120 
129  char const *a,
130  char const *b,
131  size_t length);
132 
139 EXTERNAL int fiftyoneDegreesStringCompare(char *a, char *b);
140 
145 #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:302
Type of collection where the collection is streamed from file.
Definition: collection.h:437
String structure containing its value and size.
Definition: string.h:80
Data structure used for reusing memory which may have been allocated in a previous operation.
Definition: data.h:99
EXTERNAL int fiftyoneDegreesStringCompareLength(char const *a, char const *b, size_t length)
Case insensitively compare two strings up to the length requested.
Definition: string.c:69
EXTERNAL int fiftyoneDegreesStringCompare(char *a, char *b)
Case insensitively compare two strings.
Definition: string.c:56
int16_t size
Size of the string in memory.
Definition: string.h:81
EXTERNAL fiftyoneDegreesString * fiftyoneDegreesStringGet(fiftyoneDegreesCollection *strings, uint32_t offset, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets the string at the required offset from the collection provided.
Definition: string.c:44
EXTERNAL 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.
Definition: string.c:26
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition: exceptions.h:109
All the shared methods and fields required by file, memory and cached collections.
Definition: collection.h:400
char value
The first character of the string.
Definition: string.h:82