]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/pkg/cxx/lib/base/include/string
update
[l4.git] / l4 / pkg / cxx / lib / base / include / string
index 3a94584f43a67d44a3c94e63561c2a676b198180..71c0947e86a2bb4dfbacbd943e198bef1d469a52 100644 (file)
@@ -124,13 +124,13 @@ public:
 
   }
 
-  bool starts_with(cxx::String const &c) const
+  Index starts_with(cxx::String const &c) const
   {
     unsigned long i;
     for (i = 0; i < c._len && i < _len; ++i)
       if (_start[i] != c[i])
-       return false;
-    return i == c._len;
+       return 0;
+    return i == c._len ? start() + i : 0;
   }
 
   char const *find(int c, char const *s) const
@@ -174,6 +174,25 @@ public:
 
   bool eof(char const *s) const { return s >= _start + _len || !*s; }
 
+  template<typename INT>
+  int from_dec(INT *v) const
+  {
+    *v = 0;
+    Index c;
+    for (c = start(); !eof(c); ++c)
+      {
+       unsigned char n;
+       if (*c >= '0' && *c <= '9')
+         n = *c - '0';
+       else
+         return c - start();
+
+        *v *= 10;
+       *v += n;
+      }
+    return c - start();
+  }
+
   template<typename INT>
   int from_hex(INT *v) const
   {
@@ -185,7 +204,6 @@ public:
        shift += 4;
        if (shift > sizeof(INT) * 8)
          return -1;
-        *v <<= 4;
        unsigned char n;
        if (*c >= '0' && *c <= '9')
          n = *c - '0';
@@ -196,6 +214,7 @@ public:
        else
          return c - start();
 
+        *v <<= 4;
        *v |= n;
       }
     return c - start();