libfreehand_utils.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libfreehand project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef __LIBFREEHAND_UTILS_H__
00011 #define __LIBFREEHAND_UTILS_H__
00012 
00013 #include <stdio.h>
00014 #include <string>
00015 #include <math.h>
00016 #include <libwpd/libwpd.h>
00017 #include <libwpd-stream/libwpd-stream.h>
00018 
00019 #ifndef M_PI
00020 #define M_PI 3.14159265358979323846
00021 #endif
00022 
00023 #define FH_EPSILON 1E-6
00024 #define FH_ALMOST_ZERO(m) (fabs(m) <= FH_EPSILON)
00025 
00026 #ifdef _MSC_VER
00027 
00028 typedef unsigned char uint8_t;
00029 typedef unsigned short uint16_t;
00030 typedef unsigned uint32_t;
00031 typedef unsigned __int64 uint64_t;
00032 typedef signed char int8_t;
00033 typedef short int16_t;
00034 typedef int int32_t;
00035 typedef __int64 int64_t;
00036 
00037 #else
00038 
00039 #ifdef HAVE_CONFIG_H
00040 
00041 #include <config.h>
00042 
00043 #ifdef HAVE_STDINT_H
00044 #include <stdint.h>
00045 #endif
00046 
00047 #ifdef HAVE_INTTYPES_H
00048 #include <inttypes.h>
00049 #endif
00050 
00051 #else
00052 
00053 // assume that the headers are there inside LibreOffice build when no HAVE_CONFIG_H is defined
00054 #include <stdint.h>
00055 #include <inttypes.h>
00056 
00057 #endif
00058 
00059 #endif
00060 
00061 // debug message includes source file and line number
00062 //#define VERBOSE_DEBUG 1
00063 
00064 // do nothing with debug messages in a release compile
00065 #ifdef DEBUG
00066 #ifdef VERBOSE_DEBUG
00067 #define FH_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
00068 #define FH_DEBUG(M) M
00069 #else
00070 #define FH_DEBUG_MSG(M) printf M
00071 #define FH_DEBUG(M) M
00072 #endif
00073 #else
00074 #define FH_DEBUG_MSG(M)
00075 #define FH_DEBUG(M)
00076 #endif
00077 
00078 namespace libfreehand
00079 {
00080 
00081 uint8_t readU8(WPXInputStream *input);
00082 uint16_t readU16(WPXInputStream *input);
00083 uint32_t readU32(WPXInputStream *input);
00084 int8_t readS8(WPXInputStream *input);
00085 int16_t readS16(WPXInputStream *input);
00086 int32_t readS32(WPXInputStream *input);
00087 
00088 class EndOfStreamException
00089 {
00090 };
00091 
00092 class GenericException
00093 {
00094 };
00095 
00096 } // namespace libfreehand
00097 
00098 #endif // __LIBFREEHAND_UTILS_H__
00099 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */