SectionsCmd.h revision f33f6de54db174aa679a4b6d1e040d37e95541c0
1//===- SectionsCmd.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_SECTIONSCMD_H
10#define MCLD_SCRIPT_SECTIONSCMD_H
11#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14
15#include <mcld/Script/ScriptCommand.h>
16#include <llvm/Support/DataTypes.h>
17#include <vector>
18
19namespace mcld
20{
21
22class Module;
23
24/** \class SectionsCmd
25 *  \brief This class defines the interfaces to SECTIONS command.
26 */
27
28class SectionsCmd : public ScriptCommand
29{
30public:
31  typedef std::vector<ScriptCommand*> SectionCommands;
32  typedef SectionCommands::const_iterator const_iterator;
33  typedef SectionCommands::iterator iterator;
34  typedef SectionCommands::const_reference const_reference;
35  typedef SectionCommands::reference reference;
36
37public:
38  SectionsCmd();
39  ~SectionsCmd();
40
41  const_iterator  begin() const { return m_SectionCommands.begin(); }
42  iterator        begin()       { return m_SectionCommands.begin(); }
43  const_iterator  end()   const { return m_SectionCommands.end(); }
44  iterator        end()         { return m_SectionCommands.end(); }
45
46  const_reference front() const { return m_SectionCommands.front(); }
47  reference       front()       { return m_SectionCommands.front(); }
48  const_reference back()  const { return m_SectionCommands.back(); }
49  reference       back()        { return m_SectionCommands.back(); }
50
51  size_t size() const { return m_SectionCommands.size(); }
52
53  bool empty() const { return m_SectionCommands.empty(); }
54
55  void dump() const;
56
57  static bool classof(const ScriptCommand* pCmd)
58  {
59    return pCmd->getKind() == ScriptCommand::SECTIONS;
60  }
61
62  void activate(Module& pModule);
63
64  void push_back(ScriptCommand* pCommand);
65
66private:
67  SectionCommands m_SectionCommands;
68};
69
70} // namespace of mcld
71
72#endif
73