本文整理汇总了C++中boost::optional::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ optional::empty方法的具体用法?C++ optional::empty怎么用?C++ optional::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::optional
的用法示例。
在下文中一共展示了optional::empty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: broadcastPhotoHash
void Client::broadcastPhotoHash(const boost::optional<std::string>& hash)
{
TRACE();
if (hash)
{
if (hash->empty())
{
// Bug in gloox: if the hash is empty then VCardUpdate will not generate
// a empty photo tag as it should.
gloox::VCardUpdate card("dummy");
gloox::Tag* tag = card.tag();
tag->removeChild("photo");
new gloox::Tag(tag, "photo");
myClient.addPresenceExtension(new gloox::VCardUpdate(tag));
delete tag;
}
else
myClient.addPresenceExtension(new gloox::VCardUpdate(*hash));
}
else
{
myClient.addPresenceExtension(new gloox::VCardUpdate);
}
myClient.setPresence();
}
示例2: datasource_exception
Connection(std::string const& connection_str,boost::optional<std::string> const& password)
: cursorId(0),
closed_(false),
pending_(false)
{
std::string connect_with_pass = connection_str;
if (password && !password->empty())
{
connect_with_pass += " password=" + *password;
}
conn_ = PQconnectdb(connect_with_pass.c_str());
MAPNIK_LOG_DEBUG(postgis) << "postgis_connection: postgresql connection create - " << this;
if (PQstatus(conn_) != CONNECTION_OK)
{
std::string err_msg = "Postgis Plugin: ";
err_msg += status();
err_msg += "\nConnection string: '";
err_msg += connection_str;
err_msg += "'\n";
MAPNIK_LOG_DEBUG(postgis) << "postgis_connection: creation failed, closing connection - " << this;
close();
throw mapnik::datasource_exception(err_msg);
}
PGresult *result = PQexec(conn_, "SET DEFAULT_TRANSACTION_READ_ONLY = TRUE;");
bool ok = (result && (PQresultStatus(result) == PGRES_COMMAND_OK));
if ( result ) PQclear(result);
if ( ! ok ) {
std::string err_msg = "Postgis Plugin: ";
err_msg += status();
err_msg += "\nConnection string: '";
err_msg += connection_str;
err_msg += "'\n";
throw mapnik::datasource_exception(err_msg);
}
}
示例3:
inline std::string connection_string() const {
std::string rs = *host_;
if (port_ && !port_->empty())
rs += ":" + *port_;
return rs;
}
示例4:
VrpnBasedConnection::VrpnBasedConnection(
boost::optional<std::string const &> iface, boost::optional<int> port) {
int myPort = port.get_value_or(0);
if (iface && !(iface->empty())) {
m_initConnection(iface->c_str(), myPort);
} else {
m_initConnection(nullptr, myPort);
}
}