From 5c3b39340d365f5ff37a79424956591e87b44816 Mon Sep 17 00:00:00 2001 From: Determinant Date: Tue, 26 Jun 2018 12:58:54 -0400 Subject: init --- include/salticidae/type.h | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 include/salticidae/type.h (limited to 'include/salticidae/type.h') diff --git a/include/salticidae/type.h b/include/salticidae/type.h new file mode 100644 index 0000000..edf38a6 --- /dev/null +++ b/include/salticidae/type.h @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2018 Cornell University. + * + * Author: Ted Yin + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _SALTICIDAE_TYPE_H +#define _SALTICIDAE_TYPE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace salticidae { + +const auto _1 = std::placeholders::_1; +const auto _2 = std::placeholders::_2; + +using bytearray_t = std::vector; +using mutex_lg_t = std::lock_guard; +using mutex_ul_t = std::unique_lock; + +template T htole(T) = delete; +template<> inline uint16_t htole(uint16_t x) { return htole16(x); } +template<> inline uint32_t htole(uint32_t x) { return htole32(x); } +template<> inline uint64_t htole(uint64_t x) { return htole64(x); } + +template T letoh(T) = delete; +template<> inline uint16_t letoh(uint16_t x) { return le16toh(x); } +template<> inline uint32_t letoh(uint32_t x) { return le32toh(x); } +template<> inline uint64_t letoh(uint64_t x) { return le64toh(x); } + +template +struct is_ranged : std::false_type {}; + +template +struct is_ranged().begin()), + decltype(std::declval().end())>> : std::true_type {}; + +} + +#endif -- cgit v1.2.3