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

Side by Side Diff: compiled/subscription/UserDefinedSubscription.cpp

Issue 29385742: Issue 4127 - [emscripten] Convert subscription classes to C++ - Part 2 (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Rebased Created April 13, 2017, 1:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « compiled/subscription/UserDefinedSubscription.h ('k') | test/subscriptionClasses.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 void UserDefinedSubscription::MakeDefaultFor(const Filter* filter) 63 void UserDefinedSubscription::MakeDefaultFor(const Filter* filter)
64 { 64 {
65 if (filter->mType >= Filter::Type::VALUE_COUNT) 65 if (filter->mType >= Filter::Type::VALUE_COUNT)
66 { 66 {
67 assert(false, "Filter type exceeds valid range"); 67 assert(false, "Filter type exceeds valid range");
68 abort(); 68 abort();
69 } 69 }
70 mDefaults |= filterTypeToCategory[filter->mType]; 70 mDefaults |= filterTypeToCategory[filter->mType];
71 } 71 }
72 72
73 void UserDefinedSubscription::InsertFilterAt(Filter* filter, unsigned pos)
74 {
75 if (pos >= mFilters.size())
76 mFilters.emplace_back(filter);
77 else
78 mFilters.emplace(mFilters.begin() + pos, filter);
79 }
80
81 bool UserDefinedSubscription::RemoveFilterAt(unsigned pos)
82 {
83 if (pos >= mFilters.size())
84 return false;
85
86 mFilters.erase(mFilters.begin() + pos);
87 return true;
88 }
89
73 OwnedString UserDefinedSubscription::Serialize() const 90 OwnedString UserDefinedSubscription::Serialize() const
74 { 91 {
75 OwnedString result(Subscription::Serialize()); 92 OwnedString result(Subscription::Serialize());
76 if (mDefaults) 93 if (mDefaults)
77 { 94 {
78 result.append(u"defaults="_str); 95 result.append(u"defaults="_str);
79 if (mDefaults & FilterCategory::BLOCKING) 96 if (mDefaults & FilterCategory::BLOCKING)
80 result.append(u" blocking"_str); 97 result.append(u" blocking"_str);
81 if (mDefaults & FilterCategory::WHITELIST) 98 if (mDefaults & FilterCategory::WHITELIST)
82 result.append(u" whitelist"_str); 99 result.append(u" whitelist"_str);
83 if (mDefaults & FilterCategory::ELEMHIDE) 100 if (mDefaults & FilterCategory::ELEMHIDE)
84 result.append(u" elemhide"_str); 101 result.append(u" elemhide"_str);
85 result.append(u'\n'); 102 result.append(u'\n');
86 } 103 }
87 return result; 104 return result;
88 } 105 }
OLDNEW
« no previous file with comments | « compiled/subscription/UserDefinedSubscription.h ('k') | test/subscriptionClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld