2020-08-30 00:25:41 +02:00
|
|
|
// The Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) The Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2020 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// 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")))
|
|
|
|
{
|
2020-10-31 09:15:57 +01:00
|
|
|
template<class parent_error>
|
|
|
|
struct expectation_failure;
|
2020-08-30 00:25:41 +02:00
|
|
|
|
|
|
|
// parse.cc
|
2020-10-31 09:15:57 +01:00
|
|
|
extern thread_local char rule_buffer[128];
|
2020-08-30 00:25:41 +02:00
|
|
|
}}
|
|
|
|
|
|
|
|
template<class parent_error>
|
|
|
|
struct __attribute__((visibility("default")))
|
|
|
|
ircd::spirit::expectation_failure
|
|
|
|
:parent_error
|
|
|
|
{
|
|
|
|
template<class it = const char *>
|
|
|
|
expectation_failure(const qi::expectation_failure<it> &e,
|
2020-10-31 09:15:57 +01:00
|
|
|
const ssize_t &show_max = 128);
|
2020-08-30 00:25:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
template<class parent>
|
|
|
|
template<class it>
|
2020-11-24 04:44:16 +01:00
|
|
|
[[gnu::noinline]]
|
2020-08-30 00:25:41 +02:00
|
|
|
ircd::spirit::expectation_failure<parent>::expectation_failure(const qi::expectation_failure<it> &e,
|
|
|
|
const ssize_t &show_max)
|
|
|
|
:parent
|
|
|
|
{
|
2020-10-31 09:15:57 +01:00
|
|
|
"expected %s with %zu characters remaining '%s'...",
|
2020-08-30 00:25:41 +02:00
|
|
|
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)}
|
|
|
|
}
|
|
|
|
{}
|