diff options
author | Robert Gemmell <robbie@apache.org> | 2015-06-25 10:22:51 +0000 |
---|---|---|
committer | Robert Gemmell <robbie@apache.org> | 2015-06-25 10:22:51 +0000 |
commit | 32ae758bc2e8fd962b66a4ab6341b14009f1907e (patch) | |
tree | 2f4d8174813284a6ea58bb6b7f6520aa92287476 /qpid/cpp/src/qpid/broker/SelectorValue.h | |
parent | 116d91ad7825a98af36a869fc751206fbce0c59f (diff) | |
parent | f7e896076143de4572b4f1f67ef0765125f2498d (diff) | |
download | qpid-python-32ae758bc2e8fd962b66a4ab6341b14009f1907e.tar.gz |
NO-JIRA: create branch for qpid-cpp 0.34 RC process
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/qpid-cpp-0.34-rc@1687469 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qpid/broker/SelectorValue.h')
-rw-r--r-- | qpid/cpp/src/qpid/broker/SelectorValue.h | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/qpid/cpp/src/qpid/broker/SelectorValue.h b/qpid/cpp/src/qpid/broker/SelectorValue.h new file mode 100644 index 0000000000..3a731fd000 --- /dev/null +++ b/qpid/cpp/src/qpid/broker/SelectorValue.h @@ -0,0 +1,121 @@ +#ifndef QPID_BROKER_SELECTORVALUE_H +#define QPID_BROKER_SELECTORVALUE_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/sys/IntegerTypes.h" + +#include <iosfwd> +#include <string> + +namespace qpid { +namespace broker { + +enum BoolOrNone { + BN_FALSE = false, + BN_TRUE = true, + BN_UNKNOWN +}; + +// The user of the Value class for strings must ensure that +// the string has a lifetime longer than the string used and +// is responsible for managing its lifetime. +class Value { +public: + union { + bool b; + int64_t i; + double x; + const std::string* s; + }; + enum { + T_UNKNOWN, + T_BOOL, + T_STRING, + T_EXACT, + T_INEXACT + } type; + + // Default copy contructor + // Default assignment operator + // Default destructor + Value() : + type(T_UNKNOWN) + {} + + Value(const std::string& s0) : + s(&s0), + type(T_STRING) + {} + + Value(const int64_t i0) : + i(i0), + type(T_EXACT) + {} + + Value(const int32_t i0) : + i(i0), + type(T_EXACT) + {} + + Value(const double x0) : + x(x0), + type(T_INEXACT) + {} + + Value(bool b0) : + b(b0), + type(T_BOOL) + {} + + Value(BoolOrNone bn) : + b(bn), + type(bn==BN_UNKNOWN ? T_UNKNOWN : T_BOOL) + {} +}; + +inline bool unknown(const Value& v) { + return v.type == Value::T_UNKNOWN; +} + +inline bool numeric(const Value& v) { + return v.type == Value::T_EXACT || v.type == Value::T_INEXACT; +} + +std::ostream& operator<<(std::ostream& os, const Value& v); + +bool operator==(const Value&, const Value&); +bool operator!=(const Value&, const Value&); +bool operator<(const Value&, const Value&); +bool operator>(const Value&, const Value&); +bool operator<=(const Value&, const Value&); +bool operator>=(const Value&, const Value&); + +Value operator+(const Value&, const Value&); +Value operator-(const Value&, const Value&); +Value operator*(const Value&, const Value&); +Value operator/(const Value&, const Value&); +Value operator-(const Value&); + +}} + +#endif |