Module: Advanced Tools Package: Serialization
Does not inherit
#include <rw/serial/RWObjectInputStream.h>
This class consists of a guard object that opens and closes a context within a lexical scope. To use RWWithObjectInputContext, simply declare an automatic instance of this class initialized with a object input stream, and all object references within the scope of the automatic variable will be streamed within the same context.
// Read in one or more objects from an object stream that // were output in the same context. #include <rw/serial/RWCompactObjectInputStreamImp.h> #include <rw/serial/RWObjectInputStream.h> #include <fstream.h> #include <iostream.h> int main() { ifstream fstrm; fstrm.open("RWWithObjectOutputContext.out", ios::in | ios::nocreate); if (!fstrm) { cout << "The file does not exist."<< endl; } else { RWObjectInputStream in = RWCompactObjectInputStreamImp::make(fstrm); RWWithObjectInputContext context(in); int i,j; in >> i >> j; cout << "i = " << i << " j = " << j << endl; } return 0; }
RWWithObjectInputContext(RWObjectInputStream& strm, bool readContext = true);
Constructor taking object input stream reference argument. If readContext is true then read in any document header at the outer context.
RWWithObjectInputContext(RWObjectInputStreamImp* strm, bool readContext = true);
Constructor taking object input stream pointer argument. If readContext is true then read in any document header at the outer context.
~RWWithObjectInputContext();
Destructor automatically closes context.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.