本文整理汇总了C++中LString::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ LString::begin方法的具体用法?C++ LString::begin怎么用?C++ LString::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LString
的用法示例。
在下文中一共展示了LString::begin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
LString LString::fromUtf8(const std::string &s) {
if (s.size() == 0) return LString();
const uint8_t *begin = reinterpret_cast<const uint8_t*>(s.c_str());
const uint8_t *end = begin + s.size();
LString ret;
ret.reserve(s.size());
LChar *destBegin = ret.begin();
LChar *destEnd = ret.end();
bool conversionSucceeded = utf8ToUtf32(&begin, end, &destBegin, destEnd);
assert(conversionSucceeded && "Failed conversion utf8 -> utf32");
ret.resize(destBegin - ret.begin());
return ret;
}
示例2: read_constdb
bool read_constdb(ZString filename)
{
io::ReadFile in(filename);
if (!in.is_open())
{
PRINTF("can't read %s\n"_fmt, filename);
return false;
}
bool rv = true;
AString line_;
while (in.getline(line_))
{
// is_comment only works for whole-line comments
// that could change once the Z dependency is dropped ...
LString comment = "//"_s;
XString line = line_.xislice_h(std::search(line_.begin(), line_.end(), comment.begin(), comment.end())).rstrip();
if (!line)
continue;
// "%m[A-Za-z0-9_] %i %i"
// TODO promote either qsplit() or asplit()
auto _it = std::find(line.begin(), line.end(), ' ');
auto name = line.xislice_h(_it);
auto _rest = line.xislice_t(_it);
while (_rest.startswith(' '))
_rest = _rest.xslice_t(1);
auto _it2 = std::find(_rest.begin(), _rest.end(), ' ');
auto val_ = _rest.xislice_h(_it2);
auto type_ = _rest.xislice_t(_it2);
while (type_.startswith(' '))
type_ = type_.xslice_t(1);
// yes, the above actually DTRT even for underlength input
int val;
int type = 0;
// Note for future archeaologists: this code is indented correctly
if (std::find_if_not(name.begin(), name.end(),
[](char c)
{
return ('0' <= c && c <= '9')
|| ('A' <= c && c <= 'Z')
|| ('a' <= c && c <= 'z')
|| (c == '_');
}) != name.end()
|| !extract(val_, &val)
|| (!extract(type_, &type) && type_))
{
PRINTF("Bad const line: %s\n"_fmt, line_);
rv = false;
continue;
}
P<str_data_t> n = add_strp(name);
n->type = type ? StringCode::PARAM : StringCode::INT;
n->val = val;
}
return rv;
}
示例3: fromAscii
LString LString::fromAscii(const std::string &s) {
LString ret;
ret.resize(s.size());
LString::Iterator out = ret.begin();
for (std::string::const_iterator i = s.begin(); i != s.end(); ++i) {
*out = *i;
}
return ret;
}
示例4: toLower
LString LString::toLower() const {
LString ret;
ret.resize(size());
LString::Iterator out = ret.begin();
for (LString::ConstIterator i = begin(); i != end(); i++) {
char32_t ch = *i;
ch = toLower(ch);
*out = ch;
++out;
}
return ret;
}