# HG changeset patch # User Teemu Piippo # Date 1418681744 -7200 # Node ID 481073b016a998f5ca49cc7b00c154720c6e90cf # Parent 874bbfa55da802fc9193e05b78fef5b79ef55557 - added timestamps to output - removed the silly shouldExit stuff diff -r 874bbfa55da8 -r 481073b016a9 sources/basics.h --- a/sources/basics.h Tue Dec 16 00:05:27 2014 +0200 +++ b/sources/basics.h Tue Dec 16 00:15:44 2014 +0200 @@ -63,7 +63,6 @@ using Function = std::function; FUNCTION print_to_console (String a) -> void; -FUNCTION request_exit() -> void; template inline FUNCTION clamp (T a, T b, T c) -> T diff -r 874bbfa55da8 -r 481073b016a9 sources/interface.cpp --- a/sources/interface.cpp Tue Dec 16 00:05:27 2014 +0200 +++ b/sources/interface.cpp Tue Dec 16 00:15:44 2014 +0200 @@ -29,6 +29,7 @@ */ #include +#include #include "interface.h" #include "network/rconsession.h" #include "network/ipaddress.h" @@ -916,6 +917,17 @@ continue; } + if (g_output[g_output.size() - 1].length() == 0) + { + time_t now; + time (&now); + char timestamp[32]; + strftime (timestamp, sizeof timestamp, "[%H:%M:%S] ", localtime (&now)); + + for (char* cp = timestamp; *cp != '\0'; ++cp) + g_output[g_output.size() - 1].add_char (*cp); + } + g_output[g_output.size() - 1].add_char (ch); } diff -r 874bbfa55da8 -r 481073b016a9 sources/list.h --- a/sources/list.h Tue Dec 16 00:05:27 2014 +0200 +++ b/sources/list.h Tue Dec 16 00:15:44 2014 +0200 @@ -68,9 +68,11 @@ auto find (const T& needle) const -> ConstIterator; auto find (Function func) -> Iterator; auto find (Function func) const -> ConstIterator; + auto first() -> T&; auto first() const -> const T&; auto insert (int pos, const T& value) -> void; auto is_empty() const -> bool; + auto last() -> T&; auto last() const -> const T&; auto merge (const Self& other) -> void; auto pop (T& val) -> bool; @@ -484,6 +486,14 @@ // ------------------------------------------------------------------------------------------------- // template +auto Container::first() -> T& +{ + return *m_container.begin(); +} + +// ------------------------------------------------------------------------------------------------- +// +template auto Container::first() const -> const T& { return *m_container.cbegin(); @@ -492,6 +502,14 @@ // ------------------------------------------------------------------------------------------------- // template +auto Container::last() -> T& +{ + return *(m_container.end() - 1); +} + +// ------------------------------------------------------------------------------------------------- +// +template auto Container::last() const -> const T& { return *(m_container.cend() - 1); diff -r 874bbfa55da8 -r 481073b016a9 sources/main.cpp --- a/sources/main.cpp Tue Dec 16 00:05:27 2014 +0200 +++ b/sources/main.cpp Tue Dec 16 00:15:44 2014 +0200 @@ -35,8 +35,6 @@ #include "huffman/huffman.h" #include "interface.h" -static bool g_shouldExit = false; - // ------------------------------------------------------------------------------------------------- // FUNCTION @@ -60,9 +58,6 @@ { for (;;) { - if (g_shouldExit) - break; - fd_set fdset; int highest = 0; timeval timeout; @@ -98,11 +93,3 @@ return EXIT_SUCCESS; } - -// ------------------------------------------------------------------------------------------------- -// -FUNCTION -request_exit() -> void -{ - g_shouldExit = true; -}