SearchDirs.h revision 5460a1f25d9ddecb5c70667267d66d51af177a99
1//===- SearchDirs.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 SEARCHDIRS_H
10#define SEARCHDIRS_H
11#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14#include <llvm/ADT/StringRef.h>
15#include "mcld/ADT/Uncopyable.h"
16#include "mcld/MC/MCLDInput.h"
17
18namespace mcld
19{
20
21class MCLDFile;
22class MCLDDirectory;
23
24namespace sys {
25namespace fs {
26class Path;
27} // namespace of fs
28} // namespace of sys
29
30/** \class SearchDirs
31 *  \brief SearchDirs contains the list of paths that MCLinker will search for
32 *  archive libraries and control scripts.
33 *
34 *  SearchDirs is customized for linking. It handles -L on the command line
35 *  and SEARCH_DIR macro in the link script.
36 *
37 *  @see MCLDDirectory.
38 */
39class SearchDirs : private Uncopyable
40{
41public:
42  typedef std::vector<MCLDDirectory*> DirList;
43  typedef DirList::iterator iterator;
44  typedef DirList::const_iterator const_iterator;
45
46public:
47  SearchDirs();
48  ~SearchDirs();
49
50  /// find - give a namespec, return a real path of the shared object.
51  sys::fs::Path* find(const std::string& pNamespec, mcld::Input::Type pType);
52
53  // -----  iterators  ----- //
54  iterator begin()
55  { return m_DirList.begin(); }
56
57  iterator end()
58  { return m_DirList.end(); }
59
60  const_iterator begin() const
61  { return m_DirList.begin(); }
62
63  const_iterator end() const
64  { return m_DirList.end(); }
65
66  // -----  modifiers  ----- //
67  void add(const MCLDDirectory& pDirectory);
68
69private:
70  DirList m_DirList;
71};
72
73} // namespace of mcld
74
75#endif
76
77