Module: sems Branch: master Commit: bdc30b757a0cd920836c000107631b5cbb9e3d51 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=bdc30b757a0cd920836c000107631b5cbb9e3d51
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Mon Dec 13 03:46:12 2010 +0100 b/f: unsigned int2str function save for big ones --- core/AmUtils.cpp | 16 ++++++++++++++++ core/AmUtils.h | 4 ++++ 2 files changed, 20 insertions(+), 0 deletions(-) diff --git a/core/AmUtils.cpp b/core/AmUtils.cpp index 3c1b58c..29c024e 100644 --- a/core/AmUtils.cpp +++ b/core/AmUtils.cpp @@ -68,6 +68,22 @@ static char _int2str_lookup[] = { '0', '1', '2', '3', '4', '5', '6' , '7', '8', '9' }; + +string int2str(unsigned int val) +{ + char buffer[64] = {0}; + int i=62; + lldiv_t d; + + d.quot = val; + do{ + d = lldiv(d.quot,10); + buffer[i] = _int2str_lookup[d.rem]; + }while(--i && d.quot); + + return string((char*)(buffer+i+1)); +} + string int2str(int val) { char buffer[64] = {0,0}; diff --git a/core/AmUtils.h b/core/AmUtils.h index 6b9562c..6b7e1e5 100644 --- a/core/AmUtils.h +++ b/core/AmUtils.h @@ -49,6 +49,10 @@ using std::string; */ string int2str(int val); +/** + * Convert an unsigned int to a string. + */ +string int2str(unsigned int val); /** * Convert a long to a string. _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
