12#include "utils/lsyscache.h"
16#include <unordered_set>
25int parse_int_strict(
const std::string &s,
bool &ok) {
27 if (s.empty())
return 0;
30 int v = std::stoi(s, &idx);
31 if (idx != s.size())
return 0;
40double parse_double_strict(
const std::string &s,
bool &ok) {
42 if (s.empty())
return 0.0;
45 double v = std::stod(s, &idx);
46 if (idx != s.size())
return 0.0;
81 const auto &w = c.
getWires(semimod_gate);
82 if (w.size() != 2)
return false;
86 m_out = parse_int_strict(c.
getExtra(w[1]), ok);
87 if (!ok)
return false;
112 int v = parse_int_strict(c.
getExtra(w[1]), ok);
128 double v = parse_double_strict(c.
getExtra(x), ok);
138 std::vector<gate_t> out;
139 std::vector<gate_t> stack;
140 stack.push_back(start);
142 std::unordered_set<gate_t> seen;
144 while (!stack.empty()) {
145 gate_t cur = stack.back();
148 if (!seen.insert(cur).second)
continue;
152 if (cw.size() == 2) {
167 for (
gate_t ch : w) stack.push_back(ch);
ComparisonOperator cmpOpFromOid(Oid op_oid, bool &ok)
Map a PostgreSQL comparison-operator OID to a ComparisonOperator.
ComparisonOperator
SQL comparison operators used in gate_cmp circuit gates.
@ LE
Less than or equal (<=).
@ GE
Greater than or equal (>=).
gate_t
Strongly-typed gate identifier.
std::vector< gate_t > & getWires(gate_t g)
Return a mutable reference to the child-wire list of gate g.
gateType getGateType(gate_t g) const
Return the type of gate g.
In-memory provenance circuit with semiring-generic evaluation.
std::string getExtra(gate_t g) const
Return the string extra for gate g.
std::pair< unsigned, unsigned > getInfos(gate_t g) const
Return the integer annotation pair for gate g.
Provenance evaluation helper for HAVING-clause circuits.
bool extract_constant_C(GenericCircuit &c, gate_t x, int &C_out)
bool extract_constant_double(GenericCircuit &c, gate_t x, double &C_out)
ComparisonOperator flip_op(ComparisonOperator op)
std::vector< gate_t > collect_sp_cmp_gates(GenericCircuit &c, gate_t start)
bool semimod_extract_M_and_K(GenericCircuit &c, gate_t semimod_gate, int &m_out, gate_t &k_gate_out)
ComparisonOperator map_cmp_op(GenericCircuit &c, gate_t cmp_gate, bool &ok)