// The Construct // // Copyright (C) The Construct Developers, Authors & Contributors // Copyright (C) 2016-2020 Jason Volk // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice is present in all copies. The // full license for this software is available in the LICENSE file. #pragma once #define HAVE_IRCD_SPIRIT_EXPECTATION_FAILURE_H namespace ircd { namespace spirit __attribute__((visibility("default"))) { template struct expectation_failure; // parse.cc extern thread_local char rule_buffer[64]; }} template struct __attribute__((visibility("default"))) ircd::spirit::expectation_failure :parent_error { template expectation_failure(const qi::expectation_failure &e, const ssize_t &show_max = 64); template expectation_failure(const qi::expectation_failure &e, const it &start, const ssize_t &show_max = 64); }; template template ircd::spirit::expectation_failure::expectation_failure(const qi::expectation_failure &e, const ssize_t &show_max) :parent { "Expected %s. You input %zd invalid characters :%s", ircd::string(rule_buffer, e.what_), std::distance(e.first, e.last), string_view{e.first, e.first + std::min(std::distance(e.first, e.last), show_max)} } {} template template ircd::spirit::expectation_failure::expectation_failure(const qi::expectation_failure &e, const it &start, const ssize_t &show_max) :parent { "Expected %s. You input %zd invalid characters somewhere between position %zd and %zd :%s", ircd::string(rule_buffer, e.what_), std::distance(e.first, e.last), std::distance(start, e.first), std::distance(start, e.last), string_view{e.first, e.first + std::min(std::distance(e.first, e.last), show_max)} } {}