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

stringBuilder.h

1/* *********************************************************************
2 * This Original Work is copyright of 51 Degrees Mobile Experts Limited.
3 * Copyright 2026 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_BUILDER_H_INCLUDED
24#define FIFTYONE_DEGREES_STRING_BUILDER_H_INCLUDED
25
26#ifdef FIFTYONE_DEGREES_IPI_SYMBOLS
27#include "ipiSymbols.h"
28#endif
29
69
70#include <stdint.h>
71#include <ctype.h>
72#include "exceptions.h"
73#include "collection.h"
74#include "float.h"
75#include "common.h"
76#include "ip.h"
77#include "propertyValueType.h"
78
79union fiftyone_degrees_stored_binary_value_t;
80typedef union fiftyone_degrees_stored_binary_value_t fiftyoneDegreesStoredBinaryValue;
81
82struct fiftyone_degrees_var_length_byte_array_t;
83typedef struct fiftyone_degrees_var_length_byte_array_t fiftyoneDegreesVarLengthByteArray;
84
86typedef struct fiftyone_degrees_string_builder_t {
87 char* const ptr;
88 size_t const length;
89 char* current;
90 size_t remaining;
91 size_t added;
93 bool full;
95
103
112 char const value);
113
122 int64_t const value);
123
133 double value,
134 uint8_t decimalPlaces);
135
145 const char* value,
146 size_t length);
147
157 const fiftyoneDegreesVarLengthByteArray *ipAddress,
159 fiftyoneDegreesException *exception);
160
172 fiftyoneDegreesPropertyValueType valueType,
173 uint8_t decimalPlaces,
174 fiftyoneDegreesException *exception);
175
183
187
188#endif
fiftyoneDegreesStringBuilder * fiftyoneDegreesStringBuilderAddInteger(fiftyoneDegreesStringBuilder *builder, int64_t const value)
Adds the integer to the buffer.
fiftyoneDegreesStringBuilder * fiftyoneDegreesStringBuilderAddStringValue(fiftyoneDegreesStringBuilder *builder, const fiftyoneDegreesStoredBinaryValue *value, fiftyoneDegreesPropertyValueType valueType, uint8_t decimalPlaces, fiftyoneDegreesException *exception)
Adds a potentially packed value as a proper string to the buffer.
fiftyoneDegreesStringBuilder * fiftyoneDegreesStringBuilderComplete(fiftyoneDegreesStringBuilder *builder)
Adds a null terminating character to the buffer.
void fiftyoneDegreesStringBuilderAddIpAddress(fiftyoneDegreesStringBuilder *builder, const fiftyoneDegreesVarLengthByteArray *ipAddress, fiftyoneDegreesIpType type, fiftyoneDegreesException *exception)
Adds an the IP (as string) from byte "string".
fiftyoneDegreesStringBuilder * fiftyoneDegreesStringBuilderInit(fiftyoneDegreesStringBuilder *builder)
Initializes the buffer.
fiftyoneDegreesStringBuilder * fiftyoneDegreesStringBuilderAddChars(fiftyoneDegreesStringBuilder *builder, const char *value, size_t length)
Adds the string to the buffer.
fiftyoneDegreesStringBuilder * fiftyoneDegreesStringBuilderAddDouble(fiftyoneDegreesStringBuilder *builder, double value, uint8_t decimalPlaces)
Adds the double to the buffer.
fiftyoneDegreesStringBuilder * fiftyoneDegreesStringBuilderAddChar(fiftyoneDegreesStringBuilder *builder, char const value)
Adds the character to the buffer.
fiftyoneDegreesIpType
Enum indicating the type of IP address.
Definition ip.h:63
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition exceptions.h:115
String buffer for building strings with memory checks.
Definition stringBuilder.h:86
size_t added
Characters added to the buffer or that would be added if the buffer were long enough.
Definition stringBuilder.h:91
size_t const length
Length of buffer.
Definition stringBuilder.h:88
char *const ptr
Pointer to the memory used by the buffer.
Definition stringBuilder.h:87
char * current
/ Current position to add characters in the buffer
Definition stringBuilder.h:89
bool full
True if the buffer is full, otherwise false.
Definition stringBuilder.h:93
size_t remaining
Remaining characters in the buffer.
Definition stringBuilder.h:90
Definition storedBinaryValue.h:75
"Packed" value that can be present inside "strings" of dataset.
Definition storedBinaryValue.h:85