34 #include <type_traits> 37 inline bool hexdecode(
const char *from, std::size_t length,
void *to) {
39 for (
i = 0;
i < length;
i++) {
41 if (from[2 *
i] >=
'0' && from[2 *
i] <=
'9') {
42 v = from[2 *
i] -
'0';
43 }
else if (from[2 *
i] >=
'a' && from[2 *
i] <=
'f') {
44 v = from[2 *
i] -
'a' + 10;
49 if (from[2 *
i + 1] >=
'0' && from[2 *
i + 1] <=
'9') {
50 v |= from[2 *
i + 1] -
'0';
51 }
else if (from[2 *
i + 1] >=
'a' && from[2 *
i + 1] <=
'f') {
52 v |= from[2 *
i + 1] -
'a' + 10;
56 *(
reinterpret_cast<unsigned char *
>(to) +
i) = v;
61 inline void get(std::istream &input,
bool &
res) {
64 if (sres ==
"false") {
66 }
else if (sres ==
"true") {
69 input.setstate(std::ios_base::failbit);
75 get(std::istream &input,
T &
res) {
79 inline void getvar(std::istream &input, std::size_t length,
void *
res) {
82 if (sres.length() != 2 * length || !
hexdecode(sres.data(), length,
res)) {
83 input.setstate(std::ios_base::failbit);
89 get(std::istream &input,
T &
res) {
93 inline void get(std::istream &input, std::vector<char> &
res) {
98 }
else if (sres.length() % 2 != 0) {
99 input.setstate(std::ios_base::failbit);
101 std::size_t length = sres.length() / 2;
104 input.setstate(std::ios_base::failbit);
109 #if !defined(_MSC_VER) || _MSC_VER >= 1800 111 template<
typename T,
typename... TT>
113 get(std::istream &input,
T &
res, TT &... resres) {
115 get(input, resres...);
119 #include <boost/preprocessor/cat.hpp> 120 #include <boost/preprocessor/repetition/enum_binary_params.hpp> 121 #include <boost/preprocessor/repetition/enum_params.hpp> 122 #include <boost/preprocessor/repetition/repeat.hpp> 123 #include <boost/preprocessor/repetition/repeat_from_to.hpp> 125 #define NESTED_GET(z, n, data) get(input, BOOST_PP_CAT(res, n)); 126 #define GET(z, n, data) \ 127 template<BOOST_PP_ENUM_PARAMS(n, typename T)> \ 128 void get(std::istream &input, BOOST_PP_ENUM_BINARY_PARAMS(n, T, &res)) { \ 129 BOOST_PP_REPEAT(n, NESTED_GET, ~) \ 131 BOOST_PP_REPEAT_FROM_TO(2, 5, GET, ~)
const char * res
Definition: hmac_keccak.cpp:42
const uint32_t T[512]
Definition: groestl_tables.h:36
int i
Definition: pymoduletest.py:23
::std::string string
Definition: gtest-port.h:1097
int type
Definition: superscalar.cpp:50
void getvar(std::istream &input, std::size_t length, void *res)
Definition: io.h:79
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
typename std::enable_if< C >::type enable_if
Definition: expect.h:77
bool hexdecode(const char *from, std::size_t length, void *to)
Definition: io.h:37