Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_iostream_helpers.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_IOSTREAM_HELPERS_HPP
11 #define TEUCHOS_IOSTREAM_HELPERS_HPP
12 
13 
19 #include "Teuchos_Assert.hpp"
20 
21 
22 namespace Teuchos {
23 
24 
25 template<class EnumType>
26 std::istream& enumIstreamExtractor(std::istream& std_is, EnumType& enum_value)
27 {
28  int intval;
29  std_is >> intval;
30  enum_value = static_cast<EnumType>(intval);
31  return std_is;
32 }
33 
34 
35 } // namespace Teuchos
36 
37 
38 #define TEUCHOS_ENUM_INPUT_STREAM_OPERATOR(ENUMTYPE) \
39 inline \
40 std::istream& operator>>(std::istream& std_is, ENUMTYPE& enum_value) \
41 { return Teuchos::enumIstreamExtractor(std_is, enum_value); }
42 
43 
44 #endif // TEUCHOS_IOSTREAM_HELPERS_HPP
std::istream & enumIstreamExtractor(std::istream &std_is, EnumType &enum_value)