30 #ifndef __LIBMSPUB_UTILS_H__
31 #define __LIBMSPUB_UTILS_H__
36 #include <libwpd/libwpd.h>
37 #include <libwpd-stream/libwpd-stream.h>
43 typedef unsigned char uint8_t;
44 typedef unsigned short uint16_t;
45 typedef unsigned uint32_t;
46 typedef signed char int8_t;
47 typedef short int16_t;
49 typedef unsigned __int64 uint64_t;
61 #ifdef HAVE_INTTYPES_H
81 #define MSPUB_DEBUG_MSG(M) printf("%15s:%5d: ", __FILE__, __LINE__); printf M
82 #define MSPUB_DEBUG(M) M
84 #define MSPUB_DEBUG_MSG(M) printf M
85 #define MSPUB_DEBUG(M) M
88 #define MSPUB_DEBUG_MSG(M)
89 #define MSPUB_DEBUG(M)
97 uint8_t
readU8(WPXInputStream *input);
98 uint16_t
readU16(WPXInputStream *input);
99 uint32_t
readU32(WPXInputStream *input);
100 uint64_t
readU64(WPXInputStream *input);
101 int8_t
readS8(WPXInputStream *input);
102 int16_t
readS16(WPXInputStream *input);
103 int32_t
readS32(WPXInputStream *input);
106 void readNBytes(WPXInputStream *input,
unsigned long length, std::vector<unsigned char> &out);
108 void appendCharacters(WPXString &text, std::vector<unsigned char> characters,
const char *encoding);
110 bool stillReading(WPXInputStream *input,
unsigned long until);
112 void rotateCounter(
double &x,
double &y,
double centerX,
double centerY,
short rotation);
113 void flipIfNecessary(
double &x,
double &y,
double centerX,
double centerY,
bool flipVertical,
bool flipHorizontal);
118 template <
class MapT>
typename MapT::mapped_type *
getIfExists(MapT &map,
const typename MapT::key_type &key)
120 typename MapT::iterator i = map.find(key);
121 return i == map.end() ? NULL : &(i->second);
124 template <
class MapT>
const typename MapT::mapped_type *
getIfExists_const(MapT &map,
const typename MapT::key_type &key)
126 typename MapT::const_iterator i = map.find(key);
127 return i == map.end() ? NULL : &(i->second);
130 template <
class MapT>
typename MapT::mapped_type
ptr_getIfExists(MapT &map,
const typename MapT::key_type &key)
132 typename MapT::iterator i = map.find(key);
133 return i == map.end() ? NULL : i->second;
148 #endif // __LIBMSPUB_UTILS_H__