1169691Skan/* 2169691Skan * File: GlobSectionSelector.h 3169691Skan * 4169691Skan * Copyright (c) Freescale Semiconductor, Inc. All rights reserved. 5169691Skan * See included license file for license details. 6169691Skan */ 7169691Skan#if !defined(_StringMatcher_h_) 8169691Skan#define _StringMatcher_h_ 9169691Skan 10169691Skan#include <string> 11169691Skan 12169691Skannamespace elftosb 13169691Skan{ 14169691Skan 15169691Skan/*! 16169691Skan * \brief Abstract interface class used to select strings by name. 17169691Skan */ 18169691Skanclass StringMatcher 19169691Skan{ 20169691Skanpublic: 21169691Skan //! \brief Performs a single string match test against testValue. 22169691Skan //! 23169691Skan //! \retval true The \a testValue argument matches. 24169691Skan //! \retval false No match was made against the argument. 25169691Skan virtual bool match(const std::string & testValue)=0; 26169691Skan}; 27169691Skan 28169691Skan/*! 29169691Skan * \brief String matcher subclass that matches all test strings. 30169691Skan */ 31169691Skanclass WildcardMatcher : public StringMatcher 32169691Skan{ 33169691Skanpublic: 34169691Skan //! \brief Always returns true, indicating a positive match. 35169691Skan virtual bool match(const std::string & testValue) { return true; } 36169691Skan}; 37169691Skan 38169691Skan/*! 39169691Skan * \brief Simple string matcher that compares against a fixed value. 40169691Skan */ 41169691Skanclass FixedMatcher : public StringMatcher 42169691Skan{ 43169691Skanpublic: 44169691Skan //! \brief Constructor. Sets the string to compare against to be \a fixedValue. 45169691Skan FixedMatcher(const std::string & fixedValue) : m_value(fixedValue) {} 46169691Skan 47169691Skan //! \brief Returns whether \a testValue is the same as the value passed to the constructor. 48169691Skan //! 49169691Skan //! \retval true The \a testValue argument matches the fixed compare value. 50169691Skan //! \retval false The argument is not the same as the compare value. 51169691Skan virtual bool match(const std::string & testValue) 52169691Skan { 53169691Skan return testValue == m_value; 54169691Skan } 55169691Skan 56169691Skanprotected: 57169691Skan const std::string & m_value; //!< The section name to look for. 58169691Skan}; 59169691Skan 60169691Skan}; // namespace elftosb 61169691Skan 62169691Skan#endif // _StringMatcher_h_ 63169691Skan