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;
47 typedef signed char int8_t;
48 typedef short int16_t;
50 typedef unsigned __int64 uint64_t;
62 #ifdef HAVE_INTTYPES_H
82 #define MSPUB_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
83 #define MSPUB_DEBUG(M) M
85 #define MSPUB_DEBUG_MSG(M) printf M
86 #define MSPUB_DEBUG(M) M
89 #define MSPUB_DEBUG_MSG(M)
90 #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 int8_t
readS8(WPXInputStream *input);
106 int16_t
readS16(WPXInputStream *input);
107 int32_t
readS32(WPXInputStream *input);
110 void readNBytes(WPXInputStream *input,
unsigned long length, std::vector<unsigned char> &out);
112 void appendCharacters(WPXString &text, std::vector<unsigned char> characters,
const char *encoding);
114 bool stillReading(WPXInputStream *input,
unsigned long until);
116 void rotateCounter(
double &x,
double &y,
double centerX,
double centerY,
short rotation);
117 void flipIfNecessary(
double &x,
double &y,
double centerX,
double centerY,
bool flipVertical,
bool flipHorizontal);
122 template <
class MapT>
typename MapT::mapped_type *
getIfExists(MapT &map,
const typename MapT::key_type &key)
124 typename MapT::iterator i = map.find(key);
125 return i == map.end() ? NULL : &(i->second);
128 template <
class MapT>
const typename MapT::mapped_type *
getIfExists_const(MapT &map,
const typename MapT::key_type &key)
130 typename MapT::const_iterator i = map.find(key);
131 return i == map.end() ? NULL : &(i->second);
134 template <
class MapT>
typename MapT::mapped_type
ptr_getIfExists(MapT &map,
const typename MapT::key_type &key)
136 typename MapT::iterator i = map.find(key);
137 return i == map.end() ? NULL : i->second;
152 #endif // __LIBMSPUB_UTILS_H__