当前位置: 首页>>代码示例>>C++>>正文


C++ string_ref类代码示例

本文整理汇总了C++中string_ref的典型用法代码示例。如果您正苦于以下问题:C++ string_ref类的具体用法?C++ string_ref怎么用?C++ string_ref使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了string_ref类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: operator

void Writer::operator() (const string_ref &s) {
  if (need_indent) {
    need_indent = 0;
    write_indent();
  }
  append (s.begin(), s.length());
}
开发者ID:AbramovVitaliy,项目名称:kphp-kdb,代码行数:7,代码来源:io.cpp

示例2: find_char

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);
}
开发者ID:ahiguti,项目名称:ase,代码行数:7,代码来源:string_util.hpp

示例3: next

 string_ref next() const {
     const int pos = src_.substr(pos_).find_first_of(sep_);
     const int old_pos = pos_;
     if (pos != -1)
         pos_ += pos + 1;
     else
         finished_ = true;
     return src_.substr(old_pos, pos);
 }
开发者ID:chenrushan,项目名称:code-snippets,代码行数:9,代码来源:string_split.cpp

示例4: id_value

        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();
            }
        }
开发者ID:CASL,项目名称:vera_tpls,代码行数:14,代码来源:id_manager.cpp

示例5: while

void
consensus::create(
  const string_ref cached_consensus_path,
  bool force_download
  )
{
  string consensus_content;
  bool have_valid_consensus = false;

  //
  // if no path to the cached consensus file
  // was provided, we have to download it.
  //
  if (cached_consensus_path.is_empty() || !io::file::exists(cached_consensus_path))
  {
    force_download = true;
  }

  while (!have_valid_consensus)
  {
    consensus_content = force_download
      ? download_from_random_authority("/tor/status-vote/current/consensus")
      : io::file::read_to_string(cached_consensus_path);

    parse_consensus(consensus_content);

    have_valid_consensus = _valid_until >= time::now();

    //
    // if the consensus is invalid, we have to download it anyway.
    //
    if (!have_valid_consensus)
    {
      force_download = true;
    }
  }

  //
  // save the consensus content, if the path was provided.
  //
  if (force_download && !cached_consensus_path.is_empty())
  {
    io::file::write_from_string(cached_consensus_path, consensus_content);
  }
}
开发者ID:mprota,项目名称:mini-tor,代码行数:45,代码来源:consensus.cpp

示例6: append_escaped

void conn_info::append_escaped(const string_ref& rng, std::string& dst)
{
    for(string_ref::difference_type i=0; i < rng.size(); ++i) {
        if(rng[i]=='\\')
            dst+="\\\\";
        else if(rng[i]=='\'')
            dst+="\\\'";
        else
            dst+=rng[i];
    }
}
开发者ID:shuffle-c,项目名称:edba,代码行数:11,代码来源:conn_info.cpp

示例7: response_code

int
smtp_client::detail::read_response(buffered_file& conn,
  string_ref& resp_r, posix_error_callback& ec)
{
  ssize_t len = 0;
  char *line = 0;
  while (true) {
    len = conn.read_line_crlf(line, ec);
    if (len <= 0) {
      resp_r.reset();
      break;
    }
    DBG_SMTP(std::cout << "R: " << std::string(line, len));
    if (len <= 5 || line[3] == ' ') {
      resp_r.set(line, len);
      return response_code(line, len);
    }
  }
  return len; /* <= 0 (unexpected eof or error) */
}
开发者ID:ahiguti,项目名称:ase,代码行数:20,代码来源:smtp_client.cpp

示例8:

string
consensus::download_from_random_authority(
  const string_ref path
  )
{
  net::ip_address ip;
  uint16_t port;

  auto authority = default_authority_list[
    3
    //  mini::crypto::random_device->get_random(default_authority_list.get_size())
  ];

  ip = authority.ip;
  port = authority.dir_port;

  mini_debug(
    "consensus::download_from_random_authority() [path: http://%s:%u%s]",
    ip.to_string().get_buffer(),
    port,
    path.get_buffer());

  return net::http::client::get(ip.to_string(), port, path);
}
开发者ID:mprota,项目名称:mini-tor,代码行数:24,代码来源:consensus.cpp

示例9: operator

 size_t operator()(string_ref const& sr) const {
     return boost::hash_range(sr.begin(), sr.end());
 }
开发者ID:CCJY,项目名称:coliru,代码行数:3,代码来源:main.cpp

示例10: finish

 void finish(string_ref xml)
 {
     result.append(source_pos, xml.end());
     source_pos = xml.end();
 }
开发者ID:CASL,项目名称:vera_tpls,代码行数:5,代码来源:id_manager.cpp

示例11: swap

 inline void swap(string_ref& x, string_ref& y)
 {
     x.swap(y);
 }
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:4,代码来源:string_ref.hpp

示例12: return

inline bool
operator !=(const string_ref& x, const string_ref& y) {
    return (x.size() != y.size()) ||
           (::memcmp(x.begin(), y.begin(), x.size()) != 0);
}
开发者ID:liuqian1990,项目名称:mariadb-10.0,代码行数:5,代码来源:string_ref.hpp

示例13: close

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("\[email protected]\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;
}
开发者ID:AllenWeb,项目名称:mariadb,代码行数:63,代码来源:hstcpcli.cpp

示例14: rest

 string_ref rest() const { return src_.substr(pos_); }
开发者ID:chenrushan,项目名称:code-snippets,代码行数:1,代码来源:string_split.cpp

示例15: char

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);
}
开发者ID:liuqian1990,项目名称:mariadb-10.0,代码行数:4,代码来源:string_ref.hpp


注:本文中的string_ref类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。