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


C++ WContainerWidget::clear方法代码示例

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


在下文中一共展示了WContainerWidget::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadGrammar

void Tester::LoadGrammar()
{
    string h = internalPathNextPart("/share/");
    fs::path input = fs::path(appRoot()) / "share" / (h + ".data");
    mInput->setText("");
    mGrammar->setText("");
    mResult->clear();

    ifstream data_fs(input.string().c_str());
    if (data_fs) {
        data_fs.unsetf(std::ios::skipws);
        string data((istream_iterator<char>(data_fs)), istream_iterator<char>());
        mInput->setText(data);
        data_fs.close();
    } else {
        stringstream ss;
        ss << "share not found: " << h;
        Wt::WText* t = new Wt::WText(ss.str(), mResult);
        t->setStyleClass("result_error");
        Wt::log("info") << ss.str();
        return;
    }

    fs::path grammar = fs::path(appRoot()) / "share" / (h + ".lua");
    ifstream grammar_fs(grammar.string().c_str());
    if (grammar_fs) {
        grammar_fs.unsetf(std::ios::skipws);
        string data((istream_iterator<char>(grammar_fs)), istream_iterator<char>());
        mGrammar->setText(data);
        grammar_fs.close();
    }
}
开发者ID:cluo,项目名称:lpeg_tester,代码行数:32,代码来源:lpeg_tester.cpp

示例2: TestGrammar

void Tester::TestGrammar(bool benchmark)
{
    mResult->clear();

    fs::path grammar = fs::path("/tmp") / (sessionId() + ".lua");
    ofstream ofs(grammar.string().c_str());
    if (ofs) {
        ofs << mGrammar->text();
        ofs.close();
    } else {
        stringstream ss;
        ss << "failed to open: " << grammar;
        Wt::WText* t = new Wt::WText(ss.str(), mResult);
        t->setStyleClass("result_error");
        Wt::log("error") << ss.str();
        return;
    }
    lua_sandbox* sb = lsb_create(NULL, grammar.string().c_str(), "modules",
                                 8*1024*1024, 1e6, 1024*63);
    if (!sb) {
        stringstream ss;
        ss << "lsb_create() failed";
        Wt::WText* t = new Wt::WText(ss.str(), mResult);
        t->setStyleClass("result_error");
        Wt::log("error") << ss.str();
        return;
    }
    if (lsb_init(sb, nullptr)) {
        stringstream ss;
        string error = lsb_get_error(sb);
        size_t pos = error.find_first_of(':');
        if (pos != string::npos) {
            ss << "line " << error.substr(pos + 1);
        } else {
            ss << error;
        }
        Wt::WText* t = new Wt::WText(ss.str(), mResult);
        t->setStyleClass("result_error");
        Wt::log("info") << ss.str();
        return;

    }
    if (benchmark) {
        Benchmark(sb, mInput->text().narrow());
    } else {
        Match(sb, mInput->text().narrow());
    }
    char* e = lsb_destroy(sb, nullptr);
    if (e) {
        stringstream ss;
        ss << "lsb_destroy() failed: " << e;
        Wt::WText* t = new Wt::WText(ss.str(), mResult);
        t->setStyleClass("result_error");
        Wt::log("info") << ss.str();
        free(e);
    }
}
开发者ID:cluo,项目名称:lpeg_tester,代码行数:57,代码来源:lpeg_tester.cpp


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