Boost logo

Boost :

From: James Curran/MVP (jamescurran_at_[hidden])
Date: 2002-06-12 12:36:12


Ok, I've tried that, but it leads to a declaration even more contorted than
the original:

 typedef boost::tokenizer<name_value_pair2, string::const_iterator,
std::pair<string, string> > TokNV2;

 name_value_pair2 nv2('=', '\n');

 TokNV2 tok2(input, nv2);
 TokNV2::iterator iter2 = tok2.begin();
 while (iter2 != tok2.end())
 {
  cout << '[' << iter2->first << ']' << "/";
  cout << '[' << iter2->second << ']' << endl;
  ++iter2;
 }

I'll have name_value_pair2 included in the posted source files later today.

--
Truth,
James Curran
www.NovelTheory.com  (Personal)
www.NJTheater.com   (Professional)
www.aurora-inc.com   (Day job)
"Victor A. Wagner, Jr." <vawjr_at_[hidden]> wrote in message
news:4.3.1.2.20020612090403.03aa2450_at_mail.rudbek.com...
> 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"
>
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>

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