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