本文整理汇总了C++中boost::string_ref::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ string_ref::empty方法的具体用法?C++ string_ref::empty怎么用?C++ string_ref::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::string_ref
的用法示例。
在下文中一共展示了string_ref::empty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseExprSum
double CInfixExpressionCalculator::ParseExprSum(boost::string_ref &ref)
{
double value = ParseExprMul(ref);
while (true)
{
SkipSpaces(ref);
if (!ref.empty() && ref[0] == '+')
{
ref.remove_prefix(1);
value += ParseExprMul(ref);
}
else if (!ref.empty() && ref[0] == '-')
{
ref.remove_prefix(1);
value -= ParseExprMul(ref);
}
else
{
break;
}
}
return value;
}
示例2: ParseDouble
double CInfixExpressionCalculator::ParseDouble(boost::string_ref &ref)
{
SkipSpaces(ref);
double value = 0;
bool parsedAny = false;
while (!ref.empty() && std::isdigit(ref[0]))
{
parsedAny = true;
const int digit = ref[0] - '0';
value = value * 10.0 + double(digit);
ref.remove_prefix(1);
}
if (!parsedAny)
{
return std::numeric_limits<double>::quiet_NaN();
}
if (ref.empty() || (ref[0] != '.'))
{
return value;
}
ref.remove_prefix(1);
double factor = 1.0;
while (!ref.empty() && std::isdigit(ref[0]))
{
const int digit = ref[0] - '0';
factor *= 0.1;
value += factor * double(digit);
ref.remove_prefix(1);
}
return value;
}
示例3: checkSimpleArgumentFor
void DatabaseImpl::checkSimpleArgumentFor(const boost::string_ref& key, partNum_t partNum) const
{
RAISE_INVALID_ARGUMENT_IF(key.size() > MAX_KEY_SIZE, "key too long");
RAISE_INVALID_ARGUMENT_IF(key.empty(), "empty key is not allowed");
RAISE_INVALID_ARGUMENT_IF(partNum > MAX_PARTNUM, "partNum is too large");
RAISE_INVALID_ARGUMENT_IF(partNum == ALL_PARTS, "partNum ALL_PARTS is not allowed");
RAISE_INVALID_ARGUMENT_IF(partNum < 0, "negative partNum is not allowed");
}
示例4: make_pair
std::pair<std::string, bool>
history::up (const boost::string_ref & current_text)
{
int next;
if (this->realpos == HISTORY_SIZE - 1)
{
if (this->pos == 0)
return std::make_pair(std::string{}, false);
} else
{
if (this->pos == this->realpos + 1)
return std::make_pair(std::string{}, false);
}
next = HISTORY_SIZE - 1;
if (this->pos != 0)
next = this->pos - 1;
if (!this->lines[next].empty())
{
if
(
!current_text.empty() && this->lines[next] != current_text &&
(this->lines[this->pos].empty() || current_text != this->lines[this->pos]) &&
(this->lines[this->realpos].empty() || current_text != this->lines[this->pos])
)
{
this->add (current_text);
}
this->pos = next;
return std::make_pair(this->lines[this->pos], true);
}
return std::make_pair(std::string{}, false);
}
示例5: snprintf
bool
server::p_raw(const boost::string_ref &raw)
{
char tbuf[4096];
if (!raw.empty())
{
if (raw.size() < sizeof (tbuf) - 3)
{
auto len = snprintf(tbuf, sizeof(tbuf), "%s\r\n", raw.data());
if (len < 0)
{
PrintText(current_sess, _("Unable to send message to server, and error has occurred"));
return false;
}
tcp_send_len(*this, boost::string_ref{ tbuf, static_cast<std::size_t>(len)});
} else
{
tcp_send_len (*this, raw);
tcp_send_len(*this, boost::string_ref{ "\r\n", 2 });
}
return true;
}
return false;
}