// Copyright (C) 2014-2020 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_SERIALIZABLEARGUMENTS_HPP_ #define COMMONAPI_SERIALIZABLEARGUMENTS_HPP_ #include #include namespace CommonAPI { template struct SerializableArguments; template struct SerializableArguments { static bool serialize(OutputStream &_output) { (void)_output; return true; } static bool deserialize(InputStream &_input) { (void)_input; return true; } }; template struct SerializableArguments { static bool serialize(OutputStream &_output, const ArgumentType_ &_argument) { _output << _argument; return !_output.hasError(); } static bool deserialize(InputStream &_input, ArgumentType_ &_argument) { _input >> _argument; return !_input.hasError(); } }; template struct SerializableArguments { static bool serialize(OutputStream &_output, const ArgumentType_ &_argument, const Rest_&... _rest) { _output << _argument; return !_output.hasError() ? SerializableArguments::serialize(_output, _rest...) : false; } static bool deserialize(InputStream &_input, ArgumentType_ &_argument, Rest_&... _rest) { _input >> _argument; return !_input.hasError() ? SerializableArguments::deserialize(_input, _rest...) : false; } }; } // namespace CommonAPI #endif // COMMONAPI_SERIALIZABLE_ARGUMENTS_HPP_