1 //===-- FileSpecList.h ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_FileSpecList_h_
11 #define liblldb_FileSpecList_h_
12 #if defined(__cplusplus)
14 #include "lldb/lldb-private.h"
15 #include "lldb/Host/FileSpec.h"
18 namespace lldb_private {
20 //----------------------------------------------------------------------
21 /// @class FileSpecList FileSpecList.h "lldb/Core/FileSpecList.h"
22 /// @brief A file collection class.
24 /// A class that contains a mutable list of FileSpec objects.
25 //----------------------------------------------------------------------
29 //------------------------------------------------------------------
30 /// Default constructor.
32 /// Initialize this object with an empty file list.
33 //------------------------------------------------------------------
36 //------------------------------------------------------------------
39 /// Initialize this object with a copy of the file list from \a rhs.
42 /// A const reference to another file list object.
43 //------------------------------------------------------------------
44 FileSpecList (const FileSpecList &rhs);
46 //------------------------------------------------------------------
48 //------------------------------------------------------------------
51 //------------------------------------------------------------------
52 /// Assignment operator.
54 /// Replace the file list in this object with the file list from
58 /// A file list object to copy.
61 /// A const reference to this object.
62 //------------------------------------------------------------------
64 operator= (const FileSpecList &rhs);
66 //------------------------------------------------------------------
67 /// Append a FileSpec object to the list.
69 /// Appends \a file to the end of the file list.
72 /// A new file to append to this file list.
73 //------------------------------------------------------------------
75 Append (const FileSpec &file);
77 //------------------------------------------------------------------
78 /// Append a FileSpec object if unique.
80 /// Appends \a file to the end of the file list if it doesn't
81 /// already exist in the file list.
84 /// A new file to append to this file list.
87 /// \b true if the file was appended, \b false otherwise.
88 //------------------------------------------------------------------
90 AppendIfUnique (const FileSpec &file);
92 //------------------------------------------------------------------
93 /// Clears the file list.
94 //------------------------------------------------------------------
98 //------------------------------------------------------------------
99 /// Dumps the file list to the supplied stream pointer "s".
102 /// The stream that will be used to dump the object description.
103 //------------------------------------------------------------------
105 Dump (Stream *s, const char *separator_cstr = "\n") const;
107 //------------------------------------------------------------------
108 /// Find a file index.
110 /// Find the index of the file in the file spec list that matches
111 /// \a file starting \a idx entries into the file spec list.
114 /// An index into the file list.
117 /// The file specification to search for.
120 /// Should FileSpec::Equal be called with "full" true or false.
122 /// @param[in] remove_backup_dots
123 /// Should FileSpec::Equal be called with "remove_backup_dots" true or false.
126 /// The index of the file that matches \a file if it is found,
127 /// else UINT32_MAX is returned.
128 //------------------------------------------------------------------
130 FindFileIndex (size_t idx, const FileSpec &file, bool full, bool remove_backup_dots = false) const;
132 //------------------------------------------------------------------
133 /// Get file at index.
135 /// Gets a file from the file list. If \a idx is not a valid index,
136 /// an empty FileSpec object will be returned. The file objects
137 /// that are returned can be tested using
138 /// FileSpec::operator void*().
141 /// An index into the file list.
144 /// A copy of the FileSpec object at index \a idx. If \a idx
145 /// is out of range, then an empty FileSpec object will be
147 //------------------------------------------------------------------
149 GetFileSpecAtIndex (size_t idx) const;
151 //------------------------------------------------------------------
152 /// Get file specification pointer at index.
154 /// Gets a file from the file list. The file objects that are
155 /// returned can be tested using FileSpec::operator void*().
158 /// An index into the file list.
161 /// A pointer to a contained FileSpec object at index \a idx.
162 /// If \a idx is out of range, then an NULL is returned.
163 //------------------------------------------------------------------
165 GetFileSpecPointerAtIndex (size_t idx) const;
167 //------------------------------------------------------------------
168 /// Get the memory cost of this object.
170 /// Return the size in bytes that this object takes in memory. This
171 /// returns the size in bytes of this object, not any shared string
172 /// values it may refer to.
175 /// The number of bytes that this object occupies in memory.
177 /// @see ConstString::StaticMemorySize ()
178 //------------------------------------------------------------------
185 return m_files.empty();
188 //------------------------------------------------------------------
189 /// Get the number of files in the file list.
192 /// The number of files in the file spec list.
193 //------------------------------------------------------------------
198 Insert (size_t idx, const FileSpec &file)
200 if (idx < m_files.size())
202 m_files.insert(m_files.begin() + idx, file);
205 else if (idx == m_files.size())
207 m_files.push_back(file);
214 Replace (size_t idx, const FileSpec &file)
216 if (idx < m_files.size())
227 if (idx < m_files.size())
229 m_files.erase(m_files.begin() + idx);
235 static size_t GetFilesMatchingPartialPath (const char *path, bool dir_okay, FileSpecList &matches);
238 typedef std::vector<FileSpec> collection; ///< The collection type for the file list.
239 collection m_files; ///< A collection of FileSpec objects.
242 } // namespace lldb_private
245 #endif // #if defined(__cplusplus)
246 #endif // liblldb_FileSpecList_h_