本文整理汇总了C++中std::string_view::end方法的典型用法代码示例。如果您正苦于以下问题:C++ string_view::end方法的具体用法?C++ string_view::end怎么用?C++ string_view::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::string_view
的用法示例。
在下文中一共展示了string_view::end方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _
static std::string sides(const std::string_view &v)
{
if (v == CUPS_SIDES_ONE_SIDED)
return _("Off");
if (v == CUPS_SIDES_TWO_SIDED_PORTRAIT)
return _("Duplex (Long Edge)");
if (v == CUPS_SIDES_TWO_SIDED_LANDSCAPE)
return _("Duplex (Short Edge)");
return {v.begin(), v.end()};
}
示例2: set_option
void job_implObj::set_option(const std::string_view &name,
const std::string_view &value)
{
size_t s=name.size();
char name_str[s+1];
std::copy(name.begin(), name.end(), name_str);
name_str[s]=0;
s=value.size();
char value_str[s+1];
std::copy(value.begin(), value.end(), value_str);
value_str[s]=0;
job_info_t::lock lock{job_info};
lock->num_options=cupsAddOption(name_str, value_str,
lock->num_options,
&lock->options);
}
示例3: supported
bool destination_implObj::supported(const std::string_view &option,
const std::string_view &value) const
{
auto s=option.size();
char option_s[s+1];
std::copy(option.begin(), option.end(), option_s);
option_s[s]=0;
s=value.size();
char value_s[s+1];
std::copy(value.begin(), value.end(), value_s);
value_s[s]=0;
info_t::lock lock{*this};
return !!cupsCheckDestSupported(lock->http,
lock->dest,
lock->info,
option_s,
value_s);
}
示例4: parse_attribute_values
option_values_t
destination_implObj::ready_option_values(const std::string_view &option)
const
{
auto s=option.size();
char option_s[s+1];
std::copy(option.begin(), option.end(), option_s);
option_s[s]=0;
auto[name, unicode_flag]=parse_unicode_option(option_s);
info_t::lock lock{*this};
auto attrs=cupsFindDestReady(lock->http, lock->dest,
lock->info,
name);
return parse_attribute_values(lock, attrs, name, unicode_flag);
}
示例5: submit
int job_implObj::submit(const std::string_view &title)
{
size_t s=title.size();
char title_str[s+1];
std::copy(title.begin(), title.end(), title_str);
title_str[s]=0;
job_info_t::lock job_lock{job_info};
if (job_lock->documents.empty())
return 0;
destination_implObj::info_t::lock lock{*destination};
int job_id;
auto status=cupsCreateDestJob(lock->http,
lock->dest,
lock->info,
&job_id,
title_str,
job_lock->num_options,
job_lock->options);
if (status != IPP_STATUS_OK)
throw EXCEPTION(ippErrorString(status));
auto job_sentry=make_sentry([&]
{
cupsCancelDestJob(lock->http,
lock->dest,
job_id);
});
job_sentry.guard();
for (const auto &doc:job_lock->documents)
{
auto [mime_type, contents]=doc.document();
auto status=cupsStartDestDocument(lock->http,
lock->dest, lock->info,
job_id,
doc.name.c_str(),
mime_type.c_str(),
0, NULL, 0);
if (status != HTTP_STATUS_CONTINUE)
throw EXCEPTION(httpStatus(status));
auto doc_sentry=make_sentry
([&]
{
cupsFinishDestDocument(lock->http,
lock->dest,
lock->info);
});
doc_sentry.guard();
while (auto res=contents())
{
status=cupsWriteRequestData(lock->http,
res->data(),
res->size());
if (status != HTTP_STATUS_CONTINUE)
throw EXCEPTION(httpStatus(status));
}
doc_sentry.unguard();
auto ipp_status=cupsFinishDestDocument(lock->http,
lock->dest,
lock->info);
if (ipp_status != IPP_STATUS_OK)
throw EXCEPTION(cupsLastErrorString());
}
job_sentry.unguard();
auto ipp_status=cupsCloseDestJob(lock->http,
lock->dest,
lock->info,
job_id);
if (ipp_status != IPP_STATUS_OK)
throw EXCEPTION(cupsLastErrorString());
return job_id;
}
示例6: log
void log(ELoggingLevel lvl, std::string_view str, T&&... args) const
{
constexpr int index[]{-1, 1, 2, 3};
std::cregex_token_iterator begin{str.begin(), str.end(), regex(), index}, end;
std::ostringstream stream;
while(begin != end)
{
unsigned position = -1U;
int alignment = 0;
char format = 0;
int width = 0;
for(int i : index)
{
if(begin == end)
break;
auto cm = *begin++;
if(!cm.matched)
continue;
switch(i)
{
case -1:
stream.write(cm.first, cm.length());
break;
case 1:
position = number<unsigned>(cm.first, cm.second);
break;
case 2:
alignment = number<int>(cm.first + 1, cm.second);
break;
case 3:
format = cm.first[1];
width = number<int>(cm.first + 2, cm.second);
break;
}
}
if(position < 10)
{
util::parameter_pack::at
(
position,
[&stream, alignment, format, width](auto&& object)
{
auto&& str = print(format, width, std::forward<decltype(object)>(object));
if(alignment > 0)
stream << std::setw(alignment - int(str.tellp())) << "";
stream << str.rdbuf();
if(alignment < 0)
stream << std::setw(-alignment - int(str.tellp())) << "";
},
std::forward<T>(args)...
);
}
}
this->log(lvl, stream.str().c_str());
}
示例7:
static std::string no_localizer(const std::string_view &v)
{
return {v.begin(), v.end()};
}
示例8: parseInt
inline int parseInt( std::string_view input, int fallback ){
int value = 0;
auto result = std::from_chars( input.begin(), input.end(), value, 10 );
return result.ptr == input.begin() ? fallback : value;
}