30 #ifndef __LIBMSPUB_UTILS_H__
31 #define __LIBMSPUB_UTILS_H__
36 #include <boost/ptr_container/ptr_map.hpp>
37 #include <libwpd/libwpd.h>
38 #include <libwpd-stream/libwpd-stream.h>
44 typedef unsigned char uint8_t;
45 typedef unsigned short uint16_t;
46 typedef unsigned uint32_t;
48 typedef unsigned __int64 uint64_t;
60 #ifdef HAVE_INTTYPES_H
80 #define MSPUB_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
81 #define MSPUB_DEBUG(M) M
83 #define MSPUB_DEBUG_MSG(M) printf M
84 #define MSPUB_DEBUG(M) M
87 #define MSPUB_DEBUG_MSG(M)
88 #define MSPUB_DEBUG(M)
100 uint16_t
readU16(
const unsigned char *input,
unsigned offset);
101 uint32_t
readU32(
const unsigned char *input,
unsigned offset);
103 uint8_t
readU8(WPXInputStream *input);
104 uint16_t
readU16(WPXInputStream *input);
105 uint32_t
readU32(WPXInputStream *input);
106 uint64_t
readU64(WPXInputStream *input);
107 int8_t
readS8(WPXInputStream *input);
108 int16_t
readS16(WPXInputStream *input);
109 int32_t
readS32(WPXInputStream *input);
112 void readNBytes(WPXInputStream *input,
unsigned long length, std::vector<unsigned char> &out);
116 bool stillReading(WPXInputStream *input,
unsigned long until);
118 void rotateCounter(
double &x,
double &y,
double centerX,
double centerY,
short rotation);
119 void flipIfNecessary(
double &x,
double &y,
double centerX,
double centerY,
bool flipVertical,
bool flipHorizontal);
124 template <
class MapT>
typename MapT::mapped_type *
getIfExists(MapT &map,
const typename MapT::key_type &key)
126 typename MapT::iterator i = map.find(key);
127 return i == map.end() ? NULL : &(i->second);
130 template <
class MapT>
const typename MapT::mapped_type *
getIfExists_const(MapT &map,
const typename MapT::key_type &key)
132 typename MapT::const_iterator i = map.find(key);
133 return i == map.end() ? NULL : &(i->second);
136 template <
class MapT>
typename MapT::mapped_type
ptr_getIfExists(MapT &map,
const typename MapT::key_type &key)
138 typename MapT::iterator i = map.find(key);
139 return i == map.end() ? NULL : i->second;
154 #endif // __LIBMSPUB_UTILS_H__