Boolean.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 SCHUNK GmbH & Co. KG
3  * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef UTIL_BOOLEAN_H
19 #define UTIL_BOOLEAN_H
20 
21 #include "Config.h"
22 
23 # ifdef __GNUC__
24 # if (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
25  #include <bool.h>
26 # endif
27 # endif
28 
29 #include <vector>
30 #include <iostream>
31 
32 /*
33  Reads boolean value from an input stream.\\
34  Is called by work-around of operator
35  std::istream& operator>>(std::istream& rclStream, bool& rbBool)
36  which is missing in some C++-compilers such as
37  WATCOM and MICROSOFT (see the operator>> itself).
38  rclStream: reference to input stream from which a boolean value will be read
39  rbBool: reference to boolean value
40  reference to the input stream which was passed as argument
41 */
42 
43 inline std::istream& util_readBool(std::istream& rclStream, bool& rbBool)
44 {
45 #if defined(NO_ISTREAM_OPERATOR_BOOL)
46 
47  #if defined(NO_CAST_FUNCTION_TEMPLATES)
48 
49  int tempL;
50  rclStream >> tempL;
51  rbBool = bool(tempL);
52  return rclStream;
53 
54  #else
55 
56  int tempL;
57  rclStream >> tempL;
58  rbBool = static_cast<bool>(tempL);
59  return rclStream;
60  #endif // NO_CAST_FUNCTION_TEMPLATES
61 
62 #else
63 
64  rclStream >> rbBool;
65  return rclStream;
66 
67 #endif // NO_ISTREAM_OPERATOR_BOOL
68 };
69 
70 /*
71  Reads boolean value from an input stream.
72  This inline function represents a workaround
73  for the following operator
74  std::istream& operator>>(std::istream& rclStream, bool& rbBool)
75  which is missing in some C++-compilers such as
76  WATCOM and MICROSOFT.}
77  rclStream: reference to input stream from which a boolean value will be read
78  rbBool: reference to boolean value
79  reference to the input stream which was passed as argument
80 */
81 
82 #if defined(NO_ISTREAM_OPERATOR_BOOL)
83 #if !defined(__HAS_ISTREAM_OPERATOR_BOOL__) && (defined(__WATCOM_CPLUSPLUS__) || defined(_MSC_VER))
84 
85 // check of definition __HAS_ISTREAM_OPERATOR_BOOL__ necessary due to
86 // name clashes with similar LEDA definition (see LEDA/param_types.h)
87 
88 inline std::istream& operator>>(std::istream& rclStream, bool& rbBool)
89 {
90  return util_readBool(rclStream, rbBool);
91 };
92 
93 #define __HAS_ISTREAM_OPERATOR_BOOL__
94 #endif
95 #endif // NO_ISTREAM_OPERATOR_BOOL
96 
97 #endif // UTIL_BOOLEAN_H
std::istream & util_readBool(std::istream &rclStream, bool &rbBool)
Definition: Boolean.h:43


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Mon Nov 25 2019 03:48:19