Bug 1885602 - Part 5: Implement navigating to the SUMO help topic from the menu heade...
[gecko.git] / toolkit / crashreporter / CrashAnnotations.cpp
blob87a9ac594e1ffcb5d6cdd1b1dd1932cdbf1c1891
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "CrashAnnotations.h"
7 #include <algorithm>
8 #include <cstring>
9 #include <iterator>
11 using std::begin;
12 using std::end;
13 using std::find_if;
15 namespace CrashReporter {
17 bool AnnotationFromString(Annotation& aResult, const char* aValue) {
18 const auto* elem = find_if(
19 begin(kAnnotationStrings), end(kAnnotationStrings),
20 [&aValue](const char* aString) { return strcmp(aString, aValue) == 0; });
22 if (elem == end(kAnnotationStrings)) {
23 return false;
26 aResult = static_cast<Annotation>(elem - begin(kAnnotationStrings));
27 return true;
30 bool IsAnnotationAllowedForPing(Annotation aAnnotation) {
31 const auto* elem = find_if(
32 begin(kCrashPingAllowedList), end(kCrashPingAllowedList),
33 [&aAnnotation](Annotation aElement) { return aElement == aAnnotation; });
35 return elem != end(kCrashPingAllowedList);
38 bool ShouldIncludeAnnotation(Annotation aAnnotation, const char* aValue) {
39 const auto* elem = find_if(begin(kSkipIfList), end(kSkipIfList),
40 [&aAnnotation](AnnotationSkipValue aElement) {
41 return aElement.annotation == aAnnotation;
42 });
44 if (elem != end(kSkipIfList)) {
45 if (strcmp(aValue, elem->value) == 0) {
46 return false;
50 return true;
53 } // namespace CrashReporter