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 <librevenge/librevenge.h>
00017 
00018 #ifndef M_PI
00019 #define M_PI 3.14159265358979323846
00020 #endif
00021 
00022 #define FH_EPSILON 1E-6
00023 #define FH_ALMOST_ZERO(m) (fabs(m) <= FH_EPSILON)
00024 
00025 #ifdef _MSC_VER
00026 
00027 typedef unsigned char uint8_t;
00028 typedef unsigned short uint16_t;
00029 typedef unsigned uint32_t;
00030 typedef unsigned __int64 uint64_t;
00031 typedef signed char int8_t;
00032 typedef short int16_t;
00033 typedef int int32_t;
00034 typedef __int64 int64_t;
00035 
00036 #else
00037 
00038 #ifdef HAVE_CONFIG_H
00039 
00040 #include <config.h>
00041 
00042 #ifdef HAVE_STDINT_H
00043 #include <stdint.h>
00044 #endif
00045 
00046 #ifdef HAVE_INTTYPES_H
00047 #include <inttypes.h>
00048 #endif
00049 
00050 #else
00051 
00052 // assume that the headers are there inside LibreOffice build when no HAVE_CONFIG_H is defined
00053 #include <stdint.h>
00054 #include <inttypes.h>
00055 
00056 #endif
00057 
00058 #endif
00059 
00060 // debug message includes source file and line number
00061 //#define VERBOSE_DEBUG 1
00062 
00063 // do nothing with debug messages in a release compile
00064 #ifdef DEBUG
00065 #ifdef VERBOSE_DEBUG
00066 #define FH_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
00067 #define FH_DEBUG(M) M
00068 #else
00069 #define FH_DEBUG_MSG(M) printf M
00070 #define FH_DEBUG(M) M
00071 #endif
00072 #else
00073 #define FH_DEBUG_MSG(M)
00074 #define FH_DEBUG(M)
00075 #endif
00076 
00077 namespace libfreehand
00078 {
00079 
00080 uint8_t readU8(librevenge::RVNGInputStream *input);
00081 uint16_t readU16(librevenge::RVNGInputStream *input);
00082 uint32_t readU32(librevenge::RVNGInputStream *input);
00083 int8_t readS8(librevenge::RVNGInputStream *input);
00084 int16_t readS16(librevenge::RVNGInputStream *input);
00085 int32_t readS32(librevenge::RVNGInputStream *input);
00086 
00087 class EndOfStreamException
00088 {
00089 };
00090 
00091 class GenericException
00092 {
00093 };
00094 
00095 } // namespace libfreehand
00096 
00097 #endif // __LIBFREEHAND_UTILS_H__
00098 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */