本文整理汇总了C++中XML_PARSER::copy_element方法的典型用法代码示例。如果您正苦于以下问题:C++ XML_PARSER::copy_element方法的具体用法?C++ XML_PARSER::copy_element怎么用?C++ XML_PARSER::copy_element使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML_PARSER
的用法示例。
在下文中一共展示了XML_PARSER::copy_element方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse_from_client
int SCHED_DB_RESULT::parse_from_client(XML_PARSER& xp) {
double dtemp;
bool btemp;
string stemp;
int itemp;
// should be non-zero if exit_status is not found
exit_status = ERR_NO_EXIT_STATUS;
memset(this, 0, sizeof(*this));
while (!xp.get_tag()) {
if (xp.match_tag("/result")) {
return 0;
}
if (xp.parse_str("name", name, sizeof(name))) continue;
if (xp.parse_int("state", client_state)) continue;
if (xp.parse_double("final_cpu_time", cpu_time)) continue;
if (xp.parse_double("final_elapsed_time", elapsed_time)) continue;
if (xp.parse_int("exit_status", exit_status)) continue;
if (xp.parse_int("app_version_num", app_version_num)) continue;
if (xp.match_tag("file_info")) {
string s;
xp.copy_element(s);
safe_strcat(xml_doc_out, s.c_str());
continue;
}
if (xp.match_tag("stderr_out" )) {
copy_element_contents(xp.f->f, "</stderr_out>", stderr_out, sizeof(stderr_out));
continue;
}
if (xp.parse_string("platform", stemp)) continue;
if (xp.parse_int("version_num", itemp)) continue;
if (xp.parse_string("plan_class", stemp)) continue;
if (xp.parse_double("completed_time", dtemp)) continue;
if (xp.parse_string("file_name", stemp)) continue;
if (xp.match_tag("file_ref")) {
xp.copy_element(stemp);
continue;
}
if (xp.parse_string("open_name", stemp)) continue;
if (xp.parse_bool("ready_to_report", btemp)) continue;
if (xp.parse_double("report_deadline", dtemp)) continue;
if (xp.parse_string("wu_name", stemp)) continue;
// deprecated stuff
if (xp.parse_double("fpops_per_cpu_sec", dtemp)) continue;
if (xp.parse_double("fpops_cumulative", dtemp)) continue;
if (xp.parse_double("intops_per_cpu_sec", dtemp)) continue;
if (xp.parse_double("intops_cumulative", dtemp)) continue;
log_messages.printf(MSG_NORMAL,
"RESULT::parse_from_client(): unrecognized: %s\n",
xp.parsed_tag
);
}
return ERR_XML_PARSE;
}
示例2: process_file_info
//.........这里部分代码省略.........
if (file_number < 0) {
fprintf(stderr, "No file number found\n");
return ERR_XML_PARSE;
}
if (file_number >= ninfiles) {
fprintf(stderr,
"Too few input files given; need at least %d\n",
file_number+1
);
return ERR_XML_PARSE;
}
if (input_file_found[file_number]) {
fprintf(stderr,
"Input file %d listed twice\n", file_number
);
return ERR_XML_PARSE;
}
input_file_found[file_number] = true;
if (generated_locally) {
sprintf(buf,
" <name>%s</name>\n"
" <generated_locally/>\n"
"</file_info>\n",
infiles[file_number]
);
} else if (nbytesdef == -1) {
// here if nybtes was not supplied; stage the file
//
dir_hier_path(
infiles[file_number], config_loc.download_dir,
config_loc.uldl_dir_fanout, path, true
);
// if file isn't found in hierarchy,
// look for it at top level and copy
//
if (!boinc_file_exists(path)) {
sprintf(top_download_path,
"%s/%s",config_loc.download_dir,
infiles[file_number]
);
boinc_copy(top_download_path, path);
}
if (!config_loc.cache_md5_info || !got_md5_info(path, md5, &nbytes)) {
retval = md5_file(path, md5, nbytes);
if (retval) {
fprintf(stderr, "process_input_template: md5_file %d\n", retval);
return retval;
} else if (config_loc.cache_md5_info) {
write_md5_info(path, md5, nbytes);
}
}
dir_hier_url(
infiles[file_number], config_loc.download_url,
config_loc.uldl_dir_fanout, url
);
sprintf(buf,
" <name>%s</name>\n"
" <url>%s</url>\n"
" <md5_cksum>%s</md5_cksum>\n"
" <nbytes>%.0f</nbytes>\n"
"</file_info>\n",
infiles[file_number],
url,
md5,
nbytes
);
} else {
// here if nbytes etc. was supplied,
// i.e the file is already staged, possibly remotely
//
urlstr = "";
for (unsigned int i=0; i<urls.size(); i++) {
urlstr += " <url>" + urls.at(i) + "</url>\n";
}
sprintf(buf,
" <name>%s</name>\n"
"%s"
" <md5_cksum>%s</md5_cksum>\n"
" <nbytes>%.0f</nbytes>\n"
"</file_info>\n",
infiles[file_number],
urlstr.c_str(),
md5str.c_str(),
nbytesdef
);
}
out += buf;
break;
} else {
retval = xp.copy_element(tmpstr);
if (retval) return retval;
out += tmpstr;
out += "\n";
}
}
return 0;
}
示例3: process_workunit
static int process_workunit(
XML_PARSER& xp, WORKUNIT& wu, string& out,
const char** infiles,
const char* command_line,
const char* additional_xml
) {
char buf[256], open_name[256];
int file_number;
string tmpstr, cmdline;
int retval;
out += "<workunit>\n";
if (command_line) {
//fprintf(stderr, "appending command line: %s\n", command_line);
out += "<command_line>\n";
out += command_line;
out += "\n</command_line>\n";
}
while (!xp.get_tag()) {
if (xp.match_tag("/workunit")) {
if (additional_xml && strlen(additional_xml)) {
out += additional_xml;
out += "\n";
}
out += "</workunit>";
break;
} else if (xp.match_tag("file_ref")) {
out += "<file_ref>\n";
bool found_file_number = false, found_open_name = false;
while (!xp.get_tag()) {
if (xp.parse_int("file_number", file_number)) {
sprintf(buf, " <file_name>%s</file_name>\n",
infiles[file_number]
);
out += buf;
found_file_number = true;
continue;
} else if (xp.parse_str("open_name", open_name, sizeof(open_name))) {
sprintf(buf, " <open_name>%s</open_name>\n", open_name);
out += buf;
found_open_name = true;
continue;
} else if (xp.match_tag("/file_ref")) {
if (!found_file_number) {
fprintf(stderr, "No file number found\n");
return ERR_XML_PARSE;
}
if (!found_open_name) {
fprintf(stderr, "No open name found\n");
return ERR_XML_PARSE;
}
out += "</file_ref>\n";
break;
} else if (xp.parse_string("file_name", tmpstr)) {
fprintf(stderr, "<file_name> ignored in <file_ref> element.\n");
continue;
} else {
retval = xp.copy_element(tmpstr);
if (retval) return retval;
out += tmpstr;
out += "\n";
}
}
} else if (xp.parse_string("command_line", cmdline)) {
if (command_line) {
fprintf(stderr, "Can't specify command line twice");
return ERR_XML_PARSE;
}
out += "<command_line>\n";
out += cmdline;
out += "\n</command_line>\n";
} else if (xp.parse_double("rsc_fpops_est", wu.rsc_fpops_est)) {
continue;
} else if (xp.parse_double("rsc_fpops_bound", wu.rsc_fpops_bound)) {
continue;
} else if (xp.parse_double("rsc_memory_bound", wu.rsc_memory_bound)) {
continue;
} else if (xp.parse_double("rsc_bandwidth_bound", wu.rsc_bandwidth_bound)) {
continue;
} else if (xp.parse_double("rsc_disk_bound", wu.rsc_disk_bound)) {
continue;
} else if (xp.parse_int("batch", wu.batch)) {
continue;
} else if (xp.parse_int("delay_bound", wu.delay_bound)){
continue;
} else if (xp.parse_int("min_quorum", wu.min_quorum)) {
continue;
} else if (xp.parse_int("target_nresults", wu.target_nresults)) {
continue;
} else if (xp.parse_int("max_error_results", wu.max_error_results)) {
continue;
} else if (xp.parse_int("max_total_results", wu.max_total_results)) {
continue;
} else if (xp.parse_int("max_success_results", wu.max_success_results)) {
continue;
} else {
retval = xp.copy_element(tmpstr);
if (retval) return retval;
out += tmpstr;
out += "\n";
//.........这里部分代码省略.........
示例4: process_file_info
//.........这里部分代码省略.........
gzipped_nbytes
);
strcat(buf, buf2);
}
strcat(buf, "</file_info>\n");
} else if (infile.is_remote) {
sprintf(buf,
" <name>jf_%s</name>\n"
" <url>%s</url>\n"
" <md5_cksum>%s</md5_cksum>\n"
" <nbytes>%.0f</nbytes>\n"
"</file_info>\n",
infile.md5,
infile.url,
infile.md5,
infile.nbytes
);
} else {
// here if file is local; we need to find its size and MD5;
// stage the file if needed
//
dir_hier_path(
infile.name, config_loc.download_dir,
config_loc.uldl_dir_fanout, path, true
);
// if file isn't found in hierarchy,
// look for it at top level and copy
//
if (!boinc_file_exists(path)) {
sprintf(top_download_path,
"%s/%s",config_loc.download_dir, infile.name
);
boinc_copy(top_download_path, path);
}
if (!config_loc.cache_md5_info || !got_md5_info(path, md5, &nbytes)) {
retval = md5_file(path, md5, nbytes);
if (retval) {
fprintf(stderr,
"process_input_template: md5_file %s\n",
boincerror(retval)
);
return retval;
} else if (config_loc.cache_md5_info) {
write_md5_info(path, md5, nbytes);
}
}
dir_hier_url(
infile.name, config_loc.download_url,
config_loc.uldl_dir_fanout, url
);
if (gzip) {
sprintf(gzip_path, "%s.gz", path);
retval = file_size(gzip_path, gzipped_nbytes);
if (retval) {
fprintf(stderr,
"process_input_template: missing gzip file %s\n",
gzip_path
);
return ERR_FILE_MISSING;
}
sprintf(gzipped_url,
" <gzipped_url>%s.gz</gzipped_url>\n"
" <gzipped_nbytes>%.0f</gzipped_nbytes>\n",
url, gzipped_nbytes
);
} else {
strcpy(gzipped_url, "");
}
sprintf(buf,
" <name>%s</name>\n"
" <url>%s</url>\n"
"%s"
" <md5_cksum>%s</md5_cksum>\n"
" <nbytes>%.0f</nbytes>\n"
"</file_info>\n",
infile.name,
url,
gzipped_url,
md5,
nbytes
);
}
out += buf;
break;
} else {
// copy any other elements from input template to XML doc
//
retval = xp.copy_element(tmpstr);
if (retval) return retval;
out += tmpstr;
out += "\n";
}
}
return 0;
}