1//===- StringList.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_STRINGLIST_H_
10#define MCLD_SCRIPT_STRINGLIST_H_
11
12#include "mcld/Config/Config.h"
13#include "mcld/Support/Allocators.h"
14
15#include <vector>
16
17namespace mcld {
18
19class StrToken;
20
21/** \class StringList
22 *  \brief This class defines the interfaces to StringList.
23 */
24
25class StringList {
26 public:
27  typedef std::vector<StrToken*> Tokens;
28  typedef Tokens::const_iterator const_iterator;
29  typedef Tokens::iterator iterator;
30  typedef Tokens::const_reference const_reference;
31  typedef Tokens::reference reference;
32
33 private:
34  friend class Chunk<StringList, MCLD_SYMBOLS_PER_INPUT>;
35  StringList();
36
37 public:
38  ~StringList();
39
40  const_iterator begin() const { return m_Tokens.begin(); }
41  iterator begin() { return m_Tokens.begin(); }
42  const_iterator end() const { return m_Tokens.end(); }
43  iterator end() { return m_Tokens.end(); }
44
45  const_reference front() const { return m_Tokens.front(); }
46  reference front() { return m_Tokens.front(); }
47  const_reference back() const { return m_Tokens.back(); }
48  reference back() { return m_Tokens.back(); }
49
50  bool empty() const { return m_Tokens.empty(); }
51
52  void push_back(StrToken* pToken);
53
54  void dump() const;
55
56  /* factory methods */
57  static StringList* create();
58  static void destroy(StringList*& pStringList);
59  static void clear();
60
61 private:
62  Tokens m_Tokens;
63};
64
65}  // namespace mcld
66
67#endif  // MCLD_SCRIPT_STRINGLIST_H_
68