Index: compiled/String.h |
=================================================================== |
--- a/compiled/String.h |
+++ b/compiled/String.h |
@@ -16,22 +16,28 @@ |
*/ |
#pragma once |
#include <algorithm> |
#include <cstddef> |
#include <cstring> |
#include <type_traits> |
+#include <vector> |
#include "debug.h" |
#include "library.h" |
+#include "intrusive_ptr.h" |
+#include "bindings/runtime.h" |
inline void String_assert_writable(bool isWritable); |
+class OwnedString; |
+class ReMatchResults; |
+ |
class String |
{ |
friend class DependentString; |
friend class OwnedString; |
public: |
typedef char16_t value_type; |
typedef size_t size_type; |
@@ -186,16 +192,19 @@ |
if (currChar >= u'A' && currChar <= u'Z') |
mBuf[i] = currChar + u'a' - u'A'; |
else if (currChar >= 128) |
{ |
mBuf[i] = CharToLower(currChar); |
} |
} |
} |
+ |
+ OwnedString substr(size_type pos, size_type len = npos) const; |
+ bool match(int id, ReMatchResults*) const; |
hub
2017/09/26 21:48:59
String API that mimic JS string API.
|
}; |
class DependentString : public String |
{ |
public: |
explicit DependentString() |
: String(nullptr, 0, INVALID) |
{ |
@@ -400,8 +409,19 @@ |
for (int i = size - 1; i >= 0; i--) |
{ |
mBuf[pos + i] = '0' + (num % 10); |
num /= 10; |
} |
} |
}; |
+ |
+// Utility class to get match from JS code in library.js |
+class ReMatchResults : public ref_counted |
hub
2017/09/26 21:48:59
This it the hack to be able to get the array of st
sergei
2017/10/02 12:02:32
I thin it's fine, I had experienced a demand in so
|
+{ |
+public: |
+ void BINDINGS_EXPORTED push(OwnedString&& s) |
+ { |
+ candidates.push_back(s); |
+ } |
+ std::vector<OwnedString> candidates; |
+}; |