Boost logo

Boost :

From: James Curran (JamesCurran_at_[hidden])
Date: 2002-06-12 06:37:14

    Out of personal need I've written a TokenizerFunction which might be
worth sharing.

    It's designed to parse a collection of name/value pairs (with the key
feature for me being that everything after the first delimiter is the second
field, regardless of delimiters it migth contain). It will always return an
even number of tokens. For example, given the input:


then the code

 name_value_pair nv(':', '\n'); // == to nv()
boost::tokenizer<name_value_pair > tok(input, nv);
boost::tokenizer<name_value_pair > ::iterator iter = tok.begin();
 while (iter != tok.end())
  cout << '[' << *iter << ']' << "/";
  cout << '[' << *iter << ']' << endl;

would print

[Name] \ [James]
[File] \ [C:\temp\test.txt]
[Flag] \ []

The code is at: and
(I used the source for offset_separator as a template, so it should be
grossly off boost standards, but so far I haven't tried to meet them either)

James Curran     (Professional)  (Personal)

Boost list run by bdawes at, gregod at, cpdaniel at, john at