1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 #ifndef SBUF_STREAM_H 3 #define SBUF_STREAM_H 4 5 /* required per C++ standard */ 6 #ifndef __STDC_FORMAT_MACROS 7 #define __STDC_FORMAT_MACROS 8 #endif 9 10 using namespace std; 11 12 #include <stdlib.h> 13 #include <inttypes.h> 14 #include <string> 15 #include <sstream> 16 #include "sbuf.h" 17 18 /** \addtogroup bulk_extractor_APIs 19 * @{ 20 */ 21 22 /** \file */ 23 /** 24 * sbuf_stream provides the get services of sbuf_t but wrapped in a Stream interface. 25 * Note that sbuf_stream is not particularly optimized; it is simply a wrapper. 26 */ 27 class sbuf_stream { 28 private: 29 const sbuf_t sbuf; 30 size_t offset; 31 public: 32 sbuf_stream(const sbuf_t &sbuf_); 33 ~sbuf_stream(); 34 void seek(size_t offset); 35 size_t tell(); 36 37 /** 38 * \name integer-based stream readers 39 * @{ */ 40 uint8_t get8u(); 41 uint16_t get16u(); 42 uint32_t get32u(); 43 uint64_t get64u(); 44 45 uint8_t get8uBE(); 46 uint16_t get16uBE(); 47 uint32_t get32uBE(); 48 uint64_t get64uBE(); 49 50 uint8_t get8u(sbuf_t::byte_order_t bo); 51 uint16_t get16u(sbuf_t::byte_order_t bo); 52 uint32_t get32u(sbuf_t::byte_order_t bo); 53 uint64_t get64u(sbuf_t::byte_order_t bo); 54 55 int8_t get8i(); 56 int16_t get16i(); 57 int32_t get32i(); 58 int64_t get64i(); 59 60 int8_t get8iBE(); 61 int16_t get16iBE(); 62 int32_t get32iBE(); 63 int64_t get64iBE(); 64 65 int8_t get8i(sbuf_t::byte_order_t bo); 66 int16_t get16i(sbuf_t::byte_order_t bo); 67 int32_t get32i(sbuf_t::byte_order_t bo); 68 int64_t get64i(sbuf_t::byte_order_t bo); 69 /** @} */ 70 71 /** 72 * \name string and wstring stream readers 73 * @{ */ 74 void getUTF8(string &utf8_string); 75 void getUTF8(size_t num_octets_requested, string &utf8_string); 76 void getUTF16(wstring &utf16_string); 77 void getUTF16(size_t num_code_units_requested, wstring &utf16_string); 78 /** @} */ 79 }; 80 81 #endif