本文整理汇总了C++中Bottle::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ Bottle::copy方法的具体用法?C++ Bottle::copy怎么用?C++ Bottle::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bottle
的用法示例。
在下文中一共展示了Bottle::copy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tail
Bottle Bottle::tail() const
{
Bottle b;
if (isNull()) {
return *this;
}
b.copy(*this, 1, size() - 1);
return b;
}
示例2: fromCommand
void fromCommand(int argc, char *argv[],bool wipe=true) {
String tag = "";
Bottle accum;
Bottle total;
bool qualified = false;
for (int i=0; i<argc; i++) {
String work = argv[i];
bool isTag = false;
if (work.length()>=2) {
if (work[0]=='-'&&work[1]=='-') {
work = work.substr(2,work.length()-2);
isTag = true;
if (work.find("::")!=String::npos) {
qualified = true;
}
}
}
if (isTag) {
if (tag!="") {
total.addList().copy(accum);
}
tag = work;
accum.clear();
} else {
if (work.find("\\")!=String::npos) {
// Specifically when reading from the command
// line, we will allow windows-style paths.
// Hence we have to break the "\" character
String buf = "";
for (unsigned int i=0; i<work.length(); i++) {
buf += work[i];
if (work[i]=='\\') {
buf += work[i];
}
}
work = buf;
}
}
accum.add(Value::makeValue(work.c_str()));
}
if (tag!="") {
total.addList().copy(accum);
}
if (!qualified) {
fromBottle(total,wipe);
return;
}
if (wipe) {
clear();
}
Bottle *cursor = NULL;
for (int i=0; i<total.size(); i++) {
cursor = NULL;
Bottle *term = total.get(i).asList();
if (!term) continue;
ConstString key = term->get(0).asString();
ConstString base = key;
while (key.length()>0) {
int at = key.find("::");
base = key;
if (at>=0) {
base = key.substr(0,at);
key = key.substr(at+2);
} else {
key = "";
}
Bottle& result = (cursor!=NULL)? (cursor->findGroup(base.c_str())) : owner.findGroup(base.c_str());
if (result.isNull()) {
if (!cursor) {
cursor = &putBottle((base).c_str());
} else {
cursor = &cursor->addList();
}
cursor->addString(base);
} else {
cursor = &result;
}
}
if (cursor) {
cursor->copy(*term);
cursor->get(0) = Value(base);
}
}
}
示例3: configure
//.........这里部分代码省略.........
int tag = 0;
int unit_length = 0;
int wire_unit_length = -1;
bool item = false;
if (kind=="item") {
kind = vtag;
item = true;
}
if (kind=="int8"||kind=="uint8"||kind=="bool") {
tag = BOTTLE_TAG_INT8;
unit_length = 1;
} else if (kind=="int16"||kind=="uint16") {
tag = BOTTLE_TAG_INT16;
unit_length = 2;
} else if (kind=="int32"||kind=="uint32") {
tag = BOTTLE_TAG_INT32;
unit_length = 4;
} else if (kind=="int64"||kind=="uint64") {
tag = BOTTLE_TAG_INT64;
unit_length = 8;
} else if (kind=="float32") {
tag = BOTTLE_TAG_FLOAT32;
unit_length = 4;
} else if (kind=="float64") {
tag = BOTTLE_TAG_FLOAT64;
unit_length = 8;
} else if (kind=="vocab") {
tag = BOTTLE_TAG_VOCAB;
unit_length = 4;
} else if (kind=="string") {
tag = BOTTLE_TAG_STRING;
unit_length = -1;
//len = -1;
} else if (kind=="blob") {
tag = BOTTLE_TAG_BLOB;
unit_length = -1;
//len = -1;
} else if (kind=="list"||kind=="vector"||computing) {
//pass
} else {
fprintf(stderr,"%s does not know about %s\n", __FILE__, kind.c_str());
std::exit(1);
}
dbg_printf("Type %s (%s) len %d unit %d %s\n",
kind.c_str(),
is_list?"LIST":(is_vector?"VECTOR":"PRIMITIVE"), len,
unit_length,
ignore?"SKIP":"");
if (!ignore) {
if (is_vector) {
buffer.push_back(BOTTLE_TAG_LIST+tag);
if (len!=-1) {
buffer.push_back(len);
}
} else if (is_list) {
buffer.push_back(BOTTLE_TAG_LIST);
buffer.push_back(len);
} else {
if (!item) buffer.push_back(tag);
}
}
if (data) {
WireTwiddlerGap gap;
if (!ignore) {
gap.buffer_start = buffer_start;
gap.buffer_length = (int)buffer.size()-buffer_start;
buffer_start = (int)buffer.size();
} else {
gap.buffer_start = 0;
gap.buffer_length = 0;
}
gap.unit_length = unit_length;
gap.wire_unit_length = (wire_unit_length!=-1)?wire_unit_length:unit_length;
gap.length = len;
gap.ignore_external = ignore;
gap.save_external = saving;
gap.load_external = loading;
gap.computing = computing;
gap.var_name = var;
Bottle tmp;
tmp.copy(desc,start,offset-start-1);
gap.origin = tmp.toString();
gap.flavor = tag;
gaps.push_back(gap);
}
ignored = ignore;
if (is_list) {
int i=0;
while (i<len) {
bool ign = false;
offset = configure(desc,offset,ign,kind);
if (!ign) i++;
}
}
return offset;
}