summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
Diffstat (limited to 'AK')
-rw-r--r--AK/Compiler.h1
-rw-r--r--AK/String.cpp15
-rw-r--r--AK/String.h2
3 files changed, 18 insertions, 0 deletions
diff --git a/AK/Compiler.h b/AK/Compiler.h
index 0ae775e888..f7ebfa12d6 100644
--- a/AK/Compiler.h
+++ b/AK/Compiler.h
@@ -2,6 +2,7 @@
#define PACKED __attribute__ ((packed))
#define NORETURN __attribute__ ((noreturn))
+#undef ALWAYS_INLINE
#define ALWAYS_INLINE __attribute__ ((always_inline))
#define NEVER_INLINE __attribute__ ((noinline))
#define MALLOC_ATTR __attribute__ ((malloc))
diff --git a/AK/String.cpp b/AK/String.cpp
index e589438c1b..ccc61dd08f 100644
--- a/AK/String.cpp
+++ b/AK/String.cpp
@@ -75,4 +75,19 @@ ByteBuffer String::toByteBuffer() const
return ByteBuffer::copy(reinterpret_cast<const byte*>(characters()), length());
}
+unsigned String::toUInt(bool& ok) const
+{
+ unsigned value = 0;
+ for (size_t i = 0; i < length(); ++i) {
+ if (characters()[i] < '0' || characters()[i] > '9') {
+ ok = false;
+ return 0;
+ }
+ value = value * 10;
+ value += characters()[i] - '0';
+ }
+ ok = true;
+ return value;
+}
+
}
diff --git a/AK/String.h b/AK/String.h
index 023d9f300e..b639fe478c 100644
--- a/AK/String.h
+++ b/AK/String.h
@@ -44,6 +44,8 @@ public:
{
}
+ unsigned toUInt(bool& ok) const;
+
String toLowercase() const
{
if (!m_impl)