Boolean.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012 SCHUNK GmbH & Co. KG
00003  * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *   http://www.apache.org/licenses/LICENSE-2.0
00010 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef UTIL_BOOLEAN_H
00019 #define UTIL_BOOLEAN_H
00020 
00021 #include "Config.h"
00022 
00023 # ifdef __GNUC__
00024 #   if (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
00025                 #include <bool.h>
00026 #   endif
00027 # endif
00028 
00029 #include <vector>
00030 #include <iostream>
00031 
00032 /*
00033         Reads boolean value from an input stream.\\
00034      Is called by work-around of operator
00035                   std::istream& operator>>(std::istream& rclStream, bool& rbBool)
00036          which is missing in some C++-compilers such as
00037          WATCOM and MICROSOFT (see the operator>> itself).
00038         rclStream: reference to input stream from which a boolean value will be read
00039         rbBool: reference to boolean value
00040         reference to the input stream which was passed as argument
00041 */
00042 
00043 inline std::istream& util_readBool(std::istream& rclStream, bool& rbBool)
00044 {
00045 #if defined(NO_ISTREAM_OPERATOR_BOOL)
00046     
00047         #if defined(NO_CAST_FUNCTION_TEMPLATES)
00048 
00049                 int tempL;
00050                 rclStream >> tempL;
00051                 rbBool = bool(tempL);
00052                 return rclStream;
00053     
00054         #else
00055 
00056                 int tempL;
00057                 rclStream >> tempL;
00058                 rbBool = static_cast<bool>(tempL);
00059                 return rclStream;
00060         #endif  // NO_CAST_FUNCTION_TEMPLATES
00061 
00062 #else
00063 
00064         rclStream >> rbBool;
00065         return rclStream;
00066 
00067 #endif  // NO_ISTREAM_OPERATOR_BOOL
00068 };
00069 
00070 /*
00071         Reads boolean value from an input stream.
00072          This inline function represents a workaround
00073          for the following operator
00074                   std::istream& operator>>(std::istream& rclStream, bool& rbBool)
00075          which is missing in some C++-compilers such as
00076          WATCOM and MICROSOFT.}
00077         rclStream: reference to input stream from which a boolean value will be read
00078         rbBool: reference to boolean value
00079         reference to the input stream which was passed as argument
00080 */
00081 
00082 #if defined(NO_ISTREAM_OPERATOR_BOOL)
00083 #if !defined(__HAS_ISTREAM_OPERATOR_BOOL__) && (defined(__WATCOM_CPLUSPLUS__) || defined(_MSC_VER))
00084 
00085 // check of definition __HAS_ISTREAM_OPERATOR_BOOL__ necessary due to
00086 // name clashes with similar LEDA definition (see LEDA/param_types.h)
00087 
00088 inline std::istream& operator>>(std::istream& rclStream, bool& rbBool)
00089 {
00090         return util_readBool(rclStream, rbBool);
00091 };
00092 
00093 #define __HAS_ISTREAM_OPERATOR_BOOL__
00094 #endif
00095 #endif // NO_ISTREAM_OPERATOR_BOOL
00096 
00097 #endif // UTIL_BOOLEAN_H


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Sat Jun 8 2019 20:25:13