mirror of
https://github.com/matrix-construct/construct
synced 2024-11-11 12:31:07 +01:00
ircd::spirit: Split substring_view into header.
This commit is contained in:
parent
f68e4886e8
commit
c9ec0b3923
3 changed files with 53 additions and 22 deletions
|
@ -23,6 +23,7 @@
|
|||
#include <ircd/ircd.h>
|
||||
#include <ircd/spirit/boost.h>
|
||||
#include <ircd/spirit/spirit.h>
|
||||
#include <ircd/spirit/substring_view.h>
|
||||
#include <ircd/spirit/expectation_failure.h>
|
||||
#include <ircd/spirit/custom_parser.h>
|
||||
#include <ircd/spirit/parse.h>
|
||||
|
|
|
@ -19,8 +19,6 @@ namespace ircd {
|
|||
namespace spirit
|
||||
__attribute__((visibility("internal")))
|
||||
{
|
||||
struct substring_view;
|
||||
|
||||
template<class rule,
|
||||
class... attr>
|
||||
bool parse(const char *&start, const char *const &stop, rule&&, attr&&...);
|
||||
|
@ -36,26 +34,6 @@ __attribute__((visibility("internal")))
|
|||
bool parse(std::nothrow_t, const char *&start, const char *const &stop, rule&&, attr&&...) noexcept;
|
||||
}}
|
||||
|
||||
struct [[clang::internal_linkage]]
|
||||
ircd::spirit::substring_view
|
||||
:ircd::string_view
|
||||
{
|
||||
using _iterator = const char *;
|
||||
using _iterator_range = boost::iterator_range<_iterator>;
|
||||
using _indirect_iterator = karma::detail::indirect_iterator<_iterator>;
|
||||
using _indirect_iterator_range = boost::iterator_range<_indirect_iterator>;
|
||||
|
||||
explicit substring_view(const _iterator_range &range)
|
||||
:ircd::string_view(std::addressof(*range.begin()), std::addressof(*range.end()))
|
||||
{}
|
||||
|
||||
explicit substring_view(const _indirect_iterator_range &range)
|
||||
:ircd::string_view(std::addressof(*range.begin()), std::addressof(*range.end()))
|
||||
{}
|
||||
|
||||
using ircd::string_view::string_view;
|
||||
};
|
||||
|
||||
/// Execute the parse. The start pointer is advanced upon successful execution.
|
||||
/// Failures must not throw: If the grammar contains any epsilon expressions or
|
||||
/// callbacks which throw it is UB. This overload exists to force suppression
|
||||
|
|
52
include/ircd/spirit/substring_view.h
Normal file
52
include/ircd/spirit/substring_view.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
// The Construct
|
||||
//
|
||||
// Copyright (C) The Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2022 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_SUBSTRING_VIEW_H
|
||||
|
||||
// This file is not part of the IRCd standard include list (stdinc.h) because
|
||||
// it involves extremely expensive boost headers for creating formal spirit
|
||||
// grammars. This file is automatically included in the spirit.h group.
|
||||
|
||||
namespace ircd::spirit
|
||||
{
|
||||
struct substring_view;
|
||||
}
|
||||
|
||||
struct ircd::spirit::substring_view
|
||||
:ircd::string_view
|
||||
{
|
||||
using _iterator = const char *;
|
||||
using _iterator_range = boost::iterator_range<_iterator>;
|
||||
using _indirect_iterator = karma::detail::indirect_iterator<_iterator>;
|
||||
using _indirect_iterator_range = boost::iterator_range<_indirect_iterator>;
|
||||
|
||||
explicit substring_view(const _indirect_iterator_range &range);
|
||||
explicit substring_view(const _iterator_range &range);
|
||||
using ircd::string_view::string_view;
|
||||
};
|
||||
|
||||
inline
|
||||
ircd::spirit::substring_view::substring_view(const _iterator_range &range)
|
||||
:ircd::string_view
|
||||
{
|
||||
std::addressof(*range.begin()),
|
||||
std::addressof(*range.end())
|
||||
}
|
||||
{}
|
||||
|
||||
inline
|
||||
ircd::spirit::substring_view::substring_view(const _indirect_iterator_range &range)
|
||||
:ircd::string_view
|
||||
{
|
||||
std::addressof(*range.begin()),
|
||||
std::addressof(*range.end())
|
||||
}
|
||||
{}
|
Loading…
Reference in a new issue