mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
io.h
Go to the documentation of this file.
1 #ifndef MF_UTILITY_IO_H_
2 #define MF_UTILITY_IO_H_
3 
4 #include <iosfwd>
5 #include <limits>
6 #include <string>
7 #include "../common.h"
8 
9 namespace mf {
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 std::size_t file_size(const std::string&);
34 std::size_t file_size(std::ifstream&);
35 
36 }
37 
38 #endif
std::uint8_t byte
Single byte type.
Definition: common.h:56
const bool host_is_little_endian
Definition: io.cc:30
void end_line(std::ostream &str, line_delimitor ld)
Definition: io.cc:88
void write_line(std::ostream &str, const std::string &line, line_delimitor ld)
Definition: io.cc:82
line_delimitor
Definition: io.h:11
void flip_endianness(byte *data, std::size_t sz)
Definition: io.cc:100
line_delimitor detect_line_delimitor(std::istream &str, std::size_t max_offset)
Detects line delimitor used in given file.
Definition: io.cc:34
const line_delimitor default_line_delimitor
Definition: io.cc:25
std::size_t file_size(const std::string &filename)
Definition: io.cc:108
void skip_line(std::istream &str, line_delimitor ld)
Definition: io.cc:68
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