Om
pair.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Pair_
16 
17  #include "om/language/pair.hpp"
18 
19 #else
20 
21 // MARK: - Om::Language::Pair
22 
23  #define Type_ \
24  Om::Language::Pair
25 
26 // MARK: public (static)
27 
28 inline Om::Language::Pair const & Type_::GetEmpty() {
29  static Pair thePair;
30  return thePair;
31 }
32 
33 // MARK: public (non-static)
34 
35 inline Type_::~Pair() {}
36 
37 inline Type_::Pair():
38 thisOperator(),
39 thisOperand() {}
40 
41 inline void Type_::ClearOperand() {
42  this->thisOperand.Clear();
43 }
44 
45 inline Om::Language::Operand const & Type_::GetOperand() const {
46  return this->thisOperand;
47 }
48 
49 inline Om::Language::Operator const & Type_::GetOperator() const {
50  return this->thisOperator;
51 }
52 
53 inline void Type_::GiveElements(Consumer & theConsumer) {
54  this->GiveElements(
55  *this,
56  theConsumer
57  );
58  this->thisOperator.Clear();
59  this->thisOperand.Clear();
60 }
61 
62 inline void Type_::GiveElements(Consumer & theConsumer) const {
63  this->GiveElements(
64  *this,
65  theConsumer
66  );
67 }
68 
69 inline bool Type_::IsEmpty() const {
70  return (
71  this->thisOperator.IsEmpty() &&
72  this->thisOperand.IsEmpty()
73  );
74 }
75 
76 template <typename TheOperand>
77 inline void Type_::TakeOperand(TheOperand & theOperand) {
78  this->thisOperand.Take(theOperand);
79 }
80 
81 template <typename TheOperator>
82 inline void Type_::TakeOperator(TheOperator & theOperator) {
83  this->thisOperator.Take(theOperator);
84 }
85 
86 template <typename TheProducer>
87 inline void Type_::TakeQuotedProducer(TheProducer & theProducer) {
88  this->thisOperand.SetProgram(
89  theProducer.GiveProgram()
90  );
91 }
92 
93 // MARK: private (non-static)
94 
95 template <typename ThePair>
96 inline void Type_::GiveElements(
97  ThePair & thePair,
98  Consumer & theConsumer
99 ) {
100  if (
101  !thePair.thisOperator.IsEmpty()
102  ) {
103  theConsumer.TakeElement(thePair.thisOperator);
104  }
105  if (
106  !thePair.thisOperand.IsEmpty()
107  ) {
108  theConsumer.TakeElement(thePair.thisOperand);
109  }
110 }
111 
112  #undef Type_
113 
114 #endif
The Operand implementation.
Definition: operand.hpp:56
The Operator implementation.
Definition: operator.hpp:60
An Operator and an Operand.
Definition: pair.hpp:32
Om header file.