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 short int16_t;
00053 typedef unsigned uint32_t;
00054 typedef int int32_t;
00055 typedef unsigned __int64 uint64_t;
00056 typedef __int64 int64_t;
00057
00058 #else
00059
00060 #ifdef HAVE_CONFIG_H
00061
00062 #include <config.h>
00063
00064 #ifdef HAVE_STDINT_H
00065 #include <stdint.h>
00066 #endif
00067
00068 #ifdef HAVE_INTTYPES_H
00069 #include <inttypes.h>
00070 #endif
00071
00072 #else
00073
00074
00075 #include <stdint.h>
00076 #include <inttypes.h>
00077
00078 #endif
00079
00080 #endif
00081
00082
00083
00084
00085
00086 #ifdef DEBUG
00087 #ifdef VERBOSE_DEBUG
00088 #define CDR_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
00089 #define CDR_DEBUG(M) M
00090 #else
00091 #define CDR_DEBUG_MSG(M) printf M
00092 #define CDR_DEBUG(M) M
00093 #endif
00094 #else
00095 #define CDR_DEBUG_MSG(M)
00096 #define CDR_DEBUG(M)
00097 #endif
00098
00099 namespace libcdr
00100 {
00101
00102 uint8_t readU8(WPXInputStream *input, bool bigEndian=false);
00103 uint16_t readU16(WPXInputStream *input, bool bigEndian=false);
00104 uint32_t readU32(WPXInputStream *input, bool bigEndian=false);
00105 uint64_t readU64(WPXInputStream *input, bool bigEndian=false);
00106 int32_t readS32(WPXInputStream *input, bool bigEndian=false);
00107 int16_t readS16(WPXInputStream *input, bool bigEndian=false);
00108
00109 double readDouble(WPXInputStream *input, bool bigEndian=false);
00110
00111 double readFixedPoint(WPXInputStream *input, bool bigEndian=false);
00112
00113 int cdr_round(double d);
00114
00115 void writeU8(WPXBinaryData &buffer, const int value);
00116 void writeU16(WPXBinaryData &buffer, const int value);
00117 void writeU32(WPXBinaryData &buffer, const int value);
00118 void appendCharacters(WPXString &text, std::vector<unsigned char> characters, unsigned short charset);
00119 void appendCharacters(WPXString &text, std::vector<unsigned char> characters);
00120
00121 #ifdef DEBUG
00122 const char *toFourCC(unsigned value, bool bigEndian=false);
00123 #endif
00124
00125 class EndOfStreamException
00126 {
00127 };
00128
00129 class GenericException
00130 {
00131 };
00132
00133 class UnknownPrecisionException
00134 {
00135 };
00136
00137 class EncodingException
00138 {
00139 };
00140
00141 }
00142
00143 #endif // __LIBCDR_UTILS_H__
00144