Example #1
0
inline size_t find_char(const string_ref& s, char c)
{
  const char *b = s.begin();
  const char *e = s.end();
  const char *const p = memchr_char(b, c, e - b);
  return p ? (p - b) : (e - b);
}
Example #2
0
void Writer::operator() (const string_ref &s) {
  if (need_indent) {
    need_indent = 0;
    write_indent();
  }
  append (s.begin(), s.length());
}
Example #3
0
        void id_value(string_ref value)
        {
            if (id_placeholder* p = state.get_placeholder(value))
            {
                assert(!use_resolved_ids ||
                    p->check_state(id_placeholder::generated));
                std::string const& id = use_resolved_ids ?
                    p->id : p->unresolved_id;

                result.append(source_pos, value.begin());
                result.append(id.begin(), id.end());
                source_pos = value.end();
            }
        }
Example #4
0
void syntax_highlight_actions::callout(parse_iterator, parse_iterator)
{
    out << state.add_callout(qbk_value(state.current_file,
                                       marked_text.begin(), marked_text.end()));
    marked_text.clear();
}
//  Should be equal
void interop ( const std::string &str, string_ref ref ) {
//  BOOST_CHECK ( str == ref );
    BOOST_CHECK ( str.size () == ref.size ());
    BOOST_CHECK ( std::equal ( str.begin (),  str.end (),  ref.begin ()));
    BOOST_CHECK ( std::equal ( str.rbegin (), str.rend (), ref.rbegin ()));
    }
Example #6
0
inline bool
operator !=(const string_ref& x, const string_ref& y) {
    return (x.size() != y.size()) ||
           (::memcmp(x.begin(), y.begin(), x.size()) != 0);
}
Example #7
0
inline bool
operator ==(const string_ref& x, const string_ref& y) {
    return (x.size() == y.size()) &&
           (::memcmp(x.begin(), y.begin(), x.size()) == 0);
}
Example #8
0
template <size_t N> inline bool
operator ==(const string_ref& x, const char (& y)[N]) {
    return (x.size() == N - 1) && (::memcmp(x.begin(), y, N - 1) == 0);
}
Example #9
0
File: main.cpp Project: CCJY/coliru
 size_t operator()(string_ref const& sr) const {
     return boost::hash_range(sr.begin(), sr.end());
 }
Example #10
0
 void start(string_ref xml)
 {
     source_pos = xml.begin();
 }
Example #11
0
void
hstcpcli::request_buf_exec_generic(size_t pst_id, const string_ref& op,
  const string_ref *kvs, size_t kvslen, uint32_t limit, uint32_t skip,
  const string_ref& mod_op, const string_ref *mvs, size_t mvslen,
  const hstcpcli_filter *fils, size_t filslen, int invalues_keypart,
  const string_ref *invalues, size_t invalueslen)
{
  if (num_req_sent > 0 || num_req_rcvd > 0) {
    close();
    set_error(-1, "request_buf_exec_generic: protocol out of sync");
    return;
  }
  append_uint32(writebuf, pst_id); // FIXME size_t ?
  writebuf.append_literal("\t");
  writebuf.append(op.begin(), op.end());
  writebuf.append_literal("\t");
  append_uint32(writebuf, kvslen); // FIXME size_t ?
  for (size_t i = 0; i < kvslen; ++i) {
    const string_ref& kv = kvs[i];
    append_delim_value(writebuf, kv.begin(), kv.end());
  }
  if (limit != 0 || skip != 0 || invalues_keypart >= 0 ||
    mod_op.size() != 0 || filslen != 0) {
    /* has more option */
    writebuf.append_literal("\t");
    append_uint32(writebuf, limit); // FIXME size_t ?
    if (skip != 0 || invalues_keypart >= 0 ||
      mod_op.size() != 0 || filslen != 0) {
      writebuf.append_literal("\t");
      append_uint32(writebuf, skip); // FIXME size_t ?
    }
    if (invalues_keypart >= 0) {
      writebuf.append_literal("\t@\t");
      append_uint32(writebuf, invalues_keypart);
      writebuf.append_literal("\t");
      append_uint32(writebuf, invalueslen);
      for (size_t i = 0; i < invalueslen; ++i) {
	const string_ref& s = invalues[i];
	append_delim_value(writebuf, s.begin(), s.end());
      }
    }
    for (size_t i = 0; i < filslen; ++i) {
      const hstcpcli_filter& f = fils[i];
      writebuf.append_literal("\t");
      writebuf.append(f.filter_type.begin(), f.filter_type.end());
      writebuf.append_literal("\t");
      writebuf.append(f.op.begin(), f.op.end());
      writebuf.append_literal("\t");
      append_uint32(writebuf, f.ff_offset);
      append_delim_value(writebuf, f.val.begin(), f.val.end());
    }
    if (mod_op.size() != 0) {
      writebuf.append_literal("\t");
      writebuf.append(mod_op.begin(), mod_op.end());
      for (size_t i = 0; i < mvslen; ++i) {
	const string_ref& mv = mvs[i];
	append_delim_value(writebuf, mv.begin(), mv.end());
      }
    }
  }
  writebuf.append_literal("\n");
  ++num_req_bufd;
}