本文整理汇总了C++中ConstString::length方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstString::length方法的具体用法?C++ ConstString::length怎么用?C++ ConstString::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstString
的用法示例。
在下文中一共展示了ConstString::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ncmdList
Bottle NameServer::ncmdList(int argc, char *argv[]) {
Bottle response;
ConstString prefix = "";
if (argc==1) {
prefix = STR(argv[0]);
}
response.addString("ports");
for (PLATFORM_MAP(ConstString,NameRecord)::iterator it = nameMap.begin(); it!=nameMap.end(); it++) {
NameRecord& rec = PLATFORM_MAP_ITERATOR_SECOND(it);
ConstString iname = rec.getAddress().getRegName();
if (iname.find(prefix)==0) {
if (iname==prefix || iname[prefix.length()]=='/' ||
prefix[prefix.length()-1]=='/') {
if (rec.getAddress().isValid()) {
response.addList() = botify(rec.getAddress());
}
}
}
}
return response;
}
示例2: generateTypeMap
static void generateTypeMap(RosType& t, ConstString& txt) {
txt = "";
generateTypeMap1(t,txt);
if (txt.length()>0) {
txt = txt.substr(1,txt.length());
}
if (!t.reply) return;
txt += " ---";
generateTypeMap1(*(t.reply),txt);
}
示例3: appendResourceType
static void appendResourceType(ConstString& path,
const ConstString& resourceType) {
if (resourceType=="") return;
ConstString slash = NetworkBase::getDirectorySeparator();
if (path.length()>0) {
if (path[path.length()-1] != slash[0]) {
path += NetworkBase::getDirectorySeparator();
}
}
path += resourceType;
}
示例4: getPath
ConstString context2path(Property& config, const ConstString& context ) {
ConstString cap =
config.check("capability_directory",Value("app")).asString();
ConstString path = getPath(root,cap,context,"");
if (path.length()>1) {
if (path[path.length()-1]=='/') {
path = path.substr(0,path.length()-1);
}
}
return path;
}
示例5: sendSenderSpecifier
bool AbstractCarrier::sendSenderSpecifier(ConnectionState& proto)
{
NetInt32 numberSrc;
Bytes number((char*)&numberSrc, sizeof(NetInt32));
const ConstString senderName = proto.getSenderSpecifier();
//const ConstString& senderName = getRoute().getFromName();
NetType::netInt((int)senderName.length()+1, number);
OutputStream& os = proto.os();
os.write(number);
Bytes b((char*)senderName.c_str(), senderName.length()+1);
os.write(b);
os.flush();
return os.isOk();
}
示例6: SetName
void Class::SetName(ConstString name,bool badd2map)
{
if(name.length())
{
mClassName = AddPooledString(name.c_str());
if( badd2map )
{
ClassMapType::iterator it = mClassMap.find(mClassName);
if(it != mClassMap.end())
{
if(it->second != this)
{
Class *previous = it->second;
orkprintf("ERROR: Duplicate class name %s! previous class %p\n", mClassName.c_str(), previous);
OrkAssert(false);
}
}
else
{
mClassMap.AddSorted(mClassName, this);
}
}
}
}
示例7: report
virtual void report(const SearchReport& report, const char *context) {
ConstString ctx = context;
ConstString key = report.key.c_str();
ConstString prefix = "";
prefix = ctx;
prefix += ".";
key = prefix + key;
if (key.substr(0,1)==".") {
key = key.substr(1,key.length());
}
if (!present.check(key.c_str())) {
present.put(key.c_str(),"present");
order.addString(key.c_str());
}
if (report.isFound) {
actual.put(key.c_str(),report.value);
return;
}
if (report.isComment==true) {
comment.put(key.c_str(),report.value);
return;
}
if (report.isDefault==true) {
fallback.put(key.c_str(),report.value);
return;
}
}
示例8: run
void FallbackNameClient::run() {
NameConfig nc;
Contact call = FallbackNameServer::getAddress();
DgramTwoWayStream send;
send.join(call, true);
listen.join(call, false);
if (!listen.isOk()) {
YARP_ERROR(Logger::get(), ConstString("Multicast not available"));
return;
}
ConstString msg = ConstString("NAME_SERVER query ") + nc.getNamespace();
send.beginPacket();
send.writeLine(msg.c_str(), (int)msg.length());
send.flush();
send.endPacket();
for (int i=0; i<5; i++) {
listen.beginPacket();
ConstString txt = listen.readLine();
listen.endPacket();
if (closed) return;
YARP_DEBUG(Logger::get(), ConstString("Fallback name client got ") + txt);
if (txt.find("registration ")==0) {
address = NameClient::extractAddress(txt);
YARP_INFO(Logger::get(), ConstString("Received address ") +
address.toURI());
return;
}
}
}
示例9: applyConvertTextMode
bool BufferedConnectionWriter::applyConvertTextMode() {
if (convertTextModePending) {
convertTextModePending = false;
Bottle b;
StringOutputStream sos;
for (size_t i=0; i<lst_used; i++) {
yarp::os::ManagedBytes& m = *(lst[i]);
sos.write(m.usedBytes());
}
const String& str = sos.str();
b.fromBinary(str.c_str(),str.length());
ConstString replacement = b.toString() + "\n";
for (size_t i=0; i<lst.size(); i++) {
delete lst[i];
}
lst_used = 0;
target = &lst;
lst.clear();
stopPool();
Bytes data((char*)replacement.c_str(),replacement.length());
appendBlockCopy(data);
}
return true;
}
示例10: checkFormat
void checkFormat() {
report(0,"check matrix format conforms to network standard...");
Matrix m;
unsigned int rr = 10;
unsigned int cc = 5;
makeTestMatrix(m,rr,cc);
BufferedConnectionWriter writer;
m.write(writer);
ConstString s = writer.toString();
Bottle bot;
bot.fromBinary(s.c_str(),(int)s.length());
checkEqual(bot.get(0).asInt(),rr,"row count matches");
checkEqual(bot.get(1).asInt(),cc,"column count matches");
Bottle *lst = bot.get(2).asList();
checkTrue(lst!=NULL,"have data");
if (!lst) return;
checkEqual(lst->size(),(int)(rr*cc),"data length matches");
if (lst->size()!=(int)(rr*cc)) return;
bool ok = true;
for (int i=0; i<(int)(rr*cc); i++) {
double v = lst->get(i).asDouble();
if (fabs(v-i)>0.01) {
ok = false;
checkEqualish(v,i,"cell matches");
break;
}
}
checkTrue(ok,"data matches");
}
示例11: matchCarrier
static bool matchCarrier(const Bytes *header, Bottle& code) {
int at = 0;
bool success = true;
bool done = false;
for (int i=0; i<code.size() && !done; i++) {
Value& v = code.get(i);
if (v.isString()) {
ConstString str = v.asString();
for (int j=0; j<(int)str.length(); j++) {
if ((int)header->length()<=at) {
success = false;
done = true;
break;
}
if (str[j] != header->get()[at]) {
success = false;
done = true;
break;
}
at++;
}
} else {
at++;
}
}
return success;
}
示例12: getSenderSpecifier
ConstString Protocol::getSenderSpecifier() {
Route r = getRoute();
// We pull the sender name from the route.
ConstString from = r.getFromName();
// But we need to add any qualifiers looking in the carrier
// name. Ideally, we wouldn't need to bundle that in with
// the sender name, but we do it for now in the name of
// backwards compatibility.
ConstString carrier = r.getCarrierName();
size_t start = carrier.find("+");
if (start!=String::npos) {
from += " (";
for (size_t i=start+1; i<(size_t)carrier.length(); i++) {
char ch = carrier[i];
if (ch=='+') {
from += ") (";
} else if (ch=='.') {
from += " ";
} else {
from += ch;
}
}
from += ")";
}
return from;
}
示例13: encode
NetInt32 Vocab::encode(const ConstString& str) {
char a = '\0';
char b = '\0';
char c = '\0';
char d = '\0';
if (str.length()>=1) {
a = str[0];
if (str.length()>=2) {
b = str[1];
if (str.length()>=3) {
c = str[2];
if (str.length()>=4) {
d = str[3];
}
}
}
}
return VOCAB(a,b,c,d);
}
示例14: testNulls
void testNulls() {
report(0,"testing null insertion");
ConstString s;
s += 'h';
s += '\0';
s += 'd';
checkEqual((int)s.length(),3,"length with internal null");
checkEqual(s[1],'\0',"null is there");
checkEqual(s[2],'d',"after null");
}
示例15: toRosName
ConstString RosNameSpace::toRosName(const ConstString& name) {
if (name.find(':')==ConstString::npos) return name;
ConstString result;
for (size_t i=0; i<name.length(); i++) {
if (name[i]!=':') {
result += name[i];
} else {
result += "__";
}
}
return result;
}