本文整理汇总了C++中NameConfig::getSafeString方法的典型用法代码示例。如果您正苦于以下问题:C++ NameConfig::getSafeString方法的具体用法?C++ NameConfig::getSafeString怎么用?C++ NameConfig::getSafeString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NameConfig
的用法示例。
在下文中一共展示了NameConfig::getSafeString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
bool Port::open(const Contact& contact, bool registerName,
const char *fakeName)
{
Contact contact2 = contact;
if (!NetworkBase::initialized()) {
YARP_ERROR(Logger::get(), "YARP not initialized; create a yarp::os::Network object before using ports");
return false;
}
std::string n = contact2.getName();
NameConfig conf;
std::string nenv = std::string("YARP_RENAME") + conf.getSafeString(n);
std::string rename = NetworkBase::getEnvironment(nenv.c_str());
if (rename!="") {
n = rename;
contact2.setName(n);
}
bool local = false;
if (n == "" && contact2.getPort()<=0) {
local = true;
registerName = false;
n = "...";
}
NestedContact nc(n);
if (nc.getNestedName()!="") {
if (nc.getNodeName() == "") {
Nodes& nodes = NameClient::getNameClient().getNodes();
nodes.requireActiveName();
std::string node_name = nodes.getActiveName();
if (node_name!="") {
n = n + node_name;
}
}
}
PortCoreAdapter *currentCore = &(IMPL());
if (currentCore!=nullptr) {
currentCore->active = false;
if (n!="" && (n[0]!='/'||currentCore->includeNode) && n[0]!='=' && n!="..." && n.substr(0, 3)!="...") {
if (fakeName==nullptr) {
Nodes& nodes = NameClient::getNameClient().getNodes();
std::string node_name = nodes.getActiveName();
if (node_name!="") {
n = (n[0]=='/'?"":"/") + n + "@" + node_name;
}
}
}
}
if (n!="" && n[0]!='/' && n[0]!='=' && n!="..." && n.substr(0, 3)!="...") {
if (fakeName==nullptr) {
YARP_SPRINTF1(Logger::get(), error,
"Port name '%s' needs to start with a '/' character",
n.c_str());
return false;
}
}
if (n!="" && n!="..." && n[0]!='=' && n.substr(0, 3)!="...") {
if (fakeName==nullptr) {
std::string prefix = NetworkBase::getEnvironment("YARP_PORT_PREFIX");
if (prefix!="") {
n = prefix + n;
contact2.setName(n);
}
}
}
if (currentCore!=nullptr) {
NestedContact nc;
nc.fromString(n);
if (nc.getNestedName()!="") {
if (nc.getCategory()=="") {
// we need to add in a category
std::string cat;
if (currentCore->commitToRead) {
cat = "-";
} else if (currentCore->commitToWrite) {
cat = "+";
}
if (cat!="") {
if (currentCore->commitToRpc) {
cat += "1";
}
contact2.setName(nc.getNestedName() +
cat +
"@" +
nc.getNodeName());
} else {
YARP_SPRINTF1(Logger::get(), error,
"Error: Port '%s' is not committed to being either an input or output port.",
n.c_str());
YARP_SPRINTF0(Logger::get(), error,
"YARP does not mind, but we are trying to register with a name server that does.");
YARP_SPRINTF0(Logger::get(), error,
"You can call Port::setWriteOnly() or Port::setReadOnly(), OR rename the port.");
NestedContact nc2 = nc;
nc2.setCategoryWrite();
YARP_SPRINTF1(Logger::get(), error,
//.........这里部分代码省略.........