#include <enum2str.h>
Collaboration diagram for Dv::Util::enum_parser< E >:
Static Public Member Functions | |
const char * | enum2str (E e) throw (std::logic_error) |
Convert enum value to string. | |
E | str2enum (const std::string &s) throw (std::logic_error) |
Convert string to enum value. | |
Static Public Attributes | |
enum_entry | enum_table [] |
Table containing one enum_entry for each E value, as well as a sentinel entry (with s=0). | |
const char * | E_NAME |
Name of enum type, should be defined by user. |
Example:
const char* Dv::Util::enum_parser<X>::E_NAME("X"); // "name" of enum type X Dv::Util::enum_parser<X>::enum_entry Dv::Util::enum_parser<X>::enum_table[] = { { A, "A" }, { B, "B" }, { C, "C" }, { A, 0 } // should end with 0 in 2nd component of last array element! }; std::cout << Dv::Util::enum2str(A) << std::endl; std::cout << Dv::Util::str2enum<X>("A") << std::endl;
Definition at line 28 of file enum2str.h.
|
Convert enum value to string.
References Dv::Util::enum_parser< E >::enum_entry::e, Dv::Util::enum_parser< E >::E_NAME, Dv::Util::enum_parser< E >::enum_table, Dv::Util::enum_parser< E >::enum_entry::s, and Dv::Util::tostring(). |
|
Convert string to enum value.
References Dv::Util::enum_parser< E >::enum_entry::e, Dv::Util::enum_parser< E >::E_NAME, Dv::Util::enum_parser< E >::enum_table, and Dv::Util::enum_parser< E >::enum_entry::s. |
|
Table containing one enum_entry for each E value, as well as a sentinel entry (with s=0). Definition at line 35 of file enum2str.h. Referenced by Dv::Util::enum_parser< E >::enum2str(), and Dv::Util::enum_parser< E >::str2enum(). |
|
Name of enum type, should be defined by user. Definition at line 37 of file enum2str.h. Referenced by Dv::Util::enum_parser< E >::enum2str(), and Dv::Util::enum_parser< E >::str2enum(). |
dvutil-0.13.15 | [30 December, 2004] |