11 namespace error_model {
19 const std::string &name,
20 const std::string ¶m_types
23 param_types(types::
from_spec(param_types))
55 namespace primitives {
62 map.append_string(
"n", obj->name);
63 auto aw = map.append_array(
"t");
64 for (
const auto &t : obj->param_types) {
72 if (!map.count(
"n")) {
75 auto model = tree::make<error_model::ErrorModel>(map.at(
"n").as_string(),
"");
76 auto ar = map.at(
"t").as_array();
77 for (
size_t i = 0; i < ar.size(); i++) {
78 model->param_types.add(::tree::base::deserialize<types::Node>(ar.at(i).as_binary()));
80 return std::move(model);
tree::Maybe< ErrorModel > ErrorModelRef
Optional reference to an error model, used within the semantic tree.
std::string name
The name of the error model.
types::Types param_types
The vector of parameter types that this error model expects.
This file contains the ErrorModel class and support types, each instance representing an error model ...
error_model::ErrorModelRef deserialize(const ::tree::cbor::MapReader &map)
Deserializes the given primitive object from CBOR.
Types from_spec(const std::string &spec)
Constructs a set of types from a shorthand string representation.
Toplevel namespace with entry points for the new API.
Defines various utility functions.
Defines the types for the cQASM semantic tree, based on the classes from cqasm::tree.
void serialize(const error_model::ErrorModelRef &obj, ::tree::cbor::MapWriter &map)
Representation of an error model.
Namespace for the "new" cQASM 1.x API.
bool case_insensitive_equals(const std::string &lhs, const std::string &rhs)
Case-insensitive string compare.
std::ostream & operator<<(std::ostream &os, const ErrorModel &model)
Stream << overload for error models.
ErrorModel(const std::string &name, const std::string ¶m_types="")
Creates a new error model.
bool operator==(const ErrorModel &rhs) const
Equality operator.