diff --git a/CHANGELOG b/CHANGELOG index 5329d9c99f7eb2c016d73a3074d1c393de26d323..78cce87d726e5fad35651da78208acf5b9b6db36 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +16dec14: + + - API change in string_ops: 'string2words' -> 'split', + admitting arbitary delimiter characters. + 26aug13: - API of RNG has changed diff --git a/lib/file_ops.cpp b/lib/file_ops.cpp index 729bfa20a11c5cce8eb106f626b4517ebf3a9acb..585d3a3c2d271c0222849fd72ab8d0f2b9263aaa 100644 --- a/lib/file_ops.cpp +++ b/lib/file_ops.cpp @@ -121,7 +121,7 @@ void triv::glob_file_list( // add extension to input pattern: string extended_pattern = ""; vector<string> words; - string2words( pattern, words ); + split( pattern, words ); if ( !words.size() ) throw string( "empty file list" ); for ( size_t i=0; ; ) { diff --git a/lib/string_ops.cpp b/lib/string_ops.cpp index 433a0ed858504d43120273642ec6722964fd6f5b..7ab9358549edae517855adfd48fed88996a39dcb 100644 --- a/lib/string_ops.cpp +++ b/lib/string_ops.cpp @@ -132,11 +132,11 @@ void triv::string_extract_line( const string& in, string *out1, string *out2 ) } } -//! Split string at whitespaces, set vector of words. +//! Split string at given delimiters, return vector of tokens. -void triv::string2words( const string& in, vector<string>& out ) +void triv::split( + const string& in, vector<string>& out, const string& delimiters ) { - const string delimiters = " \t"; // skip delimiters at beginning: string::size_type lastPos = in.find_first_not_of( delimiters, 0 ); // find first non-delimiter: diff --git a/lib/string_ops.hpp b/lib/string_ops.hpp index f0cafced905d9de7774a9430e5f729d96dab3736..e83e4235f281d77647a26b553ce289f16f18b33d 100644 --- a/lib/string_ops.hpp +++ b/lib/string_ops.hpp @@ -14,7 +14,8 @@ namespace triv { string *out1, string *out2 ); void string_extract_line( const string& in, string *out1, string *out2 ); - void string2words( const string& in, vector<string>& out ); + void split( const string& in, vector<string>& out, + const string& delimiters = " \t" ); string strip( const string& str, const char* sepSet=" \n" ); }