void Parser::parse( const char *str, int len, bool end ) { const char *p = str; const char *pos = p; const char *s = 0;//数据开始位置 const char *e = 0;//数据结束位置 while( len > 0 ) { if( *p == '<' ) { pos = p; if( s ) e = p;//记下数据结束位置 } else if( *p=='>' ) { std::string tag( pos + 1, p - pos - 1 ); reArrange(tag); if( is_version( tag ) ) ;//std::cout << tag << "\n"; else if(is_help(tag)) ; else if( is_end( tag ) ) { if( s && e ) { std::string data( s + 1, e -s - 1 ); on_data( data ); s = e = 0; } on_end( tag ); } else if( is_element( tag ) ) { parse_property( tag ); on_end( tag ); } else { parse_property( tag ); s = p;//记下数据开位置 } } p++; len--; } }
static int parse_properties(xmlTextReaderPtr reader, tmx_property **prop_headadr) { tmx_property *res; int curr_depth; const char *name; curr_depth = xmlTextReaderDepth(reader); /* Parse each child */ do { if (xmlTextReaderRead(reader) != 1) return 0; /* error_handler has been called */ if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_ELEMENT) { name = (char*)xmlTextReaderConstName(reader); if (!strcmp(name, "property")) { if (!(res = alloc_prop())) return 0; res->next = *prop_headadr; *prop_headadr = res; if (!parse_property(reader, res)) return 0; } else { /* Unknow element, skip its tree */ if (xmlTextReaderNext(reader) != 1) return 0; } } } while (xmlTextReaderNodeType(reader) != XML_READER_TYPE_END_ELEMENT || xmlTextReaderDepth(reader) != curr_depth); return 1; }
static void parse_root(Log4gConfigurator *base, xmlNodePtr node) { Log4gLogger *logger = log4g_log_manager_get_root_logger(); if (!logger) { return; } node = node->xmlChildrenNode; while (node) { if (!xmlStrcmp(node->name, (const xmlChar *)"property")) { parse_property(base, node, logger); } else if (!xmlStrcmp(node->name, (const xmlChar *)"level")) { parse_level(base, node, logger); } else if (!xmlStrcmp(node->name, (const xmlChar *)"appender")) { Log4gAppender *appender = parse_appender(base, node); if (appender) { log4g_logger_add_appender(logger, appender); g_object_unref(appender); } } else if (!xmlStrcmp(node->name, (const xmlChar *)"text")) { log4g_log_warn(Q_("invalid text element")); } else if (!xmlStrcmp(node->name, (const xmlChar *)"comment")) { /* do nothing */ } else { log4g_log_warn(Q_("%s: invalid element"), node->name); } node = node->next; } }
static int parse_status_line(FILE *fp, struct status_line *status) { struct block *block = NULL; struct block global; char line[2048]; memset(&global, 0, sizeof(struct block)); while (fgets(line, sizeof(line), fp) != NULL) { int len = strlen(line); if (line[len - 1] != '\n') { error("line \"%s\" is not terminated by a newline", line); return 1; } line[len - 1] = '\0'; switch (*line) { /* Comment or empty line? */ case '#': case '\0': break; /* Section? */ case '[': block = add_block(status); if (!block) return 1; /* Init the block with default settings (if any) */ memcpy(block, &global, sizeof(struct block)); if (parse_section(line, block->name, sizeof(block->name))) return 1; bdebug(block, "new block"); break; /* Property? */ case 'a' ... 'z': if (!block) { debug("no section yet, consider global properties"); block = &global; } if (parse_property(line, block)) return 1; break; /* Syntax error */ default: error("malformated line: %s", line); return 1; } } return duplicate_blocks(status); }
/// Rewrites the test cases list from the input to the output. /// /// \param [in,out] input Stream from which to read the test program's test /// cases list. The current location must be after the header and at the /// first identifier (if any). /// \param [out] output Stream to which to write the generic list. /// /// \return An error object. static kyua_error_t parse_tests(FILE* input, FILE* output) { char line[512]; // It's ugly to have a limit, but it's easier this way. if (fgets_no_newline(line, sizeof(line), input) == NULL) { return fgets_error(input, "Empty test cases list"); } kyua_error_t error; do { char* key = NULL; char* value = NULL; error = parse_property(line, &key, &value); if (kyua_error_is_set(error)) break; if (strcmp(key, "ident") == 0) { error = parse_test_case(input, output, value); } else { error = kyua_generic_error_new("Expected ident property, got %s", key); } } while (!kyua_error_is_set(error) && fgets_no_newline(line, sizeof(line), input) != NULL); if (!kyua_error_is_set(error)) { if (ferror(input)) error = kyua_libc_error_new(errno, "fgets failed"); else assert(feof(input)); } return error; }
/// Parses a single test case and writes it to the output. /// /// This has to be called after the ident property has been read, and takes care /// of reading the rest of the test case and printing the parsed result. /// /// Be aware that this consumes the newline after the test case. The caller /// should not look for it. /// /// \param [in,out] input File from which to read the header. /// \param [in,out] output File to which to write the parsed test case. /// \param [in,out] name The name of the test case. This is a non-const pointer /// and the input string is modified to simplify tokenization. /// /// \return OK if the parsing succeeds; an error otherwise. static kyua_error_t parse_test_case(FILE* input, FILE* output, char* name) { kyua_error_t error; char line[1024]; // It's ugly to have a limit, but it's easier this way. fprintf(output, "test_case{name="); print_quoted(name, output, true); error = kyua_error_ok(); while (!kyua_error_is_set(error) && fgets_no_newline(line, sizeof(line), input) != NULL && strcmp(line, "") != 0) { char* key = NULL; char* value = NULL; error = parse_property(line, &key, &value); if (!kyua_error_is_set(error)) { const char* out_key = rewrite_property(key); if (out_key == rewrite_error) { error = kyua_generic_error_new("Unknown ATF property %s", key); } else if (out_key == NULL) { fprintf(output, ", ['custom."); print_quoted(key, output, false); fprintf(output, "']="); print_quoted(value, output, true); } else { fprintf(output, ", %s=", out_key); print_quoted(value, output, true); } } } fprintf(output, "}\n"); return error; }
static int parse(config_desc * config, const char * filename, const char* home_path) { FILE * fp = fopen(filename, "rb"); if (!fp) { char * pkg_filename = (char *) malloc(sizeof(char) * (strlen(filename) + strlen(home_path) + 2)); sprintf(pkg_filename, "%s/%s", home_path, filename); printf ("pkg_filename %s\n",pkg_filename); fp = fopen(pkg_filename, "rb"); if (!fp) { free(pkg_filename); errnum = CONFIG_ERROR_CANNOT_ACCESS_CONFIG_FILE; return -1; } free(pkg_filename); } config->home_dir = (char*)malloc(sizeof(char) * (strlen(home_path) + 1)); sprintf(config->home_dir, "%s",home_path); static char buff[BUFFER_SIZE]; while (fgets(buff, BUFFER_SIZE, fp) != NULL) { char * trimed_buff = parse_trim(buff); if (*trimed_buff == ';' || *trimed_buff == '#' || *trimed_buff == '\0') { /* Comment Line or empty line */ continue; } char * key = NULL, * value = NULL; if (parse_line(trimed_buff, &key, &value) == -1) { free(key); free(value); fclose(fp); errnum = CONFIG_ERROR_PARSE; return -1; } if (parse_property(config, key, value) == -1) { free(key); free(value); fclose(fp); return -1; } free(key); free(value); } fclose(fp); return 0; }
static void parse_level(Log4gConfigurator *base, xmlNodePtr node, Log4gLogger *logger) { xmlChar *value = NULL; Log4gLevel *level = NULL; Log4gLevelClass *klass = NULL; xmlChar *type = xmlGetProp(node, (const xmlChar *)"type"); if (type) { GType gtype = g_type_from_name((const gchar *)type); if (!gtype) { log4g_log_error(Q_("%s: invalid `type'"), type); goto exit; } klass = g_type_class_ref(gtype); } else { klass = g_type_class_ref(LOG4G_TYPE_LEVEL); } if (!klass) { log4g_log_error(Q_("g_type_class_ref() returned NULL")); goto exit; } value = xmlGetProp(node, (const xmlChar *)"value"); if (!value) { log4g_log_error(Q_("levels require a `value'")); goto exit; } if (!klass->string_to_level) { log4g_log_error(Q_("Log4gLevel virtual function " "string_to_level() is NULL")); goto exit; } level = klass->string_to_level((gchar *)value); node = node->xmlChildrenNode; while (node) { if (!xmlStrcmp(node->name, (const xmlChar *)"property")) { parse_property(base, node, level); } else if (!xmlStrcmp(node->name, (const xmlChar *)"text")) { log4g_log_warn(Q_("invalid text element")); } else if (!xmlStrcmp(node->name, (const xmlChar *)"comment")) { /* do nothing */ } else { log4g_log_warn(Q_("%s: invalid element"), node->name); } node = node->next; } log4g_logger_set_level(logger, level); exit: if (klass) { g_type_class_unref(klass); } if (type) { xmlFree(type); } if (value) { xmlFree(value); } }
static GObject * parse_object(Log4gConfigurator *base, xmlNodePtr node) { GObject *object = NULL; xmlChar *name = xmlGetProp(node, (const xmlChar *)"name"); xmlChar *type = xmlGetProp(node, (const xmlChar *)"type"); if (!name) { log4g_log_error(Q_("objects must have a `name'")); goto exit; } if (!type) { log4g_log_error(Q_("objects must have a `type'")); goto exit; } GType gtype = g_type_from_name((const gchar *)type); if (!gtype) { log4g_log_error(Q_("%s: invalid `type'"), type); goto exit; } if (!G_TYPE_IS_INSTANTIATABLE(gtype)) { log4g_log_error(Q_("%s: is a non-instantiable type"), type); goto exit; } object = g_object_new(gtype, NULL); if (!object) { log4g_log_error(Q_("%s: g_object_new() returned NULL"), type); goto exit; } node = node->xmlChildrenNode; while (node) { if (!xmlStrcmp(node->name, (const xmlChar *)"property")) { parse_property(base, node, object); } else if (!xmlStrcmp(node->name, (const xmlChar *)"text")) { log4g_log_warn(Q_("invalid text element")); } else if (!xmlStrcmp(node->name, (const xmlChar *)"comment")) { /* do nothing */ } else { log4g_log_warn(Q_("%s: invalid element"), node->name); } node = node->next; } g_hash_table_insert(GET_PRIVATE(base)->objects, name, object); exit: if (name) { xmlFree(name); } if (type) { xmlFree(type); } return object; }
static Log4gFilter * parse_filter(Log4gConfigurator *base, xmlNodePtr node) { Log4gFilter *filter = NULL; xmlChar *type = xmlGetProp(node, (const xmlChar *)"type"); if (!type) { log4g_log_error(Q_("filters must have a `type'")); goto exit; } GType gtype = g_type_from_name((const gchar *)type); if (!gtype) { log4g_log_error(Q_("%s: invalid `type'"), type); goto exit; } if (!G_TYPE_IS_INSTANTIATABLE(gtype)) { log4g_log_error(Q_("%s: is a non-instantiable type"), type); goto exit; } filter = g_object_new(gtype, NULL); if (!filter) { log4g_log_error(Q_("%s: g_object_new() returned NULL"), type); goto exit; } if (!LOG4G_IS_FILTER(filter)) { log4g_log_error(Q_("%s: not an instance of Log4gFilter"), type); g_object_unref(filter); filter = NULL; goto exit; } node = node->xmlChildrenNode; while (node) { if (!xmlStrcmp(node->name, (const xmlChar *)"property")) { parse_property(base, node, filter); } else if (!xmlStrcmp(node->name, (const xmlChar *)"text")) { log4g_log_warn(Q_("invalid text element")); } else if (!xmlStrcmp(node->name, (const xmlChar *)"comment")) { /* do nothing */ } else { log4g_log_warn(Q_("%s: invalid element"), node->name); } node = node->next; } log4g_filter_activate_options(filter); exit: if (type) { xmlFree(type); } return filter; }
static boolean translate( struct translate_ctx *ctx ) { eat_opt_white( &ctx->cur ); if (!parse_header( ctx )) return FALSE; if (ctx->processor == TGSI_PROCESSOR_TESS_CTRL || ctx->processor == TGSI_PROCESSOR_TESS_EVAL) ctx->implied_array_size = 32; while (*ctx->cur != '\0') { uint label_val = 0; if (!eat_white( &ctx->cur )) { report_error( ctx, "Syntax error" ); return FALSE; } if (*ctx->cur == '\0') break; if (parse_label( ctx, &label_val )) { if (!parse_instruction( ctx, TRUE )) return FALSE; } else if (str_match_nocase_whole( &ctx->cur, "DCL" )) { if (!parse_declaration( ctx )) return FALSE; } else if (str_match_nocase_whole( &ctx->cur, "IMM" )) { if (!parse_immediate( ctx )) return FALSE; } else if (str_match_nocase_whole( &ctx->cur, "PROPERTY" )) { if (!parse_property( ctx )) return FALSE; } else if (!parse_instruction( ctx, FALSE )) { return FALSE; } } return TRUE; }
static boolean translate( struct translate_ctx *ctx ) { eat_opt_white( &ctx->cur ); if (!parse_header( ctx )) return FALSE; while (*ctx->cur != '\0') { uint label_val = 0; if (!eat_white( &ctx->cur )) { report_error( ctx, "Syntax error" ); return FALSE; } if (*ctx->cur == '\0') break; if (parse_label( ctx, &label_val )) { if (!parse_instruction( ctx, TRUE )) return FALSE; } else if (str_match_no_case( &ctx->cur, "DCL" )) { if (!parse_declaration( ctx )) return FALSE; } else if (str_match_no_case( &ctx->cur, "IMM" )) { if (!parse_immediate( ctx )) return FALSE; } else if (str_match_no_case( &ctx->cur, "PROPERTY" )) { if (!parse_property( ctx )) return FALSE; } else if (!parse_instruction( ctx, FALSE )) { return FALSE; } } return TRUE; }
static void start_element (GMarkupParseContext *context, const gchar *element_name, const gchar **names, const gchar **values, gpointer user_data, GError **error) { ParserData *data = (ParserData*)user_data; #ifdef G_ENABLE_DEBUG if (GTK_DEBUG_CHECK (BUILDER)) { GString *tags = g_string_new (""); int i; for (i = 0; names[i]; i++) g_string_append_printf (tags, "%s=\"%s\" ", names[i], values[i]); if (i) { g_string_insert_c (tags, 0, ' '); g_string_truncate (tags, tags->len - 1); } g_message ("<%s%s>", element_name, tags->str); g_string_free (tags, TRUE); } #endif if (!data->last_element && strcmp (element_name, "interface") != 0) { error_unhandled_tag (data, element_name, error); return; } data->last_element = element_name; if (data->subparser) { if (!subparser_start (context, element_name, names, values, data, error)) return; } if (strcmp (element_name, "requires") == 0) parse_requires (data, element_name, names, values, error); else if (strcmp (element_name, "object") == 0) parse_object (context, data, element_name, names, values, error); else if (strcmp (element_name, "template") == 0) parse_template (context, data, element_name, names, values, error); else if (data->requested_objects && !data->inside_requested_object) { /* If outside a requested object, simply ignore this tag */ } else if (strcmp (element_name, "child") == 0) parse_child (data, element_name, names, values, error); else if (strcmp (element_name, "property") == 0) parse_property (data, element_name, names, values, error); else if (strcmp (element_name, "signal") == 0) parse_signal (data, element_name, names, values, error); else if (strcmp (element_name, "interface") == 0) parse_interface (data, element_name, names, values, error); else if (strcmp (element_name, "menu") == 0) _gtk_builder_menu_start (data, element_name, names, values, error); else if (strcmp (element_name, "placeholder") == 0) { /* placeholder has no special treatmeant, but it needs an * if clause to avoid an error below. */ } else if (!parse_custom (context, element_name, names, values, data, error)) error_unhandled_tag (data, element_name, error); }
static void start_element (GMarkupParseContext *context, const gchar *element_name, const gchar **names, const gchar **values, gpointer user_data, GError **error) { ParserData *data = (ParserData*)user_data; #ifdef GTK_ENABLE_DEBUG if (gtk_debug_flags & GTK_DEBUG_BUILDER) { GString *tags = g_string_new (""); int i; for (i = 0; names[i]; i++) g_string_append_printf (tags, "%s=\"%s\" ", names[i], values[i]); if (i) { g_string_insert_c (tags, 0, ' '); g_string_truncate (tags, tags->len - 1); } g_print ("<%s%s>\n", element_name, tags->str); g_string_free (tags, TRUE); } #endif if (!data->last_element && strcmp (element_name, "interface") != 0) { g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_UNHANDLED_TAG, _("Invalid root element: '%s'"), element_name); return; } data->last_element = element_name; if (data->subparser) if (!subparser_start (context, element_name, names, values, data, error)) return; if (strcmp (element_name, "requires") == 0) parse_requires (data, element_name, names, values, error); else if (strcmp (element_name, "object") == 0) parse_object (context, data, element_name, names, values, error); else if (data->requested_objects && !data->inside_requested_object) { /* If outside a requested object, simply ignore this tag */ return; } else if (strcmp (element_name, "child") == 0) parse_child (data, element_name, names, values, error); else if (strcmp (element_name, "property") == 0) parse_property (data, element_name, names, values, error); else if (strcmp (element_name, "signal") == 0) parse_signal (data, element_name, names, values, error); else if (strcmp (element_name, "interface") == 0) parse_interface (data, element_name, names, values, error); else if (strcmp (element_name, "placeholder") == 0) { /* placeholder has no special treatmeant, but it needs an * if clause to avoid an error below. */ } else if (!parse_custom (context, element_name, names, values, data, error)) g_set_error (error, GTK_BUILDER_ERROR, GTK_BUILDER_ERROR_UNHANDLED_TAG, _("Unhandled tag: '%s'"), element_name); }
static Log4gAppender * parse_appender(Log4gConfigurator *base, xmlNodePtr node) { xmlChar *name = NULL; Log4gAppender *appender = NULL; struct Private *priv = GET_PRIVATE(base); xmlChar *type = xmlGetProp(node, (const xmlChar *)"type"); if (type) { GType gtype = g_type_from_name((const gchar *)type); if (!gtype) { log4g_log_error(Q_("%s: invalid `type'"), type); goto exit; } if (!G_TYPE_IS_INSTANTIATABLE(gtype)) { log4g_log_error(Q_("%s: is a non-instantiable type"), type); goto exit; } appender = g_object_new(gtype, NULL); if (!appender) { log4g_log_error(Q_("%s: g_object_new() returned NULL"), type); goto exit; } if (!LOG4G_IS_APPENDER(appender)) { log4g_log_error(Q_("%s: not an instance of " "Log4gAppender"), type); g_object_unref(appender); appender = NULL; goto exit; } } name = xmlGetProp(node, (const xmlChar *)"name"); if (appender) { if (name) { g_object_ref(appender); g_hash_table_insert(priv->appenders, name, appender); name = NULL; } } else { if (name) { appender = LOG4G_APPENDER(g_hash_table_lookup( priv->appenders, name)); if (!appender) { log4g_log_error(Q_("%s: no such appender"), name); goto exit; } g_object_ref(appender); } else { log4g_log_error(Q_("appenders without a `type' must " "have a `name'")); goto exit; } } node = node->xmlChildrenNode; while (node) { if (!xmlStrcmp(node->name, (const xmlChar *)"property")) { parse_property(base, node, appender); } else if (!xmlStrcmp(node->name, (const xmlChar *)"layout")) { Log4gLayout *layout = parse_layout(base, node); if (layout) { log4g_appender_set_layout(appender, layout); g_object_unref(layout); } } else if (!xmlStrcmp(node->name, (const xmlChar *)"filter")) { Log4gFilter *filter = parse_filter(base, node); if (filter) { log4g_appender_add_filter(appender, filter); g_object_unref(filter); } } else if (!xmlStrcmp(node->name, (const xmlChar *)"appender")) { if (LOG4G_IS_APPENDER_ATTACHABLE(appender)) { Log4gAppender *child = parse_appender(base, node); if (child) { log4g_appender_attachable_add_appender( LOG4G_APPENDER_ATTACHABLE(appender), child); g_object_unref(child); } } else { log4g_log_error(Q_("%s: does not implement " "log4g_appender_attachable"), type); } } else if (!xmlStrcmp(node->name, (const xmlChar *)"text")) { log4g_log_warn(Q_("invalid text element")); } else if (!xmlStrcmp(node->name, (const xmlChar *)"comment")) { /* do nothing */ } else { log4g_log_warn(Q_("%s: invalid element"), node->name); } node = node->next; } if (log4g_appender_requires_layout(appender) && !log4g_appender_get_layout(appender)) { log4g_log_error(Q_("%s: appender requires a layout"), type); g_hash_table_remove(priv->appenders, log4g_appender_get_name(appender)); g_object_unref(appender); appender = NULL; goto exit; } log4g_appender_activate_options(appender); exit: if (type) { xmlFree(type); } if (name) { xmlFree(name); } return appender; }
static int parse_dcs_cmds(const char *src, const char *propname, struct gen_cmds_info *cmd) { unsigned char *data; struct gen_cmd_hdr *dchdr; struct gen_cmd_desc *desc; int sz = 0, i = 0, nr_desc = 0, nr; data = kmalloc(MAX_BUF_SIZE * sizeof(unsigned char), GFP_KERNEL); if (unlikely(!data)) { pr_err("%s: failed to allocate memory\n", __func__); return -ENOMEM; } sz = parse_property(data, src, propname); if (!sz || sz < 0) { pr_err("%s: failed to parse (%s)\n", __func__, propname); kfree(data); return 0; } /* scan dcs commands */ while (sz > i + sizeof(*dchdr)) { dchdr = (struct gen_cmd_hdr *)(data + i); dchdr->dlen = ntohs(dchdr->dlen); dchdr->wait = ntohs(dchdr->wait); if (i + dchdr->dlen > sz) { pr_err("%s: parse error dtsi cmd=0x%02x, len=0x%02x, nr_desc=%d\n", __func__, dchdr->dtype, dchdr->dlen, nr_desc); dchdr = NULL; kfree(data); return -ENOMEM; } i += sizeof(*dchdr) + dchdr->dlen; nr_desc++; } if (unlikely(sz != i)) { pr_err("%s: dcs_cmd=%x len=%d error!", __func__, data[0], sz); kfree(data); return -ENOMEM; } cmd->desc = kzalloc(nr_desc * sizeof(struct gen_cmd_desc), GFP_KERNEL); cmd->name = kzalloc(sizeof(char) * (strlen(propname) + 1), GFP_KERNEL); strncpy(cmd->name, propname, strlen(propname) + 1); cmd->nr_desc = nr_desc; if (unlikely(!cmd->desc)) { pr_err("%s: fail to allocate cmd\n", __func__); goto err_alloc_cmds; } desc = cmd->desc; for (i = 0, nr = 0; nr < nr_desc; nr++) { dchdr = (struct gen_cmd_hdr *)(data + i); desc[nr].data_type = dchdr->dtype; desc[nr].lp = dchdr->txmode; desc[nr].delay = dchdr->wait; desc[nr].length = dchdr->dlen; desc[nr].data = kzalloc(dchdr->dlen * sizeof(unsigned char), GFP_KERNEL); if (!desc[nr].data) { pr_err("%s: fail to allocate data\n", __func__); goto err_alloc_data; } memcpy(desc[nr].data, &data[i + sizeof(*dchdr)], dchdr->dlen * sizeof(unsigned char)); i += sizeof(*dchdr) + dchdr->dlen; pr_info("type:%x, %s, %d ms, %d bytes, %02Xh\n", desc[nr].data_type, "hs-mode", desc[nr].delay, desc[nr].length, (desc[nr].data)[0]); } kfree(data); pr_info("parse %s done!\n", propname); return 0; err_alloc_data: for (nr = 0; nr < nr_desc; nr++) { kfree(desc[nr].data); desc[nr].data = NULL; } err_alloc_cmds: kfree(cmd->name); cmd->name = NULL; kfree(cmd->desc); cmd->desc = NULL; kfree(data); return -EINVAL; }
cmdline::cmdline(int args, char ** argv) { bool propertyValueExpect = false; bool outputDirectoryExpect = false; for(int i = 1; i < args; ++ i) { std::string arg(argv[i]); if(_lifecycleOrGoal.empty()) { //parse the first arg of command line. if(arg.find("-D") != arg.npos || arg.find("-o") != arg.npos) { trace::write(trace::error,"invalid input, first argument must be Goal or Lifecycle name"); throw std::runtime_error("parse command line error !!!!"); } _lifecycleOrGoal = arg; continue; } if(propertyValueExpect) { if(arg.find("-D") != arg.npos || arg.find("-o") != arg.npos) { trace::write(trace::error,"invalid input, expect property key value pair(%d)",i - 1); throw std::runtime_error("parse command line error !!!!"); } propertyValueExpect = false; parse_property(arg); continue; } if(outputDirectoryExpect) { if(arg.find("-D") != arg.npos || arg.find("-o") != arg.npos) { trace::write(trace::error,"invalid input, expect output directory (%d)",i - 1); throw std::runtime_error("parse command line error !!!!"); } outputDirectoryExpect = false; _outputDirectory = arg; continue; } if(arg.find("-D") != arg.npos) { arg = arg.substr(2); if(arg.empty()) { propertyValueExpect = true; continue;} parse_property(arg); continue; } if(arg.find("-o") != arg.npos) { arg = arg.substr(2); if(arg.empty()) { outputDirectoryExpect = true; continue;} _outputDirectory = arg; continue; } if(i == args - 1) _workspace = arg; } if(_outputDirectory.empty()) _outputDirectory = "./"; if(_workspace.empty()) _workspace = "./"; }