当前位置: 首页>>代码示例>>C++>>正文


C++ LString::end方法代码示例

本文整理汇总了C++中LString::end方法的典型用法代码示例。如果您正苦于以下问题:C++ LString::end方法的具体用法?C++ LString::end怎么用?C++ LString::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LString的用法示例。


在下文中一共展示了LString::end方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:Latexi95,项目名称:CBCompiler,代码行数:15,代码来源:lstring.cpp

示例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;
}
开发者ID:GermanTMW2015,项目名称:tmwa,代码行数:58,代码来源:script-startup.cpp


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