From 6c463fcc3dcee619925f08ea09e19a86b9e581cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Gehring?= Date: Thu, 11 Jun 2015 06:57:47 -0700 Subject: CommonAPI 3.1.1 --- include/CommonAPI/InputStream.hpp | 241 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 include/CommonAPI/InputStream.hpp (limited to 'include/CommonAPI/InputStream.hpp') diff --git a/include/CommonAPI/InputStream.hpp b/include/CommonAPI/InputStream.hpp new file mode 100644 index 0000000..f5cbc12 --- /dev/null +++ b/include/CommonAPI/InputStream.hpp @@ -0,0 +1,241 @@ +// Copyright (C) 2013-2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef COMMONAPI_INPUT_STREAM_HPP_ +#define COMMONAPI_INPUT_STREAM_HPP_ + +#include + +#include +#include +#include +#include +#include +#include +#include + +namespace CommonAPI { + +template +class InputStream { +public: + template + InputStream &readValue(bool &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(int8_t &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(int16_t &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(int32_t &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(int64_t &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(uint8_t &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(uint16_t &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(uint32_t &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(uint64_t &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(float &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(double &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(std::string &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(Enumeration<_Base> &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(Struct<_Types...> &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(std::shared_ptr<_PolymorphicStruct> &_value, + const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(Variant<_Types...> &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(std::vector<_ElementType> &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(std::unordered_map<_KeyType, _ValueType, _HasherType> &_value, + const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + template + InputStream &readValue(Version &_value, const _Deployment *_depl = nullptr) { + return get()->readValue(_value, _depl); + } + + bool hasError() const { + return get()->hasError(); + } + +private: + inline _Derived *get() { + return static_cast<_Derived *>(this); + } + + inline const _Derived *get() const { + return static_cast(this); + } +}; + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, bool &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, int8_t &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, int16_t &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, int32_t &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, int64_t &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, uint8_t &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, uint16_t &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, uint32_t &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, uint64_t &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, float &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, double &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, std::string &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, Version &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, Enumeration<_Base> &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, Struct<_Types...> &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, std::shared_ptr<_PolymorphicStruct> &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> & operator>>(InputStream<_Derived> &_input, Variant<_Types...> &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, std::vector<_ElementType> &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, std::unordered_map<_KeyType, _ValueType, _HasherType> &_value) { + return _input.template readValue(_value); +} + +template +InputStream<_Derived> &operator>>(InputStream<_Derived> &_input, Deployable<_Type, _TypeDeployment> &_value) { + return _input.template readValue<_TypeDeployment>(_value.getValue(), _value.getDepl()); +} + +} // namespace CommonAPI + +#endif // COMMONAPI_INPUT_STREAM_HPP_ -- cgit v1.2.1