Repository :
http://git.fedorahosted.org/cgit/firewalld-recode.git
On branch : master
---------------------------------------------------------------
commit 959b7a39e4c70415e38914ad1435a4a30c12fe9b
Author: Daniel Kopecek <dkopecek(a)redhat.com>
Date: Tue Dec 9 17:49:27 2014 +0100
Extended the numberToString function
It's now possible to specify a prefix and the numeric
base of the string representation of the number.
---------------------------------------------------------------
src/Common/Utility.hpp | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/src/Common/Utility.hpp b/src/Common/Utility.hpp
index dd12b64..cf0b590 100644
--- a/src/Common/Utility.hpp
+++ b/src/Common/Utility.hpp
@@ -27,6 +27,7 @@
#include <vector>
#include <sstream>
#include <regex>
+#include <iomanip>
#include <sys/types.h>
#include <dirent.h>
@@ -104,9 +105,13 @@ namespace firewalld
* representation.
*/
template<typename T>
- String numberToString(T number)
+ String numberToString(T number, const String& prefix = String(), int base = 10)
{
std::ostringstream ss;
+ if (!prefix.empty()) {
+ ss << prefix;
+ }
+ ss << std::setbase(base);
ss << number;
return ss.str();
}