示例#1
0
文件: scan.hpp 项目: e42s/libbert
 std::string get_string(Range &r) {
   boost::uint16_t const len = detail::get_2byte_size(r);
   std::string ret;
   std::copy(r.begin(), detail::get_nth_iterator(r, len), std::back_inserter(ret));
   r.advance_begin(len);
   return ret;
 }
示例#2
0
文件: scan.hpp 项目: e42s/libbert
 binary_t get_binary(Range &r) {
   boost::uint32_t const len = detail::get_size(r);
   binary_t ret;
   ret.reserve(len);
   std::copy(r.begin(), detail::get_nth_iterator(r, len), std::back_inserter(ret));
   r.advance_begin(len);
   return ret;
 }
示例#3
0
文件: scan.hpp 项目: nbowe/libbert
 atom_t get_atom(Range &r) {
   boost::uint16_t const len = detail::get_2byte_size(r);
   assert(r.size() >= len);
   atom_t ret;
   std::copy(r.begin(), detail::get_nth_iterator(r, len), std::back_inserter(ret));
   r.advance_begin(len);
   return ret;
 }
示例#4
0
文件: scan.hpp 项目: e42s/libbert
  real_t x_get_new_float(Range &r) {
    char buf[8];
    std::copy(r.begin(), detail::get_nth_iterator(r, 8), buf);
#ifndef LIBBERT_BIGENDIAN
    std::reverse(buf, buf+8);
#endif
    r.advance_begin(8);
    return *reinterpret_cast<real_t*>(buf);
  }
示例#5
0
文件: scan.hpp 项目: e42s/libbert
    boost::uint16_t get_2byte_size(Range &r) {
      assert_bytes_remaining(r,2);
#ifdef LIBBERT_BIGENDIAN
      boost::uint16_t const len = (static_cast<boost::uint16_t>(r[1]) << 8) + r[0];
#else
      boost::uint16_t const len = (static_cast<boost::uint16_t>(r[0]) << 8) + r[1];
#endif
      r.advance_begin(2);
      return len;
    }
示例#6
0
文件: scan.hpp 项目: e42s/libbert
 real_t get_float(Range &r) {
   char buf[32];
   std::copy(r.begin(), detail::get_nth_iterator(r, 32), buf);
   r.advance_begin(32);
   buf[31] = '\0';
   real_t ret;
   /*
     yuck! should actually use NEW_FLOAT_EXT but that is not part of the
     BERT spec. But should be added as an extension!
   */
   std::sscanf(buf, "%lf", &ret);
   return ret;
 }
示例#7
0
文件: scan.hpp 项目: e42s/libbert
  boost::int32_t get_integer(Range &r) {
    detail::assert_bytes_remaining(r,4);
#ifdef LIBBERT_BIGENDIAN
    boost::int32_t const ret =
      (static_cast<boost::int32_t>(r[3]) << 24) +
      (static_cast<boost::int32_t>(r[2]) << 16) +
      (static_cast<boost::int32_t>(r[1]) << 8) +
      (r[0]);
#else
    boost::int32_t const ret =
      (static_cast<boost::int32_t>(r[0]) << 24) +
      (static_cast<boost::int32_t>(r[1]) << 16) +
      (static_cast<boost::int32_t>(r[2]) << 8) +
      (r[3]);
#endif
    r.advance_begin(4);
    return ret;
  }
示例#8
0
文件: scan.hpp 项目: nbowe/libbert
  boost::int32_t get_integer(Range &r) {
    assert(r && r.size() >= 4);
#ifdef LIBBERT_BIGENDIAN
    boost::int32_t const ret =
      (static_cast<boost::int32_t>(r[3]) << 24) +
      (static_cast<boost::int32_t>(r[2]) << 16) +
      (static_cast<boost::int32_t>(r[1]) << 8) +
      (r[0]);
#else
    boost::int32_t const ret =
      (static_cast<boost::int32_t>(r[0]) << 24) +
      (static_cast<boost::int32_t>(r[1]) << 16) +
      (static_cast<boost::int32_t>(r[2]) << 8) +
      (r[3]);
#endif
    r.advance_begin(4);
    return ret;
  }
示例#9
0
文件: scan.hpp 项目: e42s/libbert
 byte_t extract_one_byte(Range &r) {
   assert_bytes_remaining(r,1);
   byte_t const b = r.front();
   r.advance_begin(1);
   return b;
 }
示例#10
0
文件: scan.hpp 项目: nbowe/libbert
 byte_t extract_one_byte(Range &r) {
   assert(r);
   byte_t const b = r.front();
   r.advance_begin(1);
   return b;
 }