当前位置: 首页>>代码示例>>C++>>正文


C++ parse_file函数代码示例

本文整理汇总了C++中parse_file函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_file函数的具体用法?C++ parse_file怎么用?C++ parse_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main( int argc, char** argv ) {

  screen s;
  struct matrix *edges;
  struct matrix *transform;

  edges = new_matrix(4, 4);
  transform = new_matrix(4, 4);

  if ( argc == 2 )
    parse_file( argv[1], transform, edges, s );
  else
    parse_file( "stdin", transform, edges, s );

  free_matrix( transform );
  free_matrix( edges );
}  
开发者ID:esqu1,项目名称:graphics,代码行数:17,代码来源:main.c

示例2: parse_file

void
wav_reader_c::read_headers() {
  if (!wav_reader_c::probe_file(m_in.get(), m_size))
    throw mtx::input::invalid_format_x();

  parse_file();
  create_demuxer();
}
开发者ID:CheesyWiggles,项目名称:mkvtoolnix,代码行数:8,代码来源:r_wav.cpp

示例3: ompi_btl_wv_ini_init

/*
 * Read the INI files for device-specific values and save them in
 * internal data structures for later lookup.
 */
int ompi_btl_wv_ini_init(void)
{
    int ret = OMPI_ERR_NOT_FOUND;
    char *colon;

    char separator = ';';

    OBJ_CONSTRUCT(&devices, opal_list_t);

    colon = strchr(mca_btl_wv_component.device_params_file_names, separator);
    if (NULL == colon) {
        /* If we've only got 1 file (i.e., no colons found), parse it
           and be done */
        ret = parse_file(mca_btl_wv_component.device_params_file_names);
    } else {
        /* Otherwise, loop over all the files and parse them */
        char *orig = strdup(mca_btl_wv_component.device_params_file_names);
        char *str = orig;

        while (NULL != (colon = strchr(str, ':'))) {
            *colon = '\0';
            ret = parse_file(str);
            /* Note that NOT_FOUND and SUCCESS are not fatal errors
               and we keep going.  Other errors are treated as
               fatal */
            if (OMPI_ERR_NOT_FOUND != OPAL_SOS_GET_ERROR_CODE(ret) && OMPI_SUCCESS != ret) {
                break;
            }
            str = colon + 1;
        }
        /* Parse the last file if we didn't have a fatal error above */
        if (OMPI_ERR_NOT_FOUND != OPAL_SOS_GET_ERROR_CODE(ret) && OMPI_SUCCESS != ret) {
            ret = parse_file(str);
        }

        /* All done */
        free(orig);
    }

    /* Return SUCCESS unless we got a fatal error */

    initialized = true;
    return (OMPI_SUCCESS == ret || OMPI_ERR_NOT_FOUND == OPAL_SOS_GET_ERROR_CODE(ret)) ?
        OMPI_SUCCESS : ret;
}
开发者ID:DmitrySigaev,项目名称:ompi-release,代码行数:49,代码来源:btl_wv_ini.c

示例4: parse_file

void xml_configuration::parse_all()
{
    for (auto && file : _files)
    {
        auto result = parse_file(file);
        if (!result.empty()) // no need to throw because desperion has default values for config options
            std::cerr << "parsing failed " << file << ": " << result << std::endl;
    }
}
开发者ID:Ryuuke,项目名称:desperion,代码行数:9,代码来源:xml_configuration.cpp

示例5: make_makefile

void make_makefile(char* module_name) {
	printf("Make Makefile %s/%s/Makefile \n",out_dir,module_name);
	char buf[4096] = {0}; 
	FILE *fp = NULL ;
	char new_file_name[128];
	char *replace_args[] = {"{{src_dir}}",src_dir,"{{module_name}}",module_name};
	sprintf(new_file_name,"%s/%s/Makefile",out_dir,module_name);
	parse_file("tpls/Makefile.tpl",new_file_name,replace_args,4);
}
开发者ID:qixingyue,项目名称:ngx_tool,代码行数:9,代码来源:ngx_tool.c

示例6: parse_directory

/**
 * @short Bulk converts all files at dirname, excepting *~, and the creates a handler for such directory.
 */
void parse_directory(const char *prefix, const char *dirname, FILE * outfd,
                     onion_assets_file * assets) {
  DIR *dir = opendir(dirname);
  if (!dir) {
    fprintf(stderr, "ERROR: Could not open directory %s, check permissions.",
            dirname);
    exit(4);
  }
  // First create other files/dirs
  struct dirent *de;
  char fullname[1024];
  while ((de = readdir(dir))) {
    if (de->d_name[0] == '.' || de->d_name[strlen(de->d_name) - 1] == '~')
      continue;
    snprintf(fullname, sizeof(fullname), "%s/%s", dirname, de->d_name);
    if (de->d_type == DT_DIR) {
      char prefix2[256];
      snprintf(prefix2, sizeof(prefix2), "%s/%s", prefix, de->d_name);
      parse_directory(prefix2, fullname, outfd, assets);
    } else
      parse_file(prefix, fullname, outfd, assets);
  }
  closedir(dir);
  // Now create current
  char *fname = funcname(prefix, NULL);
  snprintf(fullname, sizeof(fullname),
           "onion_connection_status %s(void *_, onion_request *req, onion_response *res);",
           fname);
  onion_assets_file_update(assets, fullname);
  fprintf(stderr, "Parsing directory: %s to '%s'.\n", dirname, fullname);
  fprintf(outfd,
          "onion_connection_status %s(void *_, onion_request *req, onion_response *res){\n",
          fname);
  fprintf(outfd, "  const char *path=onion_request_get_path(req);\n\n");

  dir = opendir(dirname);
  while ((de = readdir(dir))) {
    if (de->d_name[0] == '.' || de->d_name[strlen(de->d_name) - 1] == '~')
      continue;
    char *fname = funcname(prefix, de->d_name);
    if (de->d_type == DT_DIR) {
      int l = strlen(de->d_name);
      fprintf(outfd, "  if (strncmp(\"%s/\", path, %d)==0){\n", de->d_name,
              l + 1);
      fprintf(outfd, "    onion_request_advance_path(req, %d);\n", l + 1);
    } else
      fprintf(outfd, "  if (strcmp(\"%s\", path)==0){\n", de->d_name);
    fprintf(outfd, "    return %s(_, req, res);\n", fname);
    fprintf(outfd, "  }\n");
    free(fname);
  }
  closedir(dir);

  fprintf(outfd, "  return OCS_NOT_PROCESSED;\n");
  fprintf(outfd, "}\n\n");
  free(fname);
}
开发者ID:davidmoreno,项目名称:onion,代码行数:60,代码来源:opack.c

示例7: main

int main(int argc, char *argv[])
{
	// needs at least 1 argument
	if (argc < 2)
	{
		fprintf(stderr,
			"Usage:\n"
			"  makelist <source.lst>\n"
		);
		return 0;
	}

	// extract arguments
	const char *srcfile = argv[1];

	// parse the root file, exit early upon failure
	drivcount = 0;
	ignorecount = 0;
	if (parse_file(srcfile))
		return 1;

	// output a count
	if (drivcount == 0)
	{
		fprintf(stderr, "No drivers found\n");
		return 1;
	}
	fprintf(stderr, "%d drivers found\n", drivcount);

	// add a reference to the ___empty driver
	drivlist[drivcount++] = "___empty";

	// sort the list
	qsort(drivlist, drivcount, sizeof(*drivlist), sort_callback);

	// start with a header
	printf("#include \"emu.h\"\n\n");
	printf("#include \"drivenum.h\"\n\n");

	// output the list of externs first
	for (int index = 0; index < drivcount; index++)
		printf("GAME_EXTERN(%s);\n", drivlist[index]);
	printf("\n");

	// then output the array
	printf("const game_driver * const driver_list::s_drivers_sorted[%d] =\n", drivcount);
	printf("{\n");
	for (int index = 0; index < drivcount; index++)
		printf("\t&GAME_NAME(%s)%s\n", drivlist[index], (index == drivcount - 1) ? "" : ",");
	printf("};\n");
	printf("\n");

	// also output a global count
	printf("int driver_list::s_driver_count = %d;\n", drivcount);

	return 0;
}
开发者ID:Ilgrim,项目名称:MAMEHub,代码行数:57,代码来源:makelist.c

示例8: QCOMPARE

void TestRenumber::testMerge()
{
	QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/test47b.xml"), 0);
	process_dives(true, false);
	QCOMPARE(dive_table.nr, 1);
	QCOMPARE(unsaved_changes(), 1);
	mark_divelist_changed(false);
	dive_table.preexisting = dive_table.nr;
}
开发者ID:neolit123,项目名称:subsurface,代码行数:9,代码来源:testrenumber.cpp

示例9: parse_configuration

void parse_configuration(struct ccx_s_options *opt)
{
    FILE *f = NULL;
    if( (f = fopen(CNF_FILE,"r") ) != NULL)
    {
        parse_file(f,opt);
        fclose(f);
    }
}
开发者ID:sagar20896,项目名称:ccextractor,代码行数:9,代码来源:configuration.c

示例10: main

int main( int argc, char** argv ) {

  screen s;
  struct matrix *edges;
  struct matrix *transform;
  color c;
  c.red = 0;
  c.green = 255;
  c.blue = 255;

  edges = new_matrix(4, 4);
  transform = new_matrix(4, 4);

  if ( argc == 2 )
    parse_file( argv[1], transform, edges, s );
  else
    parse_file( "stdin", transform, edges, s );

  add_edge( edges, 250,0,0, 250,25,0 );//M                       
  add_edge( edges, 250,25,0, 263,0,0 );
  add_edge( edges, 263,0,0, 275,25,0 );
  add_edge( edges, 275,25,0, 275,0,0 );
  add_edge( edges, 280,0,0, 293,25,0 );//A                      
  add_edge( edges, 293,25,0, 305,0,0 );
  add_edge( edges, 287,13,0, 299,13,0 );
  add_edge( edges, 310,0,0, 325,25,0 );//Y                               
  add_edge( edges, 318,13,0, 305,25,0 );
  add_edge( edges, 330,0,0, 343,25,0 );//A                              
  add_edge( edges, 343,25,0, 355,0,0 );
  add_edge( edges, 337,13,0, 349,13,0 );
  add_edge( edges, 360,0,0, 360,25,0 );//N                         
  add_edge( edges, 360,25,0, 385,0,0 );
  add_edge( edges, 385,0,0, 385,25,0 );
  add_edge( edges, 390,0,0, 390,25,0 );//K                           
  add_edge( edges, 390,13,0, 408,25,0 );
  add_edge( edges, 395,14,0, 408,0,0 );
  draw_lines(edges, s, c);

  save_extension(s, "dimensional.png");
  display(s);

  free_matrix( transform );
  free_matrix( edges );
}  
开发者ID:mayankvanjani,项目名称:mayank_el_3D,代码行数:44,代码来源:main.c

示例11: parse_document

    static int
    parse_document(
        fs::path const& filein_
      , fs::path const& fileout_
      , fs::path const& deps_out_
      , fs::path const& locations_out_
      , fs::path const& xinclude_base_
      , int indent
      , int linewidth
      , bool pretty_print)
    {
        string_stream buffer;
        id_manager ids;

        int result = 0;

        try {
            quickbook::state state(filein_, xinclude_base_, buffer, ids);
            set_macros(state);

            if (state.error_count == 0) {
                state.add_dependency(filein_);
                state.current_file = load(filein_); // Throws load_error

                parse_file(state);

                if(state.error_count) {
                    detail::outerr()
                        << "Error count: " << state.error_count << ".\n";
                }
            }

            result = state.error_count ? 1 : 0;

            if (!deps_out_.empty())
            {
                fs::ofstream out(deps_out_);
                BOOST_FOREACH(quickbook::state::dependency_list::value_type
                        const& d, state.dependencies)
                {
                    if (d.second) {
                        out << detail::path_to_generic(d.first) << std::endl;
                    }
                }
            }

            if (!locations_out_.empty())
            {
                fs::ofstream out(locations_out_);
                BOOST_FOREACH(quickbook::state::dependency_list::value_type
                        const& d, state.dependencies)
                {
                    out << (d.second ? "+ " : "- ")
                        << detail::path_to_generic(d.first) << std::endl;
                }
            }
开发者ID:cpascal,项目名称:af-cpp,代码行数:56,代码来源:quickbook.cpp

示例12: write_profile_string

/**
* @brief writeFile a profile string to a ini file
* @param section [in] name of the section,can't be NULL and empty string
* @param key [in] name of the key pairs to value, can't be NULL and empty string
* @param value [in] profile string value
* @param file [in] path of ini file
* @return 1 : success\n 0 : failure
*/
int write_profile_string(const char *section, const char *key,
        const char *value, const char *file) {
    char buf[MAX_FILE_SIZE] = {0};
    char w_buf[MAX_FILE_SIZE] = {0};
    int sec_s, sec_e, key_s, key_e, value_s, value_e;
    int value_len = (int) strlen(value);
    int file_size;
    FILE *out;

    //check parameters
    assert(section != NULL && strlen(section));
    assert(key != NULL && strlen(key));
    assert(value != NULL);
    assert(file != NULL && strlen(key));

    if (!load_ini_file(file, buf, &file_size)) {
        sec_s = -1;
    } else {
        parse_file(section, key, buf, &sec_s, &sec_e, &key_s, &key_e, &value_s,
                &value_e);
    }

    if (-1 == sec_s) {
        if (0 == file_size) {
            sprintf(w_buf + file_size, "[%s]\n%s=%s\n", section, key, value);
        } else {
            //not find the section, then add the new section at end of the file
            memcpy(w_buf, buf, file_size);
            sprintf(w_buf + file_size, "\n[%s]\n%s=%s\n", section, key, value);
        }
    } else if (-1 == key_s) {
        //not find the key, then add the new key=value at end of the section
        memcpy(w_buf, buf, sec_e);
        sprintf(w_buf + sec_e, "%s=%s\n", key, value);
        sprintf(w_buf + sec_e + strlen(key) + strlen(value) + 2, buf + sec_e,
                file_size - sec_e);
    } else {
        //update value with new value
        memcpy(w_buf, buf, value_s);
        memcpy(w_buf + value_s, value, value_len);
        memcpy(w_buf + value_s + value_len, buf + value_e, file_size - value_e);
    }

    out = fopen(file, "w");
    if (NULL == out) {
        return 0;
    }

    if (-1 == fputs(w_buf, out)) {
        fclose(out);
        return 0;
    }

    fclose(out);
    return 1;
}
开发者ID:shoutrain,项目名称:ComEgg,代码行数:64,代码来源:inifile.cpp

示例13: mca_coll_ml_config_file_init

int mca_coll_ml_config_file_init(void)
{

    int ret = OMPI_ERR_NOT_FOUND;

    ret = parse_file(mca_coll_ml_component.config_file_name);

    return (OMPI_SUCCESS == ret ) ?
        OMPI_SUCCESS : ret;
}
开发者ID:jimmycao,项目名称:ompi-slurm,代码行数:10,代码来源:coll_ml_config.c

示例14: generate_file

void generate_file(const char *file_name, int article) {
  parsed_article *pa = parse_file(file_name);

  extend_buffer(article);
  parse_xrefs(pa);
  if (pa != NULL) {
    pa->article = article;
    generate_article(pa);
  }
}
开发者ID:larsmagne,项目名称:reticule,代码行数:10,代码来源:novgen.c

示例15: gfp_load_files

void gfp_load_files(const char **filelist, int n)
{
	_byte_order = get_bit_endian();
	_msg_defs._type = GF_PROTO_TYPE_ARRAY;
	_msg_defs._len = 0;
	for (int i = 0; i < n; i++)
	{
		parse_file(filelist[i]);
	}
}
开发者ID:cokeboL,项目名称:gf_proto,代码行数:10,代码来源:gfproto.c


注:本文中的parse_file函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。