sbuild-personality.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef SBUILD_PERSONALITY_H
00020 #define SBUILD_PERSONALITY_H
00021
00022 #include <sbuild/sbuild-custom-error.h>
00023
00024 #include <map>
00025 #include <ostream>
00026 #include <string>
00027
00028 namespace sbuild
00029 {
00030
00040 class personality
00041 {
00042 public:
00044 typedef unsigned long type;
00045
00047 enum error_code
00048 {
00049 BAD,
00050 SET
00051 };
00052
00054 typedef custom_error<error_code> error;
00055
00061 personality ();
00062
00068 personality (std::string const& persona);
00069
00071 ~personality ();
00072
00078 std::string const& get_name () const;
00079
00086 void set_name (std::string const& persona);
00087
00093 type
00094 get () const;
00095
00101 void
00102 set () const;
00103
00109 static std::string
00110 get_personalities ();
00111
00119 template <class charT, class traits>
00120 friend
00121 std::basic_istream<charT,traits>&
00122 operator >> (std::basic_istream<charT,traits>& stream,
00123 personality& rhs)
00124 {
00125 std::string personality_name;
00126
00127 if (std::getline(stream, personality_name))
00128 {
00129 rhs.set_name(personality_name);
00130 }
00131
00132 return stream;
00133 }
00134
00142 template <class charT, class traits>
00143 friend
00144 std::basic_ostream<charT,traits>&
00145 operator << (std::basic_ostream<charT,traits>& stream,
00146 personality const& rhs)
00147 {
00148 return stream << find_personality(rhs.persona);
00149 }
00150
00151 private:
00160 static type
00161 find_personality (std::string const& persona);
00162
00170 static std::string const&
00171 find_personality (type persona);
00172
00174 std::string persona_name;
00175
00177 type persona;
00178
00180 static std::map<std::string,type> personalities;
00181 };
00182
00183 }
00184
00185 #endif
00186
00187
00188
00189
00190
00191