SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWWithObjectInputContext Class Reference

Represents a guard object that opens and closes a context within a lexical scope for input streams. More...

#include <rw/serial/RWObjectInputStream.h>

Public Member Functions

 RWWithObjectInputContext (RWObjectInputStream &strm, bool readContext=true)
 
 RWWithObjectInputContext (RWObjectInputStreamImp *strm, bool readContext=true)
 
 ~RWWithObjectInputContext ()
 

Detailed Description

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.

Example
// 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 {
int i, j;
in >> i >> j;
cout << "i = " << i << " j = " << j << endl;
}
return 0;
}
static RWObjectInputStream make(const RWDataInputStream &source, bool annotateStream=false)
Handle class for object input stream implementation classes.
Definition RWObjectInputStream.h:59
Represents a guard object that opens and closes a context within a lexical scope for input streams.
Definition RWObjectInputStream.h:473
See also
RWObjectInputStream

Constructor & Destructor Documentation

◆ RWWithObjectInputContext() [1/2]

RWWithObjectInputContext::RWWithObjectInputContext ( RWObjectInputStream & strm,
bool readContext = true )
inline

Constructor taking an object input stream reference argument. If readContext is true, then read in any document header at the outer context.

◆ RWWithObjectInputContext() [2/2]

RWWithObjectInputContext::RWWithObjectInputContext ( RWObjectInputStreamImp * strm,
bool readContext = true )
inline

Constructor taking an object input stream pointer argument. If readContext is true, then read in any document header at the outer context.

◆ ~RWWithObjectInputContext()

RWWithObjectInputContext::~RWWithObjectInputContext ( )
inline

Destructor automatically closes context.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.