source: libcfa/src/strstream.hfa@ b28ce93

Last change on this file since b28ce93 was ae0c1c3, checked in by Andrew Beach <ajbeach@…>, 5 months ago

Rewrote the iostream traits to have a single assertion each, a table containing function pointers. This is just an experiment right now. It seems that it does cause significant speed up of assertion resolution, but for some reason also seems to add a flat overhead that mostly eats up that saving.

  • Property mode set to 100644
File size: 2.9 KB
Line 
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 : Mon Apr 14 20:57:15 2025
13// Update Count : 61
14//
15
16#pragma once
17
18#include "iostream.hfa"
19#include <stdio.h>
20
21
22// *********************************** ostrstream ***********************************
23
24
25enum { ostrstream_sepSize = 16 };
26struct 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
41extern basic_ostream_data(ostrstream) const & basic_ostream_table;
42
43// private
44bool sepPrt$( ostrstream & );
45void sepReset$( ostrstream & );
46void sepReset$( ostrstream &, bool );
47const char * sepGetCur$( ostrstream & );
48void sepSetCur$( ostrstream &, const char [] );
49bool getNL$( ostrstream & );
50bool setNL$( ostrstream &, bool );
51bool getANL$( ostrstream & );
52bool setANL$( ostrstream &, bool );
53bool getPrt$( ostrstream & );
54bool setPrt$( ostrstream &, bool );
55
56// public
57void nlOn( ostrstream & );
58void nlOff( ostrstream & );
59
60void sep( ostrstream & );
61void nosep( ostrstream & );
62bool sepOn( ostrstream & );
63bool sepOff( ostrstream & );
64const char * sepGet( ostrstream & );
65void sepSet( ostrstream &, const char [] );
66const char * sepGetTuple( ostrstream & );
67void sepSetTuple( ostrstream &, const char [] );
68
69void ends( ostrstream & );
70int fmt( ostrstream &, const char format[], ... ) __attribute__(( format(printf, 2, 3) ));
71
72ostrstream & write( ostrstream & os, FILE * stream ); // FIX ME: use default = stdout
73ostrstream & write( ostrstream & os );
74
75void ?{}( ostrstream &, char buf[], size_t size );
76
77
78// *********************************** istrstream ***********************************
79
80
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
84struct istrstream {
85 char * buf$;
86 size_t cursor$;
87 bool nlOnOff$;
88}; // istrstream
89
90void ?{}( istrstream &, char buf[] );
91
92// Satisfies basic_istream
93extern basic_istream_data(istrstream) const & basic_istream_table;
94
95// private
96bool getANL$( istrstream & );
97bool setANL$( istrstream &, bool );
98
99// public
100void nlOn( istrstream & );
101void nlOff( istrstream & );
102int fmt( istrstream &, const char format[], ... ) __attribute__(( format(scanf, 2, 3) ));
103istrstream & ungetc( char, istrstream & );
104bool eof( istrstream & );
105void clearerr( istrstream & );
106void ends( istrstream & );
107
108// Local Variables: //
109// mode: c //
110// tab-width: 4 //
111// End: //
Note: See TracBrowser for help on using the repository browser.