187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines//===- StringList.h -------------------------------------------------------===//
287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines//
387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines//                     The MCLinker Project
487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines//
587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines// This file is distributed under the University of Illinois Open Source
687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines// License. See LICENSE.TXT for details.
787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines//
887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines//===----------------------------------------------------------------------===//
987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#ifndef MCLD_SCRIPT_STRINGLIST_H
1087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#define MCLD_SCRIPT_STRINGLIST_H
1187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
1287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#include <mcld/Config/Config.h>
1387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#include <mcld/Support/Allocators.h>
1487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#include <vector>
1587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
1687f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesnamespace mcld
1787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines{
1887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
1987f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesclass StrToken;
2087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
2187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines/** \class StringList
2287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines *  \brief This class defines the interfaces to StringList.
2387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines */
2487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
2587f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesclass StringList
2687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines{
2787f34658dec9097d987d254a990ea7f311bfc95fStephen Hinespublic:
2887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  typedef std::vector<StrToken*> Tokens;
2987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  typedef Tokens::const_iterator const_iterator;
3087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  typedef Tokens::iterator iterator;
3187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  typedef Tokens::const_reference const_reference;
3287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  typedef Tokens::reference reference;
3387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
3487f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesprivate:
3587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  friend class Chunk<StringList, MCLD_SYMBOLS_PER_INPUT>;
3687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  StringList();
3787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
3887f34658dec9097d987d254a990ea7f311bfc95fStephen Hinespublic:
3987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  ~StringList();
4087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
4187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  const_iterator  begin() const { return m_Tokens.begin(); }
4287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  iterator        begin()       { return m_Tokens.begin(); }
4387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  const_iterator  end()   const { return m_Tokens.end(); }
4487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  iterator        end()         { return m_Tokens.end(); }
4587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
4687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  const_reference front() const { return m_Tokens.front(); }
4787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  reference       front()       { return m_Tokens.front(); }
4887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  const_reference back()  const { return m_Tokens.back(); }
4987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  reference       back()        { return m_Tokens.back(); }
5087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
5187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  bool empty() const { return m_Tokens.empty(); }
5287f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
5387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  void push_back(StrToken* pToken);
5487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
5587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  void dump() const;
5687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
5787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  /* factory methods */
5887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  static StringList* create();
5987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  static void destroy(StringList*& pStringList);
6087f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  static void clear();
6187f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
6287f34658dec9097d987d254a990ea7f311bfc95fStephen Hinesprivate:
6387f34658dec9097d987d254a990ea7f311bfc95fStephen Hines  Tokens m_Tokens;
6487f34658dec9097d987d254a990ea7f311bfc95fStephen Hines};
6587f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
6687f34658dec9097d987d254a990ea7f311bfc95fStephen Hines} // namepsace of mcld
6787f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
6887f34658dec9097d987d254a990ea7f311bfc95fStephen Hines#endif
6987f34658dec9097d987d254a990ea7f311bfc95fStephen Hines
70