#ifndef OBFS_STRING #define OBFS_STRING #include "random.hpp" #include "sequence.hpp" #include namespace obfs { using Encoder = char(*)(char); using Decoder = char(*)(char); template class String { public: template constexpr String(char const* str, std::index_sequence): str{ encoder(str[Idx])... } { // Do Nothing } inline char const* decode() const { for (char& chr : str) { chr = decoder(chr); } return str; } private: mutable char str[size]; }; template constexpr auto make_string(char const (&str)[size]) { return String(str, std::make_index_sequence()); } template using encoder_seq = Sequence; template using decoder_seq = Sequence; template using make_table = SeqPack; template using encoder_pair = Sequence; template using make_pair_table = TypeSeq; template constexpr auto make_string(char const(&str)[size]) { using pair = typename Table::template index; constexpr Encoder encoder = pair::template index<0>::value; constexpr Decoder decoder = pair::template index<1>::value; return make_string(str); } } #define MAKE_STRING(Var, String, ...) constexpr auto Var = obfs::make_string<__VA_ARGS__>(String); #endif