本文整理汇总了C++中parse_file函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_file函数的具体用法?C++ parse_file怎么用?C++ parse_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: parse_nf
int
parse_nf (char *string, List *list)
{
newts_nfref *ref = nfref_alloc ();
char *copy;
if (string == NULL || list == NULL)
return -1;
copy = newts_strdup (string);
if (!pattern_flag)
sense = PARSE_ADD;
if (*copy == ':')
{
return parse_file (copy + 1, list);
}
if (*copy == '!')
{
char *change = newts_strdup (copy + 1);
newts_free (copy);
copy = change;
sense = PARSE_DELETE;
}
if (!pattern_flag &&
(strchr (copy, '?') || strchr (copy, '[') || strchr (copy, '*') ||
strchr (copy, ' ')))
{
/* Pattern matching. */
int result;
pattern_flag = TRUE;
result = parse_pattern (copy, list);
pattern_flag = FALSE;
return result;
}
parse_single_nf (copy, ref);
if (sense == PARSE_ADD)
list_insert_next (list, list_tail (list), (void *) ref);
else
{
list_remove_match (list, (void *) ref);
nfref_free (ref);
}
newts_free (copy);
return 0;
}
开发者ID:tylerberry,项目名称:newts,代码行数:55,代码来源:parse.c
示例17: read_header
/*
* Read in the entire mtree file into memory on the first request.
* Then use the next unused file to satisfy each header request.
*/
static int
read_header(struct archive_read *a, struct archive_entry *entry)
{
struct mtree *mtree;
char *p;
int r, use_next;
mtree = (struct mtree *)(a->format->data);
if (mtree->fd >= 0) {
close(mtree->fd);
mtree->fd = -1;
}
if (mtree->entries == NULL) {
mtree->resolver = archive_entry_linkresolver_new();
if (mtree->resolver == NULL)
return ARCHIVE_FATAL;
archive_entry_linkresolver_set_strategy(mtree->resolver,
ARCHIVE_FORMAT_MTREE);
r = read_mtree(a, mtree);
if (r != ARCHIVE_OK)
return (r);
}
a->archive.archive_format = mtree->archive_format;
a->archive.archive_format_name = mtree->archive_format_name;
for (;;) {
if (mtree->this_entry == NULL)
return (ARCHIVE_EOF);
if (strcmp(mtree->this_entry->name, "..") == 0) {
mtree->this_entry->used = 1;
if (archive_strlen(&mtree->current_dir) > 0) {
/* Roll back current path. */
p = mtree->current_dir.s
+ mtree->current_dir.length - 1;
while (p >= mtree->current_dir.s && *p != '/')
--p;
if (p >= mtree->current_dir.s)
--p;
mtree->current_dir.length
= p - mtree->current_dir.s + 1;
}
}
if (!mtree->this_entry->used) {
use_next = 0;
r = parse_file(a, entry, mtree, mtree->this_entry,
&use_next);
if (use_next == 0)
return (r);
}
mtree->this_entry = mtree->this_entry->next;
}
}
开发者ID:andrewgregory,项目名称:libarchive,代码行数:59,代码来源:archive_read_support_format_mtree.c
示例18: main
int main(int argc, char** argv)
{
std::cout << "Hello, world!" << std::endl;
// setup signal interrupt handler
signal(SIGINT, signal_callback_handler);
// specify which options are available as cmd line arguments
setupCmdLineReader();
// read agent id from command line parameters (--agent=mario)
agent = readAgentFromCmdLine(argc, argv);
// initialize the behavior tree client node
ros::init(argc, argv, std::string("behavior_tree") + "_" + agent);
// initialize OpenGL engine for visualization
glut_setup(argc, argv);
// point to the root of the behavior tree
node_cursor = node = &root;
node_cursor->set_highlighted(true);
// create the bt from the file bt.txt (put on the path)
std::cout << "----------------- PARSE FILE -----------------" << std::endl;
parse_file(std::string("bt") + "_" + agent + ".txt");
// print the data parsed from the specification file
std::cout << "----------------- PRINT TREE -----------------" << std::endl;
root.print_subtree();
// wait until user inputs Enter to start
std::cout << "Press Enter To Start" << std::endl;
std::cin.get();
// start ticking the root of the tree at frequency: TICK_FREQUENCY
while (ros::ok())
{
std::cout << "**** run" << run << std::endl;
std::cout << "-------------- EXECUTE TREE --------------" << std::endl;
root.execute_reset_status();
root.execute(); // sending tick
get_keypressed(); // processing keystrokes
process_keypressed();
glut_process(); // update visualization
glutPostRedisplay();
ros::Duration(1.0/TICK_FREQUENCY).sleep();
std::cout << "**** run" << run << std::endl;
}
// missing to clear the dynamically allocated tree
// delete_tree();
return 0;
}
开发者ID:miccol,项目名称:Nao-Demo,代码行数:55,代码来源:main.cpp
示例19: most_load_user_keymaps
int most_load_user_keymaps (void)
{
#ifndef VMS
char filebuf[MAX_PATHLEN];
unsigned int len;
#endif
char *file;
#ifdef MOST_SYSTEM_INITFILE
if (MOST_SYSTEM_INITFILE != NULL)
{
int status;
status = parse_file (MOST_SYSTEM_INITFILE);
if (status == -1)
return -1;
}
#endif
if (NULL == (file = getenv ("MOST_INITFILE")))
{
#ifdef VMS
file = "SYS$LOGIN:MOST.RC";
#else
*filebuf = 0;
file = getenv ("HOME");
if (file == NULL)
return -1;
len = strlen (file);
if (len + 8 >= sizeof (filebuf)) /* 8 for strlen("/.mostrc") */
return -1;
strcpy (filebuf, file);
file = filebuf;
if (len && (file[len - 1] == '/'))
len--;
strcpy (file + len, "/.mostrc");
#endif
}
return parse_file (file);
}
开发者ID:uberchicgeekchick,项目名称:most,代码行数:42,代码来源:keyparse.c
示例20: main
int main(int argc, const char *argv[])
{
char *file;
file = read_file(FILENAME);
//printf("%s", file);
parse_file(file);
printf("The value of total_servers: %s\n", total_servers);
sleep(100);
return 0;
}
开发者ID:liunx,项目名称:myworks,代码行数:11,代码来源:main.c
注:本文中的parse_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论