SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
Attribute.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Common.h"
4 #include "TheoryTypes.h"
5 
6 #include <boost/optional.hpp>
7 
8 namespace smtrat {
9 namespace parser {
10 
11 /**
12  * Represents an Attribute.
13  */
14 class Attribute {
15 public:
17  std::string key;
19 
20  Attribute() {}
21  explicit Attribute(const std::string& key) : key(key) {}
22  Attribute(const std::string& key, const AttributeValue& value) : key(key), value(value) {
23  simplify();
24  }
25  Attribute(const std::string& key, const boost::optional<AttributeValue>& value) : key(key) {
26  if (value.is_initialized()) this->value = value.get();
27  simplify();
28  }
29  //Attribute(const std::string& key, bool value): key(key), value(FormulaT(value ? carl::FormulaType::TRUE : carl::FormulaType::FALSE)) {}
30 
31  bool hasValue() const {
32  return boost::get<boost::spirit::unused_type>(&value) == nullptr;
33  }
34  void simplify() {
35  if (FormulaT* f = boost::get<FormulaT>(&value)) {
36  if (f->is_true()) value = true;
37  else if (f->is_false()) value = false;
38  }
39  }
40 };
41 inline std::ostream& operator<<(std::ostream& os, const Attribute& attr) {
42  os << "(:" << attr.key;
43  if (attr.hasValue()) os << " " << attr.value;
44  return os << ")";
45 }
46 
47 }
48 }
Represents an Attribute.
Definition: Attribute.h:14
Attribute(const std::string &key, const boost::optional< AttributeValue > &value)
Definition: Attribute.h:25
types::AttributeValue AttributeValue
Definition: Attribute.h:16
Attribute(const std::string &key, const AttributeValue &value)
Definition: Attribute.h:22
AttributeValue value
Definition: Attribute.h:18
bool hasValue() const
Definition: Attribute.h:31
Attribute(const std::string &key)
Definition: Attribute.h:21
carl::mpl_variant_of< AttributeTypes >::type AttributeValue
Variant type for all attributes.
Definition: TheoryTypes.h:177
std::ostream & operator<<(std::ostream &os, OptimizationType ot)
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
Definition: types.h:37