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)
95 uint16_t
readU16(
const unsigned char *input,
unsigned offset);
96 uint32_t
readU32(
const unsigned char *input,
unsigned offset);
98 uint8_t
readU8(WPXInputStream *input);
99 uint16_t
readU16(WPXInputStream *input);
100 uint32_t
readU32(WPXInputStream *input);
101 uint64_t
readU64(WPXInputStream *input);
102 int32_t
readS32(WPXInputStream *input);
105 void readNBytes(WPXInputStream *input,
unsigned long length, std::vector<unsigned char> &out);
107 void appendCharacters(WPXString &text, std::vector<unsigned char> characters);
109 bool stillReading(WPXInputStream *input,
unsigned long until);
111 void rotateCounter(
double &x,
double &y,
double centerX,
double centerY,
short rotation);
112 void flipIfNecessary(
double &x,
double &y,
double centerX,
double centerY,
bool flipVertical,
bool flipHorizontal);
117 template <
class MapT>
typename MapT::mapped_type *
getIfExists(MapT &map,
const typename MapT::key_type &key)
119 typename MapT::iterator i = map.find(key);
120 return i == map.end() ? NULL : &(i->second);
123 template <
class MapT>
const typename MapT::mapped_type *
getIfExists_const(MapT &map,
const typename MapT::key_type &key)
125 typename MapT::const_iterator i = map.find(key);
126 return i == map.end() ? NULL : &(i->second);
129 template <
class MapT>
typename MapT::mapped_type
ptr_getIfExists(MapT &map,
const typename MapT::key_type &key)
131 typename MapT::iterator i = map.find(key);
132 return i == map.end() ? NULL : i->second;
147 #endif // __LIBMSPUB_UTILS_H__