\r\n

51Degrees Device Detection C/C++  4.5

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 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_BUILDER_H_INCLUDED
24 #define FIFTYONE_DEGREES_STRING_BUILDER_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 
75 union fiftyone_degrees_stored_binary_value_t;
76 typedef union fiftyone_degrees_stored_binary_value_t fiftyoneDegreesStoredBinaryValue;
77 
78 struct fiftyone_degrees_var_length_byte_array_t;
79 typedef struct fiftyone_degrees_var_length_byte_array_t fiftyoneDegreesVarLengthByteArray;
80 
82 typedef struct fiftyone_degrees_string_builder_t {
83  char* const ptr;
84  size_t const length;
85  char* current;
86  size_t remaining;
87  size_t added;
89  bool full;
91 
99 
108  char const value);
109 
118  int64_t const value);
119 
129  double value,
130  uint8_t decimalPlaces);
131 
141  const char* value,
142  size_t length);
143 
153  const fiftyoneDegreesVarLengthByteArray *ipAddress,
155  fiftyoneDegreesException *exception);
156 
168  fiftyoneDegreesPropertyValueType valueType,
169  uint8_t decimalPlaces,
170  fiftyoneDegreesException *exception);
171 
179 
184 #endif
size_t remaining
Remaining characters in the buffer.
Definition: stringBuilder.h:86
String buffer for building strings with memory checks.
Definition: stringBuilder.h:82
fiftyoneDegreesStringBuilder * fiftyoneDegreesStringBuilderInit(fiftyoneDegreesStringBuilder *builder)
Initializes the buffer.
size_t const length
Length of buffer.
Definition: stringBuilder.h:84
Definition: storedBinaryValue.h:71
fiftyoneDegreesStringBuilder * fiftyoneDegreesStringBuilderAddInteger(fiftyoneDegreesStringBuilder *builder, int64_t const value)
Adds the integer to the buffer.
bool full
True if the buffer is full, otherwise false.
Definition: stringBuilder.h:89
size_t added
Characters added to the buffer or that would be added if the buffer were long enough.
Definition: stringBuilder.h:87
fiftyoneDegreesStringBuilder * fiftyoneDegreesStringBuilderAddChar(fiftyoneDegreesStringBuilder *builder, char const value)
Adds the character to the buffer.
char * current
/ Current position to add characters in the buffer
Definition: stringBuilder.h:85
fiftyoneDegreesStringBuilder * fiftyoneDegreesStringBuilderComplete(fiftyoneDegreesStringBuilder *builder)
Adds a null terminating character 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.
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition: exceptions.h:111
char *const ptr
Pointer to the memory used by the buffer.
Definition: stringBuilder.h:83
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.
fiftyoneDegreesIpType
Enum indicating the type of IP address.
Definition: ip.h:59
void fiftyoneDegreesStringBuilderAddIpAddress(fiftyoneDegreesStringBuilder *builder, const fiftyoneDegreesVarLengthByteArray *ipAddress, fiftyoneDegreesIpType type, fiftyoneDegreesException *exception)
Adds an the IP (as string) from byte "string".
"Packed" value that can be present inside "strings" of dataset.
Definition: storedBinaryValue.h:81