• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ string_buffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1:

void
ngram_search::xor_block(string_buffer& sb, unsigned int val)
{
  for (string_buffer::iterator i = sb.begin(); i != sb.end(); ++i) {
    (*i) ^= val;
  }
}
开发者ID:ahiguti,项目名称:ase,代码行数:7,代码来源:ngramsearch.cpp


示例2: append_uint32

void
append_uint32(string_buffer& buf, uint32_t v)
{
  char *const wp = buf.make_space(64);
  const int len = snprintf(wp, 64, "%lu", static_cast<unsigned long>(v));
  if (len > 0) {
    buf.space_wrote(len);
  }
}
开发者ID:Epictetus,项目名称:HandlerSocket-Plugin-for-MySQL,代码行数:9,代码来源:string_util.cpp


示例3: while

template <typename T> void
ngram_search::serialize_nat(string_buffer& sb, T value)
{
  do {
    const unsigned char b7 = value & 0x7fU;
    value >>= 7;
    const unsigned char cf = (value != 0) ? 0x80U : 0;
    const unsigned char b = b7 | cf;
    sb.append(reinterpret_cast<const char *>(&b), 1);
  } while (value != 0);
}
开发者ID:ahiguti,项目名称:ase,代码行数:11,代码来源:ngramsearch.cpp


示例4: append_string_buffer

 append_string_buffer(string_buffer& b) : b(b) { b.reserve(100); }
开发者ID:anibalanto,项目名称:hyp,代码行数:1,代码来源:shell_escape.hpp


示例5: close

size_t
hstcpcli::request_buf_append(const char *start, const char *finish)
{
/*
  if (num_req_sent > 0 || num_req_rcvd > 0) {
*/
  if (num_req_rcvd > 0) {
    close();
    set_error(-1, "request_buf_append: protocol out of sync");
    return 0;
  }
  const char *nl = start;
  size_t num_req = 0;
  while ((nl = memchr_char(nl, '\n', finish - nl))) {
    if (nl == finish)
      break;
    num_req++;
    nl++;
  }
  num_req++;
  writebuf.append(start, finish);
  if (*(finish - 1) != '\n')
    writebuf.append_literal("\n");
  num_req_bufd += num_req;
  return num_req;
}
开发者ID:SunguckLee,项目名称:MariaDB,代码行数:26,代码来源:hstcpcli.cpp


示例6: set_error

int
hstcpcli::request_send()
{
  if (error_code < 0) {
    return error_code;
  }
  clear_error();
  if (fd.get() < 0) {
    close();
    return set_error(-1, "write: closed");
  }
  if (num_req_bufd == 0 || num_req_sent > 0 || num_req_rcvd > 0) {
    close();
    return set_error(-1, "request_send: protocol out of sync");
  }
  const size_t wrlen = writebuf.size();
  const ssize_t r = send(fd.get(), writebuf.begin(), wrlen, MSG_NOSIGNAL);
  if (r <= 0) {
    close();
    return set_error(-1, r < 0 ? "write: failed" : "write: eof");
  }
  writebuf.erase_front(r);
  if (static_cast<size_t>(r) != wrlen) {
    close();
    return set_error(-1, "write: incomplete");
  }
  num_req_sent = num_req_bufd;
  num_req_bufd = 0;
  DBG(fprintf(stderr, "REQSEND 0\n"));
  return 0;
}
开发者ID:AllenWeb,项目名称:mariadb,代码行数:31,代码来源:hstcpcli.cpp


示例7: DBG

const string_ref *
hstcpcli::get_next_row()
{
  if (num_flds == 0) {
    DBG(fprintf(stderr, "GNR NF 0\n"));
    return 0;
  }
  if (flds.size() < num_flds) {
    flds.resize(num_flds);
  }
  char *start = readbuf.begin() + cur_row_offset;
  char *const finish = readbuf.begin() + response_end_offset - 1;
  if (start >= finish) { /* start[0] == nl */
    DBG(fprintf(stderr, "GNR FIN 0 %p %p\n", start, finish));
    return 0;
  }
  for (size_t i = 0; i < num_flds; ++i) {
    skip_one(start, finish);
    char *const fld_begin = start;
    read_token(start, finish);
    char *const fld_end = start;
    char *wp = fld_begin;
    if (is_null_expression(fld_begin, fld_end)) {
      /* null */
      flds[i] = string_ref();
    } else {
      unescape_string(wp, fld_begin, fld_end); /* in-place */
      flds[i] = string_ref(fld_begin, wp);
    }
  }
  cur_row_offset = start - readbuf.begin();
  return &flds[0];
}
开发者ID:AllenWeb,项目名称:mariadb,代码行数:33,代码来源:hstcpcli.cpp


示例8:

void
hstcpcli::request_reset()
{
  if (num_req_bufd) {
    writebuf.erase_front(writebuf.size());
    num_req_bufd = 0;
  }
}
开发者ID:SunguckLee,项目名称:MariaDB,代码行数:8,代码来源:hstcpcli.cpp


示例9: read

int
hstcpcli::read_more()
{
  const size_t block_size = 4096; // FIXME
  char *const wp = readbuf.make_space(block_size);
  const ssize_t rlen = read(fd.get(), wp, block_size);
  if (rlen <= 0) {
    if (rlen < 0) {
      error_str = "read: failed";
    } else {
      error_str = "read: eof";
    }
    return rlen;
  }
  readbuf.space_wrote(rlen);
  return rlen;
}
开发者ID:AllenWeb,项目名称:mariadb,代码行数:17,代码来源:hstcpcli.cpp


示例10: read_id

 dtoken read_id() {
     while (!eos() && m_curr_char != '(' && m_curr_char != ')' && 
            m_curr_char != '#' && m_curr_char != ',' && (m_parsing_domains || m_curr_char != '.') && 
            m_curr_char != ':' && m_curr_char != '=' && !iswspace(m_curr_char) ) {
         save_and_next();
     }
     return m_reserved_symbols.string2dtoken(m_buffer.c_str());
 }
开发者ID:EinNarr,项目名称:z3,代码行数:8,代码来源:datalog_parser.cpp


示例11: read_bid

 // read an id of the form '|'.*'|' 
 dtoken read_bid() {
     while (!eos() && m_curr_char != '|') {
         save_and_next();
     }
     if (m_curr_char == '|') {
         next();
     }
     return m_reserved_symbols.string2dtoken(m_buffer.c_str());
 }
开发者ID:EinNarr,项目名称:z3,代码行数:10,代码来源:datalog_parser.cpp


示例12: lookahead_newline

 bool lookahead_newline() {
     while (m_curr_char == ' ') {
         save_and_next();
     }
     if (m_curr_char == '\n') {
         next();
         m_line++;
         m_buffer.reset();
         return true;
     }
     if (m_curr_char == '#') {
         m_buffer.reset();
         m_prev_char = 0;
         read_comment();
         return true;
     }
     return false;
 }
开发者ID:EinNarr,项目名称:z3,代码行数:18,代码来源:datalog_parser.cpp


示例13: typ_ref

void
hstcpcli::request_buf_auth(const char *secret, const char *typ)
{
  if (num_req_sent > 0 || num_req_rcvd > 0) {
    close();
    set_error(-1, "request_buf_auth: protocol out of sync");
    return;
  }
  if (typ == 0) {
    typ = "1";
  }
  const string_ref typ_ref(typ, strlen(typ));
  const string_ref secret_ref(secret, strlen(secret));
  writebuf.append_literal("A\t");
  writebuf.append(typ_ref.begin(), typ_ref.end());
  writebuf.append_literal("\t");
  writebuf.append(secret_ref.begin(), secret_ref.end());
  writebuf.append_literal("\n");
  ++num_req_bufd;
}
开发者ID:AllenWeb,项目名称:mariadb,代码行数:20,代码来源:hstcpcli.cpp


示例14: while

int
hstcpcli::read_more()
{
  const size_t block_size = 4096; // FIXME
  char *const wp = readbuf.make_space(block_size);
  int rlen;
  errno = 0;
  while ((rlen = read(fd.get(), wp, block_size)) <= 0) {
    errno_buf = errno;
    if (rlen < 0) {
      if (errno == EINTR || errno == EAGAIN)
      {
        errno = 0;
        continue;
      }
      error_str = String("read: failed", &my_charset_bin);
    } else {
      error_str = String("read: eof", &my_charset_bin);
    }
    return rlen;
  }
  readbuf.space_wrote(rlen);
  return rlen;
}
开发者ID:SunguckLee,项目名称:MariaDB,代码行数:24,代码来源:hstcpcli.cpp


示例15: set_error

int
hstcpcli::get_result(hstresult& result)
{
/*
  readbuf.swap(result.readbuf);
*/
  char *const wp = result.readbuf.make_space(response_end_offset);
  memcpy(wp, readbuf.begin(), response_end_offset);
  result.readbuf.space_wrote(response_end_offset);
  result.response_end_offset = response_end_offset;
  result.num_flds = num_flds;
  result.cur_row_offset = cur_row_offset;
  if (result.flds.max_element < num_flds)
  {
    if (allocate_dynamic(&result.flds, num_flds))
      return set_error(-1, "out of memory");
  }
  result.flds.elements = num_flds;
  return 0;
}
开发者ID:SunguckLee,项目名称:MariaDB,代码行数:20,代码来源:hstcpcli.cpp


示例16:

 const char * get_token_data() const {
     return m_buffer.c_str();
 }
开发者ID:EinNarr,项目名称:z3,代码行数:3,代码来源:datalog_parser.cpp


示例17: next_token

 dtoken next_token() {
     for(;;) {
         if (eos()) {
             return TK_EOS;
         }
         
         m_buffer.reset();
         switch (m_curr_char) {
         case '#': // comment
             read_comment();
             break;
         case '\n':
             next();
             m_line++;
             return TK_NEWLINE;
         case '\\':
             // here we ignore a newline if it is preceded by a backslash.
             // We need to take care, since anywhere else backshlash is used
             // as a regular character
             next();
             save_char('\\');
             if (lookahead_newline()) {
                 break;
             }
             return read_id();
         case '(':
             m_tok_pos = m_pos;
             next();
             return TK_LP;
         case ')':
             m_tok_pos = m_pos;
             next();
             return TK_RP;               
         case ',':
             m_tok_pos = m_pos;
             next();
             return TK_COMMA; 
         case '=':
             m_tok_pos = m_pos;
             next();
             return TK_EQ; 
         case '!':
             m_tok_pos = m_pos;
             next();
             if(m_curr_char == '=') {
                 next();
                 return TK_NEQ;
             }
             return TK_NEG; 
         case ':':
             m_tok_pos = m_pos;
             next();
             if (m_curr_char == '-') {
                 next();
                 return TK_LEFT_ARROW;
             }
             return TK_COLON;
         case '\"':
             return read_string();
         case '|':
             next();
             return read_bid();
         default:
             if (iswspace(m_curr_char)) {
                 next();
                 break;
             }
             else if (iswdigit(m_curr_char)) {
                 m_tok_pos = m_pos;
                 save_and_next();
                 return read_num();
             }
             else {
                 char old = m_curr_char;
                 m_tok_pos = m_pos;
                 save_and_next();
                 if (old == '-' && iswdigit(m_curr_char)) {
                     return read_num();
                 }
                 else {
                     return read_id();
                 }
             }
         }
     }
 }
开发者ID:EinNarr,项目名称:z3,代码行数:86,代码来源:datalog_parser.cpp


示例18: 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


示例19: dbn_ref

void
hstcpcli::request_buf_open_index(size_t pst_id, const char *dbn,
  const char *tbl, const char *idx, const char *retflds, const char *filflds)
{
  if (num_req_sent > 0 || num_req_rcvd > 0) {
    close();
    set_error(-1, "request_buf_open_index: protocol out of sync");
    return;
  }
  const string_ref dbn_ref(dbn, strlen(dbn));
  const string_ref tbl_ref(tbl, strlen(tbl));
  const string_ref idx_ref(idx, strlen(idx));
  const string_ref rfs_ref(retflds, strlen(retflds));
  writebuf.append_literal("P\t");
  append_uint32(writebuf, pst_id); // FIXME size_t ?
  writebuf.append_literal("\t");
  writebuf.append(dbn_ref.begin(), dbn_ref.end());
  writebuf.append_literal("\t");
  writebuf.append(tbl_ref.begin(), tbl_ref.end());
  writebuf.append_literal("\t");
  writebuf.append(idx_ref.begin(), idx_ref.end());
  writebuf.append_literal("\t");
  writebuf.append(rfs_ref.begin(), rfs_ref.end());
  if (filflds != 0) {
    const string_ref fls_ref(filflds, strlen(filflds));
    writebuf.append_literal("\t");
    writebuf.append(fls_ref.begin(), fls_ref.end());
  }
  writebuf.append_literal("\n");
  ++num_req_bufd;
}
开发者ID:AllenWeb,项目名称:mariadb,代码行数:31,代码来源:hstcpcli.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ string_ref类代码示例发布时间:2022-05-31
下一篇:
C++ stringVector类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap