30 #ifndef __LIBMSPUB_UTILS_H__
31 #define __LIBMSPUB_UTILS_H__
33 const double PI = 3.1415926;
39 #include <boost/ptr_container/ptr_map.hpp>
40 #include <libwpd/libwpd.h>
41 #include <libwpd-stream/libwpd-stream.h>
47 typedef unsigned char uint8_t;
48 typedef unsigned short uint16_t;
49 typedef unsigned uint32_t;
51 typedef unsigned __int64 uint64_t;
63 #ifdef HAVE_INTTYPES_H
83 #define MSPUB_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
84 #define MSPUB_DEBUG(M) M
86 #define MSPUB_DEBUG_MSG(M) printf M
87 #define MSPUB_DEBUG(M) M
90 #define MSPUB_DEBUG_MSG(M)
91 #define MSPUB_DEBUG(M)
98 uint16_t
readU16(
const unsigned char *input,
unsigned offset);
99 uint32_t
readU32(
const unsigned char *input,
unsigned offset);
101 uint8_t
readU8(WPXInputStream *input);
102 uint16_t
readU16(WPXInputStream *input);
103 uint32_t
readU32(WPXInputStream *input);
104 uint64_t
readU64(WPXInputStream *input);
105 int32_t
readS32(WPXInputStream *input);
108 void readNBytes(WPXInputStream *input,
unsigned long length, std::vector<unsigned char> &out);
110 void appendCharacters(WPXString &text, std::vector<unsigned char> characters);
112 bool stillReading(WPXInputStream *input,
unsigned long until);
114 void rotateCounter(
double &x,
double &y,
double centerX,
double centerY,
short rotation);
115 void flipIfNecessary(
double &x,
double &y,
double centerX,
double centerY,
bool flipVertical,
bool flipHorizontal);
120 template <
class MapT>
typename MapT::mapped_type *
getIfExists(MapT &map,
const typename MapT::key_type &key)
122 typename MapT::iterator i = map.find(key);
123 return i == map.end() ? NULL : &(i->second);
126 template <
class MapT>
const typename MapT::mapped_type *
getIfExists_const(MapT &map,
const typename MapT::key_type &key)
128 typename MapT::const_iterator i = map.find(key);
129 return i == map.end() ? NULL : &(i->second);
132 template <
class MapT>
typename MapT::mapped_type
ptr_getIfExists(MapT &map,
const typename MapT::key_type &key)
134 typename MapT::iterator i = map.find(key);
135 return i == map.end() ? NULL : i->second;
150 #endif // __LIBMSPUB_UTILS_H__