matcher_util.h revision d54f9dd6251c7bd7033630b7afa770190d41c409
1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef MATCHER_UTIL_H 18#define MATCHER_UTIL_H 19 20#include <log/log_read.h> 21#include <log/logprint.h> 22#include <set> 23#include <string> 24#include <unordered_map> 25#include <vector> 26#include "frameworks/base/cmds/statsd/src/stats_log.pb.h" 27#include "frameworks/base/cmds/statsd/src/statsd_config.pb.h" 28 29namespace android { 30namespace os { 31namespace statsd { 32 33typedef struct { 34 int tagId; 35 long timestamp_ns; 36 std::unordered_map<int, long> intMap; 37 std::unordered_map<int, std::string> strMap; 38 std::unordered_map<int, bool> boolMap; 39 std::unordered_map<int, float> floatMap; 40 41 std::string toString() const; 42} LogEventWrapper; 43 44enum MatchingState { 45 kNotComputed = -1, 46 kNotMatched = 0, 47 kMatched = 1, 48}; 49 50LogEventWrapper parseLogEvent(log_msg msg); 51 52bool combinationMatch(const std::vector<int>& children, const LogicalOperation& operation, 53 const std::vector<MatchingState>& matcherResults); 54 55bool matchesSimple(const SimpleLogEntryMatcher& simpleMatcher, const LogEventWrapper& wrapper); 56 57} // namespace statsd 58} // namespace os 59} // namespace android 60#endif // MATCHER_UTIL_H 61