| 1 | // 
 | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2021 University of Waterloo
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the
 | 
|---|
| 5 | // file "LICENCE" distributed with Cforall.
 | 
|---|
| 6 | // 
 | 
|---|
| 7 | // strstream.hfa -- 
 | 
|---|
| 8 | // 
 | 
|---|
| 9 | // Author           : Peter A. Buhr
 | 
|---|
| 10 | // Created On       : Thu Apr 22 22:20:59 2021
 | 
|---|
| 11 | // Last Modified By : Peter A. Buhr
 | 
|---|
| 12 | // Last Modified On : Sun Oct 10 10:14:22 2021
 | 
|---|
| 13 | // Update Count     : 47
 | 
|---|
| 14 | // 
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #pragma once
 | 
|---|
| 17 | 
 | 
|---|
| 18 | #include "iostream.hfa"
 | 
|---|
| 19 | #include <stdio.h>
 | 
|---|
| 20 | 
 | 
|---|
| 21 | 
 | 
|---|
| 22 | // *********************************** ostrstream ***********************************
 | 
|---|
| 23 | 
 | 
|---|
| 24 | 
 | 
|---|
| 25 | enum { ostrstream_sepSize = 16 };
 | 
|---|
| 26 | struct ostrstream {                                                                             // satisfied basic_ostream
 | 
|---|
| 27 |         char * buf$;
 | 
|---|
| 28 |         size_t size$;
 | 
|---|
| 29 |         size_t cursor$;
 | 
|---|
| 30 |         bool sepDefault$;
 | 
|---|
| 31 |         bool sepOnOff$;
 | 
|---|
| 32 |         bool nlOnOff$;
 | 
|---|
| 33 |         bool prt$;                                                                                      // print text
 | 
|---|
| 34 |         bool sawNL$;
 | 
|---|
| 35 |         const char * sepCur$;
 | 
|---|
| 36 |         char separator$[ostrstream_sepSize];
 | 
|---|
| 37 |         char tupleSeparator$[ostrstream_sepSize];
 | 
|---|
| 38 | }; // ostrstream
 | 
|---|
| 39 | 
 | 
|---|
| 40 | // Satisfies basic_ostream
 | 
|---|
| 41 | 
 | 
|---|
| 42 | // private
 | 
|---|
| 43 | bool sepPrt$( ostrstream & );
 | 
|---|
| 44 | void sepReset$( ostrstream & );
 | 
|---|
| 45 | void sepReset$( ostrstream &, bool );
 | 
|---|
| 46 | const char * sepGetCur$( ostrstream & );
 | 
|---|
| 47 | void sepSetCur$( ostrstream &, const char [] );
 | 
|---|
| 48 | bool getNL$( ostrstream & );
 | 
|---|
| 49 | void setNL$( ostrstream &, bool );
 | 
|---|
| 50 | bool getANL$( ostrstream & );
 | 
|---|
| 51 | bool getPrt$( ostrstream & );
 | 
|---|
| 52 | void setPrt$( ostrstream &, bool );
 | 
|---|
| 53 | 
 | 
|---|
| 54 | // public
 | 
|---|
| 55 | void sepOn( ostrstream & );
 | 
|---|
| 56 | void sepOff( ostrstream & );
 | 
|---|
| 57 | bool sepDisable( ostrstream & );
 | 
|---|
| 58 | bool sepEnable( ostrstream & );
 | 
|---|
| 59 | void nlOn( ostrstream & );
 | 
|---|
| 60 | void nlOff( ostrstream & );
 | 
|---|
| 61 | 
 | 
|---|
| 62 | const char * sepGet( ostrstream & );
 | 
|---|
| 63 | void sepSet( ostrstream &, const char [] );
 | 
|---|
| 64 | const char * sepGetTuple( ostrstream & );
 | 
|---|
| 65 | void sepSetTuple( ostrstream &, const char [] );
 | 
|---|
| 66 | 
 | 
|---|
| 67 | void ends( ostrstream & );
 | 
|---|
| 68 | int fmt( ostrstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
 | 
|---|
| 69 | 
 | 
|---|
| 70 | ostrstream & write( ostrstream & os, FILE * stream ); // FIX ME: use default = stdout
 | 
|---|
| 71 | ostrstream & write( ostrstream & os );
 | 
|---|
| 72 | 
 | 
|---|
| 73 | void ?{}( ostrstream &, char buf[], size_t size );
 | 
|---|
| 74 | 
 | 
|---|
| 75 | 
 | 
|---|
| 76 | // *********************************** istrstream ***********************************
 | 
|---|
| 77 | 
 | 
|---|
| 78 | 
 | 
|---|
| 79 | struct istrstream {
 | 
|---|
| 80 |         char * buf$;
 | 
|---|
| 81 |         size_t cursor$;
 | 
|---|
| 82 |         bool nlOnOff$;
 | 
|---|
| 83 | }; // istrstream
 | 
|---|
| 84 | 
 | 
|---|
| 85 | // Satisfies basic_istream
 | 
|---|
| 86 | 
 | 
|---|
| 87 | // private
 | 
|---|
| 88 | bool getANL$( istrstream & );
 | 
|---|
| 89 | 
 | 
|---|
| 90 | // public
 | 
|---|
| 91 | void nlOn( istrstream & );
 | 
|---|
| 92 | void nlOff( istrstream & );
 | 
|---|
| 93 | void ends( istrstream & );
 | 
|---|
| 94 | 
 | 
|---|
| 95 | int fmt( istrstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
 | 
|---|
| 96 | istrstream & ungetc( istrstream &, char );
 | 
|---|
| 97 | bool eof( istrstream & );
 | 
|---|
| 98 | 
 | 
|---|
| 99 | void ?{}( istrstream &, char buf[] );
 | 
|---|
| 100 | 
 | 
|---|
| 101 | // Local Variables: //
 | 
|---|
| 102 | // mode: c //
 | 
|---|
| 103 | // tab-width: 4 //
 | 
|---|
| 104 | // End: //
 | 
|---|