diff options
author | Florent Le Coz <louiz@louiz.org> | 2014-11-12 07:52:07 +0100 |
---|---|---|
committer | Florent Le Coz <louiz@louiz.org> | 2014-11-12 08:13:02 +0100 |
commit | c20bdd68796c0fc31441ffe059a462a0d423cc77 (patch) | |
tree | da5111d80473022f66733fa3a6774ebfc64f0989 /src | |
parent | d8da7984b23bf8f30b5f8f53895cbae5be50347a (diff) | |
download | biboumi-c20bdd68796c0fc31441ffe059a462a0d423cc77.tar.gz biboumi-c20bdd68796c0fc31441ffe059a462a0d423cc77.tar.bz2 biboumi-c20bdd68796c0fc31441ffe059a462a0d423cc77.tar.xz biboumi-c20bdd68796c0fc31441ffe059a462a0d423cc77.zip |
Add utils::revstr
Diffstat (limited to 'src')
-rw-r--r-- | src/test.cpp | 4 | ||||
-rw-r--r-- | src/utils/revstr.cpp | 9 | ||||
-rw-r--r-- | src/utils/revstr.hpp | 11 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/test.cpp b/src/test.cpp index 1b7a873..59c0a1e 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -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 */ diff --git a/src/utils/revstr.cpp b/src/utils/revstr.cpp new file mode 100644 index 0000000..87fd801 --- /dev/null +++ b/src/utils/revstr.cpp @@ -0,0 +1,9 @@ +#include <utils/revstr.hpp> + +namespace utils +{ + std::string revstr(const std::string& original) + { + return {original.rbegin(), original.rend()}; + } +} diff --git a/src/utils/revstr.hpp b/src/utils/revstr.hpp new file mode 100644 index 0000000..0f00076 --- /dev/null +++ b/src/utils/revstr.hpp @@ -0,0 +1,11 @@ +#ifndef REVSTRP_INCLUDED +# define REVSTR_INCLUDED + +#include <string> + +namespace utils +{ + std::string revstr(const std::string& original); +} + +#endif // REVSTR_INCLUDED |