StrToken.h revision 87f34658dec9097d987d254a990ea7f311bfc95f
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#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14
15#include <mcld/Support/Allocators.h>
16#include <mcld/Config/Config.h>
17#include <string>
18
19namespace mcld
20{
21
22/** \class StrToken
23 *  \brief This class defines the interfaces to a element in EXCLUDE_FILE list
24 *         or in Output Section Phdr, or be a base class of other str token.
25 */
26
27class StrToken
28{
29public:
30  enum Kind {
31    Unknown,
32    String,
33    Input,
34    Wildcard
35  };
36
37private:
38  friend class Chunk<StrToken, MCLD_SYMBOLS_PER_INPUT>;
39protected:
40  StrToken();
41  StrToken(Kind pKind, const std::string& pString);
42
43public:
44  virtual ~StrToken();
45
46  Kind kind() const { return m_Kind; }
47
48  const std::string& name() const { return m_Name; }
49
50  static bool classof(const StrToken* pToken)
51  {
52    return pToken->kind() == StrToken::String;
53  }
54
55  /* factory method */
56  static StrToken* create(const std::string& pString);
57  static void destroy(StrToken*& pToken);
58  static void clear();
59
60private:
61  Kind m_Kind;
62  std::string m_Name;
63};
64
65} // namepsace of mcld
66
67#endif
68