forked from OctaForge/libostd
update examples to use new ctor style
This commit is contained in:
parent
46d8844a49
commit
091b4dbf73
|
@ -72,12 +72,12 @@ int main() {
|
|||
writefln("[ %#(<%d|%f|%s>%|, %) ]", xt);
|
||||
|
||||
/* custom format */
|
||||
writefln("%s", Foo());
|
||||
writefln("%i", Foo());
|
||||
writefln("%s", Foo{});
|
||||
writefln("%i", Foo{});
|
||||
|
||||
/* custom format via method */
|
||||
writefln("%s", Bar());
|
||||
writefln("%i", Bar());
|
||||
writefln("%s", Bar{});
|
||||
writefln("%i", Bar{});
|
||||
|
||||
/* format into string */
|
||||
auto s = appender<String>();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
using namespace ostd;
|
||||
|
||||
void list_dirs(ConstCharRange path, int off = 0) {
|
||||
DirectoryStream ds(path);
|
||||
DirectoryStream ds{path};
|
||||
/* iterate all items in directory */
|
||||
for (auto v: ds.iter()) {
|
||||
if (v.type() != FileType::directory)
|
||||
|
|
|
@ -8,11 +8,11 @@ void print_result(Uint32 x) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
FileStream wtest("test.bin", StreamMode::write);
|
||||
FileStream wtest{"test.bin", StreamMode::write};
|
||||
copy(iter({ 0xABCD1214, 0xBADC3264, 0xDEADBEEF, 0xBEEFDEAD }), wtest.iter<Uint32>());
|
||||
wtest.close();
|
||||
|
||||
FileStream rtest("test.bin");
|
||||
FileStream rtest{"test.bin"};
|
||||
writefln("stream size: %d", rtest.size());
|
||||
|
||||
for (Uint32 x: map(rtest.iter<Uint32>(), FromBigEndian<Uint32>()))
|
||||
|
|
|
@ -7,7 +7,7 @@ using namespace ostd;
|
|||
int main() {
|
||||
writeln("writing sample file...");
|
||||
|
||||
FileStream wtest("test.txt", StreamMode::write);
|
||||
FileStream wtest{"test.txt", StreamMode::write};
|
||||
|
||||
String smpl = "This is a test file for later read.\n"
|
||||
"It contains some sample text in order to see whether "
|
||||
|
@ -19,18 +19,18 @@ int main() {
|
|||
copy(smpl.iter(), wtest.iter());
|
||||
wtest.close();
|
||||
|
||||
FileStream test("test.txt");
|
||||
FileStream test{"test.txt"};
|
||||
|
||||
writeln("## WHOLE FILE READ ##\n");
|
||||
|
||||
String ts1(test.iter());
|
||||
String ts1{test.iter()};
|
||||
writefln("-- str beg --\n%s-- str end --", ts1);
|
||||
|
||||
test.seek(0);
|
||||
|
||||
writeln("\n## PART FILE READ ##\n");
|
||||
|
||||
String ts2(test.iter().take(25));
|
||||
String ts2{test.iter().take(25)};
|
||||
writefln("-- str beg --\n%s\n-- str end --", ts2);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue