LMCAS
Lamina Computer Algebra System
Toggle main menu visibility
载入中...
搜索中...
未找到
query_support.hpp
浏览该文件的文档.
1
#pragma once
2
3
#include <utility>
4
5
#include "
query_interface.hpp
"
6
#include "
internal/symbolic_ast.hpp
"
7
8
namespace
LMCAS::query_detail
{
9
10
11
template
<
typename
T,
typename
Query>
12
Result<T>
checked_expression_result
(
13
const
SymbolicExpr& expr,
14
const
std::string& operation,
15
Query&& query) {
16
if
(!
LMCAS::detail::node
(expr)) {
17
return
Result<T>::failure
(
18
CasErrc::InvalidArgument
,
"query expression must not be null"
, operation);
19
}
20
try
{
21
return
Result<T>::success
(std::forward<Query>(query)());
22
}
catch
(
const
std::bad_alloc&) {
23
return
Result<T>::failure
(
24
CasErrc::ResourceLimit
,
"query allocation failed"
, operation);
25
}
catch
(
const
std::exception& ex) {
26
return
Result<T>::failure
(
CasErrc::InternalInvariant
, ex.what(), operation);
27
}
28
}
29
30
template
<
typename
Query>
31
auto
checked_expression_result
(
32
const
SymbolicExpr& expr,
33
const
std::string& operation,
34
Query&& query) ->
decltype
(std::forward<Query>(query)()) {
35
using
ResultType =
decltype
(std::forward<Query>(query)());
36
if
(!
LMCAS::detail::node
(expr)) {
37
return
ResultType::failure(
38
CasErrc::InvalidArgument
,
"query expression must not be null"
, operation);
39
}
40
try
{
41
return
std::forward<Query>(query)();
42
}
catch
(
const
std::bad_alloc&) {
43
return
ResultType::failure(
44
CasErrc::ResourceLimit
,
"query allocation failed"
, operation);
45
}
catch
(
const
std::exception& ex) {
46
return
ResultType::failure(
47
CasErrc::InternalInvariant
, ex.what(), operation);
48
}
49
}
50
51
}
LMCAS::Result
定义
result.hpp:39
LMCAS::Result::failure
static Result failure(CasErrc code, std::string message, std::string operation={})
定义
result.hpp:52
LMCAS::Result::success
static Result success(T value)
定义
result.hpp:48
LMCAS::detail::node
const SymbolicNodePtr & node(const ::LMCAS::SymbolicExpr &expression) noexcept
定义
base.hpp:91
LMCAS::query_detail
定义
query_support.hpp:8
LMCAS::query_detail::checked_expression_result
Result< T > checked_expression_result(const SymbolicExpr &expr, const std::string &operation, Query &&query)
定义
query_support.hpp:12
LMCAS::CasErrc::InvalidArgument
@ InvalidArgument
定义
result.hpp:13
LMCAS::CasErrc::InternalInvariant
@ InternalInvariant
定义
result.hpp:28
LMCAS::CasErrc::ResourceLimit
@ ResourceLimit
定义
result.hpp:25
query_interface.hpp
QueryInterface class - unified tri-state query API for property questions on arbitrary expressions.
symbolic_ast.hpp
内部 AST 定义。
src
internal
query_support.hpp
生成于
, 为 LMCAS使用
1.18.0