ScaleOut C++ Native Client API  5.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
reference_comparand.h
1 /*
2  Copyright (c) 2013 by ScaleOut Software, Inc.
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #pragma once
18 
19 #include <string>
20 #include <vector>
21 #include <stdint.h>
22 #include <boost/shared_ptr.hpp>
23 
24 #include "soss_client/filter.h"
25 #include "soss_client/query_expression.h"
26 #include "soss_client/expression_comparand.h"
27 
28 namespace sosscli {
29 
30 class ValueComparand;
31 class QueryExpression;
32 
33 namespace internal {
34  class ComparisonExpression;
35 }
36 
63 {
64 public:
65  // We use 'explicit' here so that C++ implicit type conversion will default to converting a string to a ValueOperand
66  // rather than a ReferenceOperand. As a result, an expression like ReferenceComparand("field") == "value" is no
67  // longer ambiguous. It also means that if you want to compare two field values on the server you'd need to write
68  // your expression as
69  //
70  // ReferenceComparand("field_1") == ReferenceComparand("field_2")
71 
75  explicit ReferenceComparand(std::string const & field_name);
76 
80  explicit ReferenceComparand(const char * field_name);
81 
87  Filter operator ==(ValueComparand const & value);
88 
94  Filter operator ==(ReferenceComparand const & field);
95 
101  Filter operator !=(ValueComparand const & value);
102 
108  Filter operator !=(ReferenceComparand const & field);
109 
115  Filter operator >(ValueComparand const & value);
116 
122  Filter operator >(ReferenceComparand const & field);
123 
129  Filter operator >=(ValueComparand const & value);
130 
136  Filter operator >=(ReferenceComparand const & field);
137 
143  Filter operator <(ValueComparand const & value);
144 
150  Filter operator <(ReferenceComparand const & field);
151 
157  Filter operator <=(ValueComparand const & value);
158 
164  Filter operator <=(ReferenceComparand const & field);
165 
171  Filter contains(ValueComparand const & value);
172 
179  Filter contains(ReferenceComparand const & ref);
180 
181  // TODO: HasAnyTag, HasAllTags, HasTags
182 
185  std::string const & field_name() const;
186 
190  virtual void accept(QueryExpression::Visitor & v) const;
191 
192 private:
193  std::string field_name_;
194 };
195 
196 
197 }