Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __LIBPAGEMAKER_UTILS_H__
00011 #define __LIBPAGEMAKER_UTILS_H__
00012
00013 #include <cmath>
00014 #include <cstdio>
00015
00016 #include <string>
00017
00018 #include <boost/shared_ptr.hpp>
00019
00020 #include <librevenge-stream/librevenge-stream.h>
00021 #include <librevenge/librevenge.h>
00022
00023 #ifndef M_PI
00024 #define M_PI 3.14159265358979323846
00025 #endif
00026
00027 #ifdef _MSC_VER
00028
00029 typedef unsigned char uint8_t;
00030 typedef signed char int8_t;
00031 typedef unsigned short uint16_t;
00032 typedef short int16_t;
00033 typedef unsigned uint32_t;
00034 typedef int int32_t;
00035 typedef unsigned __int64 uint64_t;
00036 typedef __int64 int64_t;
00037
00038 #else
00039
00040 #ifdef HAVE_CONFIG_H
00041
00042 #include <config.h>
00043
00044 #ifdef HAVE_STDINT_H
00045 #include <stdint.h>
00046 #endif
00047
00048 #ifdef HAVE_INTTYPES_H
00049 #include <inttypes.h>
00050 #endif
00051
00052 #else
00053
00054
00055 #include <stdint.h>
00056 #include <inttypes.h>
00057
00058 #endif
00059
00060 #endif
00061
00062
00063
00064
00065
00066 #ifdef DEBUG
00067 #ifdef VERBOSE_DEBUG
00068 #define PMD_DEBUG_MSG(M) std::printf("%15s:%5d: ", __FILE__, __LINE__); std::printf M
00069 #define PMD_DEBUG(M) M
00070 #else
00071 #define PMD_DEBUG_MSG(M) std::printf M
00072 #define PMD_DEBUG(M) M
00073 #endif
00074 #else
00075 #define PMD_DEBUG_MSG(M)
00076 #define PMD_DEBUG(M)
00077 #endif
00078
00079
00080 #define PMD_WARN_MSG(M) std::fprintf(stderr, "PageMaker [WARN] %15s:%d: ", __FILE__, __LINE__); std::fprintf(stderr, M)
00081 #define PMD_ERR_MSG(M) std::fprintf(stderr, "PageMaker [ERROR] %15s:%d: ", __FILE__, __LINE__); std::fprintf(stderr, M)
00082
00083
00084 #define PMD_NUM_ELEMENTS(array) sizeof(array)/sizeof(array[0])
00085
00086 namespace libpagemaker
00087 {
00088
00089 typedef librevenge::RVNGInputStream *RVNGInputStreamPtr;
00090
00091 struct PMDDummyDeleter
00092 {
00093 void operator()(void *) {}
00094 };
00095
00096 uint8_t readU8(const RVNGInputStreamPtr &input, bool = false);
00097 int8_t readS8(const RVNGInputStreamPtr &input, bool = false);
00098 uint16_t readU16(const RVNGInputStreamPtr &input, bool bigEndian=false);
00099 int16_t readS16(const RVNGInputStreamPtr &input, bool bigEndian=false);
00100 uint32_t readU32(const RVNGInputStreamPtr &input, bool bigEndian=false);
00101 int32_t readS32(const RVNGInputStreamPtr &input, bool bigEndian=false);
00102 uint64_t readU64(const RVNGInputStreamPtr &input, bool bigEndian=false);
00103 int64_t readS64(const RVNGInputStreamPtr &input, bool bigEndian=false);
00104
00105 const unsigned char *readNBytes(const RVNGInputStreamPtr &input, unsigned long numBytes);
00106
00107 void skip(const RVNGInputStreamPtr &input, unsigned long numBytes);
00108
00109 void seek(const RVNGInputStreamPtr &input, unsigned long pos);
00110 void seekRelative(const RVNGInputStreamPtr &input, long pos);
00111
00112 unsigned long getLength(const RVNGInputStreamPtr &input);
00113
00114 struct PMDStreamException
00115 {
00116 virtual ~PMDStreamException() { }
00117 };
00118
00119 struct EndOfStreamException : public PMDStreamException
00120 {
00121 EndOfStreamException();
00122 };
00123
00124 struct GenericException
00125 {
00126 };
00127
00128 }
00129
00130 #endif // __LIBPAGEMAKER_UTILS_H__
00131
00132