• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/Config/Config.h"
13 #include "mcld/Support/Allocators.h"
14 
15 #include <string>
16 
17 namespace mcld {
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  public:
26   enum Kind { Unknown, String, Input, Wildcard };
27 
28  private:
29   friend class Chunk<StrToken, MCLD_SYMBOLS_PER_INPUT>;
30 
31  protected:
32   StrToken();
33   StrToken(Kind pKind, const std::string& pString);
34 
35  public:
36   virtual ~StrToken();
37 
kind()38   Kind kind() const { return m_Kind; }
39 
name()40   const std::string& name() const { return m_Name; }
41 
classof(const StrToken * pToken)42   static bool classof(const StrToken* pToken) {
43     return pToken->kind() == StrToken::String;
44   }
45 
46   /* factory method */
47   static StrToken* create(const std::string& pString);
48   static void destroy(StrToken*& pToken);
49   static void clear();
50 
51  private:
52   Kind m_Kind;
53   std::string m_Name;
54 };
55 
56 }  // namespace mcld
57 
58 #endif  // MCLD_SCRIPT_STRTOKEN_H_
59