Stream i/o, Comparisons – HP Integrity NonStop J-Series User Manual

Page 33

Advertising
background image

Rwspace ClassName::binaryStoreSize() const;
Rwspace ClassName::recursiveStoreSize() const;

The member functions use the function:

RWFile& operator<<(RWFile& file, const ClassName&);

The above member functions are good for storing objects using classes

RWFileManager

and

RWBTreeOnDisk

. For objects that inherit from

RWCollectable,

the second variant

recursiveStoreSize()can calculate the number of bytes used in a recursive store. The variant uses
the function:

RWFile& operator<<(RWFile& file, const RWCollectable&)

You can use class

RWAuditStreamBuffer

in conjuction with any stream to count the number of

bytes that pass through the buffer. Therefore, this class gives you functionality for streams as
the above member functions give you functionality for files. For more information on class

RWAuditStreamBuffer,

see the Class Reference.

Stream I/O

The overloaded left-shift operator <<, taking an ostream object as its first argument, will print
the contents of an object in human-readable form. Conversely, the overloaded right-shift
operator >>, taking an istream object as its first argument, will read and parse an object from
the stream in a human-understandable format.

ostream& operator<<(ostream& ostr, const ClassName& x);
istream& operator>>(istream& istr, const ClassName& x);

The overloaded left-shift and right-shift operators contrast with the persistence operators:

Rwvostream& operator<<(RWvostream& vstream, const ClassName&);
Rwvistream& operator>>(RWvistream& vstream, ClassName&);

Although the persistence shift operators may store and restore to and from a stream, they will
not necessarily do so in a form that could be called "human-readable."

Comparisons

Finally, most classes have comparison and equality member functions:

int compareTo(ClassName*) const;
RWBoolean equalTo(ClassName*) const;

and their logical operator counterparts:

RWBoolean operator==(const ClassName&) const;
RWBoolean operator!=(const ClassName&) const;
RWBoolean operator<=(const ClassName&) const;
RWBoolean operator>=(const ClassName&) const;
RWBoolean operator<(const ClassName&) const;

Advertising
This manual is related to the following products: