libwps_internal.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* libwps
3  * Version: MPL 2.0 / LGPLv2.1+
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * Major Contributor(s):
10  * Copyright (C) 2002 William Lachance (william.lachance@sympatico.ca)
11  * Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
12  *
13  * For minor contributions see the git repository.
14  *
15  * Alternatively, the contents of this file may be used under the terms
16  * of the GNU Lesser General Public License Version 2.1 or later
17  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
18  * applicable instead of those above.
19  *
20  * For further information visit http://libwps.sourceforge.net
21  */
22 
23 #ifndef LIBWPS_INTERNAL_H
24 #define LIBWPS_INTERNAL_H
25 
26 #include <assert.h>
27 #ifdef DEBUG
28 #include <stdio.h>
29 #endif
30 
31 #include <algorithm>
32 #include <cmath>
33 #include <iostream>
34 #include <map>
35 #include <memory>
36 #include <string>
37 #include <vector>
38 
39 #include <librevenge-stream/librevenge-stream.h>
40 #include <librevenge/librevenge.h>
41 
42 #ifndef M_PI
43 #define M_PI 3.14159265358979323846
44 #endif
45 
46 #if defined(_MSC_VER) || defined(__DJGPP__)
47 typedef signed char int8_t;
48 typedef unsigned char uint8_t;
49 typedef signed short int16_t;
50 typedef unsigned short uint16_t;
51 typedef signed int int32_t;
52 typedef unsigned int uint32_t;
53 #else /* !_MSC_VER && !__DJGPP__*/
54 # include <inttypes.h>
55 #endif /* _MSC_VER || __DJGPP__*/
56 
57 /* ---------- time/... --------------- */
58 #ifdef HAVE_CONFIG_H
59 # include "config.h"
60 #endif
61 
62 // define localtime_r on Windows, so that can use
63 // thread-safe functions on other environments
64 #ifdef _WIN32
65 # define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0)
66 # define localtime_r(tp,tmp) (localtime(tp)?(*(tmp)=*localtime(tp),(tmp)):0)
67 #endif
68 
70 template <class T>
72 {
73  void operator()(T *) {}
74 };
75 
77 #if defined(HAVE_CLANG_ATTRIBUTE_FALLTHROUGH)
78 # define WPS_FALLTHROUGH [[clang::fallthrough]]
79 #elif defined(HAVE_GCC_ATTRIBUTE_FALLTHROUGH)
80 # define WPS_FALLTHROUGH __attribute__((fallthrough))
81 #else
82 # define WPS_FALLTHROUGH ((void) 0)
83 #endif
84 
85 // basic classes and autoptr