libtenum
include/tenum/detail/stream.hpp File Reference
Include dependency graph for stream.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define TENUM_STREAM_OPERATORS_DECLARATION(type_m)
#define TENUM_STREAM_OPERATORS_DEFINITION(type_m)
 Expands to templated stream operator definition for the type_m enum.

Detailed Description

Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt

Definition in file stream.hpp.


Define Documentation

#define TENUM_STREAM_OPERATORS_DECLARATION (   type_m)
Value:
template< typename OutputStream > \
static inline OutputStream& operator<<(OutputStream& ostream, TENUM_TYPE(type_m) const enum_in); \
template< typename InputStream > \
static inline InputStream& operator>>(InputStream& istream, TENUM_TYPE(type_m)& enum_out);

Definition at line 17 of file stream.hpp.

#define TENUM_STREAM_OPERATORS_DEFINITION (   type_m)
Value:
template< typename OutputStream > \
static inline OutputStream& operator<<(OutputStream& ostream, TENUM_TYPE(type_m) const enum_in) { \
  ostream << ::tenum::enum_helper< TENUM_TYPE(type_m) >::serialize(enum_in); \
  return ostream; \
} \
\
template< typename InputStream > \
static inline InputStream& operator>>(InputStream& istream, TENUM_TYPE(type_m)& enum_out) { \
  ::std::string enum_string; \
  istream >> enum_string; \
  enum_out = ::tenum::enum_helper< TENUM_TYPE(type_m) >::deserialize(enum_string); \
  return istream; \
}

Expands to templated stream operator definition for the type_m enum.

The stream operators use tenum::enum_helper (de)serialize methods to convert type_m enum to string and string to type_m enum. The input stream operator uses a temporary string to store the enum value, and will read the content of the stream up to the first white space character in this string before converting it to type_m enum. Therefore, serialized enum values should never contain white spaces.

Definition at line 32 of file stream.hpp.

 All Classes Namespaces Files Functions Defines