本文整理汇总了C++中wt::WString::toUTF8方法的典型用法代码示例。如果您正苦于以下问题:C++ WString::toUTF8方法的具体用法?C++ WString::toUTF8怎么用?C++ WString::toUTF8使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wt::WString
的用法示例。
在下文中一共展示了WString::toUTF8方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
void Popup::render(Wt::WFlags<Wt::RenderFlag> flags) {
Wt::WApplication * app = Wt::WApplication::instance();
Wt::WString initFunction = app->javaScriptClass() + ".init_popup_" + id();
Wt::WStringStream stream;
stream
<< "{" << initFunction.toUTF8() << " = function() {"
<< " var self = " << jsRef() << ";"
<< " if (!self) {"
<< " setTimeout(" << initFunction.toUTF8() << ", 0);"
<< " }";
stream
<< " self.popup = new mapboxgl.Popup( {"
<< " closeButton: " << ToScript(closeButton_).toUTF8() << ", "
<< " closeOnClick: " << ToScript(closeOnClick_).toUTF8() << ", "
<< " anchor: " << ToScript(anchor_).toUTF8()
<< " });";
for (unsigned int i = 0; i < additions_.size(); i++) {
stream << additions_[i].toUTF8();
}
additions_.clear();
stream
<< " setTimeout(function(){ delete " << initFunction.toUTF8() << ";}, 0)};\n"
<< "}\n"
<< initFunction.toUTF8() << "();\n";
app->doJavaScript(stream.str());
}
示例2: reindent
Wt::WString TopicWidget::reindent(const Wt::WString& text)
{
std::vector<std::string> lines;
std::string s = text.toUTF8();
boost::split(lines, s, boost::is_any_of("\n"));
std::string result;
int indent = -1;
int newlines = 0;
for (unsigned i = 0; i < lines.size(); ++i) {
const std::string& line = lines[i];
if (line.empty()) {
++newlines;
} else {
if (indent == -1) {
indent = countSpaces(line);
} else {
for (int j = 0; j < newlines; ++j)
result += '\n';
}
newlines = 0;
if (!result.empty())
result += '\n';
result += skipSpaces(line, indent);
}
}
return Wt::WString::fromUTF8(result);
}
示例3: set_query
void set_query() {
dbo::Transaction t(tApp->session());
ULP::Q q;
if (only_blocked_) {
q = tApp->session().query<UserPtr>(
"select U from thechess_message_filter F "
"left join thechess_user U on F.bad_id = U.id");
q.where("F.good_id = ?").bind(tApp->user());
} else {
q = tApp->session().find<User>();
}
if (not_removed_) {
q.where("rights != ?").bind(NONE);
q.where("vacation_until is null");
q.where("last_online > ?").bind(now() - 10 * WEEK);
}
if (only_online_) {
q.where("last_online >= ?");
q.bind(now() - Options::instance()->away_timeout());
}
if (!name_like_.empty()) {
q.where("(username like ? or id = ?)");
q.bind("%" + name_like_ + "%");
q.bind(Wt::Wc::str2int(name_like_.toUTF8()));
}
q.orderBy("games_stat_elo desc");
setQuery(q, /* keep_columns */ true);
}
示例4:
Wt::Auth::User RDAUserDatabase::findWithIdentity (const std::string &provider,
const Wt::WString &identity)
const
{
std::string i;
/*
* David: find the 'id' for a user with name _identity_, leave it
* empty if no user with this name exists
*/
if(SEC_USERS_FILENO==(-1))
{
return Wt::Auth::User();
}
ZERNRD(SEC_USERS_FILENO);
i=identity.toUTF8();
USERLOGIN=stralloc(i.c_str());
FINDFLDSETSTRING(SEC_USERS_FILENO,"USER IDENTIFICATION",USERLOGIN);
if(EQLNRD(SEC_USERS_FILENO,1))
{
KEYNRD(SEC_USERS_FILENO,1);
return Wt::Auth::User();
} else {
return Wt::Auth::User(i, *this);
}
}
示例5: consoleAddData
void AbstractRPM::consoleAddData(const Wt::WString &computerName, const Wt::WString &data)
{
Wt::WString date = Wt::WDate::currentServerDate().toString("yyyy/MM/dd");
Wt::WString time = Wt::WTime::currentServerTime().toString("hh:mm:ss");
std::string user = currentUser();
Wt::WString header = date + "-" + time;
if (!user.empty())
header += ": " + user;
Wt::WString entry = header + ": " + data + "\n";
computerStateLock.lock();
Wt::WString logs = entry + _computerLogs[computerName];
logs = logs.toUTF8().substr(0, 1000); /* limit to 1k */
_computerLogs[computerName] = logs;
computerStateLock.unlock();
viewsLock.lock();
std::map< std::string, View* >::iterator it;
for (it = views.begin(); it != views.end(); ++it) {
server->post((*it).first, boost::bind(&View::consoleDataAdded,
(*it).second, computerName,
entry));
}
viewsLock.unlock();
}
示例6: submitMessage
void CreatePostWidget::submitMessage()
{
Wt::WString text = _messageTextArea->text();
if(text == ""){
// can use setEmptyText instead of this
enterDefaultText();
}else{
PostMsg msg;
uint32_t token;
RsGxsId author = _idChooser->getSelectedId();
if(author.isNull()){
return;
}
msg.mMeta.mAuthorId = author;
RsGxsGroupId targetWall = _wallChooser->getSelectedWallId();
if(targetWall.isNull()){
return;
}
// this is a trick:
// use the group id to signal the wall the post should appear on
msg.mMeta.mGroupId = targetWall;
// todo: circle
msg.mPostText = text.toUTF8();
rsWall->createPost(token, msg);
}
}
示例7: doDelayedJavaScript
void Popup::doDelayedJavaScript(const Wt::WString & jscode) {
if (isRendered()) {
doJavaScript(jscode.toUTF8());
}
else {
additions_.push_back(jscode);
}
}
示例8: consoleDataAdded
void ComputerView::consoleDataAdded(const Wt::WString &data)
{
Wt::WString logs = data + _logs_edit->valueText();
logs = logs.toUTF8().substr(0, 1000); /* limit to 1k */
_logs_edit->setValueText(logs);
app->triggerUpdate();
}
示例9: asciidoc
/* ****************************************************************************
* asciidoc
*/
WString asciidoc(const Wt::WString& src)
{
std::string srcFileName = tempFileName();
std::string htmlFileName = tempFileName();
{
std::ofstream srcFile(srcFileName.c_str(), std::ios::out);
std::string ssrc = src.toUTF8();
srcFile.write(ssrc.c_str(), (std::streamsize)ssrc.length());
srcFile.close();
}
#if defined(ASCIIDOC_EXECUTABLE)
#define xstr(s) str(s)
#define str(s) #s
std::string cmd = xstr(ASCIIDOC_EXECUTABLE);
#else
std::string cmd = "asciidoc";
#endif
std::string command = cmd + " -o " + htmlFileName + " -s " + srcFileName;
#ifndef WIN32
/*
* So, asciidoc apparently sends a SIGINT which is caught by its parent process..
* So we have to temporarily ignore it.
*/
struct sigaction newAction, oldAction;
newAction.sa_handler = SIG_IGN;
newAction.sa_flags = 0;
sigemptyset(&newAction.sa_mask);
sigaction(SIGINT, &newAction, &oldAction);
#endif
bool ok = system(command.c_str()) == 0;
#ifndef WIN32
sigaction(SIGINT, &oldAction, 0);
#endif
WString result;
if (ok)
{
result = WString::fromUTF8(readFileToString(htmlFileName));
}
else
{
result = WString::fromUTF8("<i>Could not execute asciidoc</i>");
}
unlink(srcFileName.c_str());
unlink(htmlFileName.c_str());
return result;
}
示例10: validate
Result validate(const Wt::WString& input) const
{
auto res = Wt::WValidator::validate(input);
if (res.state() != Wt::ValidationState::Valid)
return res;
auto password = Config::instance().getString("upload-password", "");
if (input.toUTF8() == password)
return Result(Wt::ValidationState::Valid);
return Result(Wt::ValidationState::Invalid, Wt::WString::tr("msg-bad-password"));
}
示例11: saveFragments
Wt::Json::Value saveFragments(MyTreeTableNode *root)
{
Wt::Json::Value retVal = Wt::Json::Value(Wt::Json::ArrayType);
Wt::Json::Array& ret = retVal;
Wt::WString name;
name = root->text;
std::string str = name.toUTF8();
str.erase(std::remove(str.begin(), str.end(), ' '), str.end()); //This removes whitespace
if(str.length()<1)
{
name = Wt::WString("New Node");
}
if(root->childNodes().size()>0)
{
ret.push_back(Wt::Json::Value(Wt::WString("group")));
ret.push_back(Wt::Json::Value(name));
Wt::Json::Value out_children_value = Wt::Json::Value(Wt::Json::ArrayType);
Wt::Json::Array& out_children = out_children_value;
for(auto mynode:root->childNodes()) //I wonder, what order do we get these in?
{
out_children.push_back(saveFragments(dynamic_cast<MyTreeTableNode*>(mynode)));
}
ret.push_back(out_children_value);
}
else //TODO add room for annotations
{
ret.push_back(Wt::Json::Value(Wt::WString("fragment")));
ret.push_back(Wt::Json::Value(name));
long long start = root->startWidget->time();
long long stop = root->stopWidget->time();
//this->log("info")<< "Saving fragment "<<std::to_string(start) << " "<<std::to_string(stop);
ret.push_back(Wt::Json::Value(start));
ret.push_back(Wt::Json::Value(stop));
}
return retVal;
}