home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!news.claremont.edu!ucivax!news.service.uci.edu!network.ucsd.edu!sdd.hp.com!think.com!enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!ugle.unit.no!nuug!ifi.uio.no!nntp.ifi.uio.no!jar
- From: jar@solva.ifi.uio.no (Jo Are Rosland)
- Newsgroups: comp.lang.c++
- Subject: Re: xdr layer above iostream's
- Message-ID: <JAR.93Jan10162442@solva.ifi.uio.no>
- Date: 10 Jan 93 15:24:42 GMT
- References: <1ih5puINN4fj@buzz.bmc.uu.se>
- Sender: jar@ifi.uio.no (Jo Are Rosland)
- Organization: Dept. of Informatics, University of Oslo, Norway
- Lines: 42
- Nntp-Posting-Host: solva.ifi.uio.no
- In-Reply-To: sundvall@perrier.embnet.se's message of 7 Jan 1993 11:56:46 GMT
- X-Md4-Signature: 998719afc70bc82f213d281d10eb0eda
- Originator: jar@solva.ifi.uio.no
-
- In article <1ih5puINN4fj@buzz.bmc.uu.se> Mats Sundvall writes:
- I have implemented an Xdr class with the help of the xdr_rec. I have
- a constructor Xdr(iostream*) and can then put a XDR layer above a stream.
- All the operator input and output methods are then implemented to read
- from and write to Xdr.
-
- Another way to implement it would be to implement a new iostream subclassing
- from ios and streambuf.
-
- I now wonder what pros and cons there is with these different approches, and
- if there are other ways to do it that I haven't thought about.
-
- I think the best solution is to make xdrstream an independent class
- with an interface similar to ios, and a constructor (among others)
- looking like xdrstream(streambuf*). Then you implement the << and >>
- operators for all the types you need (at least the primitive types.)
-
- There are a number of reasons for this:
-
- The ios class doesn't seem to offer xdrstream very much, so it's not
- much use in having it as a subclass. All the formatting functionality
- (things like field widths etc.) are just superfluous in xdrstream. It
- would just be unnecessary baggage to carry around.
-
- Since ios formatting (all the << and >> defined for ios) is mainly
- text based, while xdr is binary, you need to implement all the >> and
- << whatever solution you choose.
-
- With the xdrstream(streambuf *) constructor (and a corresponding
- streambuf* member) you can perform xdr IO with all your excisting
- streambuf subclasses, including your tcp and tli classes if they are
- implemented correctly. Outputting to standard output would be
- possible by creating the xdrstream with xdrstream(cout.rdbuf()), if
- you want to output to a file, you could do it like this: xdrstream(new
- filebuf("file")). (Or whatever the constructor for filebuf looks
- like :-)).
-
- Hope this helps,
-
- --
- Jo Are Rosland
- jar@ifi.uio.no
-