Made to Order Software Corporation Logo

LLChatLib: LLSDParser Class Reference

LLSDParser Class Reference

Abstract base class for LLSD parsers. More...

#include <llsdserialize.h>

Inheritance diagram for LLSDParser:

List of all members.

Public Types

enum  
 

Anonymous enum to indicate parsing failure.



Public Member Functions

 LLSDParser ()
 Constructor.

S32 parse (std::istream &istr, LLSD &data, S32 max_bytes)
 Call this method to parse a stream for LLSD.

S32 parseLines (std::istream &istr, LLSD &data)
void reset ()
 Resets the parser so parse() or parseLines() can be called again for another <llsd> chunk.

Protected Member Functions

void account (S32 bytes) const
 Accunt for bytes read outside of the istream helpers.

virtual S32 doParse (std::istream &istr, LLSD &data) const =0
 Pure virtual base for doing the parse.

virtual void doReset ()
 Virtual default function for resetting the parser.

virtual ~LLSDParser ()
 Destructor.

std::istream & get (std::istream &istr, std::streambuf &sb, char delim) const
 get several bytes off the stream into a streambuf

std::istream & get (std::istream &istr, char *s, std::streamsize n, char delim) const
 get several bytes off the stream into a buffer.

int get (std::istream &istr) const
 get a byte off the stream

std::istream & ignore (std::istream &istr) const
 ignore the next byte on the istream

std::istream & putback (std::istream &istr, char c) const
 put the last character retrieved back on the stream

std::istream & read (std::istream &istr, char *s, std::streamsize n) const
 read a block of n characters into a buffer

Protected Attributes

bool mCheckLimits
 boolean to set if byte counts should be checked during parsing.

S32 mMaxBytesLeft
 The maximum number of bytes left to be parsed.

bool mParseLines
 Use line-based reading to get text.


Detailed Description

Abstract base class for LLSD parsers.


Constructor & Destructor Documentation

LLSDParser::LLSDParser (  ) 

Constructor.

LLSDParser


Member Function Documentation

void LLSDParser::account ( S32  bytes  )  const [protected]

Accunt for bytes read outside of the istream helpers.

Conceptually const since it only modifies mutable members.

Parameters:
bytes The number of bytes read.
virtual S32 LLSDParser::doParse ( std::istream &  istr,
LLSD data 
) const [protected, pure virtual]

Pure virtual base for doing the parse.

This method parses the istream for a structured data. This method assumes that the istream is a complete llsd object -- for example an opened and closed map with an arbitrary nesting of elements. This method will return after reading one data object, allowing continued reading from the stream by the caller.

Parameters:
istr The input stream.
data[out] The newly parse structured data.
Returns:
Returns the number of LLSD objects parsed into data. Returns PARSE_FAILURE (-1) on parse failure.

Implemented in LLSDNotationParser, LLSDJSONParser, LLSDXMLParser, and LLSDBinaryParser.

std::istream & LLSDParser::get ( std::istream &  istr,
std::streambuf &  sb,
char  delim 
) const [protected]

get several bytes off the stream into a streambuf

Parameters:
istr The istream to work with.
sb The streambuf to read into
delim Delimiter to get until found.
Returns:
Returns istr.
std::istream & LLSDParser::get ( std::istream &  istr,
char *  s,
std::streamsize  n,
char  delim 
) const [protected]

get several bytes off the stream into a buffer.

Parameters:
istr The istream to work with.
s The buffer to get into
n Extract maximum of n-1 bytes and null temrinate.
delim Delimiter to get until found.
Returns:
Returns istr.
int LLSDParser::get ( std::istream &  istr  )  const [protected]

get a byte off the stream

Parameters:
istr The istream to work with.
Returns:
returns the next character.
std::istream & LLSDParser::ignore ( std::istream &  istr  )  const [protected]

ignore the next byte on the istream

Parameters:
istr The istream to work with.
Returns:
Returns istr.
S32 LLSDParser::parse ( std::istream &  istr,
LLSD data,
S32  max_bytes 
)

Call this method to parse a stream for LLSD.

This method parses the istream for a structured data. This method assumes that the istream is a complete llsd object -- for example an opened and closed map with an arbitrary nesting of elements. This method will return after reading one data object, allowing continued reading from the stream by the caller.

Parameters:
istr The input stream.
data[out] The newly parse structured data.
max_bytes The maximum number of bytes that will be in the stream. Pass in LLSDSerialize::SIZE_UNLIMITED (-1) to set no byte limit.
Returns:
Returns the number of LLSD objects parsed into data. Returns PARSE_FAILURE (-1) on parse failure.

Here is the call graph for this function:

S32 LLSDParser::parseLines ( std::istream &  istr,
LLSD data 
)

Like parse(), but uses a different call (istream.getline()) to read by lines This API is better suited for XML, where the parse cannot tell where the document actually ends.

Here is the call graph for this function:

std::istream & LLSDParser::putback ( std::istream &  istr,
char  c 
) const [protected]

put the last character retrieved back on the stream

Parameters:
istr The istream to work with.
c The character to put back
Returns:
Returns istr.
std::istream & LLSDParser::read ( std::istream &  istr,
char *  s,
std::streamsize  n 
) const [protected]

read a block of n characters into a buffer

Parameters:
istr The istream to work with.
s The buffer to read into
n The number of bytes to read.
Returns:
Returns istr.

The documentation for this class was generated from the following files:
Generated on Thu Sep 23 17:18:45 2010 for LLChatLib by  doxygen 1.6.3