本文整理汇总了C++中FileManager::add方法的典型用法代码示例。如果您正苦于以下问题:C++ FileManager::add方法的具体用法?C++ FileManager::add怎么用?C++ FileManager::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tokenizePatternFile
void tokenizePatternFile(std::ifstream& in) {
// tokenize a line from the pattern file. The first part will be the pattern and the second
// part is the file to write to.
std::string lineptr;
while(in.good()) {
std::getline(in, lineptr);
if(lineptr.empty()) {
continue;
}
std::vector<std::string> fields;
split(fields, lineptr, "\t");
switch(fields.size()) {
case 0:
break;
case 1:
manager.add(fields[0]);
if(opts.r_flag) {
std::string rcpattern = fields[0];
reverseComplement(rcpattern);
manager.add(rcpattern);
}
break;
default:
manager.add(fields[0], fields[1]);
if(opts.r_flag) {
std::string rcpattern = fields[0];
reverseComplement(rcpattern);
manager.add(rcpattern, fields[1]);
}
break;
}
}
}
示例2: main
int main(int argc, char * argv[])
{
int opt_idx = parseOptions(argc, argv);
std::string pattern;
if(opts.f_flag == NULL) {
if( opt_idx >= argc) {
puts("Please provide a pattern (or pattern file) and at least one input file");
usage(usage_msg);
} else if (opt_idx >= argc - 1) {
puts("Please provide an input file");
usage(usage_msg);
}
pattern = argv[opt_idx];
++opt_idx;
manager.add(pattern);
if(opts.r_flag) {
std::string rcpattern = pattern;
reverseComplement(rcpattern);
manager.add(rcpattern);
}
} else {
if (opt_idx > argc - 1) {
puts("Please provide an input file");
usage(usage_msg);
}
std::ifstream in (opts.f_flag);
if(!in.good()) {
fprintf(stderr, "problem opening pattern file\n");
exit(1);
} else {
tokenizePatternFile(in);
}
}
while(opt_idx < argc) {
Fxstream stream;
int stream_state = 1;
if(! opts.S_flag && ! opts.I_flag) {
// two read files
stream_state = stream.open(argv[opt_idx], argv[opt_idx+1], opts.I_flag);
} else {
// one read file
stream_state = stream.open(argv[opt_idx], NULL, opts.I_flag);
}
if(stream_state != 0) {
fprintf(stderr, "Failed to open stream\n");
return 1;
}
if(opts.E_flag | opts.G_flag) {
// Posix regex
regex_t px_regex;
int flags = REG_NOSUB; //only need to report success or failure
if(opts.E_flag) {
flags |= REG_EXTENDED;
} else {
flags |= REG_BASIC;
}
int ret = regcomp(&px_regex, pattern.c_str(), flags);
if(ret) {
char * errorbuf = get_regerror(ret, &px_regex);
fprintf(stderr, "%s\n", errorbuf);
free(errorbuf);
return 1;
}
ret = posix_regex_search(stream, &px_regex);
regfree(&px_regex);
}
#ifdef HAVE_PCRE
else if (opts.P_flag) {
// PCRE regex
pcre *re;
const char *error;
int erroffset;
re = pcre_compile(
pattern.c_str(), /* the pattern */
0, /* default options */
&error, /* for error message */
&erroffset, /* for error offset */
NULL); /* use default character tables */
if (re == NULL) {
printf("PCRE compilation failed at offset %d: %s\n", erroffset, error);
return 1;
}
pcre_search(stream, re);
pcre_free(re);
}
#endif
else if(opts.X_flag) {
hash_search(stream);
}
else if(opts.f_flag) {
multipattern_search(stream);
//.........这里部分代码省略.........