VapourSynth-llvmexpr
Loading...
Searching...
No Matches
StandardLibrary.cpp
Go to the documentation of this file.
1
19
20#include "StandardLibrary.hpp"
21
22#include <stdexcept>
23#include <string>
24
25namespace infix2postfix {
26
27std::vector<std::string_view>
28StandardLibraryManager::resolveDependencies(std::string_view library_name) {
29 std::vector<std::string_view> result;
30
31 std::apply(
32 [&](auto... libs) {
33 (
34 [&] {
35 using LibType = std::decay_t<decltype(libs)>;
36 if (result.empty() && LibType::NAME == library_name) {
38 std::apply(
39 [&](auto... rs) {
40 (result.push_back(
41 std::decay_t<decltype(rs)>::NAME),
42 ...);
43 },
44 Resolved{});
45 }
46 }(),
47 ...);
48 },
50
51 if (result.empty()) {
52 throw std::runtime_error(std::string("Library '") +
53 std::string(library_name) + "' not found");
54 }
55
56 return result;
57}
58
59std::optional<std::string_view>
60StandardLibraryManager::getLibraryCode(std::string_view library_name) {
61 std::optional<std::string_view> result;
62
63 std::apply(
64 [&](auto... libs) {
65 (
66 [&] {
67 using LibType = std::decay_t<decltype(libs)>;
68 if (!result.has_value() && LibType::NAME == library_name) {
69 result = LibType::CODE;
70 }
71 }(),
72 ...);
73 },
75
76 return result;
77}
78
79std::optional<std::vector<ExportedFunction>>
80StandardLibraryManager::getExports(std::string_view library_name) {
81 std::optional<std::vector<ExportedFunction>> result;
82
83 std::apply(
84 [&](auto... libs) {
85 (
86 [&] {
87 using LibType = std::decay_t<decltype(libs)>;
88 if (!result.has_value() && LibType::NAME == library_name) {
89 std::vector<ExportedFunction> out;
90 out.reserve(std::size(LibType::EXPORTS));
91 for (const auto& e : LibType::EXPORTS) {
92 out.push_back(e);
93 }
94 result = std::move(out);
95 }
96 }(),
97 ...);
98 },
100
101 return result;
102}
103
104} // namespace infix2postfix
static std::optional< std::string_view > getLibraryCode(std::string_view library_name)
static std::optional< std::vector< ExportedFunction > > getExports(std::string_view library_name)
static std::vector< std::string_view > resolveDependencies(std::string_view library_name)
std::tuple< stdlib::Algorithms, stdlib::Meta, stdlib::Std > AllStandardLibraries
typename detail::ResolveOne< Lib, std::tuple<>, std::tuple<> >::type ResolveLibraryDependencies