source: tests/collections/string-istream.cfa @ 8a33777

Last change on this file since 8a33777 was 55b060d, checked in by Peter A. Buhr <pabuhr@…>, 16 months ago

rename directories containers to collections

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[d32679d5]1#include <iostream.hfa>
[55b060d]2#include <collections/string.hfa>
3#include <collections/string_res.hfa>
[d32679d5]4
5
6void istream_cstr(void) {
[329487c]7        enum { size = 999, rsize = size - 1 }; // string size, read size
8    char s1[size], s2[size], s3[size], si[size];
9    sin | wdi(size,rsize,s1) | wdi(size,rsize,s2) | wdi(size,rsize,s3);
[d32679d5]10    sout | s1;
11    sout | s2;
12    sout | s3;
13    for(;;) {
[329487c]14        sin | wdi(size,rsize,si);
[d32679d5]15      if (si[0] == '=') break;
16        sout | si;
17    }
18}
19
20string accumulator;
21
22void reset_otherStringAction(void) {
23    accumulator = "";
24}
25void step_otherStringAction(void) {
26    string localAction = "--";
27    accumulator += localAction(0,1);
28    sout | accumulator;
29}
30
31void istream_string_res(void) {
32    string_res s1, s2, s3, si;
33    sin | s1 | s2 | s3;
34    sout | s1;        step_otherStringAction();
35    sout | s2;        step_otherStringAction();
36    sout | s3;        step_otherStringAction();
37    for(;;) {
38        sin | si;
39      if (size(si) > 0 && si[0] == '=') break;
40        sout | si;    step_otherStringAction();
41    }
42}
43
44void istream_string(void) {
45    string s1, s2, s3, si;
46    sin | s1 | s2 | s3;
47    sout | s1;        step_otherStringAction();
48    sout | s2;        step_otherStringAction();
49    sout | s3;        step_otherStringAction();
50    for(;;) {
51        sin | si;
52      if (size(si) > 0 && si[0] == '=') break;
53        sout | si;    step_otherStringAction();
54    }
55}
56
57
58int main() {
59    istream_cstr();         sout | "=";
60    istream_string_res();   sout | "=";  reset_otherStringAction();
61    istream_string();
62}
Note: See TracBrowser for help on using the repository browser.