ScaleOut C++ Native Client API  5.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
value_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 <ostream>
21 #include <vector>
22 #include <stdint.h>
23 #include <boost/shared_ptr.hpp>
24 
25 #include "soss_client/filter.h"
26 #include "soss_client/query_expression.h"
27 #include "soss_client/expression_comparand.h"
28 
29 namespace sosscli {
30 
31 namespace internal { class ValueHolder; class TypeSignature; class IndexValueWriter; }
32 class ReferenceComparand;
33 
58 {
59 
60 public:
61 
64  ValueComparand(std::string const & value);
65 
68  ValueComparand(char const * value);
69 
72  ValueComparand(wchar_t const * value);
73 
76  ValueComparand(std::wstring const & value);
77 
81  ValueComparand(uint8_t const * value, size_t length);
82 
85  ValueComparand(std::vector<uint8_t> const & value);
86 
90  ValueComparand(sosscli::internal::TypeSignature const & value);
91 
94  ValueComparand(int32_t value);
95 
98  ValueComparand(uint32_t value);
99 
102  ValueComparand(int64_t value);
103 
106  ValueComparand(uint64_t value);
107 
110  ValueComparand(double value);
111 
114  ValueComparand(float value);
115 
118  ValueComparand(bool value);
119 
125  Filter operator ==(ReferenceComparand const & field_ref);
126 
132  Filter operator !=(ReferenceComparand const & field_ref);
133 
139  Filter operator >(ReferenceComparand const & field_ref);
140 
146  Filter operator >=(ReferenceComparand const & field_ref);
147 
153  Filter operator <(ReferenceComparand const & field_ref);
154 
160  Filter operator <=(ReferenceComparand const & field_ref);
161 
168  Filter contains(ReferenceComparand const & ref);
169 
175  static ValueComparand null();
176 
179  int type_code() const;
180 
183  bool is_string_type() const;
184 
188  virtual void accept(QueryExpression::Visitor & v) const;
189 
194  friend std::ostream & operator << (std::ostream & o, ValueComparand const & p);
195 
203  void allocate_value(sosscli::internal::IndexValueWriter & writer) const;
204 
216  void allocate_value_as(sosscli::internal::IndexValueWriter & writer, int type_code) const;
217 
225  int write_value(sosscli::internal::IndexValueWriter & writer) const;
226 
236  int write_value_as(sosscli::internal::IndexValueWriter & writer, int type_code) const;
237 
238 private:
240  ValueComparand(boost::shared_ptr<sosscli::internal::ValueHolder> value_p);
241 
243  boost::shared_ptr<sosscli::internal::ValueHolder> value_p_;
244 };
245 
246 }