OGLplus  (0.59.0) a C++ wrapper for rendering APIs

eagine/bindump.cpp

Copyright Matus Chochlik. Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt

#include <iostream>
auto main(int argc, const char** argv) -> int {
using namespace eagine;
program_args args(argc, argv);
for(auto& arg : args) {
if(!arg.starts_with("-")) {
if(arg.prev().is_tag("-f", "--file")) {
file_contents fc(arg.get());
std::cout << arg << '|' << bindump(fc.block()) << std::endl;
} else if(arg.prev().is_tag("-s", "--string")) {
std::cout << arg << '|' << bindump(arg.block()) << std::endl;
}
}
}
span_size_t i = 0;
auto get = [&]() -> optionally_valid<byte> {
if(i < 256) {
return {byte(i++), true};
}
return {};
};
auto put = [](char c) {
std::cout << c;
return true;
};
return 0;
}
Class providing access to the contents of a file.
Definition: file_contents.hpp:30
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
Common code is placed in this namespace.
Definition: eagine.hpp:21
auto block() const noexcept -> memory::const_block
Returns the block viewing the loaded file contents.
Definition: file_contents.hpp:52
Primary template for conditionally valid values.
Definition: decl.hpp:49
static void apply(byte_getter get_byte, char_putter put_char)
Uses get_byte to read input bytes, encodes them and calls put_char.
unsigned char byte
Byte type alias.
Definition: types.hpp:24
Class wrapping the main function arguments, providing a convenient API.
Definition: program_args.hpp:1082
Class for encoding byte blocks into binary format.
Definition: bindump.hpp:27
constexpr const construct_from_t construct_from
The construct-from tag-dispatch constant.
Definition: selector.hpp:47

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).