NAME

ACE_Read_Buffer - Efficiently reads an artibrarily large buffer from an input stream up to an including a termination character. Also performs search/replace on single occurrences a character in the buffer using the priniciples of Integrated Layer Processing.

SYNOPSIS


#include <ace/Read_Buffer.h>


class ACE_Read_Buffer
{
  public:
    ACE_Read_Buffer (
        FILE *fp,
        int close_on_delete = 0,
        ACE_Allocator * = 0
        );
    ACE_Read_Buffer (
        int handle,
        int close_on_delete = 0,
        ACE_Allocator * = 0
        );
    ~ACE_Read_Buffer (void);
    char *read (
        int terminator = EOF,
        int search = '\n',
        int replace = '  '
        );
    size_t replaced (void) const;
    size_t size (void) const;
    void dump (void) const;
  private:
    char *rec_read (int term, int search, int replace);
    size_t size_;
    size_t occurrences_;
    FILE *stream_;
    int close_on_delete_;
    ACE_Allocator *allocator_;
    void operator= (const ACE_Read_Buffer &);
    ACE_Read_Buffer (const ACE_Read_Buffer &);
};

DESCRIPTION

This implementation is optimized to do a single dynamic allocation and make only one copy of the data. It uses recursion and the run-time stack to accomplish this efficiently.

Initialization and termination methods.

ACE_Read_Buffer (
    FILE *fp,
    int close_on_delete = 0,
    ACE_Allocator * = 0
    );
ACE_Read_Buffer (
    int handle,
    int close_on_delete = 0,
    ACE_Allocator * = 0
    );
~ACE_Read_Buffer (void);
Returns a dynamically allocated pointer to n bytes of data from the input stream up to (and including) the terminator. If search is = 0 then all occurrences of the search value are substituted with the replace value.
char *read (
    int terminator = EOF,
    int search = '\n',
    int replace = '  '
    );
size_t replaced (void) const;
size_t size (void) const;
void dump (void) const;

Disallow copying and assignment...

void operator= (const ACE_Read_Buffer &);
ACE_Read_Buffer (const ACE_Read_Buffer &);

AUTHOR

Doug Schmidt and Seth Widoff

LIBRARY

ace