ACE_Tokenizer_T< CHAR > Class Template Reference

Tokenizer. More...

#include <Tokenizer_T.h>

Collaboration diagram for ACE_Tokenizer_T< CHAR >:

Collaboration graph
[legend]

List of all members.

Classes

class  Delimiter_Entry
 Delimiter Entry. More...
class  Preserve_Entry
 Preserve Entry. More...

Public Types

enum  { MAX_DELIMITERS = 16, MAX_PRESERVES = 16 }

Public Member Functions

 ACE_Tokenizer_T (CHAR *buffer)
int delimiter (CHAR d)
int delimiter_replace (CHAR d, CHAR replacement)
int preserve_designators (CHAR start, CHAR stop, int strip=1)
CHAR * next (void)
 Returns the next token.

Protected Member Functions

int is_delimiter (CHAR d, int &replace, CHAR &r)
int is_preserve_designator (CHAR start, CHAR &stop, int &strip)

Protected Attributes

CHAR * buffer_
int index_
Preserve_Entry preserves_ [MAX_PRESERVES]
 The application can specify MAX_PRESERVES preserve designators.
int preserves_index_
 Pointer to the next free spot in preserves_.
Delimiter_Entry delimiters_ [MAX_DELIMITERS]
 The tokenizer allows MAX_DELIMITERS number of delimiters.
int delimiter_index_
 Pointer to the next free space in delimiters_.


Detailed Description

template<class CHAR>
class ACE_Tokenizer_T< CHAR >

Tokenizer.

Tokenizes a buffer. Allows application to set delimiters and preserve designators. Does not allow special characters, yet (e.g., printf ("\"like a quoted string\"")).


Member Enumeration Documentation

template<class CHAR >
anonymous enum

Enumerator:
MAX_DELIMITERS 
MAX_PRESERVES 


Constructor & Destructor Documentation

template<class CHAR >
ACE_Tokenizer_T< CHAR >::ACE_Tokenizer_T ( CHAR *  buffer  )  [inline]

buffer will be parsed. Notice that ACE_Tokenizer_T will modify buffer if you use delimiter_replace or preserve_designators to do character substitution.

Note:
You should NOT pass a constant string or string literal to this constructor, since ACE_Tokenizer_T will try to modify the string.
See also:
preserve_designators

preserve_designators


Member Function Documentation

template<class CHAR >
int ACE_Tokenizer_T< CHAR >::delimiter ( CHAR  d  )  [inline]

d is a delimiter.

Returns:
Returns 0 on success, -1 if there is no memory left.
Example:
     char buf[30];
     ACE_OS::strcpy(buf, "William/Joseph/Hagins");

     ACE_Tokenizer_T tok (buf);
     tok.delimiter ('/');
     for (char *p = tok.next (); p; p = tok.next ())
      cout << p << endl;
    

This will print out:

     William/Joseph/Hagins
      Joseph/Hagins
      Hagins 

template<class CHAR >
int ACE_Tokenizer_T< CHAR >::delimiter_replace ( CHAR  d,
CHAR  replacement 
) [inline]

d is a delimiter and, when found, will be replaced by replacement.

Returns:
0 on success, -1 if there is no memory left.
Example:
     char buf[30];
     ACE_OS::strcpy(buf, "William/Joseph/Hagins");

     ACE_Tokenizer tok (buf);
     tok.delimiter_replace ('/', 0);
     for (char *p = tok.next (); p; p = tok.next ())
       cout << p << endl;
    

This will print out:

       William
       Joseph
       Hagins 

template<class CHAR >
int ACE_Tokenizer_T< CHAR >::is_delimiter ( CHAR  d,
int &  replace,
CHAR &  r 
) [inline, protected]

Returns 1 if d is a delimiter, 0 otherwise. If d should be replaced with r, replace is set to 1, otherwise 0.

template<class CHAR >
int ACE_Tokenizer_T< CHAR >::is_preserve_designator ( CHAR  start,
CHAR &  stop,
int &  strip 
) [inline, protected]

If start is a start preserve designator, returns 1 and sets stop to the stop designator. Returns 0 if start is not a preserve designator.

template<class CHAR >
CHAR * ACE_Tokenizer_T< CHAR >::next ( void   )  [inline]

Returns the next token.

template<class CHAR >
int ACE_Tokenizer_T< CHAR >::preserve_designators ( CHAR  start,
CHAR  stop,
int  strip = 1 
) [inline]

Extract string between a pair of designator characters. For instance, quotes, or '(' and ')'. start specifies the begin designator. stop specifies the end designator. strip If strip == 1, then the preserve designators will be stripped from the tokens returned by next.

Returns:
0 on success, -1 if there is no memory left.
Example with strip = 0:
     char buf[30];
     ACE_OS::strcpy(buf, "William(Joseph)Hagins");

     ACE_Tokenizer tok (buf);
     tok.preserve_designators ('(', ')', 0);
     for (char *p = tok.next (); p; p = tok.next ())
       cout << p << endl;
    

This will print out:

      William(Joseph)Hagins
      (Joseph)Hagins
      )Hagins 

Example with strip = 1:

     char buf[30];
     ACE_OS::strcpy(buf, "William(Joseph)Hagins");

     ACE_Tokenizer tok (buf);
     tok.preserve_designators ('(', ')', 1);
     for (char *p = tok.next (); p; p = tok.next ())
       cout << p << endl;
    

This will print out:

      William
      Joseph
      Hagins 


Member Data Documentation

template<class CHAR >
CHAR* ACE_Tokenizer_T< CHAR >::buffer_ [protected]

template<class CHAR >
int ACE_Tokenizer_T< CHAR >::delimiter_index_ [protected]

Pointer to the next free space in delimiters_.

template<class CHAR >
Delimiter_Entry ACE_Tokenizer_T< CHAR >::delimiters_[MAX_DELIMITERS] [protected]

The tokenizer allows MAX_DELIMITERS number of delimiters.

template<class CHAR >
int ACE_Tokenizer_T< CHAR >::index_ [protected]

template<class CHAR >
Preserve_Entry ACE_Tokenizer_T< CHAR >::preserves_[MAX_PRESERVES] [protected]

The application can specify MAX_PRESERVES preserve designators.

template<class CHAR >
int ACE_Tokenizer_T< CHAR >::preserves_index_ [protected]

Pointer to the next free spot in preserves_.


The documentation for this class was generated from the following files:

Generated on Mon Jul 13 16:13:45 2009 for ACE by  doxygen 1.5.8