scalar.hpp
#ifndef PROTON_SCALAR_HPP
#define PROTON_SCALAR_HPP
/*
* 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 "./internal/scalar_base.hpp"
namespace proton {
namespace codec {
class decoder;
class encoder;
}
class scalar : public internal::scalar_base {
public:
PN_CPP_EXTERN scalar() {}
template <class T> scalar(const T& x) { *this = x; }
template <class T> scalar& operator=(const T& x) { put(x); return *this; }
bool empty() const { return type() == NULL_TYPE; }
void clear() { *this = null(); }
};
template<class T> T get(const scalar& s) { return internal::get<T>(s); }
template<class T> T coerce(const scalar& x) { return internal::coerce<T>(x); }
template<class T> T coerce(scalar& x) { return internal::coerce<T>(x); }
} // proton
#endif // PROTON_SCALAR_HPP
proton::scalar
A holder for an instance of any scalar AMQP type.
Definition: scalar.hpp:35
proton::scalar::coerce
T coerce(const scalar &x)
Coerce the contained value to type T.
Definition: scalar.hpp:73
proton::NULL_TYPE
The null type, contains no data.
Definition: type_id.hpp:39
proton::scalar::coerce
T coerce(scalar &x)
Coerce the contained value to type T.
Definition: scalar.hpp:86
proton::scalar::operator=
scalar & operator=(const T &x)
Assign from any scalar type.
Definition: scalar.hpp:44
proton::scalar::empty
bool empty() const
True if type() == NULL_TYPE.
Definition: scalar.hpp:47
proton::scalar::clear
void clear()
Clear the scalar, making it empty().
Definition: scalar.hpp:50
proton::scalar::scalar
scalar(const T &x)
Construct from any scalar type.
Definition: scalar.hpp:41
proton::scalar::scalar
scalar()
Create an empty scalar.
Definition: scalar.hpp:38
proton
Type traits for mapping between AMQP and C++ types.
Definition: annotation_key.hpp:28