本文整理汇总了C++中string_ref类的典型用法代码示例。如果您正苦于以下问题:C++ string_ref类的具体用法?C++ string_ref怎么用?C++ string_ref使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了string_ref类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16:
SECURITY_STATUS
ssl_socket::client_handshake(
PCredHandle phCreds,
const string_ref server_name,
CtxtHandle* phContext,
SecBuffer* pExtraData
)
{
SecBufferDesc OutBuffer;
SecBuffer OutBuffers[1];
DWORD dwSSPIFlags;
DWORD dwSSPIOutFlags;
TimeStamp tsExpiry;
SECURITY_STATUS scRet;
DWORD cbData;
dwSSPIFlags = ISC_REQ_SEQUENCE_DETECT |
ISC_REQ_REPLAY_DETECT |
ISC_REQ_CONFIDENTIALITY |
ISC_RET_EXTENDED_ERROR |
ISC_REQ_ALLOCATE_MEMORY |
ISC_REQ_STREAM;
OutBuffers[0].pvBuffer = NULL;
OutBuffers[0].BufferType = SECBUFFER_TOKEN;
OutBuffers[0].cbBuffer = 0;
OutBuffer.cBuffers = 1;
OutBuffer.pBuffers = OutBuffers;
OutBuffer.ulVersion = SECBUFFER_VERSION;
scRet = g_sspi->InitializeSecurityContext(
phCreds,
NULL,
(TCHAR*)server_name.get_buffer(),
dwSSPIFlags,
0,
SECURITY_NATIVE_DREP,
NULL,
0,
phContext,
&OutBuffer,
&dwSSPIOutFlags,
&tsExpiry);
if (scRet != SEC_I_CONTINUE_NEEDED)
{
return scRet;
}
if (OutBuffers[0].cbBuffer != 0 && OutBuffers[0].pvBuffer != NULL)
{
m_bAllowPlainText = TRUE;
cbData = static_cast<DWORD>(write_impl(OutBuffers[0].pvBuffer, static_cast<size_t>(OutBuffers[0].cbBuffer)));
m_bAllowPlainText = FALSE;
if (cbData == SOCKET_ERROR || cbData == 0)
{
g_sspi->FreeContextBuffer(OutBuffers[0].pvBuffer);
g_sspi->DeleteSecurityContext(phContext);
return SEC_E_INTERNAL_ERROR;
}
g_sspi->FreeContextBuffer(OutBuffers[0].pvBuffer);
OutBuffers[0].pvBuffer = NULL;
}
SECURITY_STATUS rc = client_handshake_loop(phCreds, phContext, TRUE, pExtraData);
if (pExtraData->pvBuffer)
{
delete[] pExtraData->pvBuffer;
}
return rc;
}
开发者ID:mprota,项目名称:mini-tor,代码行数:76,代码来源:ssl_socket.cpp
示例17: reset
//------------------------------------------------------------------------------
void transitory_text_layout::reset(
font_face& face
, string_ref const string
, int16_t const max_w
, int16_t const max_h
) {
constexpr auto tab_size = 20;
clear();
//assume 2 bytes on average per codepoint.
//overly pessimistic for mostly latin text
data_.reserve(string.size() / 2);
auto it = utf8::iterator<char const*> {cbegin(string), cbegin(string), cend(string)};
auto const end = utf8::iterator<char const*> {cend(string), cbegin(string), cend(string)};
record_t cur_record {};
format_tag cur_format {};
format_t const default_format {
make_color(255, 255, 255, 255)
, 0
, 0
};
int pos = 0;
while (it != end) {
auto cp = *it;
switch (cp) {
case token::escape :
if (auto const result = parse_escape(it, end)) {
cp = *result;
} else {
BK_TODO_FAIL();
continue;
}
break;
case token::tag_open :
cur_format = parse_tag(it, end);
if (cur_format.type == format_tag::tag_type::tag_color) {
if (cur_format.state == format_tag::tag_state::type_begin) {
format_.emplace_back(format_t {make_color(255, 0, 0, 255), pos, pos});
} else if (cur_format.state == format_tag::tag_state::type_end) {
format_.back().end = pos;
}
} else {
BK_TODO_FAIL();
}
continue;
default :
++it;
++pos;
break;
}
cur_record.codepoint = cp;
data_.push_back(cur_record);
}
auto const line_gap = face.line_gap();
auto x = 0;
auto y = face.ascender();
//--------------------------------------------------------------------------
auto const next_line = [&] {
x = 0;
y += line_gap;
};
//--------------------------------------------------------------------------
auto const next_tab = [&] {
auto const rem = x % tab_size;
auto const tab = tab_size - rem;
x += tab;
};
//--------------------------------------------------------------------------
auto const do_escape = [&](codepoint_t const cp) {
switch (cp) {
case '\t' : next_tab(); return true;
case '\n' : next_line(); return true;
}
return false;
};
//--------------------------------------------------------------------------
auto left = unicode::codepoint {};
for (auto& rec : data_) {
if (do_escape(rec.codepoint)) {
continue;
}
auto const cp = unicode::codepoint {rec.codepoint};
//.........这里部分代码省略.........
开发者ID:bkentel,项目名称:bkrl,代码行数:101,代码来源:font.cpp
示例18: data
void
basic_url_base::parse_impl (string_ref s, boost::system::error_code& ec)
{
joyent::http_parser_url p;
value_type const* const data (s.data());
int const error (joyent::http_parser_parse_url (
data, s.size(), false, &p));
if (error)
{
ec = boost::system::error_code (
boost::system::errc::invalid_argument,
boost::system::generic_category());
return;
}
if ((p.field_set & (1<<joyent::UF_SCHEMA)) != 0)
{
m_scheme = string_ref (
data + p.field_data [joyent::UF_SCHEMA].off,
p.field_data [joyent::UF_SCHEMA].len);
}
else
{
m_scheme = string_ref {};
}
if ((p.field_set & (1<<joyent::UF_HOST)) != 0)
{
m_host = string_ref (
data + p.field_data [joyent::UF_HOST].off,
p.field_data [joyent::UF_HOST].len);
}
else
{
m_host = string_ref {};
}
if ((p.field_set & (1<<joyent::UF_PORT)) != 0)
{
m_port = p.port;
m_port_string = string_ref (
data + p.field_data [joyent::UF_PORT].off,
p.field_data [joyent::UF_PORT].len);
}
else
{
m_port = 0;
m_port_string = string_ref {};
}
if ((p.field_set & (1<<joyent::UF_PATH)) != 0)
{
m_path = string_ref (
data + p.field_data [joyent::UF_PATH].off,
p.field_data [joyent::UF_PATH].len);
}
else
{
m_path = string_ref {};
}
if ((p.field_set & (1<<joyent::UF_QUERY)) != 0)
{
m_query = string_ref (
data + p.field_data [joyent::UF_QUERY].off,
p.field_data [joyent::UF_QUERY].len);
}
else
{
m_query = string_ref {};
}
if ((p.field_set & (1<<joyent::UF_FRAGMENT)) != 0)
{
m_fragment = string_ref (
data + p.field_data [joyent::UF_FRAGMENT].off,
p.field_data [joyent::UF_FRAGMENT].len);
}
else
{
m_fragment = string_ref {};
}
if ((p.field_set & (1<<joyent::UF_USERINFO)) != 0)
{
m_userinfo = string_ref (
data + p.field_data [joyent::UF_USERINFO].off,
p.field_data [joyent::UF_USERINFO].len);
}
else
{
m_userinfo = string_ref {};
}
}
开发者ID:619213152,项目名称:vpal20,代码行数:97,代码来源:basic_url.cpp
示例19: interop
// 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 ()));
}
开发者ID:BwRy,项目名称:core-android-market,代码行数:7,代码来源:string_ref_test1.cpp
示例20: start
void start(string_ref xml)
{
source_pos = xml.begin();
}
开发者ID:CASL,项目名称:vera_tpls,代码行数:4,代码来源:id_manager.cpp
注:本文中的string_ref类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论