summaryrefslogtreecommitdiff
path: root/src/util/regexp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/regexp.h')
-rw-r--r--src/util/regexp.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util/regexp.h b/src/util/regexp.h
index 4c69592d4..4d12803ff 100644
--- a/src/util/regexp.h
+++ b/src/util/regexp.h
@@ -354,6 +354,27 @@ public:
ret_vec.insert( ret_vec.end(), itr, itr + j );
return String(ret_vec);
}
+ bool isNumber() const {
+ for(unsigned int i=0; i<d_str.size(); ++i) {
+ char c = convertUnsignedIntToChar( d_str[i] );
+ if(c<'0' || c>'9') {
+ return false;
+ }
+ }
+ return true;
+ }
+ int toNumber() const {
+ if(isNumber()) {
+ int ret=0;
+ for(unsigned int i=0; i<d_str.size(); ++i) {
+ char c = convertUnsignedIntToChar( d_str[i] );
+ ret = ret * 10 + (int)c - (int)'0';
+ }
+ return ret;
+ } else {
+ return -1;
+ }
+ }
};/* class String */
namespace strings {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback