本文整理汇总了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();
}
}
示例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);
}
}