home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18795 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  2.0 KB

  1. Path: sparky!uunet!mcsun!sunic!corax.udac.uu.se!buzz.bmc.uu.se!perrier!sundvall
  2. From: sundvall@perrier.embnet.se (Mats Sundvall)
  3. Newsgroups: comp.lang.c++
  4. Subject: xdr layer above iostream's
  5. Date: 7 Jan 1993 11:56:46 GMT
  6. Organization: EMBNet Project Sweden
  7. Lines: 47
  8. Distribution: world
  9. Message-ID: <1ih5puINN4fj@buzz.bmc.uu.se>
  10. Reply-To: sundvall@perrier.embnet.se
  11. NNTP-Posting-Host: perrier.embnet.se
  12. Keywords: xdr c++ iostream
  13.  
  14.  
  15. We have a need to communicate between machines with different byte ordering.
  16. I though about using XDR, but as we are using C++ and iostreams of different
  17. kinds, even for tcp I am thinking about different ways of implementing an
  18. xdrstream.
  19.  
  20. I have implemented an Xdr class with the help of the xdr_rec. I have
  21. a constructor Xdr(iostream*) and can then put a XDR layer above a stream.
  22. All the operator input and output methods are then implemented to read
  23. from and write to Xdr.
  24.  
  25. Another way to implement it would be to implement a new iostream subclassing
  26. from ios and streambuf.
  27.  
  28. I now wonder what pros and cons there is with these different approches, and
  29. if there are other ways to do it that I haven't thought about.
  30.  
  31. If you implement it with a bunch of new streams you have to implement all the
  32. different streams again (iostreams, fstreams, tcpstreams, tlistreams) but with
  33. xdr.  Maybe you can do some smart subclassing from these but I am not confident
  34. enogh about the internals of streams to know that.
  35.  
  36. The advantage would be that they all inherit from iostreams and that all existing
  37. code that read and write to iostreams will work without having to implement
  38. Xdr::operator<<(MyClass&) and >> methods.
  39.  
  40. I am also not sure if you can get all the status in ios up to the xdr class if
  41. you use the first method, the Xdr class. I thought about implementing the 
  42. operator== and operator!= methods for Xdr to check the status but maybe that is
  43. not enough?
  44.  
  45. And what about iomanips?
  46.  
  47. If anyone have comments please tell me,
  48.  
  49. Regards,
  50.  
  51. Mats Sundvall
  52. Dept of Medical Genetics,
  53. Uppsala University
  54. Sweden
  55.  
  56. sundvall@perrier.embnet.se
  57.  
  58.  
  59.  
  60.  
  61.