Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __LIBCDR_UTILS_H__
00032 #define __LIBCDR_UTILS_H__
00033
00034 #include <stdio.h>
00035 #include <string>
00036 #include <math.h>
00037 #include <vector>
00038 #include <libwpd-stream/libwpd-stream.h>
00039 #include <libwpd/libwpd.h>
00040
00041 #ifndef M_PI
00042 #define M_PI 3.14159265358979323846
00043 #endif
00044
00045 #define CDR_EPSILON 1E-6
00046 #define CDR_ALMOST_ZERO(m) fabs(m) <= CDR_EPSILON
00047
00048 #ifdef _MSC_VER
00049
00050 typedef unsigned char uint8_t;
00051 typedef unsigned short uint16_t;
00052 typedef unsigned uint32_t;
00053 typedef int int32_t;
00054 typedef unsigned __int64 uint64_t;
00055
00056 #else
00057
00058 #ifdef HAVE_CONFIG_H
00059
00060 #include <config.h>
00061
00062 #ifdef HAVE_STDINT_H
00063 #include <stdint.h>
00064 #endif
00065
00066 #ifdef HAVE_INTTYPES_H
00067 #include <inttypes.h>
00068 #endif
00069
00070 #else
00071
00072
00073 #include <stdint.h>
00074 #include <inttypes.h>
00075
00076 #endif
00077
00078 #endif
00079
00080
00081
00082
00083
00084 #ifdef DEBUG
00085 #ifdef VERBOSE_DEBUG
00086 #define CDR_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
00087 #define CDR_DEBUG(M) M
00088 #else
00089 #define CDR_DEBUG_MSG(M) printf M
00090 #define CDR_DEBUG(M) M
00091 #endif
00092 #else
00093 #define CDR_DEBUG_MSG(M)
00094 #define CDR_DEBUG(M)
00095 #endif
00096
00097 namespace libcdr
00098 {
00099
00100 uint8_t readU8(WPXInputStream *input, bool bigEndian=false);
00101 uint16_t readU16(WPXInputStream *input, bool bigEndian=false);
00102 uint32_t readU32(WPXInputStream *input, bool bigEndian=false);
00103 uint64_t readU64(WPXInputStream *input, bool bigEndian=false);
00104 int32_t readS32(WPXInputStream *input, bool bigEndian=false);
00105 int16_t readS16(WPXInputStream *input, bool bigEndian=false);
00106
00107 double readDouble(WPXInputStream *input, bool bigEndian=false);
00108
00109 double readFixedPoint(WPXInputStream *input, bool bigEndian=false);
00110
00111 int cdr_round(double d);
00112
00113 void writeU8(WPXBinaryData &buffer, const int value);
00114 void writeU16(WPXBinaryData &buffer, const int value);
00115 void writeU32(WPXBinaryData &buffer, const int value);
00116 void appendCharacters(WPXString &text, std::vector<unsigned char> characters, unsigned short charset);
00117 void appendCharacters(WPXString &text, std::vector<unsigned char> characters);
00118
00119 #ifdef DEBUG
00120 const char *toFourCC(unsigned value, bool bigEndian=false);
00121 #endif
00122
00123 class EndOfStreamException
00124 {
00125 };
00126
00127 class GenericException
00128 {
00129 };
00130
00131 class UnknownPrecisionException
00132 {
00133 };
00134
00135 }
00136
00137 #endif // __LIBCDR_UTILS_H__
00138