| [fec63b2] | 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
 | 
|---|
| [d0cfcbe1] | 12 | // Last Modified On : Fri Aug 18 10:41:14 2023
 | 
|---|
 | 13 | // Update Count     : 55
 | 
|---|
| [fec63b2] | 14 | // 
 | 
|---|
 | 15 | 
 | 
|---|
 | 16 | #pragma once
 | 
|---|
 | 17 | 
 | 
|---|
 | 18 | #include "iostream.hfa"
 | 
|---|
 | 19 | #include <stdio.h>
 | 
|---|
 | 20 | 
 | 
|---|
 | 21 | 
 | 
|---|
| [666483d] | 22 | // *********************************** ostrstream ***********************************
 | 
|---|
| [fec63b2] | 23 | 
 | 
|---|
 | 24 | 
 | 
|---|
| [666483d] | 25 | enum { ostrstream_sepSize = 16 };
 | 
|---|
 | 26 | struct ostrstream {                                                                             // satisfied basic_ostream
 | 
|---|
| [fec63b2] | 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$;
 | 
|---|
| [666483d] | 36 |         char separator$[ostrstream_sepSize];
 | 
|---|
 | 37 |         char tupleSeparator$[ostrstream_sepSize];
 | 
|---|
 | 38 | }; // ostrstream
 | 
|---|
| [fec63b2] | 39 | 
 | 
|---|
 | 40 | // Satisfies basic_ostream
 | 
|---|
 | 41 | 
 | 
|---|
 | 42 | // private
 | 
|---|
| [666483d] | 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 & );
 | 
|---|
| [d0cfcbe1] | 49 | bool setNL$( ostrstream &, bool );
 | 
|---|
| [666483d] | 50 | bool getANL$( ostrstream & );
 | 
|---|
| [d0cfcbe1] | 51 | bool setANL$( ostrstream &, bool );
 | 
|---|
| [666483d] | 52 | bool getPrt$( ostrstream & );
 | 
|---|
| [d0cfcbe1] | 53 | bool setPrt$( ostrstream &, bool );
 | 
|---|
| [fec63b2] | 54 | 
 | 
|---|
 | 55 | // public
 | 
|---|
| [666483d] | 56 | void nlOn( ostrstream & );
 | 
|---|
 | 57 | void nlOff( ostrstream & );
 | 
|---|
| [fec63b2] | 58 | 
 | 
|---|
| [f5d9c37] | 59 | void sep( ostrstream & );
 | 
|---|
 | 60 | void nosep( ostrstream & );
 | 
|---|
 | 61 | bool sepOn( ostrstream & );
 | 
|---|
 | 62 | bool sepOff( ostrstream & );
 | 
|---|
| [666483d] | 63 | const char * sepGet( ostrstream & );
 | 
|---|
 | 64 | void sepSet( ostrstream &, const char [] );
 | 
|---|
 | 65 | const char * sepGetTuple( ostrstream & );
 | 
|---|
 | 66 | void sepSetTuple( ostrstream &, const char [] );
 | 
|---|
| [fec63b2] | 67 | 
 | 
|---|
| [666483d] | 68 | void ends( ostrstream & );
 | 
|---|
 | 69 | int fmt( ostrstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
 | 
|---|
| [fec63b2] | 70 | 
 | 
|---|
| [666483d] | 71 | ostrstream & write( ostrstream & os, FILE * stream ); // FIX ME: use default = stdout
 | 
|---|
 | 72 | ostrstream & write( ostrstream & os );
 | 
|---|
| [fec63b2] | 73 | 
 | 
|---|
| [666483d] | 74 | void ?{}( ostrstream &, char buf[], size_t size );
 | 
|---|
| [fec63b2] | 75 | 
 | 
|---|
| [666483d] | 76 | 
 | 
|---|
 | 77 | // *********************************** istrstream ***********************************
 | 
|---|
 | 78 | 
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 | struct istrstream {
 | 
|---|
 | 81 |         char * buf$;
 | 
|---|
 | 82 |         size_t cursor$;
 | 
|---|
 | 83 |         bool nlOnOff$;
 | 
|---|
 | 84 | }; // istrstream
 | 
|---|
 | 85 | 
 | 
|---|
 | 86 | // Satisfies basic_istream
 | 
|---|
 | 87 | 
 | 
|---|
| [321a1b15] | 88 | // private
 | 
|---|
 | 89 | bool getANL$( istrstream & );
 | 
|---|
| [d0cfcbe1] | 90 | bool setANL$( istrstream &, bool );
 | 
|---|
| [321a1b15] | 91 | 
 | 
|---|
| [666483d] | 92 | // public
 | 
|---|
 | 93 | void nlOn( istrstream & );
 | 
|---|
 | 94 | void nlOff( istrstream & );
 | 
|---|
 | 95 | void ends( istrstream & );
 | 
|---|
| [321a1b15] | 96 | 
 | 
|---|
| [666483d] | 97 | int fmt( istrstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
 | 
|---|
| [321a1b15] | 98 | istrstream & ungetc( istrstream &, char );
 | 
|---|
 | 99 | bool eof( istrstream & );
 | 
|---|
| [666483d] | 100 | 
 | 
|---|
| [321a1b15] | 101 | void ?{}( istrstream &, char buf[] );
 | 
|---|
| [fec63b2] | 102 | 
 | 
|---|
 | 103 | // Local Variables: //
 | 
|---|
 | 104 | // mode: c //
 | 
|---|
 | 105 | // tab-width: 4 //
 | 
|---|
 | 106 | // End: //
 | 
|---|