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

RWCTokenizer

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

Synopsis

#include <rw/ctoken.h>
RWCString str("a string of tokens");
RWCTokenizer(str);  // Lex the above string

Description

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

Persistence

None

Example

#include <rw/ctoken.h>
#include <rw/rstream.h>
main(){
  RWCString a("Something is rotten in the state of Denmark");
  RWCTokenizer next(a);           // Tokenize the string a
  RWCString 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

RWCTokenizer(const RWCString& s);

Public Member Operators

RWCSubString
operator();
RWCSubString
operator()(const char* s);
RWCSubString
operator()(const char* s,size_t num);


Previous fileContentsIndexNext file

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