2 * File: GlobSectionSelector.h
4 * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5 * See included license file for license details.
7 #if !defined(_StringMatcher_h_)
8 #define _StringMatcher_h_
16 * \brief Abstract interface class used to select strings by name.
21 //! \brief Performs a single string match test against testValue.
23 //! \retval true The \a testValue argument matches.
24 //! \retval false No match was made against the argument.
25 virtual bool match(const std::string & testValue)=0;
29 * \brief String matcher subclass that matches all test strings.
31 class WildcardMatcher : public StringMatcher
34 //! \brief Always returns true, indicating a positive match.
35 virtual bool match(const std::string & testValue) { return true; }
39 * \brief Simple string matcher that compares against a fixed value.
41 class FixedMatcher : public StringMatcher
44 //! \brief Constructor. Sets the string to compare against to be \a fixedValue.
45 FixedMatcher(const std::string & fixedValue) : m_value(fixedValue) {}
47 //! \brief Returns whether \a testValue is the same as the value passed to the constructor.
49 //! \retval true The \a testValue argument matches the fixed compare value.
50 //! \retval false The argument is not the same as the compare value.
51 virtual bool match(const std::string & testValue)
53 return testValue == m_value;
57 const std::string & m_value; //!< The section name to look for.
60 }; // namespace elftosb
62 #endif // _StringMatcher_h_