- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

libcdr_utils.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* libcdr
3 * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License or as specified alternatively below. You may obtain a copy of
8 * the License at http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * Major Contributor(s):
16 * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch>
17 * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com>
18 *
19 *
20 * All Rights Reserved.
21 *
22 * For minor contributions see the git repository.
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
26 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
27 * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
28 * instead of those above.
29 */
30
31 #ifndef __LIBCDR_UTILS_H__
32 #define __LIBCDR_UTILS_H__
33
34 #include <stdio.h>
35 #include <string>
36 #include <math.h>
37 #include <libwpd/libwpd.h>
38 #include <libwpd-stream/libwpd-stream.h>
39
40 #ifndef M_PI
41 #define M_PI 3.14159265358979323846
42 #endif
43
44 #define CDR_EPSILON 1E-6
45 #define CDR_ALMOST_ZERO(m) fabs(m) <= CDR_EPSILON
46
47 #ifdef _MSC_VER
48
49 typedef unsigned char uint8_t;
50 typedef unsigned short uint16_t;
51 typedef unsigned uint32_t;
52 typedef int int32_t;
53 typedef unsigned __int64 uint64_t;
54
55 #else
56
57 #ifdef HAVE_CONFIG_H
58 #include <config.h>
59 #endif
60
61 #ifdef HAVE_STDINT_H
62 #include <stdint.h>
63 #endif
64
65 #ifdef HAVE_INTTYPES_H
66 #include <inttypes.h>
67 #endif
68
69 #endif
70
71 // debug message includes source file and line number
72 //#define VERBOSE_DEBUG 1
73
74 // do nothing with debug messages in a release compile
75 #ifdef DEBUG
76 #ifdef VERBOSE_DEBUG
77 #define CDR_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
78 #define CDR_DEBUG(M) M
79 #else
80 #define CDR_DEBUG_MSG(M) printf M
81 #define CDR_DEBUG(M) M
82 #endif
83 #else
84 #define CDR_DEBUG_MSG(M)
85 #define CDR_DEBUG(M)
86 #endif
87
88 namespace libcdr
89 {
90
91 uint8_t readU8(WPXInputStream *input, bool bigEndian=false);
92 uint16_t readU16(WPXInputStream *input, bool bigEndian=false);
93 uint32_t readU32(WPXInputStream *input, bool bigEndian=false);
94 uint64_t readU64(WPXInputStream *input, bool bigEndian=false);
95 int32_t readS32(WPXInputStream *input, bool bigEndian=false);
96
97 double readDouble(WPXInputStream *input, bool bigEndian=false);
98
99 ::WPXString readFourCC(WPXInputStream *input);
100
101 class EndOfStreamException
102 {
103 };
104
105 class GenericException
106 {
107 };
108
109 } // namespace libcdr
110
111 #endif // __LIBCDR_UTILS_H__
112 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libcdr::readDouble
double readDouble(WPXInputStream *input, bool bigEndian=false)
Definition: libcdr_utils.cpp:90
libcdr::EndOfStreamException
Definition: libcdr_utils.h:101
libcdr::readU64
uint64_t readU64(WPXInputStream *input, bool bigEndian=false)
Definition: libcdr_utils.cpp:75
libcdr::readU8
uint8_t readU8(WPXInputStream *input, bool bigEndian=false)
Definition: libcdr_utils.cpp:35
libcdr::GenericException
Definition: libcdr_utils.h:105
libcdr::readFourCC
::WPXString readFourCC(WPXInputStream *input)
Definition: libcdr_utils.cpp:103
libcdr::readU16
uint16_t readU16(WPXInputStream *input, bool bigEndian=false)
Definition: libcdr_utils.cpp:50
libcdr::readS32
int32_t readS32(WPXInputStream *input, bool bigEndian=false)
Definition: libcdr_utils.cpp:70
libcdr::readU32
uint32_t readU32(WPXInputStream *input, bool bigEndian=false)
Definition: libcdr_utils.cpp:59