Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: compiled/String.h

Issue 29556737: Issue 5141 - Convert filter match to C++ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Fixed many issues. One test left out. Created Oct. 6, 2017, 1:45 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | compiled/StringMap.h » ('j') | compiled/StringMap.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 DependentString;
+class ReMatchResults;
+
class String
{
friend class DependentString;
friend class OwnedString;
public:
typedef char16_t value_type;
typedef size_t size_type;
@@ -186,16 +192,21 @@
if (currChar >= u'A' && currChar <= u'Z')
mBuf[i] = currChar + u'a' - u'A';
else if (currChar >= 128)
{
mBuf[i] = CharToLower(currChar);
}
}
}
+
+ bool match(int id, ReMatchResults& results) const
+ {
+ return MatchRegExp(id, *this, results);
+ }
Wladimir Palant 2017/10/09 08:39:45 This functionality doesn't belong here, it isn't b
sergei 2017/10/09 15:27:51 I would suggest for the beginning simply remove th
};
class DependentString : public String
{
public:
explicit DependentString()
: String(nullptr, 0, INVALID)
{
@@ -400,8 +411,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
+{
+public:
+ void BINDINGS_EXPORTED push(const String& s)
+ {
+ candidates.push_back(OwnedString(s));
+ }
+ std::vector<OwnedString> candidates;
+};
« no previous file with comments | « no previous file | compiled/StringMap.h » ('j') | compiled/StringMap.h » ('J')

Powered by Google App Engine
This is Rietveld