Permalink
Browse files

added `exit_reason::as_string`

  • Loading branch information...
1 parent cf4655f commit 9c1b9ca428223c49ffe09aef051cbea4b9a537a9 @Neverlord Neverlord committed Feb 20, 2013
Showing with 55 additions and 0 deletions.
  1. +1 −0 CMakeLists.txt
  2. +1 −0 cppa.files
  3. +2 −0 cppa/exit_reason.hpp
  4. +51 −0 src/exit_reason.cpp
View
@@ -116,6 +116,7 @@ set(LIBCPPA_SRC
src/empty_tuple.cpp
src/event_based_actor.cpp
src/exception.cpp
+ src/exit_reason.cpp
src/factory.cpp
src/fd_util.cpp
src/fiber.cpp
View
@@ -291,3 +291,4 @@ unit_testing/test_uniform_type.cpp
unit_testing/test_yield_interface.cpp
cppa/memory_cached_mixin.hpp
unit_testing/test.cpp
+src/exit_reason.cpp
@@ -82,6 +82,8 @@ static constexpr std::uint32_t remote_link_unreachable = 0x00101;
*/
static constexpr std::uint32_t user_defined = 0x10000;
+const char* as_string(std::uint32_t value);
+
} } // namespace cppa::exit_reason
#endif // CPPA_EXIT_REASON_HPP
View
@@ -0,0 +1,51 @@
+/******************************************************************************\
+ * ___ __ *
+ * /\_ \ __/\ \ *
+ * \//\ \ /\_\ \ \____ ___ _____ _____ __ *
+ * \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
+ * \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
+ * /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
+ * \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
+ * \ \_\ \ \_\ *
+ * \/_/ \/_/ *
+ * *
+ * Copyright (C) 2011-2013 *
+ * Dominik Charousset <dominik.charousset@haw-hamburg.de> *
+ * *
+ * This file is part of libcppa. *
+ * libcppa is free software: you can redistribute it and/or modify it under *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License *
+ * or (at your option) any later version. *
+ * *
+ * libcppa is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public License *
+ * along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
+\******************************************************************************/
+
+
+#include "cppa/exit_reason.hpp"
+
+namespace cppa { namespace exit_reason {
+
+namespace { constexpr const char* s_names_table[] = {
+ "not_exited",
+ "normal",
+ "unhandled_exception",
+ "unallowed_function_call",
+ "unhandled_sync_failure",
+ "unhandled_sync_timeout"
+}; }
+
+const char* as_string(std::uint32_t value) {
+ if (value <= unhandled_sync_timeout) return s_names_table[value];
+ if (value == remote_link_unreachable) return "remote_link_unreachable";
+ if (value >= user_defined) return "user_defined";
+ return "illegal_exit_reason";
+}
+
+} } // namespace cppa::exit_reason

0 comments on commit 9c1b9ca

Please sign in to comment.