Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ahDefs.H
Go to the documentation of this file.
1
2/*
3 Aleph_w
4
5 Data structures & Algorithms
6 version 2.0.0b
7 https://github.com/lrleon/Aleph-w
8
9 This file is part of Aleph-w library
10
11 Copyright (c) 2002-2026 Leandro Rabindranath Leon
12
13 Permission is hereby granted, free of charge, to any person obtaining a copy
14 of this software and associated documentation files (the "Software"), to deal
15 in the Software without restriction, including without limitation the rights
16 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 copies of the Software, and to permit persons to whom the Software is
18 furnished to do so, subject to the following conditions:
19
20 The above copyright notice and this permission notice shall be included in all
21 copies or substantial portions of the Software.
22
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 SOFTWARE.
30*/
31
32
44#ifndef AHDEFS_H
45#define AHDEFS_H
46
47#include <unistd.h>
48#include <time.h>
49#include <stdint.h>
50#include <cstdlib>
51#include <cstdio>
52#include <cstdarg>
53
54#include <stdexcept>
55#include <utility>
56#include <iostream>
57
65
73
82
83namespace Aleph
84{
85
90
95
105{
107 Empty_Class() { /* empty */ }
108
113
118
123
128 Empty_Class & operator=(const Empty_Class & unused) { (void) unused; return *this; }
129
133 bool operator == (const Empty_Class &) const { return true; }
134
138 bool operator != (const Empty_Class &) const { return false; }
139
144 friend std::ostream & operator << (std::ostream & o, const Empty_Class&)
145 {
146 return o;
147 }
148
153 friend std::istream & operator >> (std::istream & i, const Empty_Class&)
154 {
155 return i;
156 }
157};
158
160const int UnknownSize = -1;
161
163const int UnknownLine = -1;
164
166const int UnknownLoad = -1;
167
171extern bool daemonized;
172
176extern bool verbose;
177
181extern double max_time;
182
192extern void message(const char * file, int line, const char *format, ...);
193
203extern void error(const char * file, int line, const char *format, ...);
204
214extern void exit(const char * file, int line, const char *format, ...);
215
225extern void warning(const char * file, int line, const char *format, ...);
226
234extern void syslog(const char * format, va_list ap);
235
236} // end namespace Aleph
237
238#ifdef MESSAGES
239
245#define MESSAGE(format, args...) \
246 Aleph::message(__FILE__, __LINE__, format , ##args)
247
253#define WARNING(format, args...) \
254 Aleph::warning(__FILE__, __LINE__, format , ##args)
255
256#else
257
259#define MESSAGE(format, args...)
260
262#define WARNING(format, args...)
263
264#endif
265
271#define AH_ERROR(format, args...) \
272 Aleph::error(__FILE__, __LINE__, format , ##args)
273
279#define EXIT(format, args...) \
280 Aleph::exit(__FILE__, __LINE__, format , ##args)
281
287#define POINTER_HAS_BEEN_FOUND(ptr) ((ptr) not_eq nullptr)
288
294#define POINTER_HAS_NOT_BEEN_FOUND(ptr) ((ptr) == nullptr)
295
301#define Exception_Prototypes(list...) throw(std::exception, ##list)
302
303#endif // AHDEFS_H
EmptyCtor
Tag type for empty/default construction.
Definition ahDefs.H:64
@ emptyCtor
Definition ahDefs.H:64
SentinelCtor
Tag type for sentinel node construction.
Definition ahDefs.H:81
@ sentinelCtor
Definition ahDefs.H:81
NoExceptionCtor
Tag type for no-exception construction.
Definition ahDefs.H:72
@ no_exception_ctor
Definition ahDefs.H:72
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
const IPv4_Address Null_IPv4_Address
Null/invalid IPv4 address constant.
Definition ahDefs.C:43
double max_time
Maximum allowed execution time (in seconds).
Definition ahDefs.C:47
const int UnknownLine
Constant indicating unknown line number.
Definition ahDefs.H:163
void message(const char *file, int line, const char *format,...)
Print an informational message with file and line info.
Definition ahDefs.C:100
const int UnknownSize
Constant indicating unknown size.
Definition ahDefs.H:160
void syslog(const char *format, va_list ap)
Write a message to syslog.
void exit(const char *file, int line, const char *format,...)
Print a message and exit the program.
Definition ahDefs.C:132
void warning(const char *file, int line, const char *format,...)
Print a warning message with file and line info.
Definition ahDefs.C:160
uint32_t IPv4_Address
Type alias for IPv4 addresses stored as 32-bit integers.
Definition ahDefs.H:89
void error(const char *file, int line, const char *format,...)
Print an error message with file and line info.
Definition ahDefs.C:105
const int UnknownLoad
Constant indicating unknown load factor.
Definition ahDefs.H:166
bool daemonized
Flag indicating if the process is running as a daemon.
Definition ahDefs.C:41
bool verbose
Flag enabling verbose output.
Definition ahDefs.C:45
DynList< T > maps(const C &c, Op op)
Classic map operation.
Empty placeholder class with no data members.
Definition ahDefs.H:105
bool operator!=(const Empty_Class &) const
Inequality comparison (always false).
Definition ahDefs.H:138
bool operator==(const Empty_Class &) const
Equality comparison (always true).
Definition ahDefs.H:133
friend std::ostream & operator<<(std::ostream &o, const Empty_Class &)
Stream output operator (outputs nothing).
Definition ahDefs.H:144
Empty_Class & operator=(const Empty_Class &unused)
Copy assignment operator.
Definition ahDefs.H:128
Empty_Class(const Empty_Class &unused)
Copy constructor.
Definition ahDefs.H:122
friend std::istream & operator>>(std::istream &i, const Empty_Class &)
Stream input operator (reads nothing).
Definition ahDefs.H:153
Empty_Class(EmptyCtor unused)
Empty constructor variant.
Definition ahDefs.H:112
Empty_Class(SentinelCtor unused)
Sentinel constructor variant.
Definition ahDefs.H:117
Empty_Class()
Default constructor.
Definition ahDefs.H:107
fstream file[12]
Definition treapObs.C:67