ACE 8.0.1
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ACE_Read_Buffer Class Reference

Efficiently reads an arbitrarily large buffer from an input stream up to and including a termination character. Also performs search/replace on single occurrences a character in the buffer using the principles of Integrated Layer Processing. More...

#include <Read_Buffer.h>

Collaboration diagram for ACE_Read_Buffer:
Collaboration graph
[legend]

Public Member Functions

 ACE_Read_Buffer (FILE *fp, bool close_on_delete=false, ACE_Allocator *=0)
 Read from a FILE *.
 
 ACE_Read_Buffer (ACE_HANDLE handle, bool close_on_delete=false, ACE_Allocator *=0)
 Read from an open HANDLE.
 
 ~ACE_Read_Buffer ()
 Closes the FILE *.
 
charread (int terminator=EOF, int search='\n', int replace='\0')
 
size_t replaced () const
 Returns the number of characters replaced during a read.
 
size_t size () const
 
ACE_Allocatoralloc () const
 Returns a pointer to its allocator.
 
void dump () const
 Dump the state of the object.
 

Private Member Functions

void operator= (const ACE_Read_Buffer &)=delete
 
 ACE_Read_Buffer (const ACE_Read_Buffer &)=delete
 
void operator= (ACE_Read_Buffer &&)=delete
 
 ACE_Read_Buffer (ACE_Read_Buffer &&)=delete
 
charrec_read (int term, int search, int replace)
 Recursive helper method that does the work...
 

Private Attributes

size_t size_
 The total number of characters in the buffer.
 
size_t occurrences_
 The total number of characters replaced.
 
FILEstream_
 The stream we are reading from.
 
bool const close_on_delete_
 
ACE_Allocatorallocator_
 Pointer to the allocator.
 

Detailed Description

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

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.

Constructor & Destructor Documentation

◆ ACE_Read_Buffer() [1/4]

ACE_Read_Buffer::ACE_Read_Buffer ( FILE * fp,
bool close_on_delete = false,
ACE_Allocator * alloc = 0 )

Read from a FILE *.

◆ ACE_Read_Buffer() [2/4]

ACE_Read_Buffer::ACE_Read_Buffer ( ACE_HANDLE handle,
bool close_on_delete = false,
ACE_Allocator * alloc = 0 )

Read from an open HANDLE.

◆ ~ACE_Read_Buffer()

ACE_Read_Buffer::~ACE_Read_Buffer ( )

Closes the FILE *.

◆ ACE_Read_Buffer() [3/4]

ACE_Read_Buffer::ACE_Read_Buffer ( const ACE_Read_Buffer & )
privatedelete

◆ ACE_Read_Buffer() [4/4]

ACE_Read_Buffer::ACE_Read_Buffer ( ACE_Read_Buffer && )
privatedelete

Member Function Documentation

◆ alloc()

ACE_Allocator * ACE_Read_Buffer::alloc ( ) const
inline

Returns a pointer to its allocator.

◆ dump()

void ACE_Read_Buffer::dump ( ) const

Dump the state of the object.

◆ operator=() [1/2]

void ACE_Read_Buffer::operator= ( ACE_Read_Buffer && )
privatedelete

◆ operator=() [2/2]

void ACE_Read_Buffer::operator= ( const ACE_Read_Buffer & )
privatedelete

◆ read()

char * ACE_Read_Buffer::read ( int terminator = EOF,
int search = '\n',
int replace = '\0' )

Returns a pointer dynamically allocated with ACE_Allocator::malloc() to 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. The last of the byte of data is a 0, so that strlen can be used on it. The caller is responsible for freeing the pointer returned from this method using the ACE_Allocator::free().

◆ rec_read()

char * ACE_Read_Buffer::rec_read ( int term,
int search,
int replace )
private

Recursive helper method that does the work...

◆ replaced()

size_t ACE_Read_Buffer::replaced ( ) const
inline

Returns the number of characters replaced during a read.

◆ size()

size_t ACE_Read_Buffer::size ( ) const
inline

Returns the size of the allocated buffer obtained during a read, not including the null terminator.

Member Data Documentation

◆ allocator_

ACE_Allocator* ACE_Read_Buffer::allocator_
private

Pointer to the allocator.

◆ close_on_delete_

bool const ACE_Read_Buffer::close_on_delete_
private

Keeps track of whether we should close the FILE in the destructor.

◆ occurrences_

size_t ACE_Read_Buffer::occurrences_
private

The total number of characters replaced.

◆ size_

size_t ACE_Read_Buffer::size_
private

The total number of characters in the buffer.

◆ stream_

FILE* ACE_Read_Buffer::stream_
private

The stream we are reading from.


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