M src/test.cpp => src/test.cpp +4 -0
@@ 10,6 10,7 @@
#include <config/config.hpp>
#include <bridge/colors.hpp>
#include <utils/tolower.hpp>
+#include <utils/revstr.hpp>
#include <irc/irc_user.hpp>
#include <utils/split.hpp>
#include <xmpp/jid.hpp>
@@ 161,6 162,9 @@ int main()
std::cout << lowercase << std::endl;
assert(lowercase == "coucou les copains ♥");
+ const std::string ltr = "coucou";
+ assert(utils::revstr(ltr) == "uocuoc");
+
/**
* XML parsing
*/
A src/utils/revstr.cpp => src/utils/revstr.cpp +9 -0
@@ 0,0 1,9 @@
+#include <utils/revstr.hpp>
+
+namespace utils
+{
+ std::string revstr(const std::string& original)
+ {
+ return {original.rbegin(), original.rend()};
+ }
+}
A src/utils/revstr.hpp => src/utils/revstr.hpp +11 -0
@@ 0,0 1,11 @@
+#ifndef REVSTRP_INCLUDED
+# define REVSTR_INCLUDED
+
+#include <string>
+
+namespace utils
+{
+ std::string revstr(const std::string& original);
+}
+
+#endif // REVSTR_INCLUDED