Rogue Wave banner
Previous fileContentsIndexNext file
Click on the banner to return to the class reference home page.

RWWTokenizer

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/wtoken.h>
RWWString str("a string of tokens", RWWString::ascii);
RWWTokenizer(str);  // Lex the above string

Description

Class RWWTokenizer is designed to break a string up into separate tokens, delimited by arbitrary "white space." It can be thought of as an iterator for strings and as an alternative to the C library function wstok() which has the unfortunate side effect of changing the string being tokenized.

Persistence

None

Example

#include <rw/wtoken.h>
#include <rw/rstream.h>

main(){
  RWWString a(L"Something is rotten in the state of Denmark");

  RWWTokenizer next(a);   // Tokenize the string a

  RWWString token;        // Will receive each token

  // Advance until the null string is returned:
  while (!(token=next()).isNull())
    cout << token << "\n";
}

Program output:

   Something
   is
   rotten
   in
   the
   state
   of
   Denmark

Public Constructor

RWWTokenizer(const RWWString& s);

Public Member Function

RWWSubString
operator();
RWWSubString
operator()(const wchar_t* s);
RWWSubString
operator()(const wchar_t* s,size_t num);


Previous fileContentsIndexNext file

©Copyright 1997, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.