1 //===- WildcardPattern.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_WILDCARDPATTERN_H
10 #define MCLD_SCRIPT_WILDCARDPATTERN_H
11 
12 #include <mcld/Script/StrToken.h>
13 #include <mcld/Support/Allocators.h>
14 #include <mcld/Config/Config.h>
15 #include <llvm/ADT/StringRef.h>
16 
17 namespace mcld
18 {
19 
20 /** \class WildcardPattern
21  *  \brief This class defines the interfaces to Input Section Wildcard Patterns
22  */
23 
24 class WildcardPattern : public StrToken
25 {
26 public:
27   enum SortPolicy {
28     SORT_NONE,
29     SORT_BY_NAME,
30     SORT_BY_ALIGNMENT,
31     SORT_BY_NAME_ALIGNMENT,
32     SORT_BY_ALIGNMENT_NAME,
33     SORT_BY_INIT_PRIORITY
34   };
35 
36 private:
37   friend class Chunk<WildcardPattern, MCLD_SYMBOLS_PER_INPUT>;
38   WildcardPattern();
39   WildcardPattern(const std::string& pPattern, SortPolicy pPolicy);
40 
41 public:
42   ~WildcardPattern();
43 
sortPolicy()44   SortPolicy sortPolicy() const { return m_SortPolicy; }
45 
isPrefix()46   bool isPrefix() const { return m_bIsPrefix; }
47 
48   llvm::StringRef prefix() const;
49 
classof(const StrToken * pToken)50   static bool classof(const StrToken* pToken)
51   {
52     return pToken->kind() == StrToken::Wildcard;
53   }
54 
55   /* factory method */
56   static WildcardPattern* create(const std::string& pPattern,
57                                  SortPolicy pPolicy);
58   static void destroy(WildcardPattern*& pToken);
59   static void clear();
60 
61 private:
62   SortPolicy m_SortPolicy;
63   bool m_bIsPrefix;
64 };
65 
66 } // namepsace of mcld
67 
68 #endif
69