18 vector< string >
split(
const string& i_str,
const string& i_delim )
20 vector< string > result;
22 size_t found = i_str.find( i_delim );
23 size_t startIndex = 0;
25 while( found != string::npos )
27 result.push_back(
string( i_str.begin() + startIndex, i_str.begin() + found ) );
28 startIndex = found + i_delim.size();
29 found = i_str.find( i_delim, startIndex );
31 if( startIndex != i_str.size() ) result.push_back(
string( i_str.begin() + startIndex, i_str.end() ) );
35 int main(
int argc,
char* argv[] )
40 string inputfile, outputfile, deleteTags, keepTags;
41 opts.
addOpt<
string >(
"input,i",
"input filename ", &inputfile );
42 opts.
addOpt<
string >(
"output,o",
"output file", &outputfile );
44 opts.
addOpt<
string >(
"deleteTags,d",
"delete tags ", &deleteTags );
45 opts.
addOpt<
string >(
"keepTags,k",
"keep tags ", &keepTags );
52 vector< Tag > existingTags;
54 vector< string > tagsToDelete;
55 if( !keepTags.empty() )
57 vector< string > tagsToKeep =
split( keepTags,
string(
":" ) );
58 for(
size_t i = 0; i < existingTags.size(); i++ )
62 bool deleteTag =
false;
63 for(
size_t k = 0; k < tagsToKeep.size() && !deleteTag; k++ )
65 if( tname.compare( tagsToKeep[k] ) == 0 ) deleteTag =
true;
67 if( !deleteTag ) tagsToDelete.push_back( tname );
70 if( !deleteTags.empty() )
72 tagsToDelete =
split( deleteTags,
string(
":" ) );
74 for(
size_t i = 0; i < tagsToDelete.size(); i++ )
83 cout <<
"write file " << outputfile << endl;