| [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
 | 
|---|
| [768d091] | 12 | // Last Modified On : Mon Apr 14 20:57:15 2025
 | 
|---|
 | 13 | // Update Count     : 61
 | 
|---|
| [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
 | 
|---|
| [ae0c1c3] | 41 | extern basic_ostream_data(ostrstream) const & basic_ostream_table;
 | 
|---|
| [fec63b2] | 42 | 
 | 
|---|
 | 43 | // private
 | 
|---|
| [666483d] | 44 | bool sepPrt$( ostrstream & );
 | 
|---|
 | 45 | void sepReset$( ostrstream & );
 | 
|---|
 | 46 | void sepReset$( ostrstream &, bool );
 | 
|---|
 | 47 | const char * sepGetCur$( ostrstream & );
 | 
|---|
 | 48 | void sepSetCur$( ostrstream &, const char [] );
 | 
|---|
 | 49 | bool getNL$( ostrstream & );
 | 
|---|
| [d0cfcbe1] | 50 | bool setNL$( ostrstream &, bool );
 | 
|---|
| [666483d] | 51 | bool getANL$( ostrstream & );
 | 
|---|
| [d0cfcbe1] | 52 | bool setANL$( ostrstream &, bool );
 | 
|---|
| [666483d] | 53 | bool getPrt$( ostrstream & );
 | 
|---|
| [d0cfcbe1] | 54 | bool setPrt$( ostrstream &, bool );
 | 
|---|
| [fec63b2] | 55 | 
 | 
|---|
 | 56 | // public
 | 
|---|
| [666483d] | 57 | void nlOn( ostrstream & );
 | 
|---|
 | 58 | void nlOff( ostrstream & );
 | 
|---|
| [fec63b2] | 59 | 
 | 
|---|
| [f5d9c37] | 60 | void sep( ostrstream & );
 | 
|---|
 | 61 | void nosep( ostrstream & );
 | 
|---|
 | 62 | bool sepOn( ostrstream & );
 | 
|---|
 | 63 | bool sepOff( ostrstream & );
 | 
|---|
| [666483d] | 64 | const char * sepGet( ostrstream & );
 | 
|---|
 | 65 | void sepSet( ostrstream &, const char [] );
 | 
|---|
 | 66 | const char * sepGetTuple( ostrstream & );
 | 
|---|
 | 67 | void sepSetTuple( ostrstream &, const char [] );
 | 
|---|
| [fec63b2] | 68 | 
 | 
|---|
| [666483d] | 69 | void ends( ostrstream & );
 | 
|---|
 | 70 | int fmt( ostrstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
 | 
|---|
| [fec63b2] | 71 | 
 | 
|---|
| [666483d] | 72 | ostrstream & write( ostrstream & os, FILE * stream ); // FIX ME: use default = stdout
 | 
|---|
 | 73 | ostrstream & write( ostrstream & os );
 | 
|---|
| [fec63b2] | 74 | 
 | 
|---|
| [666483d] | 75 | void ?{}( ostrstream &, char buf[], size_t size );
 | 
|---|
| [fec63b2] | 76 | 
 | 
|---|
| [666483d] | 77 | 
 | 
|---|
 | 78 | // *********************************** istrstream ***********************************
 | 
|---|
 | 79 | 
 | 
|---|
 | 80 | 
 | 
|---|
| [768d091] | 81 | // Currently, this is a placeholder because vsscanf returns number of values read versus buffer position scanned.
 | 
|---|
 | 82 | // This issue makes it impossible to know where in the buffer the last read stopped.
 | 
|---|
 | 83 | 
 | 
|---|
| [666483d] | 84 | struct istrstream {
 | 
|---|
 | 85 |         char * buf$;
 | 
|---|
 | 86 |         size_t cursor$;
 | 
|---|
 | 87 |         bool nlOnOff$;
 | 
|---|
 | 88 | }; // istrstream
 | 
|---|
 | 89 | 
 | 
|---|
| [768d091] | 90 | void ?{}( istrstream &, char buf[] );
 | 
|---|
 | 91 | 
 | 
|---|
| [666483d] | 92 | // Satisfies basic_istream
 | 
|---|
| [ae0c1c3] | 93 | extern basic_istream_data(istrstream) const & basic_istream_table;
 | 
|---|
| [666483d] | 94 | 
 | 
|---|
| [321a1b15] | 95 | // private
 | 
|---|
 | 96 | bool getANL$( istrstream & );
 | 
|---|
| [d0cfcbe1] | 97 | bool setANL$( istrstream &, bool );
 | 
|---|
| [321a1b15] | 98 | 
 | 
|---|
| [666483d] | 99 | // public
 | 
|---|
 | 100 | void nlOn( istrstream & );
 | 
|---|
 | 101 | void nlOff( istrstream & );
 | 
|---|
 | 102 | int fmt( istrstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
 | 
|---|
| [a1a1f37d] | 103 | istrstream & ungetc( char, istrstream & );
 | 
|---|
| [321a1b15] | 104 | bool eof( istrstream & );
 | 
|---|
| [768d091] | 105 | void clearerr( istrstream & );
 | 
|---|
 | 106 | void ends( istrstream & );
 | 
|---|
| [fec63b2] | 107 | 
 | 
|---|
 | 108 | // Local Variables: //
 | 
|---|
 | 109 | // mode: c //
 | 
|---|
 | 110 | // tab-width: 4 //
 | 
|---|
 | 111 | // End: //
 | 
|---|