diff options
| author | Paul Buetow <paul@buetow.org> | 2010-11-21 17:01:59 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2010-11-21 17:01:59 +0000 |
| commit | b891420946d5269cc326d67555c6aab3db41a01a (patch) | |
| tree | f6c5e7d6dbf18ec8c0ea9ec0b037251df46b4cbb /ycurses/src/curses/tool.cpp | |
| parent | a537e8323d932125232c305f9573daef89aef0df (diff) | |
added yhttpd and ycurses trunk versions
Diffstat (limited to 'ycurses/src/curses/tool.cpp')
| -rw-r--r-- | ycurses/src/curses/tool.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ycurses/src/curses/tool.cpp b/ycurses/src/curses/tool.cpp new file mode 100644 index 0000000..1bce76f --- /dev/null +++ b/ycurses/src/curses/tool.cpp @@ -0,0 +1,37 @@ +#ifndef TOOL_CPP +#define TOOL_CPP + +#include "tool.h" + +string +tool::int2string(int i_int) +{ + char buf[64]; + sprintf(buf, "%d", i_int); + return buf; +} + +int +tool::string2int(string s) +{ + const char *p = s.c_str(); + int i_res = 0; + + // Convert each digit char and add into result. + while (*p >= '0' && *p <='9') + { + i_res = (i_res * 10) + (*p - '0'); + p++; + } + + // Check that there were no non-digits at end. + if (*p != 0) + { + return -1; + } + + return i_res; +} + +#endif + |
