libostd/examples/stream1.cc

27 lines
542 B
C++
Raw Normal View History

2016-01-31 23:19:23 +01:00
#include <ostd/functional.hh>
2016-02-02 00:10:05 +01:00
#include <ostd/io.hh>
2016-01-31 23:19:23 +01:00
using namespace ostd;
void print_result(Uint32 x) {
writefln("got x: 0x%X", x);
}
int main() {
2016-05-25 18:12:28 +02:00
FileStream wtest{"test.bin", StreamMode::write};
copy(
iter({ 0xABCD1214, 0xBADC3264, 0xDEADBEEF, 0xBEEFDEAD }),
wtest.iter<Uint32>()
);
2016-01-31 23:19:23 +01:00
wtest.close();
2016-05-25 18:12:28 +02:00
FileStream rtest{"test.bin"};
2016-02-26 16:19:54 +01:00
writefln("stream size: %d", rtest.size());
2016-01-31 23:19:23 +01:00
for (Uint32 x: map(rtest.iter<Uint32>(), FromBigEndian<Uint32>())) {
2016-01-31 23:19:23 +01:00
print_result(x);
}
2016-01-31 23:19:23 +01:00
return 0;
2016-02-07 22:17:15 +01:00
}