licornea_tools
io.h
Go to the documentation of this file.
1 #ifndef LICORNEA_UTILITY_IO_H_
2 #define LICORNEA_UTILITY_IO_H_
3 
4 #include <iosfwd>
5 #include <limits>
6 #include <string>
7 #include "common.h"
8 
9 namespace tlz {
10 
11 enum class line_delimitor { unknown, LF, CR, CRLF };
12 
14 const extern bool host_has_iec559_float;
15 const extern bool host_is_little_endian;
16 
18 
20 line_delimitor detect_line_delimitor(std::istream&, std::size_t max_offset = 512);
21 
22 void read_line(std::istream&, std::string&, line_delimitor = default_line_delimitor);
23 void skip_line(std::istream&, line_delimitor = default_line_delimitor);
24 void write_line(std::ostream&, const std::string&, line_delimitor = default_line_delimitor);
25 void end_line(std::ostream&, line_delimitor = default_line_delimitor);
26 
27 void flip_endianness(byte* data, std::size_t sz);
28 
29 template<typename T> void flip_endianness(T& t) {
30  flip_endianness(reinterpret_cast<byte*>(&t), sizeof(T));
31 }
32 
33 }
34 
35 #endif
const bool host_is_little_endian
Definition: io.cc:30
void end_line(std::ostream &str, line_delimitor ld)
Definition: io.cc:88
void skip_line(std::istream &str, line_delimitor ld)
Definition: io.cc:68
const line_delimitor default_line_delimitor
Definition: io.cc:25
void read_line(std::istream &str, std::string &line, line_delimitor ld)
Definition: io.cc:52
const bool host_has_iec559_float
Definition: io.cc:27
line_delimitor
Definition: io.h:11
line_delimitor detect_line_delimitor(std::istream &str, std::size_t max_offset)
Detects line delimitor used in given file.
Definition: io.cc:34
std::uint8_t byte
Definition: common.h:17
void write_line(std::ostream &str, const std::string &line, line_delimitor ld)
Definition: io.cc:82
void flip_endianness(byte *data, std::size_t sz)
Definition: io.cc:100