#include <cstddef>
#include <ios>
#include <iostream>
#include <type_traits>
#include <vector>
Go to the source code of this file.
|
| bool | hexdecode (const char *from, std::size_t length, void *to) |
| |
| void | get (std::istream &input, bool &res) |
| |
| template<typename T > |
| std::enable_if< std::is_integral< T >::value, void >::type | get (std::istream &input, T &res) |
| |
| void | getvar (std::istream &input, std::size_t length, void *res) |
| |
| template<typename T > |
| std::enable_if< std::is_standard_layout< T >::value &&!std::is_scalar< T >::value, void >::type | get (std::istream &input, T &res) |
| |
| void | get (std::istream &input, std::vector< char > &res) |
| |
| template<typename T , typename... TT> |
| std::enable_if<(sizeof...(TT) > 0), void >::type | get (std::istream &input, T &res, TT &... resres) |
| |
◆ get() [1/5]
| void get |
( |
std::istream & |
input, |
|
|
bool & |
res |
|
) |
| |
|
inline |
Definition at line 62 of file io.h.
65 if (sres ==
"false") {
67 }
else if (sres ==
"true") {
70 input.setstate(std::ios_base::failbit);
◆ get() [2/5]
template<typename T >
| std::enable_if<std::is_integral<T>::value, void>::type get |
( |
std::istream & |
input, |
|
|
T & |
res |
|
) |
| |
Definition at line 76 of file io.h.
◆ get() [3/5]
template<typename T >
| std::enable_if<std::is_standard_layout<T>::value && !std::is_scalar<T>::value, void>::type get |
( |
std::istream & |
input, |
|
|
T & |
res |
|
) |
| |
Definition at line 90 of file io.h.
void getvar(std::istream &input, std::size_t length, void *res)
◆ get() [4/5]
| void get |
( |
std::istream & |
input, |
|
|
std::vector< char > & |
res |
|
) |
| |
|
inline |
Definition at line 94 of file io.h.
99 }
else if (sres.length() % 2 != 0) {
100 input.setstate(std::ios_base::failbit);
102 std::size_t length = sres.length() / 2;
105 input.setstate(std::ios_base::failbit);
bool hexdecode(const char *from, std::size_t length, void *to)
◆ get() [5/5]
template<typename T , typename... TT>
| std::enable_if<(sizeof...(TT) > 0), void>::type get |
( |
std::istream & |
input, |
|
|
T & |
res, |
|
|
TT &... |
resres |
|
) |
| |
Definition at line 114 of file io.h.
116 get(input, resres...);
◆ getvar()
| void getvar |
( |
std::istream & |
input, |
|
|
std::size_t |
length, |
|
|
void * |
res |
|
) |
| |
|
inline |
Definition at line 80 of file io.h.
83 if (sres.length() != 2 * length || !
hexdecode(sres.data(), length,
res)) {
84 input.setstate(std::ios_base::failbit);
bool hexdecode(const char *from, std::size_t length, void *to)
◆ hexdecode()
| bool hexdecode |
( |
const char * |
from, |
|
|
std::size_t |
length, |
|
|
void * |
to |
|
) |
| |
|
inline |
Definition at line 38 of file io.h.
40 for (i = 0; i < length; i++) {
42 if (from[2 * i] >=
'0' && from[2 * i] <=
'9') {
43 v = from[2 * i] -
'0';
44 }
else if (from[2 * i] >=
'a' && from[2 * i] <=
'f') {
45 v = from[2 * i] -
'a' + 10;
50 if (from[2 * i + 1] >=
'0' && from[2 * i + 1] <=
'9') {
51 v |= from[2 * i + 1] -
'0';
52 }
else if (from[2 * i + 1] >=
'a' && from[2 * i + 1] <=
'f') {
53 v |= from[2 * i + 1] -
'a' + 10;
57 *(
reinterpret_cast<unsigned char *
>(to) + i) = v;