1 //===- StrToken.h ---------------------------------------------------------===// 2 // 3 // The MCLinker Project 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 #ifndef MCLD_SCRIPT_STRTOKEN_H 10 #define MCLD_SCRIPT_STRTOKEN_H 11 12 #include <mcld/Support/Allocators.h> 13 #include <mcld/Config/Config.h> 14 #include <string> 15 16 namespace mcld 17 { 18 19 /** \class StrToken 20 * \brief This class defines the interfaces to a element in EXCLUDE_FILE list 21 * or in Output Section Phdr, or be a base class of other str token. 22 */ 23 24 class StrToken 25 { 26 public: 27 enum Kind { 28 Unknown, 29 String, 30 Input, 31 Wildcard 32 }; 33 34 private: 35 friend class Chunk<StrToken, MCLD_SYMBOLS_PER_INPUT>; 36 protected: 37 StrToken(); 38 StrToken(Kind pKind, const std::string& pString); 39 40 public: 41 virtual ~StrToken(); 42 kind()43 Kind kind() const { return m_Kind; } 44 name()45 const std::string& name() const { return m_Name; } 46 classof(const StrToken * pToken)47 static bool classof(const StrToken* pToken) 48 { 49 return pToken->kind() == StrToken::String; 50 } 51 52 /* factory method */ 53 static StrToken* create(const std::string& pString); 54 static void destroy(StrToken*& pToken); 55 static void clear(); 56 57 private: 58 Kind m_Kind; 59 std::string m_Name; 60 }; 61 62 } // namepsace of mcld 63 64 #endif 65