Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
apps/elftosb/common/StringMatcher.h
1 /*
2  * File: GlobSectionSelector.h
3  *
4  * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5  * See included license file for license details.
6  */
7 #if !defined(_StringMatcher_h_)
8 #define _StringMatcher_h_
9 
10 #include <string>
11 
12 namespace elftosb
13 {
18 {
19 public:
24  virtual bool match(const std::string &testValue) = 0;
25 };
26 
31 {
32 public:
34  virtual bool match(const std::string &testValue) { return true; }
35 };
36 
41 {
42 public:
44  FixedMatcher(const std::string &fixedValue)
45  : m_value(fixedValue)
46  {
47  }
48 
53  virtual bool match(const std::string &testValue) { return testValue == m_value; }
54 protected:
55  const std::string &m_value;
56 };
57 
58 }; // namespace elftosb
59 
60 #endif // _StringMatcher_h_
String matcher subclass that matches all test strings.
Definition: apps/elftosb/common/StringMatcher.h:30
virtual bool match(const std::string &testValue)=0
Performs a single string match test against testValue.
virtual bool match(const std::string &testValue)
Always returns true, indicating a positive match.
Definition: apps/elftosb/common/StringMatcher.h:34
virtual bool match(const std::string &testValue)
Returns whether testValue is the same as the value passed to the constructor.
Definition: apps/elftosb/common/StringMatcher.h:53
const std::string & m_value
The section name to look for.
Definition: apps/elftosb/common/StringMatcher.h:55
Definition: BootImage.h:13
Simple string matcher that compares against a fixed value.
Definition: apps/elftosb/common/StringMatcher.h:40
Abstract interface class used to select strings by name.
Definition: apps/elftosb/common/StringMatcher.h:17
FixedMatcher(const std::string &fixedValue)
Constructor. Sets the string to compare against to be fixedValue.
Definition: apps/elftosb/common/StringMatcher.h:44