Synopsis - Synopsis::Buffer

namespace Synopsis
class Buffer
File: ../Synopsis/Buffer.hh

Buffer holds the memory on top of which a parse tree / syntax tree is constructed. Besides giving access to individual characters, it provides the means to register replacements for buffer chunks, such that when the Buffer's write method is executed the new file will contain the modified source.

Public Member functions Summary:
constructor Buffer(std::streambuf*, const std::string& = std :: string ( "unknown" ))
unsigned long size() const

return the size of the buffer

char get()

report the character at the current position and advance one character

void unget()

undo the last get

void reset(unsigned long c = 0)

reset the current position to position c

unsigned long position() const

report the current position

char at(unsigned long p) const

report the character at position p

const char* ptr(unsigned long p = 0) const

report the pointer at position p

void replace(const char* from, const char* to, const char* begin, unsigned long length)

replace the text between from and to by the text between begin and begin + length

unsigned long origin(const char*, std::string&) const

Return the origin of the given pointer (filename and line number)

void write(std::ostream&, const std::string&) const

Write the buffer into the given output stream The first line contains a line directive issuing the input file name; if filename is non-empty, use this to fake another one.

Private Typedefs Summary:
std::vector<Replacement> Replacements
Private Structs Summary:
struct Replacement
Private Member functions Summary:
long read_line_directive(unsigned long cursor, long line, unsigned long& begin, unsigned long& end) const

read a line directive starting at position pos, and return the line number found.

Private Data members Summary:
std::string my_filename
std::string my_buffer
unsigned long my_cursor
Replacements my_replacements
Public Member functions Details:
unsigned long size() const

return the size of the buffer

char get()

report the character at the current position and advance one character

void unget()

undo the last get

void reset(unsigned long c = 0)

reset the current position to position c

unsigned long position() const

report the current position

char at(unsigned long p) const

report the character at position p

const char* ptr(unsigned long p = 0) const

report the pointer at position p

void replace(const char* from, const char* to, const char* begin, unsigned long length)

replace the text between from and to by the text between begin and begin + length

unsigned long origin(const char*, std::string&) const

Return the origin of the given pointer (filename and line number)

void write(std::ostream&, const std::string&) const

Write the buffer into the given output stream The first line contains a line directive issuing the input file name; if filename is non-empty, use this to fake another one.

Private Member functions Details:
long read_line_directive(unsigned long cursor, long line, unsigned long& begin, unsigned long& end) const

read a line directive starting at position pos, and return the line number found. Also report the begin and end of the filename (with respect to the internal buffer). line is the default line number that gets reported on error (in which case begin and end remain unchanged)

Generated on Thu Apr 16 16:27:33 2009 by
synopsis (version devel)