I have a question about boost::tokenizer. I have a Semicolon separated
string, something like:
"All;;;;;;Bus;;;;;;BRT;;;;;;All"
When I use boost tokenizer, I get "All", "Bus", "BRT",and "All". I
want to get the the empty string between the semicolons, seems like
the tokenizer takes consecutive semicolons as a single token; is
there any way I can change this to represent different strings?
boost::char_separator<char> sep(";");
typedef boost::tokenizer
In the constructor of the char_separator, you need to specify
keep_empty_tokens. See
http://www.boost.org/libs/tokenizer/char_separator.htm
On Thu, 4 Apr 2002, macrodisk wrote:
macrod> I have a question about boost::tokenizer. I have a Semicolon separated
macrod> string, something like:
macrod> "All;;;;;;Bus;;;;;;BRT;;;;;;All"
macrod> When I use boost tokenizer, I get "All", "Bus", "BRT",and "All". I
macrod> want to get the the empty string between the semicolons, seems like
macrod> the tokenizer takes consecutive semicolons as a single token; is
macrod> there any way I can change this to represent different strings?
macrod>
macrod> boost::char_separator<char> sep(";");
macrod> typedef boost::tokenizer
Thank you for your reply. The following code gives me the error in
Borland compiler:
boost::char_separator<char> sep(";", boost::keep_empty_tokens);
[C++ Error] CVLZOut1.cpp(23): E2285 Could not find a match
for 'boost::char_separator
In the constructor of the char_separator, you need to specify keep_empty_tokens. See
Hi Vijay,
On Fri, 5 Apr 2002, macrodisk wrote:
macrod> Thank you for your reply. The following code gives me the error in
macrod> Borland compiler:
macrod>
macrod> boost::char_separator<char> sep(";", boost::keep_empty_tokens);
macrod>
macrod> [C++ Error] CVLZOut1.cpp(23): E2285 Could not find a match
macrod> for 'boost::char_separator
One minor thing to point out: macrodisk wrote:
boost::char_separator<char> sep(";", boost::keep_empty_tokens); boost::char_separator<char> sep(";", "|", boost::keep_empty_tokens);
Even if C++ default arguments worked as you liked (which they don't), those two are not equivalent. The actual default argument for kept_delims is 0 (at least in 1.27, perhaps it's different in older versions since the documentation states the default is ""). What you should be using is: boost::char_separator<char> sep(";", 0, boost::keep_empty_tokens); moo ------------------------------------------------------------ R Samuel Klatchko - Principal Software Jester Brightmail Inc - rsk@brightmail.com
participants (3)
-
Jeremy Siek
-
macrodisk
-
Samuel Klatchko