本文整理汇总了C++中FILE_INFO::parse方法的典型用法代码示例。如果您正苦于以下问题:C++ FILE_INFO::parse方法的具体用法?C++ FILE_INFO::parse怎么用?C++ FILE_INFO::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FILE_INFO
的用法示例。
在下文中一共展示了FILE_INFO::parse方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_output_file_info
int get_output_file_info(RESULT& result, FILE_INFO& fi) {
char path[1024];
string name;
MIOFILE mf;
mf.init_buf_read(result.xml_doc_in);
XML_PARSER xp(&mf);
while (!xp.get_tag()) {
if (!xp.is_tag) continue;
if (xp.match_tag("file_ref")) {
int retval = fi.parse(xp);
if (retval) return retval;
dir_hier_path(
fi.name.c_str(), config.upload_dir, config.uldl_dir_fanout, path
);
fi.path = path;
return 0;
}
}
return ERR_XML_PARSE;
}
示例2: get_output_file_infos
int get_output_file_infos(RESULT& result, vector<FILE_INFO>& fis) {
char path[1024];
MIOFILE mf;
string name;
mf.init_buf_read(result.xml_doc_in);
XML_PARSER xp(&mf);
fis.clear();
while (!xp.get_tag()) {
if (!xp.is_tag) continue;
if (xp.match_tag("file_ref")) {
FILE_INFO fi;
int retval = fi.parse(xp);
if (retval) return retval;
dir_hier_path(
fi.name.c_str(), config.upload_dir, config.uldl_dir_fanout, path
);
fi.path = path;
fis.push_back(fi);
}
}
return 0;
}
示例3: parse
// return an error message or NULL
//
const char* SCHEDULER_REQUEST::parse(XML_PARSER& xp) {
SCHED_DB_RESULT result;
int retval;
strcpy(authenticator, "");
strcpy(platform.name, "");
strcpy(cross_project_id, "");
hostid = 0;
core_client_major_version = 0;
core_client_minor_version = 0;
core_client_release = 0;
core_client_version = 0;
rpc_seqno = 0;
work_req_seconds = 0;
cpu_req_secs = 0;
cpu_req_instances = 0;
resource_share_fraction = 1.0;
rrs_fraction = 1.0;
prrs_fraction = 1.0;
cpu_estimated_delay = 0;
strcpy(global_prefs_xml, "");
strcpy(working_global_prefs_xml, "");
strcpy(code_sign_key, "");
memset(&global_prefs, 0, sizeof(global_prefs));
memset(&host, 0, sizeof(host));
have_other_results_list = false;
have_ip_results_list = false;
have_time_stats_log = false;
client_cap_plan_class = false;
sandbox = -1;
allow_multiple_clients = -1;
if (xp.get_tag()) {
return "xp.get_tag() failed";
}
if (xp.match_tag("?xml")) {
xp.get_tag();
}
if (!xp.match_tag("scheduler_request")) return "no start tag";
while (!xp.get_tag()) {
if (xp.match_tag("/scheduler_request")) {
core_client_version = 10000*core_client_major_version + 100*core_client_minor_version + core_client_release;
return NULL;
}
if (xp.parse_str("authenticator", authenticator, sizeof(authenticator))) {
remove_quotes(authenticator);
continue;
}
if (xp.parse_str("cross_project_id", cross_project_id, sizeof(cross_project_id))) continue;
if (xp.parse_int("hostid", hostid)) continue;
if (xp.parse_int("rpc_seqno", rpc_seqno)) continue;
if (xp.parse_str("platform_name", platform.name, sizeof(platform.name))) continue;
if (xp.match_tag("alt_platform")) {
CLIENT_PLATFORM cp;
retval = cp.parse(xp);
if (!retval) {
alt_platforms.push_back(cp);
}
continue;
}
if (xp.match_tag("app_versions")) {
while (!xp.get_tag()) {
if (xp.match_tag("/app_versions")) break;
if (xp.match_tag("app_version")) {
CLIENT_APP_VERSION cav;
retval = cav.parse(xp);
if (retval) {
if (!strcmp(platform.name, "anonymous")) {
if (retval == ERR_NOT_FOUND) {
g_reply->insert_message(
_("Unknown app name in app_info.xml"),
"notice"
);
} else {
g_reply->insert_message(
_("Syntax error in app_info.xml"),
"notice"
);
}
} else {
// this case happens if the app version
// refers to a deprecated app
}
cav.app = 0;
}
// store the CLIENT_APP_VERSION even if it didn't parse.
// This is necessary to maintain the correspondence
// with result.app_version
//
client_app_versions.push_back(cav);
}
}
continue;
}
if (xp.parse_int("core_client_major_version", core_client_major_version)) continue;
if (xp.parse_int("core_client_minor_version", core_client_minor_version)) continue;
if (xp.parse_int("core_client_release", core_client_release)) continue;
if (xp.parse_double("work_req_seconds", work_req_seconds)) continue;
//.........这里部分代码省略.........
示例4: parse
// return an error message or NULL
//
const char* SCHEDULER_REQUEST::parse(FILE* fin) {
char buf[256];
RESULT result;
int retval;
strcpy(authenticator, "");
strcpy(platform.name, "");
strcpy(cross_project_id, "");
hostid = 0;
core_client_major_version = 0;
core_client_minor_version = 0;
core_client_release = 0;
rpc_seqno = 0;
work_req_seconds = 0;
cpu_req_secs = 0;
cpu_req_instances = 0;
resource_share_fraction = 1.0;
rrs_fraction = 1.0;
prrs_fraction = 1.0;
cpu_estimated_delay = 0;
strcpy(global_prefs_xml, "");
strcpy(working_global_prefs_xml, "");
strcpy(code_sign_key, "");
memset(&global_prefs, 0, sizeof(global_prefs));
memset(&host, 0, sizeof(host));
have_other_results_list = false;
have_ip_results_list = false;
have_time_stats_log = false;
client_cap_plan_class = false;
sandbox = -1;
coproc_cuda = 0;
coproc_ati = 0;
fgets(buf, sizeof(buf), fin);
if (!match_tag(buf, "<scheduler_request>")) return "no start tag";
while (fgets(buf, sizeof(buf), fin)) {
// If a line is too long, ignore it.
// This can happen e.g. if the client has bad global_prefs.xml
// This won't be necessary if we rewrite this using XML_PARSER
//
if (!strchr(buf, '\n')) {
while (fgets(buf, sizeof(buf), fin)) {
if (strchr(buf, '\n')) break;
}
continue;
}
if (match_tag(buf, "</scheduler_request>")) {
core_client_version = 10000*core_client_major_version + 100*core_client_minor_version + core_client_release;
return NULL;
}
if (parse_str(buf, "<authenticator>", authenticator, sizeof(authenticator))) {
remove_quotes(authenticator);
continue;
}
if (parse_str(buf, "<cross_project_id>", cross_project_id, sizeof(cross_project_id))) continue;
if (parse_int(buf, "<hostid>", hostid)) continue;
if (parse_int(buf, "<rpc_seqno>", rpc_seqno)) continue;
if (parse_str(buf, "<platform_name>", platform.name, sizeof(platform.name))) continue;
if (match_tag(buf, "<alt_platform>")) {
CLIENT_PLATFORM cp;
retval = cp.parse(fin);
if (!retval) {
alt_platforms.push_back(cp);
}
continue;
}
if (match_tag(buf, "<app_versions>")) {
while (fgets(buf, sizeof(buf), fin)) {
if (match_tag(buf, "</app_versions>")) break;
if (match_tag(buf, "<app_version>")) {
CLIENT_APP_VERSION cav;
retval = cav.parse(fin);
if (retval) {
g_reply->insert_message(
"Invalid app version description", "high"
);
} else {
client_app_versions.push_back(cav);
}
}
}
continue;
}
if (parse_int(buf, "<core_client_major_version>", core_client_major_version)) continue;
if (parse_int(buf, "<core_client_minor_version>", core_client_minor_version)) continue;
if (parse_int(buf, "<core_client_release>", core_client_release)) continue;
if (parse_double(buf, "<work_req_seconds>", work_req_seconds)) continue;
if (parse_double(buf, "<cpu_req_secs>", cpu_req_secs)) continue;
if (parse_double(buf, "<cpu_req_instances>", cpu_req_instances)) continue;
if (parse_double(buf, "<resource_share_fraction>", resource_share_fraction)) continue;
if (parse_double(buf, "<rrs_fraction>", rrs_fraction)) continue;
if (parse_double(buf, "<prrs_fraction>", prrs_fraction)) continue;
if (parse_double(buf, "<estimated_delay>", cpu_estimated_delay)) continue;
if (parse_double(buf, "<duration_correction_factor>", host.duration_correction_factor)) continue;
if (match_tag(buf, "<global_preferences>")) {
strcpy(global_prefs_xml, "<global_preferences>\n");
while (fgets(buf, sizeof(buf), fin)) {
//.........这里部分代码省略.........
示例5: parse_app_info
// parse a project's app_info.xml (anonymous platform) file
//
int CLIENT_STATE::parse_app_info(PROJECT* p, FILE* in) {
char buf[256], path[MAXPATHLEN];
MIOFILE mf;
mf.init_file(in);
XML_PARSER xp(&mf);
while (!xp.get_tag()) {
if (xp.match_tag("app_info")) continue;
if (xp.match_tag("/app_info")) {
notices.remove_notices(p, REMOVE_APP_INFO_MSG);
return 0;
}
if (xp.match_tag("file_info") || xp.match_tag("file")) {
FILE_INFO* fip = new FILE_INFO;
if (fip->parse(xp)) {
delete fip;
continue;
}
if (!fip->download_urls.empty() || !fip->upload_urls.empty()) {
msg_printf(p, MSG_INFO,
"Can't specify URLs in app_info.xml"
);
delete fip;
continue;
}
if (link_file_info(p, fip)) {
delete fip;
continue;
}
// check that the file is actually there
//
get_pathname(fip, path, sizeof(path));
if (!boinc_file_exists(path)) {
safe_strcpy(buf,
_("File referenced in app_info.xml does not exist: ")
);
strcat(buf, fip->name);
msg_printf(p, MSG_USER_ALERT, "%s", buf);
delete fip;
continue;
}
fip->status = FILE_PRESENT;
fip->anonymous_platform_file = true;
file_infos.push_back(fip);
continue;
}
if (xp.match_tag("app")) {
APP* app = new APP;
if (app->parse(xp)) {
delete app;
continue;
}
if (lookup_app(p, app->name)) {
delete app;
continue;
}
link_app(p, app);
apps.push_back(app);
continue;
}
if (xp.match_tag("app_version")) {
APP_VERSION* avp = new APP_VERSION;
if (avp->parse(xp)) {
delete avp;
continue;
}
if (cc_config.dont_use_vbox && strstr(avp->plan_class, "vbox")) {
msg_printf(p, MSG_INFO,
"skipping vbox app in app_info.xml; vbox disabled in cc_config.xml"
);
delete avp;
continue;
}
if (strlen(avp->platform) == 0) {
safe_strcpy(avp->platform, get_primary_platform());
}
if (link_app_version(p, avp)) {
delete avp;
continue;
}
app_versions.push_back(avp);
continue;
}
if (log_flags.unparsed_xml) {
msg_printf(p, MSG_INFO,
"Unparsed line in app_info.xml: %s",
xp.parsed_tag
);
}
}
return ERR_XML_PARSE;
}
示例6: parse_state_file_aux
int CLIENT_STATE::parse_state_file_aux(const char* fname) {
PROJECT *project=NULL;
int retval=0;
string stemp;
FILE* f = fopen(fname, "r");
if (!f) return ERR_FOPEN;
MIOFILE mf;
XML_PARSER xp(&mf);
mf.init_file(f);
while (!xp.get_tag()) {
if (xp.match_tag("/client_state")) {
break;
}
if (xp.match_tag("client_state")) {
continue;
}
if (xp.match_tag("project")) {
PROJECT temp_project;
retval = temp_project.parse_state(xp);
if (retval) {
msg_printf(NULL, MSG_INTERNAL_ERROR, "Can't parse project in state file");
} else {
#ifdef SIM
project = new PROJECT;
*project = temp_project;
projects.push_back(project);
#else
project = lookup_project(temp_project.master_url);
if (project) {
project->copy_state_fields(temp_project);
} else {
msg_printf(&temp_project, MSG_INTERNAL_ERROR,
"Project %s is in state file but no account file found",
temp_project.get_project_name()
);
}
#endif
}
continue;
}
if (xp.match_tag("app")) {
APP* app = new APP;
retval = app->parse(xp);
if (!project) {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"Application %s outside project in state file",
app->name
);
delete app;
continue;
}
if (project->anonymous_platform) {
delete app;
continue;
}
if (retval) {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"Can't parse application in state file"
);
delete app;
continue;
}
retval = link_app(project, app);
if (retval) {
msg_printf(project, MSG_INTERNAL_ERROR,
"Can't handle application %s in state file",
app->name
);
delete app;
continue;
}
apps.push_back(app);
continue;
}
if (xp.match_tag("file_info") || xp.match_tag("file")) {
FILE_INFO* fip = new FILE_INFO;
retval = fip->parse(xp);
if (!project) {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"File info outside project in state file"
);
delete fip;
continue;
}
if (retval) {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"Can't handle file info in state file"
);
delete fip;
continue;
}
retval = link_file_info(project, fip);
if (project->anonymous_platform && retval == ERR_NOT_UNIQUE) {
delete fip;
continue;
}
if (retval) {
msg_printf(project, MSG_INTERNAL_ERROR,
"Can't handle file info %s in state file",
//.........这里部分代码省略.........