X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FUtil.cc;h=a97ffe50a591baa91a3ec11b54109c4e51a61dfb;hb=5377e3fde108da56894185716d47c3058032b97f;hp=0300e52bb0ee279e66f3f0611bb3749ff49bc5c0;hpb=8794d357e67abddf9fda9db77b235e294d0ec590;p=chaz%2Fopenbox diff --git a/src/Util.cc b/src/Util.cc index 0300e52b..a97ffe50 100644 --- a/src/Util.cc +++ b/src/Util.cc @@ -220,3 +220,24 @@ timeval normalizeTimeval(const timeval &tm) { return ret; } + + +string itostring(unsigned long i) { + if (i == 0) + return string("0"); + + string tmp; + for (; i > 0; i /= 10) + tmp.insert(tmp.begin(), "0123456789"[i%10]); + return tmp; +} + + +string itostring(long i) { + if (i < 0) { + std::string tmp = itostring( (unsigned long) -i); + tmp.insert(tmp.begin(), '-'); + return tmp; + } else + return itostring( (unsigned long) i); +}