Boost logo

Boost :

From: Victor A. Wagner, Jr. (vawjr_at_[hidden])
Date: 2002-06-12 11:08:09


if it always find an even number, wouldn't std::pair<std::string,
std::string> be a better thing to produce?
your outputs would then be:
{
cout << '[' << iter->first << "]/[" << iter->second << ']' << endl;
++iter;
}
no more having to deal with odd even increments.

At Wednesday 2002/06/12 04:37, you wrote:
> 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:
>
>Name:James
>File:C:\temp\test.txt
>Flag:
>
>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 << ']' << "/";
> ++iter;
> cout << '[' << *iter << ']' << endl;
> ++iter;
> }
>
>would print
>
>[Name] \ [James]
>[File] \ [C:\temp\test.txt]
>[Flag] \ []
>
>The code is at:
>http://www.noveltheory.com/boost/namevalueiter.h and
>http://www.noveltheory.com/boost/NVtest.cpp
>(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)
>
>
>--
>Truth,
>James Curran
>www.NJTheater.com (Professional)
>www.NovelTheory.com (Personal)
>
>
>
>
>
>
>
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Victor A. Wagner Jr. http://rudbek.com
PGP RSA fingerprint = 4D20 EBF6 0101 B069 3817 8DBF C846 E47A
PGP D-H fingerprint = 98BC 65E3 1A19 43EC 3908 65B9 F755 E6F4 63BB 9D93
The five most dangerous words in the English language:
               "There oughta be a law"


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk