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

Unified Diff: compiled/storage/Parser.h

Issue 29548581: Issue 4128, 5138 - Add Parser and Serializer implemented in C++ Base URL: https://github.com/adblockplus/adblockpluscore.git
Patch Set: Created Sept. 18, 2017, 5:23 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
Index: compiled/storage/Parser.h
diff --git a/compiled/storage/Parser.h b/compiled/storage/Parser.h
new file mode 100644
index 0000000000000000000000000000000000000000..7c446f860a385f3b13e9f52421760aee910f2ac4
--- /dev/null
+++ b/compiled/storage/Parser.h
@@ -0,0 +1,65 @@
+/*
+* This file is part of Adblock Plus <https://adblockplus.org/>,
+* Copyright (C) 2006-present eyeo GmbH
+*
+* Adblock Plus is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 3 as
+* published by the Free Software Foundation.
+*
+* Adblock Plus is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#pragma once
+#include "../subscription/Subscription.h"
+
+class Parser : public ref_counted
+{
+ enum class State
+ {
+ Initial, SubscriptionSection, SubscriptionFiltersSection
+ };
+ ~Parser() {}
+public:
+ typedef std::vector<SubscriptionPtr> Subscriptions;
+ Parser();
+ static Parser* BINDINGS_EXPORTED Create()
+ {
+ return new Parser();
+ }
+ void BINDINGS_EXPORTED Process(const String& untrimmedLine);
+ void BINDINGS_EXPORTED Finalize();
+
+ Subscriptions::size_type BINDINGS_EXPORTED GetSubscriptionCount() const;
+ Subscription* BINDINGS_EXPORTED SubscriptionAt(Subscriptions::size_type index);
+private:
+ SubscriptionPtr createSubscriptionFromProperties() const;
+
+ void Initial_processLine(const String& line);
+ void SubscriptionSection_processLine(const String& line);
+ void SubscriptionFiltersSection_processLine(const String& line);
+
+ void onSubscription(SubscriptionPtr subscription);
+
+ void onFail(const char* error)
+ {
Wladimir Palant 2017/12/21 10:30:37 I assume that this is supposed to do something if
+ }
+private:
+ // parser members:
+ State mCurrentState;
+ Subscriptions mSubscriptions;
+
+ // State memebers:
+ // Initial State
+ // it's also the parser member
+ Subscription::KeyValues mFileProperties;
+ // [Subscription] section
+ Subscription::KeyValues mSubscriptionProperties;
+ // [Subscription filters] section
+ SubscriptionPtr mSubscription;
+};

Powered by Google App Engine
This is Rietveld