PLearn 0.1
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Private Types | Private Attributes | Static Private Attributes
PLearn::PStream Class Reference

#include <PStream.h>

Inheritance diagram for PLearn::PStream:
Inheritance graph
[legend]
Collaboration diagram for PLearn::PStream:
Collaboration graph
[legend]

List of all members.

Public Types

enum  mode_t {
  plearn_ascii, plearn_binary, raw_ascii, raw_binary,
  pretty_ascii
}
 plearn_ascii and plearn_binary are used on output to determine in which format to write stuff. More...
enum  compr_mode_t { compr_none, compr_double_as_float, compr_sparse, compr_lossy_sparse }
 Compression mode (mostly used by binary serialization of sequences of floats or doubles, such as TMat<real>) (Used on output only; autodetect on read). More...
typedef PStream &(* pl_pstream_manip )(PStream &)
 typedef's for PStream manipulators
typedef int streamsize
 typedef's for compatibility w/ old libraries
typedef ios ios_base

Public Member Functions

 PStream ()
 PStream (streambuftype *sb)
 constructor from a PStreamBuf
 PStream (istream *pin_, bool own_pin_=false)
 ctor. from an istream (I)
 PStream (ostream *pout_, bool own_pout_=false)
 ctor. from an ostream (O)
 PStream (iostream *pios_, bool own_pios_=false)
 ctor. from an iostream (IO)
 PStream (istream *pin_, ostream *pout_, bool own_pin_=false, bool own_pout_=false)
 ctor. from an istream and an ostream (IO)
virtual ~PStream ()
 Default copy ctor. should be fine now.
void setBufferCapacities (streamsize inbuf_capacity, streamsize outbuf_capacity, streamsize unget_capacity)
mode_t setInMode (mode_t m)
mode_t setOutMode (mode_t m)
void setMode (mode_t m)
void clearOutMap ()
void clearInMap ()
void clearInOutMaps ()
mode_t switchToPLearnOutMode ()
 if outmode is raw_ascii or raw_binary, it will be switched to corresponding plearn_ascii, resp.
PStreamoperator>> (mode_t m)
PStreamoperator<< (mode_t m)
PStreamoperator= (const PStream &pios)
PStreamoperator= (streambuftype *streambuf)
bool operator== (const PStream &other)
void writeAsciiNum (char x)
void writeAsciiNum (unsigned char x)
void writeAsciiNum (signed char x)
void writeAsciiNum (short x)
void writeAsciiNum (unsigned short x)
void writeAsciiNum (int x)
void writeAsciiNum (unsigned int x)
void writeAsciiNum (long x)
void writeAsciiNum (unsigned long x)
void writeAsciiNum (long long x)
void writeAsciiNum (unsigned long long x)
void writeAsciiNum (float x)
void writeAsciiNum (double x)
void readAsciiNum (char &x)
void readAsciiNum (unsigned char &x)
void readAsciiNum (signed char &x)
void readAsciiNum (short &x)
void readAsciiNum (unsigned short &x)
void readAsciiNum (int &x)
void readAsciiNum (unsigned int &x)
void readAsciiNum (long &x)
void readAsciiNum (unsigned long &x)
void readAsciiNum (long long &x)
void readAsciiNum (unsigned long long &x)
void readAsciiNum (float &x)
void readAsciiNum (double &x)
void writeAsciiHexNum (unsigned char x)
 Writes the corresponding 2 hex digits (ex: 0A )
template<class I >
void writeBinaryNum (I x)
 Writes base types to PLearn binary format TODO: forbid this mechanism for arbitrary classes?
template<class I , class J >
void readBinaryNumAs (J &x, bool inverted_byte_order)
 Reads a J element, optionnally swaps its endianness, and returns an I.
template<class I >
void readBinaryNum (I &x, unsigned char typecode)
 Reads base types from PLearn binary format.
bool eof () const
bool good () const
 operator void * () const
 !!!
bool operator! () const
 Test whether a PStream is in an invalid state.
const char * getFloatFormat () const
 Getters/Setters for the printf format strings for writeAsciiNum for float and double.
const char * getDoubleFormat () const
void setFloatFormat (const char *f)
void setDoubleFormat (const char *f)
int get ()
 The folowing methods are 'forwarded' from {i|o}stream.
PStreamget (char &c)
 The folowing methods are 'forwarded' from {i|o}stream.
PStreamgetline (string &line, char delimitor='\n')
 Delimitor is read from stream but not appended to string.
string getline ()
int peek ()
 The folowing methods are 'forwarded' from {i|o}stream.
PStreamputback (char c)
 If you put back the result of a call to get(), make sure it is not EOF.
PStreamunget ()
 Put back the last character read by the get() or read() methods.
PStreamunread (const char *p, streamsize n)
PStreamunread (const char *p)
PStreamunread (const string &s)
PStreamread (char *s, streamsize n)
PStreamread (string &s, streamsize n)
string readAll ()
 Reads until an EOF is found, and returns the whole content as a string.
void readExpected (char expect)
 Reads the next character and launches a PLERROR if it is different from expect.
void readExpected (char *expect)
 Reads character one by one, comparing it with the sequence in expect (until terminating null character in expect).
void readExpected (const string &expect)
 Reads character one by one, comparing it with the sequence in expect.
streamsize readUntil (char *buf, streamsize n, char stop_char)
 Reads characters into buf until n characters have been read, or end-of-file has been reached, or the next character in the stream is the stop_char.
streamsize readUntil (char *buf, streamsize n, const char *stop_chars)
 Reads characters into buf until n characters have been read, or end-of-file has been reached, or the next character in the stream is one of the stop_chars (null terminated string).
PStreamwrite (const char *s, streamsize n)
PStreamput (char c)
PStreamput (unsigned char c)
PStreamput (int x)
PStreamflush ()
PStreamendl ()
PStreamwrite (const char *s)
PStreamwrite (const string &s)
void skipRestOfLine ()
 reads everything until '
' (also consumes the '
')
void skipBlanks ()
 skips any blanks (space, tab, newline)
void skipBlanksAndComments ()
 skips any blanks (space, tab, newline) and comments starting with #
void skipBlanksAndCommentsAndSeparators ()
 skips any blanks, # comments, and separators (',' and ';')
void skipAll (const char *chars_to_skip)
 skips all occurences of any of the given characters
int smartReadUntilNext (const string &stoppingsymbols, string &characters_read, bool ignore_brackets=false, bool skip_comments=true)
 Reads characters from stream, until we meet one of the stopping symbols at the current "level".
int count (char c)
 Count the number of occurrences of a character in the stream.
PStreamoperator>> (float &x)
PStreamoperator>> (double &x)
PStreamoperator>> (string &x)
PStreamoperator>> (char *x)
PStreamoperator>> (char &x)
PStreamoperator>> (signed char &x)
PStreamoperator>> (unsigned char &x)
PStreamoperator>> (bool &x)
PStreamoperator>> (short &x)
PStreamoperator>> (unsigned short &x)
PStreamoperator>> (int &x)
PStreamoperator>> (unsigned int &x)
PStreamoperator>> (long &x)
PStreamoperator>> (unsigned long &x)
PStreamoperator>> (long long &x)
PStreamoperator>> (unsigned long long &x)
PStreamoperator>> (pl_pstream_manip func)
PStreamoperator<< (float x)
PStreamoperator<< (double x)
PStreamoperator<< (const char *x)
 Warning: string output will be formatted according to outmode (if you want to output a raw string use the write method instead)
PStreamoperator<< (const void *x)
 Overload to print out raw pointers in the form 0x????????
PStreamoperator<< (const string &x)
 Warning: string output will be formatted according to outmode (if you want to output a raw string use the write method instead) (unless you're in raw_ascii or raw_binary mode!)
PStreamoperator<< (char x)
PStreamoperator<< (signed char x)
PStreamoperator<< (unsigned char x)
PStreamoperator<< (bool x)
PStreamoperator<< (short x)
PStreamoperator<< (unsigned short x)
PStreamoperator<< (int x)
PStreamoperator<< (unsigned int x)
PStreamoperator<< (long x)
PStreamoperator<< (unsigned long x)
PStreamoperator<< (long long x)
PStreamoperator<< (unsigned long long x)
PStreamoperator<< (pl_pstream_manip func)

Static Public Member Functions

static PStream::mode_t parseModeT (const string &str)
 Parse a string and return the equivalent PStream::mode_t.

Public Attributes

mode_t inmode
 mode for input formatting
map< unsigned int, void * > copies_map_in
 format flags for input
mode_t outmode
 mode for output formatting
map< void *, unsigned intcopies_map_out
 format flags for output
bool implicit_storage
 If true, then Mat and Vec will be serialized with their elements in place, If false, they will have an explicit pointer to a storage.
compr_mode_t compression_mode
 Determines the way data is compressed, if any.
bool remote_plearn_comm
 Should be true if this stream is used to communicate with a remote PLearn host.

Static Public Attributes

static bool windows_endl = false
 If true, we should emit windows end of line(
)

Private Types

typedef PP< PStreamBufinherited
typedef PStreamBuf streambuftype

Private Attributes

const char * format_float
 Current format string for floats.
const char * format_double
 Current format string for doubles.

Static Private Attributes

static const char * format_float_default = "%.8g"
 Default format string for floats.
static const char * format_double_default = "%.15g"
 Default format string for doubles.

Detailed Description

PStream: This class defines a type of stream that should be used for all I/O within PLearn. It supports most operations available for standard C++ streams, plus:

Definition at line 88 of file PStream.h.


Member Typedef Documentation

Definition at line 96 of file PStream.h.

Definition at line 105 of file PStream.h.

typedef's for PStream manipulators

Definition at line 92 of file PStream.h.

Definition at line 97 of file PStream.h.

typedef's for compatibility w/ old libraries

Definition at line 104 of file PStream.h.


Member Enumeration Documentation

Compression mode (mostly used by binary serialization of sequences of floats or doubles, such as TMat<real>) (Used on output only; autodetect on read).

Enumerator:
compr_none 

No compression.

compr_double_as_float 

In plearn_binary mode, store doubles as float.

compr_sparse 

PLearn.

compr_lossy_sparse 

Also stores double as float.

Definition at line 133 of file PStream.h.

plearn_ascii and plearn_binary are used on output to determine in which format to write stuff.

On input however, they are equivalent, as the right format is automatically detected.

Enumerator:
plearn_ascii 

PLearn ascii serialization format (can be mixed with plearn_binary)

plearn_binary 

PLearn binary serialization format (can be mixed with plearn_ascii)

raw_ascii 

Raw C++ ascii output without additional separators (direct output to underlying ostream)

raw_binary 

Simply writes the bytes as they are in memory.

pretty_ascii 

Ascii pretty print (in particular for Vec and Mat, formatted output without size info)

Definition at line 113 of file PStream.h.


Constructor & Destructor Documentation

PLearn::PStream::PStream ( )
PLearn::PStream::PStream ( streambuftype sb)
PLearn::PStream::PStream ( istream *  pin_,
bool  own_pin_ = false 
)

ctor. from an istream (I)

Definition at line 203 of file PStream.cc.

PLearn::PStream::PStream ( ostream *  pout_,
bool  own_pout_ = false 
)

ctor. from an ostream (O)

Definition at line 215 of file PStream.cc.

PLearn::PStream::PStream ( iostream pios_,
bool  own_pios_ = false 
)

ctor. from an iostream (IO)

Definition at line 227 of file PStream.cc.

PLearn::PStream::PStream ( istream *  pin_,
ostream *  pout_,
bool  own_pin_ = false,
bool  own_pout_ = false 
)

ctor. from an istream and an ostream (IO)

Definition at line 239 of file PStream.cc.

PLearn::PStream::~PStream ( ) [virtual]

Default copy ctor. should be fine now.

Destructor.

Definition at line 253 of file PStream.cc.

{ }

Member Function Documentation

void PLearn::PStream::clearInMap ( ) [inline]

Definition at line 245 of file PStream.h.

    { copies_map_in.clear(); }
void PLearn::PStream::clearInOutMaps ( ) [inline]

Definition at line 248 of file PStream.h.

Referenced by PLearn::checkWrappedObjects(), and PLearn::RemotePLearnServer::clearMaps().

Here is the caller graph for this function:

void PLearn::PStream::clearOutMap ( ) [inline]

Definition at line 242 of file PStream.h.

Referenced by PLearn::_tostring_static_pstream_().

    { copies_map_out.clear(); }

Here is the caller graph for this function:

int PLearn::PStream::count ( char  c)

Count the number of occurrences of a character in the stream.

Definition at line 488 of file PStream.cc.

Referenced by PLearn::MultiInstanceVMatrix::build_().

                         {
    char ch = get();
    int counter = 0;
    while (ch != EOF) {
        if (ch == c)
            counter++;
        ch = get();
    }
    return counter;
}

Here is the caller graph for this function:

PStream& PLearn::PStream::endl ( ) [inline]

Definition at line 606 of file PStream.h.

References PLearn::flush().

Referenced by PLearn::endl(), and printobj().

    {
        if(windows_endl)
            put('\r');
        put('\n');
        flush();
        return *this;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

bool PLearn::PStream::eof ( ) const [inline]
PStream& PLearn::PStream::flush ( ) [inline]
int PLearn::PStream::get ( ) [inline]
PStream& PLearn::PStream::get ( char &  c) [inline]

The folowing methods are 'forwarded' from {i|o}stream.

Definition at line 477 of file PStream.h.

References c.

    {
        c = (char)ptr->get();
        return *this;
    }
const char* PLearn::PStream::getDoubleFormat ( ) const [inline]

Definition at line 466 of file PStream.h.

{ return format_double; }
const char* PLearn::PStream::getFloatFormat ( ) const [inline]

Getters/Setters for the printf format strings for writeAsciiNum for float and double.

By default, this is "%.8g" for float, and "%.18g" for double. NOTE: these strings must remain accessible for the lifetime of the PStream. In particular, they (generally) should not come from a string c_str().

Definition at line 465 of file PStream.h.

{ return format_float;  }
PStream& PLearn::PStream::getline ( string &  line,
char  delimitor = '\n' 
) [inline]
string PLearn::PStream::getline ( ) [inline]

Definition at line 496 of file PStream.h.

References getline().

Referenced by getline().

    { string s; getline(s); return s; }

Here is the call graph for this function:

Here is the caller graph for this function:

bool PLearn::PStream::good ( ) const [inline]
PLearn::PStream::operator void * ( ) const [inline]

!!!

Definition at line 450 of file PStream.h.

                { PLERROR("!?! this should have failed at compile time !?!"); return 0; } 
bool PLearn::PStream::operator! ( ) const [inline]

Test whether a PStream is in an invalid state.

Definition at line 455 of file PStream.h.

    { return !good(); }
PStream & PLearn::PStream::operator<< ( const string &  x)

Warning: string output will be formatted according to outmode (if you want to output a raw string use the write method instead) (unless you're in raw_ascii or raw_binary mode!)

Definition at line 1660 of file PStream.cc.

References operator<<().

{
    const char* array = x.c_str();
    operator<<(array);
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( unsigned int  x)

Definition at line 1769 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, write(), writeAsciiNum(), and writeBinaryNum().

{
    switch(outmode)
    {
    case raw_binary:
        write(reinterpret_cast<char *>(&x), sizeof(unsigned int));
        break;
    case raw_ascii:
    case pretty_ascii:
        writeAsciiNum(x);
        break;
    case plearn_ascii:
        writeAsciiNum(x);
        put(' ');
        break;
    case plearn_binary:
        writeBinaryNum(x);
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream& PLearn::PStream::operator<< ( mode_t  m) [inline]

Definition at line 266 of file PStream.h.

References m.

Referenced by operator<<().

    {
        outmode = m;
        return *this;
    }

Here is the caller graph for this function:

PStream & PLearn::PStream::operator<< ( bool  x)

Definition at line 1667 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, and raw_binary.

{
    switch(outmode)
    {
    case plearn_ascii:
        if(x)
            put('1');
        else
            put('0');
        put(' ');
        break;
    case raw_ascii:
    case pretty_ascii:
    case raw_binary:
    case plearn_binary:
        if(x)
            put('1');
        else
            put('0');
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( float  x)

Definition at line 1894 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, write(), writeAsciiNum(), and writeBinaryNum().

{
    switch(outmode)
    {
    case raw_binary:
        write(reinterpret_cast<char *>(&x), sizeof(float));
        break;
    case raw_ascii:
    case pretty_ascii:
        writeAsciiNum(x);
        break;
    case plearn_ascii:
        writeAsciiNum(x);
        put(' ');
        break;
    case plearn_binary:
        writeBinaryNum(x);
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( double  x)

Definition at line 1919 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, write(), writeAsciiNum(), and writeBinaryNum().

{
    switch(outmode)
    {
    case raw_binary:
        write(reinterpret_cast<char *>(&x), sizeof(double));
        break;
    case raw_ascii:
    case pretty_ascii:
        writeAsciiNum(x);
        break;
    case plearn_ascii:
        writeAsciiNum(x);
        put(' ');
        break;
    case plearn_binary:
        writeBinaryNum(x);
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( const char *  x)

Warning: string output will be formatted according to outmode (if you want to output a raw string use the write method instead)

Definition at line 1601 of file PStream.cc.

References c, i, outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, PLearn::strlen(), and write().

{
    int l = (int)strlen(x);
    switch(outmode)
    {
    case PStream::raw_ascii:
    case PStream::pretty_ascii:
    case PStream::raw_binary:
        write(x);
        break;

    case PStream::plearn_ascii:
    case PStream::plearn_binary:
    {
        put('"');
        for(int i=0; i<l; i++)
        {
            char c = x[i];
            if(c=='"' || c=='\\') // escape quote and backslash
                put('\\');
            put(c);
        }
        put('"');
        put(' ');
    }
    break;

    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( const void *  x)

Overload to print out raw pointers in the form 0x????????

Definition at line 1635 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, and write().

{
    switch(outmode)
    {
    case PStream::raw_ascii:
    case PStream::pretty_ascii:
    case PStream::raw_binary:
    case PStream::plearn_ascii:
    case PStream::plearn_binary:
    {
        char buffer[1000];
        snprintf(buffer, 1000, "%p ", x);
        buffer[999] = '\0';
        write(buffer);
        break;
    }
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( char  x)

Definition at line 1542 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, and writeBinaryNum().

{
    switch(outmode)
    {
    case raw_ascii:
    case raw_binary:
    case pretty_ascii:
        put(x);
        break;
    case plearn_ascii:
        put('\'');
        put(x);
        put('\'');
        put(' ');
        break;
    case plearn_binary:
        writeBinaryNum(x);
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( signed char  x)

Definition at line 1567 of file PStream.cc.

References operator<<().

{
    operator<<(char(x));
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( unsigned long long  x)

Definition at line 1869 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, write(), writeAsciiNum(), and writeBinaryNum().

{
    switch(outmode)
    {
    case raw_binary:
        write(reinterpret_cast<char *>(&x), sizeof(unsigned long long));
        break;
    case raw_ascii:
    case pretty_ascii:
        writeAsciiNum(x);
        break;
    case plearn_ascii:
        writeAsciiNum(x);
        put(' ');
        break;
    case plearn_binary:
        writeBinaryNum(x);
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( unsigned char  x)

Definition at line 1573 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, and writeBinaryNum().

{
    switch(outmode)
    {
    case raw_ascii:
        put(x);
        put(' ');
        break;
    case raw_binary:
        put(x);
        break;
    case pretty_ascii:
    case plearn_ascii:
        put('\'');
        put(x);
        put('\'');
        put(' ');
        break;
    case plearn_binary:
        writeBinaryNum(x);
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( short  x)

Definition at line 1694 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, write(), writeAsciiNum(), and writeBinaryNum().

{
    switch(outmode)
    {
    case raw_binary:
        write(reinterpret_cast<char *>(&x), sizeof(short));
        break;
    case raw_ascii:
    case pretty_ascii:
        writeAsciiNum(x);
        break;
    case plearn_ascii:
        writeAsciiNum(x);
        put(' ');
        break;
    case plearn_binary:
        writeBinaryNum(x);
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( unsigned short  x)

Definition at line 1719 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, write(), writeAsciiNum(), and writeBinaryNum().

{
    switch(outmode)
    {
    case raw_binary:
        write(reinterpret_cast<char *>(&x), sizeof(unsigned short));
        break;
    case raw_ascii:
    case pretty_ascii:
        writeAsciiNum(x);
        break;
    case plearn_ascii:
        writeAsciiNum(x);
        put(' ');
        break;
    case plearn_binary:
        writeBinaryNum(x);
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( int  x)

Definition at line 1744 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, write(), writeAsciiNum(), and writeBinaryNum().

{
    switch(outmode)
    {
    case raw_binary:
        write(reinterpret_cast<char *>(&x), sizeof(int));
        break;
    case raw_ascii:
    case pretty_ascii:
        writeAsciiNum(x);
        break;
    case plearn_ascii:
        writeAsciiNum(x);
        put(' ');
        break;
    case plearn_binary:
        writeBinaryNum(x);
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( long  x)

Definition at line 1794 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, write(), writeAsciiNum(), and writeBinaryNum().

{
    switch(outmode)
    {
    case raw_binary:
        write(reinterpret_cast<char *>(&x), sizeof(long));
        break;
    case raw_ascii:
    case pretty_ascii:
        writeAsciiNum(x);
        break;
    case plearn_ascii:
        writeAsciiNum(x);
        put(' ');
        break;
    case plearn_binary:
        writeBinaryNum(x);
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( unsigned long  x)

Definition at line 1819 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, write(), writeAsciiNum(), and writeBinaryNum().

{
    switch(outmode)
    {
    case raw_binary:
        write(reinterpret_cast<char *>(&x), sizeof(unsigned long));
        break;
    case raw_ascii:
    case pretty_ascii:
        writeAsciiNum(x);
        break;
    case plearn_ascii:
        writeAsciiNum(x);
        put(' ');
        break;
    case plearn_binary:
        writeBinaryNum(x);
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator<< ( long long  x)

Definition at line 1844 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, put(), raw_ascii, raw_binary, write(), writeAsciiNum(), and writeBinaryNum().

{
    switch(outmode)
    {
    case raw_binary:
        write(reinterpret_cast<char *>(&x), sizeof(long long));
        break;
    case raw_ascii:
    case pretty_ascii:
        writeAsciiNum(x);
        break;
    case plearn_ascii:
        writeAsciiNum(x);
        put(' ');
        break;
    case plearn_binary:
        writeBinaryNum(x);
        break;
    default:
        PLERROR("In PStream::operator<<  unknown outmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream& PLearn::PStream::operator<< ( pl_pstream_manip  func) [inline]

Definition at line 718 of file PStream.h.

{ return (*func)(*this); }
PStream & PLearn::PStream::operator= ( const PStream pios)

Definition at line 847 of file PStream.cc.

References compression_mode, implicit_storage, inmode, PLearn::PP< PStreamBuf >::operator=(), and outmode.

{
    if(this != &pios)
    {
        inherited::operator=((const inherited&)pios);
        inmode = pios.inmode;
        outmode = pios.outmode;
        implicit_storage = pios.implicit_storage;
        compression_mode = pios.compression_mode;
    }
    return *this;
}

Here is the call graph for this function:

PStream& PLearn::PStream::operator= ( streambuftype streambuf) [inline]

Definition at line 280 of file PStream.h.

    {
        inherited::operator=(streambuf);
        return *this;
    }
bool PLearn::PStream::operator== ( const PStream other) [inline]

Definition at line 286 of file PStream.h.

References PLearn::operator==().

    { return PP<PStreamBuf>::operator==(other); }

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( float &  x)

Definition at line 1469 of file PStream.cc.

References c, inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, read(), readAsciiNum(), readBinaryNum(), skipBlanks(), skipBlanksAndCommentsAndSeparators(), and unget().

{
    switch(inmode)
    {
    case raw_ascii:
    case pretty_ascii:
        skipBlanks();
        readAsciiNum(x);
        break;
    case raw_binary:
        read(reinterpret_cast<char *>(&x), sizeof(float));
        break;
    case plearn_ascii:
    case plearn_binary:
    {
        skipBlanksAndCommentsAndSeparators();
        int c = get();
        if(c>0x00 && c<0x20)  // plearn_binary
        {
            readBinaryNum(x, c);
        }
        else  // plearn_ascii
        {
            unget();
            readAsciiNum(x);
        }
        break;
    }
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( double &  x)

Definition at line 1504 of file PStream.cc.

References c, inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, read(), readAsciiNum(), readBinaryNum(), skipBlanks(), skipBlanksAndCommentsAndSeparators(), and unget().

{
    switch(inmode)
    {
    case raw_ascii:
    case pretty_ascii:
        skipBlanks();
        readAsciiNum(x);
        break;
    case raw_binary:
        read(reinterpret_cast<char *>(&x), sizeof(double));
        break;
    case plearn_ascii:
    case plearn_binary:
    {
        skipBlanksAndCommentsAndSeparators();
        int c = get();
        if(c>0x00 && c<0x20)  // plearn_binary
        {
            readBinaryNum(x, c);
        }
        else  // ascii
        {
            unget();
            readAsciiNum(x);
        }
        break;
    }
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( string &  x)

Definition at line 1037 of file PStream.cc.

References c, PLearn::find(), inmode, peek(), plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, PLearn::raw_wordseparators(), skipBlanksAndComments(), unget(), and PLearn::wordseparators().

{
    switch(inmode)
    {
    case PStream::raw_ascii:
    case PStream::raw_binary:
    case PStream::pretty_ascii:
    {
        skipBlanksAndComments();
        int c = get();
        x.clear();
        // As long as we don't meet a (raw) wordseparator (or eof)...
        while (c!=EOF && raw_wordseparators().find(c)==string::npos)
        {
            x += static_cast<char>(c);
            c = get();
        }
        unget();
    }
    break;
    case PStream::plearn_ascii:
    case PStream::plearn_binary:
    {
        skipBlanksAndComments();
        int c = peek();
        if(c=='"') // it's a quoted string "..."
        {
            x.resize(0);
            c = get(); // skip the quote
            c = get(); // get the next character
            while(c!='"' && c!=EOF)
            {
                if(c=='\\') // escaped character
                {
                    c = get();
                    switch (c)
                    {
                    case 'n':
                        x += '\n';
                        break;
                    case 't':
                        x += '\t';
                        break;
                    case 'r':
                        x += '\r';
                        break;
                    case '0':
                        x += '\0';
                        break;
                    case 'a':
                        x += '\a';
                        break;
                    case 'b':
                        x += '\b';
                        break;
                    case 'v':
                        x += '\v';
                        break;
                    case 'f':
                        x += '\f';
                        break;

                    default:
                        x += static_cast<char>(c);
                        break;
                    }
                }
                else
                    x += static_cast<char>(c);

                c = get();
            }
            if(c==EOF)
                PLERROR("In read(istream&, string&) unterminated quoted string");
            c = get();
            if(!isspace(c)) // skip following blank if any
                unget();
        }
        else // it's a single word without quotes
        {
            x.resize(0);
            c= get();
            while(c != EOF && wordseparators().find(c)==string::npos) // as long as we don't meet a wordseparator (or eof)...
            {
                x+= static_cast<char>(c);
                c= get();
            }
            if(!isspace(c))
                unget();
        }
    }
    break;
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( char *  x)

Definition at line 936 of file PStream.cc.

References c, i, inmode, peek(), plearn_ascii, plearn_binary, PLERROR, pretty_ascii, putback(), raw_ascii, raw_binary, skipBlanksAndComments(), unget(), and PLearn::wordseparators().

{
    if(!x)
        PLERROR("In PStream::operator>>(char*) character array must already be allocated to put the read string in");

    switch(inmode)
    {
    case PStream::raw_ascii:
    case PStream::raw_binary:
    case PStream::pretty_ascii:
    {
        skipBlanksAndComments();
        int i=0; // pos within the string
        int c = get();
        while (c!=EOF && wordseparators().find(c)==string::npos) // as long as we don't meet a wordseparator (or eof)...
        {
            x[i++] = static_cast<char>(c);
            c = get();
        }
        x[i++] = 0;
        unget();
    }
    break;
    case PStream::plearn_ascii:
    case PStream::plearn_binary:
    {
        skipBlanksAndComments();
        int c = peek();
        int i=0; // pos within the string
        if(c=='"') // it's a quoted string "..."
        {
            c = get(); // skip the quote
            c = get(); // get the next character
            while(c!='"' && c!=EOF)
            {
                if(c=='\\') // escaped character
                {
                    c = get();
                    switch (c)
                    {
                    case 'n':
                        x[i++] = '\n';
                        break;
                    case 't':
                        x[i++] = '\t';
                        break;
                    case 'r':
                        x[i++] = '\r';
                        break;
                    case '0':
                        x[i++] = '\0';
                        break;
                    case 'a':
                        x[i++] = '\a';
                        break;
                    case 'b':
                        x[i++] = '\b';
                        break;
                    case 'v':
                        x[i++] = '\v';
                        break;
                    case 'f':
                        x[i++] = '\f';
                        break;

                    default:
                        x[i++] = static_cast<char>(c);
                        break;
                    }
                }
                else
                    x[i++]= static_cast<char>(c);

                c = get();
            }
            if(c==EOF)
                PLERROR("In read(istream&, char*) unterminated quoted string");
            if(!isspace(c))
                putback(c);
        }
        else // it's a single word without quotes
        {
            c= get();
            while(c != EOF && wordseparators().find(c)==string::npos) // as long as we don't meet a wordseparator (or eof)...
            {
                x[i++]= static_cast<char>(c);
                c= get();
            }
            if(!isspace(c))
                unget();
        }
        x[i++] = 0;
    }
    break;
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( char &  x)

Definition at line 862 of file PStream.cc.

References inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, skipBlanks(), skipBlanksAndCommentsAndSeparators(), and x.

{
    switch(inmode)
    {
    case raw_binary:
        get(x);
        break;
    case pretty_ascii:
    case raw_ascii:
        skipBlanks();
        get(x);
        break;
    case plearn_ascii:
    case plearn_binary:
        skipBlanksAndCommentsAndSeparators();
        get(x);
        if (x == '\'')  // ascii case (between single quotes)
        {
            get(x);
            get();
        }
        else if (x == 0x01)  // plearn_binary case
            get(x);
        break;
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( unsigned char &  x)

Definition at line 901 of file PStream.cc.

References c, inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, read(), skipBlanks(), and skipBlanksAndCommentsAndSeparators().

{
    switch(inmode)
    {
    case raw_binary:
        read(reinterpret_cast<char *>(&x), sizeof(unsigned char));
        break;
    case raw_ascii:
        skipBlanks();
        read(reinterpret_cast<char *>(&x), sizeof(unsigned char));
        break;
    case pretty_ascii:
    case plearn_ascii:
    case plearn_binary:
    {
        skipBlanksAndCommentsAndSeparators();
        char c = get();
        if (c == '\'')  // ascii
        {
            read(reinterpret_cast<char *>(&x), sizeof(unsigned char));
            get();
        }
        else if (c == 0x02)  // plearn_binary
            read(reinterpret_cast<char *>(&x), sizeof(unsigned char));
        else
            x = (unsigned char)c;
        break;
    }
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( bool x)

Definition at line 1136 of file PStream.cc.

References a, c, inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, skipBlanksAndCommentsAndSeparators(), and u.

{
    int parsed = -1;

    char c;
    switch(inmode)
    {
    case raw_ascii:
    case pretty_ascii:
    case raw_binary:
    case plearn_ascii:
    case plearn_binary:
        skipBlanksAndCommentsAndSeparators();
        c = get();
        if(c=='1')
            parsed = 1;

        else if(c=='0')
            parsed = 0;

        else if(c=='T')
        {
            char r = get();
            char u = get();
            char e = get();
            if ( r == 'r' && u == 'u' && e == 'e' )
                parsed = 1;
        }

        else if(c=='F')
        {
            char a = get();
            char l = get();
            char s = get();
            char e = get();
            if ( a == 'a' && l == 'l' && s == 's' && e == 'e' )
                parsed = 0;
        }

        if ( parsed == -1 )
            PLERROR("In PStream::operator>>(bool &x) wrong format for bool, must be one "
                    "of characters 0 or 1 or unquoted strings True or False" );
        else
            x = (parsed != 0);
        break;

    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream& PLearn::PStream::operator>> ( mode_t  m) [inline]

Definition at line 260 of file PStream.h.

References m.

Referenced by operator>>().

    {
        inmode = m;
        return *this;
    }

Here is the caller graph for this function:

PStream & PLearn::PStream::operator>> ( int x)

Definition at line 1259 of file PStream.cc.

References c, inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, read(), readAsciiNum(), readBinaryNum(), skipBlanks(), skipBlanksAndCommentsAndSeparators(), and unget().

{
    switch(inmode)
    {
    case raw_ascii:
    case pretty_ascii:
        skipBlanks();
        readAsciiNum(x);
        break;
    case raw_binary:
        read(reinterpret_cast<char *>(&x), sizeof(int));
        break;
    case plearn_ascii:
    case plearn_binary:
    {
        skipBlanksAndCommentsAndSeparators();
        int c = get();
        if(c>0x00 && c<0x20)  // plearn_binary
        {
            readBinaryNum(x, c);
        }
        else  // plearn_ascii
        {
            unget();
            readAsciiNum(x);
        }
        break;
    }
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( unsigned int x)

Definition at line 1294 of file PStream.cc.

References c, inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, read(), readAsciiNum(), readBinaryNum(), skipBlanks(), skipBlanksAndCommentsAndSeparators(), and unget().

{
    switch(inmode)
    {
    case raw_ascii:
    case pretty_ascii:
        skipBlanks();
        readAsciiNum(x);
        break;
    case raw_binary:
        read(reinterpret_cast<char *>(&x), sizeof(unsigned int));
        break;
    case plearn_ascii:
    case plearn_binary:
    {
        skipBlanksAndCommentsAndSeparators();
        int c = get();
        if(c>0x00 && c<0x20)  // plearn_binary
        {
            readBinaryNum(x, c);
        }
        else  // plearn_ascii
        {
            unget();
            readAsciiNum(x);
        }
        break;
    }
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( long &  x)

Definition at line 1329 of file PStream.cc.

References c, inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, read(), readAsciiNum(), readBinaryNum(), skipBlanks(), skipBlanksAndCommentsAndSeparators(), and unget().

{
    switch(inmode)
    {
    case raw_ascii:
    case pretty_ascii:
        skipBlanks();
        readAsciiNum(x);
        break;
    case raw_binary:
        read(reinterpret_cast<char *>(&x), sizeof(long));
        break;
    case plearn_ascii:
    case plearn_binary:
    {
        skipBlanksAndCommentsAndSeparators();
        int c = get();
        if(c>0x00 && c<0x20)  // plearn_binary
        {
            readBinaryNum(x, c);
        }
        else  // plearn_ascii
        {
            unget();
            readAsciiNum(x);
        }
        break;
    }
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( long long &  x)

Definition at line 1399 of file PStream.cc.

References c, inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, read(), readAsciiNum(), readBinaryNum(), skipBlanks(), skipBlanksAndCommentsAndSeparators(), and unget().

{
    switch(inmode)
    {
    case raw_ascii:
    case pretty_ascii:
        skipBlanks();
        readAsciiNum(x);
        break;
    case raw_binary:
        read(reinterpret_cast<char *>(&x), sizeof(long long));
        break;
    case plearn_ascii:
    case plearn_binary:
    {
        skipBlanksAndCommentsAndSeparators();
        int c = get();
        if(c>0x00 && c<0x20)  // plearn_binary
        {
            readBinaryNum(x, c);
        }
        else  // plearn_ascii
        {
            unget();
            readAsciiNum(x);
        }
        break;
    }
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( unsigned long long &  x)

Definition at line 1434 of file PStream.cc.

References c, inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, read(), readAsciiNum(), readBinaryNum(), skipBlanks(), skipBlanksAndCommentsAndSeparators(), and unget().

{
    switch(inmode)
    {
    case raw_ascii:
    case pretty_ascii:
        skipBlanks();
        readAsciiNum(x);
        break;
    case raw_binary:
        read(reinterpret_cast<char *>(&x), sizeof(unsigned long long));
        break;
    case plearn_ascii:
    case plearn_binary:
    {
        skipBlanksAndCommentsAndSeparators();
        int c = get();
        if(c>0x00 && c<0x20)  // plearn_binary
        {
            readBinaryNum(x, c);
        }
        else  // plearn_ascii
        {
            unget();
            readAsciiNum(x);
        }
        break;
    }
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream& PLearn::PStream::operator>> ( pl_pstream_manip  func) [inline]

Definition at line 683 of file PStream.h.

    { return (*func)(*this); }
PStream & PLearn::PStream::operator>> ( unsigned long &  x)

Definition at line 1364 of file PStream.cc.

References c, inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, read(), readAsciiNum(), readBinaryNum(), skipBlanks(), skipBlanksAndCommentsAndSeparators(), and unget().

{
    switch(inmode)
    {
    case raw_ascii:
    case pretty_ascii:
        skipBlanks();
        readAsciiNum(x);
        break;
    case raw_binary:
        read(reinterpret_cast<char *>(&x), sizeof(unsigned long));
        break;
    case plearn_ascii:
    case plearn_binary:
    {
        skipBlanksAndCommentsAndSeparators();
        int c = get();
        if(c>0x00 && c<0x20)  // plearn_binary
        {
            readBinaryNum(x, c);
        }
        else  // plearn_ascii
        {
            unget();
            readAsciiNum(x);
        }
        break;
    }
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( short &  x)

Definition at line 1189 of file PStream.cc.

References c, inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, read(), readAsciiNum(), readBinaryNum(), skipBlanks(), skipBlanksAndCommentsAndSeparators(), and unget().

{
    switch(inmode)
    {
    case raw_ascii:
    case pretty_ascii:
        skipBlanks();
        readAsciiNum(x);
        break;
    case raw_binary:
        read(reinterpret_cast<char *>(&x), sizeof(short));
        break;
    case plearn_ascii:
    case plearn_binary:
    {
        skipBlanksAndCommentsAndSeparators();
        int c = get();
        if(c>0x00 && c<0x20)  // plearn_binary
        {
            readBinaryNum(x, c);
        }
        else  // plearn_ascii
        {
            unget();
            readAsciiNum(x);
        }
        break;
    }
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( unsigned short &  x)

Definition at line 1224 of file PStream.cc.

References c, inmode, plearn_ascii, plearn_binary, PLERROR, pretty_ascii, raw_ascii, raw_binary, read(), readAsciiNum(), readBinaryNum(), skipBlanks(), skipBlanksAndCommentsAndSeparators(), and unget().

{
    switch(inmode)
    {
    case raw_ascii:
    case pretty_ascii:
        skipBlanks();
        readAsciiNum(x);
        break;
    case raw_binary:
        read(reinterpret_cast<char *>(&x), sizeof(unsigned short));
        break;
    case plearn_ascii:
    case plearn_binary:
    {
        skipBlanksAndCommentsAndSeparators();
        int c = get();
        if(c>0x00 && c<0x20)  // plearn_binary
        {
            readBinaryNum(x, c);
        }
        else  // plearn_ascii
        {
            unget();
            readAsciiNum(x);
        }
        break;
    }
    default:
        PLERROR("In PStream::operator>>  unknown inmode!!!!!!!!!");
        break;
    }
    return *this;
}

Here is the call graph for this function:

PStream & PLearn::PStream::operator>> ( signed char &  x)

Definition at line 893 of file PStream.cc.

References c, and operator>>().

{
    char c;
    operator>>(c);
    x = (signed char)c;
    return *this;
}

Here is the call graph for this function:

PStream::mode_t PLearn::PStream::parseModeT ( const string &  str) [static]

Parse a string and return the equivalent PStream::mode_t.

Definition at line 280 of file PStream.cc.

References PLDEPRECATED, plearn_ascii, plearn_binary, and PLERROR.

Referenced by PLearn::HyperLearner::build_().

                                                       {
    PStream::mode_t mode;
    if(str_mode.empty()) {
        PLDEPRECATED("The use of an empty string as PStream mode to default to"
                " 'plearn_ascii' is deprecated, please use 'plearn_ascii' "
                "directly");
        mode = PStream::plearn_ascii;
    } else if(str_mode=="plearn_ascii")
        mode = PStream::plearn_ascii;
    else if(str_mode=="plearn_binary")
        mode = PStream::plearn_binary;
    else
        PLERROR("In PStream::parseModeT(%s): invalid mode",
                str_mode.c_str());
    return mode;
}

Here is the caller graph for this function:

int PLearn::PStream::peek ( ) [inline]
PStream& PLearn::PStream::put ( unsigned char  c) [inline]

Definition at line 593 of file PStream.h.

References PLearn::write().

    {
        write(reinterpret_cast<char *>(&c), sizeof(c));
        return *this;
    }

Here is the call graph for this function:

PStream& PLearn::PStream::put ( int  x) [inline]

Definition at line 598 of file PStream.h.

References put().

Referenced by put().

{ return put((char)x); }

Here is the call graph for this function:

Here is the caller graph for this function:

PStream& PLearn::PStream::put ( char  c) [inline]
PStream& PLearn::PStream::putback ( char  c) [inline]

If you put back the result of a call to get(), make sure it is not EOF.

Definition at line 506 of file PStream.h.

References putback().

Referenced by PLearn::Object::newread(), operator>>(), putback(), readUntil(), skipAll(), skipBlanks(), skipBlanksAndComments(), skipBlanksAndCommentsAndSeparators(), and PLearn::test_read().

    {
        ptr->putback(c);
        return *this;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

PStream& PLearn::PStream::read ( string &  s,
streamsize  n 
) [inline]

Definition at line 540 of file PStream.h.

References n.

    {
        char* buf = new char[n];
        string::size_type nread = ptr->read(buf, n);
        s.assign(buf, nread);
        delete[] buf;
        return *this;
    }
PStream& PLearn::PStream::read ( char *  s,
streamsize  n 
) [inline]
string PLearn::PStream::readAll ( )

Reads until an EOF is found, and returns the whole content as a string.

Definition at line 300 of file PStream.cc.

References PLearn::PP< PStreamBuf >::ptr, and PLearn::PStreamBuf::read().

Referenced by PLearn::HelpSystem::helpEpilogueHTML(), PLearn::HelpSystem::helpIndexHTML(), and PLearn::HelpSystem::helpPrologueHTML().

{
    const int bufsz= 4096;
    char buf[bufsz];
    string s= "";
    int nread= ptr->read(buf, bufsz);
    while(nread > 0)
    {
        s.append(buf, nread);
        nread= ptr->read(buf, bufsz);
    }
    return s;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::PStream::readAsciiNum ( unsigned short &  x)

Definition at line 668 of file PStream.cc.

References readAsciiNum().

{
    unsigned long dx;
    readAsciiNum(dx);
    x = (unsigned short)(dx);
}

Here is the call graph for this function:

void PLearn::PStream::readAsciiNum ( int x)

Definition at line 675 of file PStream.cc.

References readAsciiNum().

{
    long dx;
    readAsciiNum(dx);
    x = int(dx);
}

Here is the call graph for this function:

void PLearn::PStream::readAsciiNum ( unsigned int x)

Definition at line 682 of file PStream.cc.

References readAsciiNum().

{
    unsigned long dx;
    readAsciiNum(dx);
    x = (unsigned int)(dx);
}

Here is the call graph for this function:

void PLearn::PStream::readAsciiNum ( long &  x)

Definition at line 689 of file PStream.cc.

References c, PLERROR, skipBlanks(), unget(), and x.

{
    skipBlanks();
    x = 0;
    char c = get();
    bool negate = false;
    if (c == '-')
    {
        negate = true;
        c = get();
    }
    else if (c == '+')
        c = get();

    if(!isdigit(c))
        PLERROR("In readAsciiNum: not a valid ascii number, expected a digit, but read %c (ascii code %d)",c,c);

    do
    {
        x = x*10 + c-'0';
        c = get();
    } while(isdigit(c));

    unget();
    if(negate)
        x = -x;
}

Here is the call graph for this function:

void PLearn::PStream::readAsciiNum ( unsigned long &  x)

Definition at line 717 of file PStream.cc.

References c, skipBlanks(), and unget().

{
    skipBlanks();
    x = 0;
    char c = get();
    while(isdigit(c))
    {
        x = x*10 + c-'0';
        c = get();
    }
    unget();
}

Here is the call graph for this function:

void PLearn::PStream::readAsciiNum ( unsigned long long &  x)

Definition at line 759 of file PStream.cc.

References c, skipBlanks(), and unget().

{
    skipBlanks();
    x = 0;
    char c = get();
    while(isdigit(c))
    {
        x *= 10;
        x += c-'0';
        c = get();
    }
    unget();
}

Here is the call graph for this function:

void PLearn::PStream::readAsciiNum ( float &  x)

Definition at line 773 of file PStream.cc.

References readAsciiNum().

{
    double dx;
    readAsciiNum(dx);
    x = float(dx);
}

Here is the call graph for this function:

void PLearn::PStream::readAsciiNum ( double &  x)

Definition at line 780 of file PStream.cc.

References c, MISSING_VALUE, PLERROR, PSTREAM_BUF_SIZE, skipBlanks(), unget(), and x.

{
    static const char* error_msg = "Bug while reading file and expecting a double";
    char tmpbuf[PSTREAM_BUF_SIZE];
    skipBlanks();
    int l=0;
    bool opposite = false;

    char c = get();
    if (c == '-') {
        tmpbuf[l++] = c;
        opposite = true;
        c = get();
    }
    else if (c == '+') // skip + sign
        c = get();

    bool E_seen= false;
    bool sign_seen= false;
    bool dot_seen= false;

    switch(c)
    {
    case '?':
        x = MISSING_VALUE;
        break;
    case 'n':
    case 'N':
        if(toupper(get())=='A' && toupper(get())=='N')
            x = MISSING_VALUE;
        else
            PLERROR(error_msg);
        break;
    case 'i':
    case 'I':
        if (toupper(get())=='N' && toupper(get())=='F')
        {
            x = numeric_limits<double>::infinity();
            if(opposite)
                x = -x;
        }
        else
            PLERROR(error_msg);
        break ;
    default:
        while(isdigit(c)
              || ((c=='e' || c=='E') && !E_seen) //only one E
              || ((c=='-' || c=='+') && E_seen && !sign_seen)//one sign, after E
              || (c=='.' && !E_seen && !dot_seen))//one dot, before E
        {
            if(c=='e' || c=='E') E_seen= true;
            if(c=='+' || c=='-') sign_seen= true;
            if(c=='.') dot_seen= true;
            tmpbuf[l++] = c;
            c = get();
        }
        tmpbuf[l] = '\0';
        unget();
        sscanf(tmpbuf,"%lf",&x);
        if(l==0)
            PLERROR("In PStream::readAsciiNum - we read (%c) while we "
                    "expected a digit", c);
        break;
    }
}

Here is the call graph for this function:

void PLearn::PStream::readAsciiNum ( long long &  x)

Definition at line 730 of file PStream.cc.

References c, PLERROR, skipBlanks(), unget(), and x.

{
    skipBlanks();
    x = 0;
    char c = get();
    bool negate = false;
    if (c == '-')
    {
        negate = true;
        c = get();
    }
    else if (c == '+')
        c = get();

    if(!isdigit(c))
        PLERROR("In readAsciiNum: not a valid ascii number, expected a digit, but read %c (ascii code %d)",c,c);

    do
    {
        x *= 10;
        x += c-'0';
        c = get();
    } while(isdigit(c));

    unget();
    if(negate)
        x = -x;
}

Here is the call graph for this function:

void PLearn::PStream::readAsciiNum ( unsigned char &  x)

Definition at line 647 of file PStream.cc.

References readAsciiNum().

{
    long dx;
    readAsciiNum(dx);
    x = (unsigned char)(dx);
}

Here is the call graph for this function:

void PLearn::PStream::readAsciiNum ( char &  x)

Definition at line 640 of file PStream.cc.

Referenced by PLearn::operator>>(), operator>>(), and readAsciiNum().

{
    long dx;
    readAsciiNum(dx);
    x = char(dx);
}

Here is the caller graph for this function:

void PLearn::PStream::readAsciiNum ( signed char &  x)

Definition at line 654 of file PStream.cc.

References readAsciiNum().

{
    long dx;
    readAsciiNum(dx);
    x = (signed char)(dx);
}

Here is the call graph for this function:

void PLearn::PStream::readAsciiNum ( short &  x)

Definition at line 661 of file PStream.cc.

References readAsciiNum().

{
    long dx;
    readAsciiNum(dx);
    x = short(dx);
}

Here is the call graph for this function:

template<class I >
void PLearn::PStream::readBinaryNum ( I &  x,
unsigned char  typecode 
) [inline]

Reads base types from PLearn binary format.

Definition at line 370 of file PStream.h.

References BIG_ENDIAN_ORDER, PLearn::byte_order(), PLearn::endianswap(), LITTLE_ENDIAN_ORDER, PLERROR, PLearn::read(), and x.

Referenced by operator>>().

    {
        // If typecode corresponds to I's typecode
        if (typecode==TypeTraits<I>::little_endian_typecode())
        {
            read(reinterpret_cast<char*>(&x), sizeof(I));
#ifdef BIGENDIAN
            endianswap(&x);
#endif
        }
        else if (typecode==TypeTraits<I>::big_endian_typecode())
        {
            read(reinterpret_cast<char*>(&x), sizeof(I));
#ifdef LITTLEENDIAN
            endianswap(&x);
#endif
        }
        // Else, we need to try all the different types
        else if (typecode==TypeTraits<int8_t>::little_endian_typecode())
            readBinaryNumAs<int8_t>(x, false);
        else if (typecode==TypeTraits<uint8_t>::little_endian_typecode())
            readBinaryNumAs<uint8_t>(x, false);
        else if (typecode==TypeTraits<int16_t>::little_endian_typecode())
            readBinaryNumAs<int16_t>(x, byte_order()==BIG_ENDIAN_ORDER);
        else if (typecode==TypeTraits<int16_t>::big_endian_typecode())
            readBinaryNumAs<int16_t>(x, byte_order()==LITTLE_ENDIAN_ORDER);
        else if (typecode==TypeTraits<uint16_t>::little_endian_typecode())
            readBinaryNumAs<uint16_t>(x, byte_order()==BIG_ENDIAN_ORDER);
        else if (typecode==TypeTraits<uint16_t>::big_endian_typecode())
            readBinaryNumAs<uint16_t>(x, byte_order()==LITTLE_ENDIAN_ORDER);
        else if (typecode==TypeTraits<int32_t>::little_endian_typecode())
            readBinaryNumAs<int32_t>(x, byte_order()==BIG_ENDIAN_ORDER);
        else if (typecode==TypeTraits<int32_t>::big_endian_typecode())
            readBinaryNumAs<int32_t>(x, byte_order()==LITTLE_ENDIAN_ORDER);
        else if (typecode==TypeTraits<uint32_t>::little_endian_typecode())
            readBinaryNumAs<uint32_t>(x, byte_order()==BIG_ENDIAN_ORDER);
        else if (typecode==TypeTraits<uint32_t>::big_endian_typecode())
            readBinaryNumAs<uint32_t>(x, byte_order()==LITTLE_ENDIAN_ORDER);
        else if (typecode==TypeTraits<int64_t>::little_endian_typecode())
            readBinaryNumAs<int64_t>(x, byte_order()==BIG_ENDIAN_ORDER);
        else if (typecode==TypeTraits<int64_t>::big_endian_typecode())
            readBinaryNumAs<int64_t>(x, byte_order()==LITTLE_ENDIAN_ORDER);
        else if (typecode==TypeTraits<uint64_t>::little_endian_typecode())
            readBinaryNumAs<uint64_t>(x, byte_order()==BIG_ENDIAN_ORDER);
        else if (typecode==TypeTraits<uint64_t>::big_endian_typecode())
            readBinaryNumAs<uint64_t>(x, byte_order()==LITTLE_ENDIAN_ORDER);
        else if (typecode==TypeTraits<float>::little_endian_typecode())
            readBinaryNumAs<float>(x, byte_order()==BIG_ENDIAN_ORDER);
        else if (typecode==TypeTraits<float>::big_endian_typecode())
            readBinaryNumAs<float>(x, byte_order()==LITTLE_ENDIAN_ORDER);
        else if (typecode==TypeTraits<double>::little_endian_typecode())
            readBinaryNumAs<double>(x, byte_order()==BIG_ENDIAN_ORDER);
        else if (typecode==TypeTraits<double>::big_endian_typecode())
            readBinaryNumAs<double>(x, byte_order()==LITTLE_ENDIAN_ORDER);
        else
            PLERROR("In PStream readBinaryNum: Unknown typecode '%c' (%x)",
                    typecode, typecode);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

template<class I , class J >
void PLearn::PStream::readBinaryNumAs ( J &  x,
bool  inverted_byte_order 
) [inline]

Reads a J element, optionnally swaps its endianness, and returns an I.

Definition at line 336 of file PStream.h.

References PLearn::endianswap(), PLearn::endl(), PLERROR, and PLearn::read().

    {
        I y;
        read(reinterpret_cast<char*>(&y), sizeof(I));
        if (inverted_byte_order)
            endianswap(&y);
#ifdef __INTEL_COMPILER
#pragma warning(disable:1682)
// Yes, I know that "implicit conversion of a 64-bit integral type to a smaller
// integral type (potential portability problem)", but the conversion is
// explicit here.
#endif
        x = static_cast<J>(y);

        // Check if there was a conversion problem (sign or overflow)

        if (static_cast<I>(x) != y
            || (!(numeric_limits<J>::is_signed) 
                && chkUnsigned<numeric_limits<I>::is_signed>::notOk(y)))
        {
            std::stringstream error;
            error << "In PStream::readBinaryNumAs, overflow error: " << std::endl
                << "unable to read value \"" << y << "\""
                << "into a " << TypeTraits<I>::name() << std::endl;

            PLERROR( error.str().c_str() );
        }
#ifdef __INTEL_COMPILER
#pragma warning(default:1682)
#endif
    }

Here is the call graph for this function:

void PLearn::PStream::readExpected ( char  expect)

Reads the next character and launches a PLERROR if it is different from expect.

Definition at line 318 of file PStream.cc.

References c, and PLERROR.

Referenced by PLearn::operator>>(), and readExpected().

{
    int c = get();
    if(c!=expect)
        PLERROR("In readExpected : expected %c, but read %c",expect,c);
}

Here is the caller graph for this function:

void PLearn::PStream::readExpected ( const string &  expect)

Reads character one by one, comparing it with the sequence in expect.

Throws a PLERROR as soon as the character read differs from the character expected.

Definition at line 331 of file PStream.cc.

References i, and readExpected().

{
    int l = int(expect.size());
    for(int i=0; i<l; i++)
        readExpected(expect[i]);
}

Here is the call graph for this function:

void PLearn::PStream::readExpected ( char *  expect)

Reads character one by one, comparing it with the sequence in expect (until terminating null character in expect).

Throws a PLERROR as soon as the character read differs from the character expected.

Definition at line 325 of file PStream.cc.

References c, and readExpected().

{
    for(char c = *expect; c!=0; c=*expect++)
        readExpected(c);
}

Here is the call graph for this function:

streamsize PLearn::PStream::readUntil ( char *  buf,
streamsize  n,
const char *  stop_chars 
)

Reads characters into buf until n characters have been read, or end-of-file has been reached, or the next character in the stream is one of the stop_chars (null terminated string).

Returns the total number of characters put into buf. The stopping character met is not extracted from the stream.

Definition at line 360 of file PStream.cc.

References c, and putback().

{
    streamsize nread = 0;

    while(nread<n)
    {
        int c = get();
        if(c==EOF)
            break;
        if(strchr(stop_chars, c))
        {
            putback(c);
            break;
        }
        *buf++ = (char)c;
        ++nread;
    }

    return nread;
}

Here is the call graph for this function:

streamsize PLearn::PStream::readUntil ( char *  buf,
streamsize  n,
char  stop_char 
)

Reads characters into buf until n characters have been read, or end-of-file has been reached, or the next character in the stream is the stop_char.

Returns the total number of characters put into buf. The stopping character met is not extracted from the stream.

Definition at line 339 of file PStream.cc.

References c, and putback().

Referenced by PLearn::TextFilesVMatrix::readAndCheckOptionName().

{
    streamsize nread = 0;

    while(nread<n)
    {
        int c = get();
        if(c==EOF)
            break;
        if((char)c == stop_char)
        {
            putback(c);
            break;
        }
        *buf++ = (char)c;
        ++nread;
    }

    return nread;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::PStream::setBufferCapacities ( streamsize  inbuf_capacity,
streamsize  outbuf_capacity,
streamsize  unget_capacity 
) [inline]

Definition at line 216 of file PStream.h.

Referenced by PLearn::get_perr(), PLearn::test_negchar(), PLearn::test_read(), PLearn::test_write(), and PLearn::test_write_unbuffered().

    {
        ptr->setBufferCapacities(inbuf_capacity,
                                 outbuf_capacity,
                                 unget_capacity);
    }

Here is the caller graph for this function:

void PLearn::PStream::setDoubleFormat ( const char *  f) [inline]

Definition at line 468 of file PStream.h.

Referenced by PLearn::vmatmain().

{ format_double = f; }

Here is the caller graph for this function:

void PLearn::PStream::setFloatFormat ( const char *  f) [inline]

Definition at line 467 of file PStream.h.

Referenced by PLearn::vmatmain().

{ format_float = f;  }

Here is the caller graph for this function:

mode_t PLearn::PStream::setInMode ( mode_t  m) [inline]

Definition at line 225 of file PStream.h.

References m.

    {
        mode_t oldmode = inmode;
        inmode = m;
        return oldmode;
    }
void PLearn::PStream::setMode ( mode_t  m) [inline]
mode_t PLearn::PStream::setOutMode ( mode_t  m) [inline]

Definition at line 232 of file PStream.h.

References m.

Referenced by PLearn::_tostring_static_pstream_(), PLearn::PL_LogPluginInterceptor::getStream(), and PLearn::PL_LogPluginPStream::getStream().

    {
        mode_t oldmode = outmode;
        outmode = m;
        return oldmode;
    }

Here is the caller graph for this function:

void PLearn::PStream::skipAll ( const char *  chars_to_skip)

skips all occurences of any of the given characters

Definition at line 429 of file PStream.cc.

References c, and putback().

{
    int c = get();
    while(c!=EOF && strchr(chars_to_skip, c))
        c = get();
    if(c!=EOF)
        putback(c);
}

Here is the call graph for this function:

void PLearn::PStream::skipBlanks ( )

skips any blanks (space, tab, newline)

Definition at line 446 of file PStream.cc.

References c, and putback().

Referenced by PLearn::LIBSVMSparseVMatrix::build_(), PLearn::DictionaryVMatrix::build_(), PLearn::VMatrix::getSavedSizes(), PLearn::VMatrix::loadStringMapping(), operator>>(), readAsciiNum(), PLearn::readSequence(), and PLearn::ws().

{
    int c = get();
    while(c!=EOF && (c==' ' || c=='\t' || c=='\n' || c=='\r'))
        c = get();
    if(c!=EOF)
        putback(c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::PStream::skipBlanksAndComments ( )

skips any blanks (space, tab, newline) and comments starting with #

Definition at line 455 of file PStream.cc.

References c, putback(), and skipRestOfLine().

Referenced by PLearn::PLearnService::connectToServers(), PLearn::RemotePLearnServer::expectResults(), PLearn::Object::newread(), operator>>(), PLearn::operator>>(), PLearn::TVec< PP< RegressionTreeNode > >::read(), PLearn::TMat< pair< real, real > >::read(), PLearn::TextFilesVMatrix::readAndCheckOptionName(), PLearn::readSequence(), and PLearn::ws().

{
    int c = get();
    while(c!=EOF)
    {
        if(c=='#')
            skipRestOfLine();
        else if(c!=' ' && c!='\t' && c!='\n' && c!='\r')
            break;
        c = get();
    }
    if(c!=EOF)
        putback(c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::PStream::skipBlanksAndCommentsAndSeparators ( )

skips any blanks, # comments, and separators (',' and ';')

Definition at line 470 of file PStream.cc.

References c, putback(), and skipRestOfLine().

Referenced by PLearn::Plide::executePyPLearn(), PLearn::TVec< T >::input(), PLearn::Object::newread(), operator>>(), PLearn::operator>>(), PLearn::TVec< PP< RegressionTreeNode > >::read(), PLearn::TMat< pair< real, real > >::read(), PLearn::SmoothedProbSparseMatrix::read(), PLearn::DoubleAccessSparseMatrix< T >::read(), PLearn::readMap(), PLearn::readObject(), PLearn::readPriorityQueue(), PLearn::readSequence(), PLearn::readSet(), PLearn::RunCommand::run(), and PLearn::PyPLearnScript::run().

{
    int c = get();
    while(c!=EOF)
    {
        if(c=='#')
            skipRestOfLine();
        else if(c!=' ' && c!='\t' && c!='\n' && c!='\r' && c!=';' && c!=',')
            break;
        c = get();
    }
    if(c!=EOF)
        putback(c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::PStream::skipRestOfLine ( )

reads everything until '
' (also consumes the '
')

Definition at line 439 of file PStream.cc.

References c.

Referenced by skipBlanksAndComments(), skipBlanksAndCommentsAndSeparators(), and smartReadUntilNext().

{
    int c = get();
    while(c!='\n' && c!=EOF)
        c=get();
}

Here is the caller graph for this function:

int PLearn::PStream::smartReadUntilNext ( const string &  stoppingsymbols,
string &  characters_read,
bool  ignore_brackets = false,
bool  skip_comments = true 
)

Reads characters from stream, until we meet one of the stopping symbols at the current "level".

i.e. any opening parenthesis, bracket, brace or quote will open a next level and we'll be back to the current level only *after* we meet the corresponding closing parenthesis, bracket, brace or quote. All characters read, except the stoppingsymbol, will be *appended* to characters_read. The stoppingsymbol is read and returned, but not appended to characters_read. Comments starting with # until the end of line may be skipped (as if they were not part of the stream)

Definition at line 381 of file PStream.cc.

References c, and skipRestOfLine().

Referenced by PLearn::VecStatsCollector::getStat(), PLearn::StatsCollector::getStat(), PLearn::LiftStatsCollector::getStat(), PLearn::VMatLanguage::preprocess(), and PLearn::readAndMacroProcess().

{
    int c;
    while( (c=get()) != EOF)
    {
        if(stoppingsymbols.find(c)!=string::npos)
            break;
        else if(skip_comments && c=='#')  // skip until end of line
            skipRestOfLine();
        else
        {
            if(characters_read.length() == characters_read.capacity())
                characters_read.reserve(characters_read.length()*2); //don't realloc&copy every time a char is appended...
            characters_read+= static_cast<char>(c);

            switch(c)
            {
            case '(':
                smartReadUntilNext(")", characters_read, ignore_brackets, skip_comments);
                characters_read+= ')';
                break;
            case '[':
                if(!ignore_brackets)
                {
                    smartReadUntilNext("]", characters_read, ignore_brackets, skip_comments);
                    characters_read+= ']';
                }
                break;
            case '{':
                smartReadUntilNext("}", characters_read, ignore_brackets, skip_comments);
                characters_read+= '}';
                break;
            case '"':
                smartReadUntilNext("\"", characters_read, ignore_brackets, false);
                characters_read+= '"';          
                break; 
            case '\\':   // we consider backslash an escape character, 
                c=get(); // thus the next character is read and appended without being interpreted
                if(c!=EOF)
                    characters_read += static_cast<char>(c);
                break;
            }
        }
    }
    return c;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PStream::mode_t PLearn::PStream::switchToPLearnOutMode ( )

if outmode is raw_ascii or raw_binary, it will be switched to corresponding plearn_ascii, resp.

plearn_binary. The old mode will be returned, so that you can call setOutMode to revert to the old mode when finished

Definition at line 259 of file PStream.cc.

References outmode, plearn_ascii, plearn_binary, pretty_ascii, raw_ascii, and raw_binary.

Referenced by PLearn::operator<<().

{
    mode_t oldmode = outmode;
    switch(outmode)
    {
    case PStream::raw_ascii:
    case PStream::pretty_ascii:
        outmode = PStream::plearn_ascii;
        break;
    case PStream::raw_binary:
        outmode = PStream::plearn_binary;
        break;
    default:
        break;
    }
    return oldmode;
}

Here is the caller graph for this function:

PStream& PLearn::PStream::unget ( ) [inline]

Put back the last character read by the get() or read() methods.

You can only call this method once (use the unread() method if you want to put back more than one character).

Definition at line 515 of file PStream.h.

References unget().

Referenced by operator>>(), PLearn::peekAfterSkipBlanks(), PLearn::RealMapping::read(), readAsciiNum(), PLearn::readWhileMatches(), PLearn::skipBlanksAndComments(), and unget().

    {
        ptr->unget();
        return *this;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

PStream& PLearn::PStream::unread ( const char *  p,
streamsize  n 
) [inline]

Definition at line 521 of file PStream.h.

References unread().

Referenced by PLearn::readObject(), PLearn::test_read(), and unread().

    {
        ptr->unread(p,n);
        return *this;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

PStream& PLearn::PStream::unread ( const char *  p) [inline]

Definition at line 527 of file PStream.h.

References PLearn::strlen(), and unread().

Referenced by unread().

    { return unread(p, streamsize(strlen(p))); }

Here is the call graph for this function:

Here is the caller graph for this function:

PStream& PLearn::PStream::unread ( const string &  s) [inline]

Definition at line 530 of file PStream.h.

References unread().

Referenced by unread().

    { return unread(s.data(), streamsize(s.length())); }

Here is the call graph for this function:

Here is the caller graph for this function:

PStream& PLearn::PStream::write ( const char *  s,
streamsize  n 
) [inline]
PStream& PLearn::PStream::write ( const string &  s) [inline]

Definition at line 623 of file PStream.h.

References PLearn::write().

    {
        write(s.data(), streamsize(s.length()));
        return *this;
    }

Here is the call graph for this function:

PStream& PLearn::PStream::write ( const char *  s) [inline]

Definition at line 617 of file PStream.h.

References PLearn::strlen(), and PLearn::write().

    {
        write(s, streamsize(strlen(s)));
        return *this;
    }

Here is the call graph for this function:

void PLearn::PStream::writeAsciiHexNum ( unsigned char  x)

Writes the corresponding 2 hex digits (ex: 0A )

Definition at line 499 of file PStream.cc.

References d, and put().

Referenced by PLearn::GhostScript::writeBitmapHexString1Bit(), PLearn::GhostScript::writeBitmapHexString24Bits(), and PLearn::GhostScript::writeBitmapHexString8Bits().

{
    int d = x>>4;
    put(d<0x0A ?(d+'0') :(d-0x0A+'A'));
    d = x & 0x0F;
    put(d<0x0A ?(d+'0') :(d-0x0A+'A'));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::PStream::writeAsciiNum ( short  x)

Definition at line 529 of file PStream.cc.

References PSTREAM_BUF_SIZE, PLearn::strlen(), and write().

{
    char tmpbuf[PSTREAM_BUF_SIZE];
    snprintf(tmpbuf, sizeof(tmpbuf), "%hd", x);
    write(tmpbuf, streamsize(strlen(tmpbuf)));
}

Here is the call graph for this function:

void PLearn::PStream::writeAsciiNum ( long long  x)

Definition at line 571 of file PStream.cc.

References put(), writeAsciiNum(), and zero.

{
    long long zero(0);
    if(x>=zero)
        writeAsciiNum((unsigned long long)x);
    else
    {
        put('-');
        writeAsciiNum((unsigned long long) -x);
    }
}

Here is the call graph for this function:

void PLearn::PStream::writeAsciiNum ( long  x)

Definition at line 557 of file PStream.cc.

References PSTREAM_BUF_SIZE, PLearn::strlen(), and write().

{
    char tmpbuf[PSTREAM_BUF_SIZE];
    snprintf(tmpbuf, sizeof(tmpbuf), "%ld", x);
    write(tmpbuf, streamsize(strlen(tmpbuf)));
}

Here is the call graph for this function:

void PLearn::PStream::writeAsciiNum ( float  x)

Definition at line 604 of file PStream.cc.

References format_float, PLearn::is_missing(), PSTREAM_BUF_SIZE, PLearn::strlen(), and write().

{
    if(is_missing(x))
        write("nan");
    else if (isinf(x)) {
        if (x < 0)
            write("-inf");
        else
            write("inf");
    }
    else
    {
        char tmpbuf[PSTREAM_BUF_SIZE];
        snprintf(tmpbuf, sizeof(tmpbuf), format_float, x);
        write(tmpbuf, streamsize(strlen(tmpbuf)));
    }
}

Here is the call graph for this function:

void PLearn::PStream::writeAsciiNum ( signed char  x)

Definition at line 522 of file PStream.cc.

References PSTREAM_BUF_SIZE, PLearn::strlen(), and write().

{
    char tmpbuf[PSTREAM_BUF_SIZE];
    snprintf(tmpbuf, sizeof(tmpbuf), "%d", (int)x);
    write(tmpbuf, streamsize(strlen(tmpbuf)));
}

Here is the call graph for this function:

void PLearn::PStream::writeAsciiNum ( unsigned short  x)

Definition at line 536 of file PStream.cc.

References PSTREAM_BUF_SIZE, PLearn::strlen(), and write().

{
    char tmpbuf[PSTREAM_BUF_SIZE];
    snprintf(tmpbuf, sizeof(tmpbuf), "%hu", x);
    write(tmpbuf, streamsize(strlen(tmpbuf)));
}

Here is the call graph for this function:

void PLearn::PStream::writeAsciiNum ( unsigned long  x)

Definition at line 564 of file PStream.cc.

References PSTREAM_BUF_SIZE, PLearn::strlen(), and write().

{
    char tmpbuf[PSTREAM_BUF_SIZE];
    snprintf(tmpbuf, sizeof(tmpbuf), "%lu", x);
    write(tmpbuf, streamsize(strlen(tmpbuf)));
}

Here is the call graph for this function:

void PLearn::PStream::writeAsciiNum ( char  x)

Definition at line 508 of file PStream.cc.

References PSTREAM_BUF_SIZE, PLearn::strlen(), and write().

Referenced by operator<<(), and writeAsciiNum().

{
    char tmpbuf[PSTREAM_BUF_SIZE];
    snprintf(tmpbuf, sizeof(tmpbuf), "%d", (int)x);
    write(tmpbuf, streamsize(strlen(tmpbuf)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PLearn::PStream::writeAsciiNum ( unsigned char  x)

Definition at line 515 of file PStream.cc.

References PSTREAM_BUF_SIZE, PLearn::strlen(), and write().

{
    char tmpbuf[PSTREAM_BUF_SIZE];
    snprintf(tmpbuf, sizeof(tmpbuf), "%d", (int)x);
    write(tmpbuf, streamsize(strlen(tmpbuf)));
}

Here is the call graph for this function:

void PLearn::PStream::writeAsciiNum ( int  x)

Definition at line 543 of file PStream.cc.

References PSTREAM_BUF_SIZE, PLearn::strlen(), and write().

{
    char tmpbuf[PSTREAM_BUF_SIZE];
    snprintf(tmpbuf, sizeof(tmpbuf), "%d", x);
    write(tmpbuf, streamsize(strlen(tmpbuf)));
}

Here is the call graph for this function:

void PLearn::PStream::writeAsciiNum ( unsigned long long  x)

Definition at line 583 of file PStream.cc.

References n, put(), write(), and zero.

{
    unsigned long long zero(0);
    if(x==zero)
        put('0');
    else
    {
        char buf[30];
        char* p = buf+29;
        int n = 0;
        while(x>zero)
        {
            *p-- = '0'+char(x%10);
            x /= 10;
            ++n;
        }
        ++p;
        write(p,n);
    }
}

Here is the call graph for this function:

void PLearn::PStream::writeAsciiNum ( unsigned int  x)

Definition at line 550 of file PStream.cc.

References PSTREAM_BUF_SIZE, PLearn::strlen(), and write().

{
    char tmpbuf[PSTREAM_BUF_SIZE];
    snprintf(tmpbuf, sizeof(tmpbuf), "%u", x);
    write(tmpbuf, streamsize(strlen(tmpbuf)));
}

Here is the call graph for this function:

void PLearn::PStream::writeAsciiNum ( double  x)

Definition at line 622 of file PStream.cc.

References format_double, PLearn::is_missing(), PSTREAM_BUF_SIZE, PLearn::strlen(), and write().

{
    if(is_missing(x))
        write("nan");
    else if (isinf(x)) {
        if (x < 0)
            write("-inf");
        else
            write("inf");
    }
    else
    {
        char tmpbuf[PSTREAM_BUF_SIZE];
        snprintf(tmpbuf, sizeof(tmpbuf), format_double, x);
        write(tmpbuf, streamsize(strlen(tmpbuf)));
    }
}

Here is the call graph for this function:

template<class I >
void PLearn::PStream::writeBinaryNum ( x) [inline]

Writes base types to PLearn binary format TODO: forbid this mechanism for arbitrary classes?

Definition at line 324 of file PStream.h.

References PLearn::write().

Referenced by operator<<().

    {
#ifdef BIGENDIAN
        put(TypeTraits<I>::big_endian_typecode());
#else
        put(TypeTraits<I>::little_endian_typecode());
#endif
        write((char*)&x, sizeof(I));
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Determines the way data is compressed, if any.

Definition at line 183 of file PStream.h.

Referenced by operator=().

map<unsigned int, void *> PLearn::PStream::copies_map_in

format flags for input

copies map for input

Definition at line 152 of file PStream.h.

Referenced by PLearn::operator>>(), PLearn::readObject(), and PLearn::PLearnServer::run().

map<void *, unsigned int> PLearn::PStream::copies_map_out
const char* PLearn::PStream::format_double [private]

Current format string for doubles.

Definition at line 168 of file PStream.h.

Referenced by writeAsciiNum().

const char * PLearn::PStream::format_double_default = "%.15g" [static, private]

Default format string for doubles.

Definition at line 174 of file PStream.h.

const char* PLearn::PStream::format_float [private]

Current format string for floats.

Definition at line 165 of file PStream.h.

Referenced by writeAsciiNum().

const char * PLearn::PStream::format_float_default = "%.8g" [static, private]

Default format string for floats.

Definition at line 171 of file PStream.h.

If true, then Mat and Vec will be serialized with their elements in place, If false, they will have an explicit pointer to a storage.

Definition at line 180 of file PStream.h.

Referenced by PLearn::PLearnServer::callFunction(), PLearn::PLearnServer::implicit_storage(), operator=(), PLearn::save(), PLearn::TVec< PP< RegressionTreeNode > >::write(), and PLearn::TMat< pair< real, real > >::write().

Should be true if this stream is used to communicate with a remote PLearn host.

Will serialize options accordingly.

Definition at line 187 of file PStream.h.

Referenced by PLearn::Object::asStringRemoteTransmit(), PLearn::Object::newwrite(), PLearn::PLearnServer::PLearnServer(), PLearn::RemotePLearnServer::RemotePLearnServer(), PLearn::PLearnServer::~PLearnServer(), and PLearn::RemotePLearnServer::~RemotePLearnServer().

If true, we should emit windows end of line(
)

Definition at line 190 of file PStream.h.

Referenced by PLearn::global_options().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines