Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef LIBEBOOK_UTILS_H_INCLUDED
00018 #define LIBEBOOK_UTILS_H_INCLUDED
00019
00020 #ifdef DEBUG
00021 #include <cstdio>
00022 #endif
00023
00024 #include <string>
00025
00026 #include <boost/shared_ptr.hpp>
00027
00028 #include <libwpd-stream/libwpd-stream.h>
00029 #include <libwpd/libwpd.h>
00030
00031 #ifdef _MSC_VER
00032
00033 typedef unsigned char uint8_t;
00034 typedef unsigned short uint16_t;
00035 typedef short int16_t;
00036 typedef unsigned uint32_t;
00037 typedef int int32_t;
00038 typedef unsigned __int64 uint64_t;
00039 typedef __int64 int64_t;
00040
00041 #else
00042
00043 #ifdef HAVE_CONFIG_H
00044
00045 #include <config.h>
00046
00047 #ifdef HAVE_STDINT_H
00048 #include <stdint.h>
00049 #endif
00050
00051 #ifdef HAVE_INTTYPES_H
00052 #include <inttypes.h>
00053 #endif
00054
00055 #else
00056
00057
00058 #include <stdint.h>
00059 #include <inttypes.h>
00060
00061 #endif
00062
00063 #endif
00064
00065
00066
00067
00068
00069 #ifdef DEBUG
00070 #ifdef VERBOSE_DEBUG
00071 #define EBOOK_DEBUG_MSG(M) std::printf("%15s:%5d: ", __FILE__, __LINE__); std::printf M
00072 #define EBOOK_DEBUG(M) M
00073 #else
00074 #define EBOOK_DEBUG_MSG(M) std::printf M
00075 #define EBOOK_DEBUG(M) M
00076 #endif
00077 #else
00078 #define EBOOK_DEBUG_MSG(M)
00079 #define EBOOK_DEBUG(M)
00080 #endif
00081
00082 #define EBOOK_NUM_ELEMENTS(array) sizeof(array)/sizeof(array[0])
00083
00084 namespace libebook
00085 {
00086
00087 uint8_t readU8(WPXInputStream *input, bool = false);
00088 uint16_t readU16(WPXInputStream *input, bool bigEndian=false);
00089 uint32_t readU32(WPXInputStream *input, bool bigEndian=false);
00090 uint64_t readU64(WPXInputStream *input, bool bigEndian=false);
00091
00092 const unsigned char *readNBytes(WPXInputStream *input, unsigned long numBytes);
00093
00094 std::string readCString(WPXInputStream *input);
00095 std::string readPascalString(WPXInputStream *input);
00096
00097 void skip(WPXInputStream *input, unsigned long numBytes);
00098
00099 void seek(WPXInputStream *input, unsigned long pos);
00100 void seekRelative(WPXInputStream *input, long pos);
00101
00102 unsigned long getLength(WPXInputStream *input);
00103
00104 uint8_t readU8(boost::shared_ptr<WPXInputStream> input, bool = false);
00105 uint16_t readU16(boost::shared_ptr<WPXInputStream> input, bool bigEndian=false);
00106 uint32_t readU32(boost::shared_ptr<WPXInputStream> input, bool bigEndian=false);
00107 uint64_t readU64(boost::shared_ptr<WPXInputStream> input, bool bigEndian=false);
00108
00109 const unsigned char *readNBytes(boost::shared_ptr<WPXInputStream> input, unsigned long numBytes);
00110
00111 std::string readCString(boost::shared_ptr<WPXInputStream> input);
00112 std::string readPascalString(boost::shared_ptr<WPXInputStream> input);
00113
00114 void skip(boost::shared_ptr<WPXInputStream> input, unsigned long numBytes);
00115
00116 void seek(boost::shared_ptr<WPXInputStream> input, unsigned long pos);
00117 void seekRelative(boost::shared_ptr<WPXInputStream> input, long pos);
00118
00119 unsigned long getLength(boost::shared_ptr<WPXInputStream> input);
00120
00121 class EndOfStreamException
00122 {
00123 public:
00124 EndOfStreamException();
00125 };
00126
00127 class GenericException
00128 {
00129 };
00130
00131 }
00132
00133 #endif // LIBEBOOK_UTILS_H_INCLUDED
00134