Falcon::StringStream Class Reference

#include <stringstream.h>

Inheritance diagram for Falcon::StringStream:

Inheritance graph
[legend]

List of all members.

Public Member Functions

uint32 allocated () const
virtual FalconDataclone () const
 Clones the stream.
virtual bool close ()
 Close target stream.
bytecloseToBuffer ()
 Gets the phisical memory created by this object.
CoreStringcloseToCoreString ()
 Gets the phisical memory created by this object and turns it into a newly created garbage collected string.
bool closeToString (String &target)
 Gets the phisical memory created by this object and turns it into a string.
StringcloseToString ()
 Gets the phisical memory created by this object and turns it into a string.
bytedata () const
virtual bool errorDescription (::Falcon::String &description) const
virtual void gcMark (uint32 mark)
virtual bool get (uint32 &chr)
 Gets next character from the stream.
CoreStringgetCoreString () const
 Gets a string copying the content of the stream, allocating in the garbage the target string.
StringgetString () const
 Gets a string copying the content of the stream, newly allocating the target string.
void getString (String &target) const
 Gets a string copying the content of the stream.
virtual int64 lastError () const
uint32 length () const
virtual bool put (uint32 chr)
 Writes a character on the stream.
virtual int32 read (void *buffer, int32 size)
 Reads from target stream.
virtual int32 readAvailable (int32 msecs, const Sys::SystemData *sysData=0)
 Determines if the stream can be read, possibly with a given timeout.
virtual bool readString (String &dest, uint32 size)
 Gets a whole string from the stream.
 StringStream (const StringStream &strbuf)
 StringStream (const String &strbuf)
 StringStream (int32 size=0)
virtual int64 tell ()
void transfer (StringStream &strbuf)
 Transfers a string stream buffer into this one.
virtual bool truncate (int64 pos=-1)
virtual int32 write (const void *buffer, int32 size)
 Write to the target stream.
virtual int32 writeAvailable (int32 msecs, const Sys::SystemData *sysData=0)
 Determines if the stream can be written, possibly with a given timeout.
virtual bool writeString (const String &source, uint32 begin=0, uint32 end=csh::npos)
 Writes a string on the stream.
virtual ~StringStream ()

Protected Member Functions

bool detachBuffer ()
virtual int64 seek (int64 pos, e_whence whence)
void setBuffer (const char *source, int size=-1)
void setBuffer (const String &source)

Protected Attributes

uint32 m_pos


Constructor & Destructor Documentation

Falcon::StringStream::StringStream ( int32  size = 0  ) 

Falcon::StringStream::StringStream ( const String strbuf  ) 

Falcon::StringStream::StringStream ( const StringStream strbuf  ) 

virtual Falcon::StringStream::~StringStream (  )  [virtual]


Member Function Documentation

uint32 Falcon::StringStream::allocated (  )  const

virtual FalconData* Falcon::StringStream::clone (  )  const [virtual]

Clones the stream.

This version returns 0 and sets error to unsupported; subclasses must properly clone the stream.

Reimplemented from Falcon::Stream.

Reimplemented in Falcon::ROStringStream.

virtual bool Falcon::StringStream::close (  )  [virtual]

Close target stream.

Reimplemented from Falcon::Stream.

Reimplemented in Falcon::ROStringStream.

byte* Falcon::StringStream::closeToBuffer (  ) 

Gets the phisical memory created by this object.

This version of the method retreives the internally allocated buffer and empties this StringStream.

The returned buffer must be de-allocated using Falcon::memFree()

Returns:
a byte * that will receive the internally created data.

CoreString* Falcon::StringStream::closeToCoreString (  ) 

Gets the phisical memory created by this object and turns it into a newly created garbage collected string.

See also:
closeToString()
Returns:
a string containing all the data in the stream.

bool Falcon::StringStream::closeToString ( String target  ) 

Gets the phisical memory created by this object and turns it into a string.

This version of the method stores the phisical memory in the given string, and configures it as a single byte memory buffer string.

Returns:
false if the stream has already been closed.

String* Falcon::StringStream::closeToString (  ) 

Gets the phisical memory created by this object and turns it into a string.

The memory that has been created by the stream-like operations is directly passed into a string object, in a very efficient way; as a result, the buffer in this object is transferred as-is into the returned string, and this object becomes unuseable (closed).

If the stream has already been closed, the function will return 0.

Returns:
a string containing all the data in the stream.

byte* Falcon::StringStream::data (  )  const

bool Falcon::StringStream::detachBuffer (  )  [protected]

virtual bool Falcon::StringStream::errorDescription ( ::Falcon::String description  )  const [virtual]

Reimplemented from Falcon::Stream.

virtual void Falcon::StringStream::gcMark ( uint32  mark  )  [inline, virtual]

Reimplemented from Falcon::Stream.

virtual bool Falcon::StringStream::get ( uint32 chr  )  [virtual]

Gets next character from the stream.

Subclasses must manage both stateful transcoding and properly popping readahead characters from the buffer.

Returns:
true if the character is available, false on stream end or error.

Implements Falcon::Stream.

CoreString* Falcon::StringStream::getCoreString (  )  const [inline]

Gets a string copying the content of the stream, allocating in the garbage the target string.

The memory that is currently held in this object is copied in a string. Read-write operations can then continue, and the status of the object is not changed.

Returns:
a string containing all the data in the stream (may be empty, but not 0).

String* Falcon::StringStream::getString (  )  const [inline]

Gets a string copying the content of the stream, newly allocating the target string.

The memory that is currently held in this object is copied in a string. Read-write operations can then continue, and the status of the object is not changed.

Returns:
a string containing all the data in the stream (may be empty, but not 0).

void Falcon::StringStream::getString ( String target  )  const

Gets a string copying the content of the stream.

The memory that is currently held in this object is copied in a string. Read-write operations can then continue, and the status of the object is not changed.

Parameters:
target The string where the buffer is copied.

virtual int64 Falcon::StringStream::lastError (  )  const [virtual]

Reimplemented from Falcon::Stream.

uint32 Falcon::StringStream::length (  )  const

virtual bool Falcon::StringStream::put ( uint32  chr  )  [virtual]

Writes a character on the stream.

Parameters:
chr the character to write.
Returns:
true success, false on stream error.

Reimplemented from Falcon::Stream.

virtual int32 Falcon::StringStream::read ( void *  buffer,
int32  size 
) [virtual]

Reads from target stream.

Parameters:
buffer the buffer where read data will be stored.
size the amount of bytes to read

Reimplemented from Falcon::Stream.

virtual int32 Falcon::StringStream::readAvailable ( int32  msecs_timeout,
const Sys::SystemData sysData = 0 
) [virtual]

Determines if the stream can be read, possibly with a given timeout.

If sysData is not zero, it will be used to honor concurrent interrupt requests.

Reimplemented from Falcon::Stream.

virtual bool Falcon::StringStream::readString ( String target,
uint32  size 
) [virtual]

Gets a whole string from the stream.

This is implemented by iteratively calling get( uint32 ). The caller should provide a string with enough space already reserved, if possible, to make operations more efficient.

The target string may be shorter than required if the stream ends before all the characters are read, or in case of error.

Returns:
true if some characters are available, false on stream end or error.

Reimplemented from Falcon::Stream.

virtual int64 Falcon::StringStream::seek ( int64  pos,
e_whence  whence 
) [protected, virtual]

Reimplemented from Falcon::Stream.

void Falcon::StringStream::setBuffer ( const char *  source,
int  size = -1 
) [protected]

void Falcon::StringStream::setBuffer ( const String source  )  [protected]

virtual int64 Falcon::StringStream::tell (  )  [virtual]

Reimplemented from Falcon::Stream.

void Falcon::StringStream::transfer ( StringStream strbuf  ) 

Transfers a string stream buffer into this one.

The original buffer is emptied, and this buffer aqcuires the same status, allocation and contents of the other one.

virtual bool Falcon::StringStream::truncate ( int64  pos = -1  )  [virtual]

Reimplemented from Falcon::Stream.

Reimplemented in Falcon::ROStringStream.

virtual int32 Falcon::StringStream::write ( const void *  buffer,
int32  size 
) [virtual]

Write to the target stream.

Reimplemented from Falcon::Stream.

Reimplemented in Falcon::ROStringStream.

virtual int32 Falcon::StringStream::writeAvailable ( int32  msecs_timeout,
const Sys::SystemData sysData = 0 
) [virtual]

Determines if the stream can be written, possibly with a given timeout.

If sysData is not zero, it will be used to honor concurrent interrupt requests.

Reimplemented from Falcon::Stream.

Reimplemented in Falcon::ROStringStream.

virtual bool Falcon::StringStream::writeString ( const String source,
uint32  begin = 0,
uint32  end = csh::npos 
) [virtual]

Writes a string on the stream.

Encoding range is in [begin, end), that is, the last character encoded is end - 1.

Parameters:
source the string that must be encoded
begin first character from which to encode
end one past last character to encode (can be safely greater than string lenght() )
Returns:
true success, false on stream error.

Reimplemented from Falcon::Stream.


Member Data Documentation


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

Generated on Mon Oct 19 10:11:47 2009 for Falcon_Core by  doxygen 1.5.8