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