Boolean.h
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003  * 
00004  * Copyright (c) 2012 
00005  * 
00006  * SCHUNK GmbH & Co. KG
00007  *  
00008  * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
00009  * 
00010  * Project name: Drivers for "Amtec M5 Protocol" Electronics V4
00011  *                                                                        
00012  * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
00013  * 
00014  * Email:robotics@schunk.com
00015  * 
00016  * ToDo: 
00017  * 
00018  * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
00019  * 
00020  * Redistribution and use in source and binary forms, with or without 
00021  * modification, are permitted provided that the following conditions are met: 
00022  * 
00023  *  * Redistributions of source code must retain the above copyright 
00024  *    notice, this list of conditions and the following disclaimer. 
00025  *  * Redistributions in binary form must reproduce the above copyright 
00026  *    notice, this list of conditions and the following disclaimer in the 
00027  *    documentation and/or other materials provided with the distribution. 
00028  *  * Neither the name of SCHUNK GmbH & Co. KG nor the names of its 
00029  *    contributors may be used to endorse or promote products derived from 
00030  *    this software without specific prior written permission. 
00031  * 
00032  * This program is free software: you can redistribute it and/or modify 
00033  * it under the terms of the GNU Lesser General Public License LGPL as 
00034  * published by the Free Software Foundation, either version 3 of the 
00035  * License, or (at your option) any later version. 
00036  * 
00037  * This program is distributed in the hope that it will be useful, 
00038  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00039  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
00040  * GNU Lesser General Public License LGPL for more details. 
00041  * 
00042  * You should have received a copy of the GNU Lesser General Public 
00043  * License LGPL along with this program. 
00044  * If not, see <http://www.gnu.org/licenses/>.
00045  * 
00046  ******************************************************************************/
00047 
00048 
00049 #ifndef UTIL_BOOLEAN_H
00050 #define UTIL_BOOLEAN_H
00051 
00052 #include "Config.h"
00053 
00054 # ifdef __GNUC__
00055 #   if (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
00056                 #include <bool.h>
00057 #   endif
00058 # endif
00059 
00060 #include <vector>
00061 #include <iostream>
00062 
00063 /*
00064         Reads boolean value from an input stream.\\
00065      Is called by work-around of operator
00066                   std::istream& operator>>(std::istream& rclStream, bool& rbBool)
00067          which is missing in some C++-compilers such as
00068          WATCOM and MICROSOFT (see the operator>> itself).
00069         rclStream: reference to input stream from which a boolean value will be read
00070         rbBool: reference to boolean value
00071         reference to the input stream which was passed as argument
00072 */
00073 
00074 inline std::istream& util_readBool(std::istream& rclStream, bool& rbBool)
00075 {
00076 #if defined(NO_ISTREAM_OPERATOR_BOOL)
00077     
00078         #if defined(NO_CAST_FUNCTION_TEMPLATES)
00079 
00080                 int tempL;
00081                 rclStream >> tempL;
00082                 rbBool = bool(tempL);
00083                 return rclStream;
00084     
00085         #else
00086 
00087                 int tempL;
00088                 rclStream >> tempL;
00089                 rbBool = static_cast<bool>(tempL);
00090                 return rclStream;
00091         #endif  // NO_CAST_FUNCTION_TEMPLATES
00092 
00093 #else
00094 
00095         rclStream >> rbBool;
00096         return rclStream;
00097 
00098 #endif  // NO_ISTREAM_OPERATOR_BOOL
00099 };
00100 
00101 /*
00102         Reads boolean value from an input stream.
00103          This inline function represents a workaround
00104          for the following operator
00105                   std::istream& operator>>(std::istream& rclStream, bool& rbBool)
00106          which is missing in some C++-compilers such as
00107          WATCOM and MICROSOFT.}
00108         rclStream: reference to input stream from which a boolean value will be read
00109         rbBool: reference to boolean value
00110         reference to the input stream which was passed as argument
00111 */
00112 
00113 #if defined(NO_ISTREAM_OPERATOR_BOOL)
00114 #if !defined(__HAS_ISTREAM_OPERATOR_BOOL__) && (defined(__WATCOM_CPLUSPLUS__) || defined(_MSC_VER))
00115 
00116 // check of definition __HAS_ISTREAM_OPERATOR_BOOL__ necessary due to
00117 // name clashes with similar LEDA definition (see LEDA/param_types.h)
00118 
00119 inline std::istream& operator>>(std::istream& rclStream, bool& rbBool)
00120 {
00121         return util_readBool(rclStream, rbBool);
00122 };
00123 
00124 #define __HAS_ISTREAM_OPERATOR_BOOL__
00125 #endif
00126 #endif // NO_ISTREAM_OPERATOR_BOOL
00127 
00128 #endif // UTIL_BOOLEAN_H


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Mon Oct 6 2014 07:30:34