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