libUTL++
util.h
1 #pragma once
2 
4 
5 extern "C" {
6 struct ssl_ctx_st;
7 typedef struct ssl_ctx_st SSL_CTX;
8 }
9 
11 
12 UTL_NS_BEGIN;
13 
15 
16 class Allocator;
17 class Object;
18 class Stream;
19 
21 
26 enum cmp_t
27 {
33 };
34 
36 
41 enum find_t
42 {
43  find_any = 0,
44  find_first = 1,
45  find_last = 2,
46  find_ip = 3
47 };
48 
50 
55 enum io_t
56 {
57  io_null = 0,
58  io_rd = 1,
59  io_wr = 2,
60  io_rdwr = 3
61 };
62 
64 
71 {
76 };
77 
79 
87 void init();
88 
90 
98 void deInit();
99 
101 
105 bool initialized();
106 
108 
117 void abort(const char* filename, int lineNo, const char* text = nullptr);
118 
120 
127 void abort(const char* text);
128 
130 
139 int compare(bool lhs, bool rhs);
140 
142 
152 void die(const char* filename, int lineNo, const char* text = nullptr, int exitCode = 1);
153 
155 
163 void die(const char* text, int exitCode = 1);
164 
166 
174 
176 
183 void setSerializeMode(uint_t mode);
184 
186 
196 void* realloc(void* ptr, size_t size, size_t newSize);
197 
199 
207 char* strdup(const char* str);
208 
210 
217 SSL_CTX* sslContext();
218 
220 
229 bool sslVerifyLocations(const char* caFile, const char* caPath);
230 
232 // Serialization of Built-In Types /////////////////////////////////////////////////////////////////
234 
244 void serialize(bool& b, Stream& stream, uint_t io, uint_t mode = ser_default);
245 
247 
257 void serialize(int8_t& i, Stream& stream, uint_t io, uint_t mode = ser_default);
258 
260 
270 void serialize(char& c, Stream& stream, uint_t io, uint_t mode = ser_default);
271 
273 
283 void serialize(uint8_t& i, Stream& stream, uint_t io, uint_t mode = ser_default);
284 
286 
296 void serialize(int16_t& i, Stream& stream, uint_t io, uint_t mode = ser_default);
297 
299 
309 void serialize(uint16_t& i, Stream& stream, uint_t io, uint_t mode = ser_default);
310 
312 
322 void serialize(int32_t& i, Stream& stream, uint_t io, uint_t mode = ser_default);
323 
325 
335 void serialize(uint32_t& i, Stream& stream, uint_t io, uint_t mode = ser_default);
336 
338 
348 void serialize(long& i, Stream& stream, uint_t io, uint_t mode = ser_default);
349 
351 
361 void serialize(ulong_t& i, Stream& stream, uint_t io, uint_t mode = ser_default);
362 
364 
365 #if UTL_SIZEOF_LONG == 4
366 
368 
378 void serialize(int64_t& i, Stream& stream, uint_t io, uint_t mode = ser_default);
379 
381 
391 void serialize(uint64_t& i, Stream& stream, uint_t io, uint_t mode = ser_default);
392 
394 
395 #endif // UTL_SIZEOF_LONG == 4
396 
398 
408 void serialize(double& n, Stream& stream, uint_t io, uint_t mode = ser_default);
409 
411 
421 void serialize(Object& object, Stream& stream, uint_t io, uint_t mode = ser_default);
422 
424 
425 // disallow serialization of pointer types
426 UTL_TYPE_NO_SERIALIZE(void*);
427 UTL_TYPE_NO_SERIALIZE(char*);
429 
431 
432 UTL_NS_END;
less-than-or-equal-to
Definition: util.h:29
bool initialized()
Determine whether UTL++ initialization has been done.
space-efficient and portable representation
Definition: util.h:73
find_t
Find strategy.
Definition: util.h:41
void deInit()
De-initialize UTL++.
find last matching object
Definition: util.h:45
unsigned char uint8_t
Unsigned 8-bit integer.
Definition: types.h:87
serialize_t
Specifies a serialization mode.
Definition: util.h:70
default representation (via getSerializeMode())
Definition: util.h:75
void setSerializeMode(uint_t mode)
Set the default serialization mode (see utl::serialize_t).
char * strdup(const char *str)
Duplicate the given string.
unsigned char byte_t
Unsigned character.
Definition: types.h:31
void abort(const char *text)
Abort the process.
read/write
Definition: util.h:60
nonportable space- and time-efficient representation
Definition: util.h:74
long int64_t
Signed 64-bit integer.
Definition: types.h:164
bool sslVerifyLocations(const char *caFile, const char *caPath)
Set default locations for trusted CA certificates.
void serialize(Object &object, Stream &stream, uint_t io, uint_t mode=ser_default)
Serialize an object.
unsigned int uint32_t
Unsigned 32-bit integer.
Definition: types.h:115
write
Definition: util.h:59
find any matching object
Definition: util.h:43
find insertion point
Definition: util.h:46
read
Definition: util.h:58
cmp_t
Comparison operators.
Definition: util.h:26
unsigned long uint64_t
Unsigned 64-bit integer.
Definition: types.h:154
signed char int8_t
Signed 8-bit integer.
Definition: types.h:93
greater-than
Definition: util.h:31
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
less-than
Definition: util.h:28
void die(const char *text, int exitCode=1)
Exit the process with an error code.
Stream I/O abstraction.
Definition: Stream.h:68
unsigned short uint16_t
Unsigned 16-bit integer.
Definition: types.h:101
null value
Definition: util.h:57
unsigned long ulong_t
Unsigned long integer.
Definition: types.h:73
signed int int32_t
Signed 32-bit integer.
Definition: types.h:121
greater-than-or-equal-to
Definition: util.h:32
io_t
I/O flags.
Definition: util.h:55
find first matching object
Definition: util.h:44
human-readable and portable representation
Definition: util.h:72
SSL_CTX * sslContext()
Get a pointer to the global SSL context.
signed short int16_t
Signed 16-bit integer.
Definition: types.h:107
void * realloc(void *ptr, size_t size, size_t newSize)
Re-allocate the given block.
uint_t getSerializeMode()
Get the default serialization mode (see utl::serialize_t).
#define UTL_TYPE_NO_SERIALIZE(typeName)
Declare that a type cannot be serialized.
Definition: macros.h:638
equal-to
Definition: util.h:30
Root of UTL++ class hierarchy.
Definition: Object.h:52
int compare(bool lhs, bool rhs)
Compare two boolean values.
void init()
Initialize UTL++.