/* * Copyright 2015 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkRecordPattern_DEFINED #define SkRecordPattern_DEFINED #include "include/private/base/SkTLogic.h" #include "src/core/SkRecord.h" namespace SkRecords { // First, some matchers. These match a single command in the SkRecord, // and may hang onto some data from it. If so, you can get the data by calling .get(). // Matches a command of type T, and stores that command. template <typename T> class Is { … }; // Matches any command that draws, and stores its paint. class IsDraw { … }; // Matches any command that draws *once* (logically), and stores its paint. class IsSingleDraw { … }; // Matches if Matcher doesn't. Stores nothing. template <typename Matcher> struct Not { … }; // Matches if any of First or Rest... does. Stores nothing. template <typename First, typename... Rest> struct Or { … }; Or<First>; // Greedy is a special matcher that greedily matches Matcher 0 or more times. Stores nothing. template <typename Matcher> struct Greedy { … }; // Pattern matches each of its matchers in order. // // This is the main entry point to pattern matching, and so provides a couple of extra API bits: // - search scans through the record to look for matches; // - first, second, third, ... return the data stored by their respective matchers in the pattern. template <typename... Matchers> class Pattern; template <> class Pattern<> { … }; Pattern<First, Rest...>; } // namespace SkRecords #endif//SkRecordPattern_DEFINED