apps/elftosb/common/StringMatcher.h
/*
* File: GlobSectionSelector.h
*
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
* See included license file for license details.
*/
#if !defined(_StringMatcher_h_)
#define _StringMatcher_h_
#include <string>
namespace elftosb
{
class StringMatcher
{
public:
virtual bool match(const std::string &testValue) = 0;
};
class WildcardMatcher : public StringMatcher
{
public:
virtual bool match(const std::string &testValue) { return true; }
};
class FixedMatcher : public StringMatcher
{
public:
FixedMatcher(const std::string &fixedValue)
: m_value(fixedValue)
{
}
virtual bool match(const std::string &testValue) { return testValue == m_value; }
protected:
const std::string &m_value;
};
}; // namespace elftosb
#endif // _StringMatcher_h_
elftosb::WildcardMatcher
String matcher subclass that matches all test strings.
Definition: apps/elftosb/common/StringMatcher.h:30
elftosb::StringMatcher::match
virtual bool match(const std::string &testValue)=0
Performs a single string match test against testValue.
elftosb::WildcardMatcher::match
virtual bool match(const std::string &testValue)
Always returns true, indicating a positive match.
Definition: apps/elftosb/common/StringMatcher.h:34
elftosb::FixedMatcher::match
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
elftosb::FixedMatcher::m_value
const std::string & m_value
The section name to look for.
Definition: apps/elftosb/common/StringMatcher.h:55
elftosb
Definition: BootImage.h:13
elftosb::FixedMatcher
Simple string matcher that compares against a fixed value.
Definition: apps/elftosb/common/StringMatcher.h:40
elftosb::StringMatcher
Abstract interface class used to select strings by name.
Definition: apps/elftosb/common/StringMatcher.h:17
elftosb::FixedMatcher::FixedMatcher
FixedMatcher(const std::string &fixedValue)
Constructor. Sets the string to compare against to be fixedValue.
Definition: apps/elftosb/common/StringMatcher.h:44