WPILibC++  unspecified
Path.h
1 //===- llvm/Support/Path.h - Path Operating System Concept ------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the llvm::sys::path namespace. It is designed after
11 // TR2/boost filesystem (v3), but modified to remove exception handling and the
12 // path class.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_SUPPORT_PATH_H
17 #define LLVM_SUPPORT_PATH_H
18 
19 #include "llvm/Twine.h"
20 #include <iterator>
21 
22 #include <stdint.h>
23 
24 namespace llvm {
25 namespace sys {
26 namespace path {
27 
30 
51  : public std::iterator<std::input_iterator_tag, const StringRef> {
52  StringRef Path;
53  StringRef Component;
54  size_t Position;
55 
56  // An end iterator has Position = Path.size() + 1.
57  friend const_iterator begin(StringRef path);
58  friend const_iterator end(StringRef path);
59 
60 public:
61  reference operator*() const { return Component; }
62  pointer operator->() const { return &Component; }
63  const_iterator &operator++(); // preincrement
64  bool operator==(const const_iterator &RHS) const;
65  bool operator!=(const const_iterator &RHS) const { return !(*this == RHS); }
66 
68  ptrdiff_t operator-(const const_iterator &RHS) const;
69 };
70 
77  : public std::iterator<std::input_iterator_tag, const StringRef> {
78  StringRef Path;
79  StringRef Component;
80  size_t Position;
81 
82  friend reverse_iterator rbegin(StringRef path);
83  friend reverse_iterator rend(StringRef path);
84 
85 public:
86  reference operator*() const { return Component; }
87  pointer operator->() const { return &Component; }
88  reverse_iterator &operator++(); // preincrement
89  bool operator==(const reverse_iterator &RHS) const;
90  bool operator!=(const reverse_iterator &RHS) const { return !(*this == RHS); }
91 
93  ptrdiff_t operator-(const reverse_iterator &RHS) const;
94 };
95 
100 
105 
109 reverse_iterator rbegin(StringRef path);
110 
114 reverse_iterator rend(StringRef path);
115 
119 
130 void remove_filename(SmallVectorImpl<char> &path);
131 
144 void replace_extension(SmallVectorImpl<char> &path, const Twine &extension);
145 
159 void replace_path_prefix(SmallVectorImpl<char> &Path,
160  const StringRef &OldPrefix,
161  const StringRef &NewPrefix);
162 
173 void append(SmallVectorImpl<char> &path, const Twine &a,
174  const Twine &b = "",
175  const Twine &c = "",
176  const Twine &d = "");
177 
189 void append(SmallVectorImpl<char> &path,
190  const_iterator begin, const_iterator end);
191 
195 
202 void native(const Twine &path, SmallVectorImpl<char> &result);
203 
209 void native(SmallVectorImpl<char> &path);
210 
214 
225 StringRef root_name(StringRef path);
226 
238 StringRef root_directory(StringRef path);
239 
246 StringRef root_path(StringRef path);
247 
258 StringRef relative_path(StringRef path);
259 
270 StringRef parent_path(StringRef path);
271 
284 StringRef filename(StringRef path);
285 
302 StringRef stem(StringRef path);
303 
318 StringRef extension(StringRef path);
319 
324 bool is_separator(char value);
325 
329 StringRef get_separator();
330 
340 void system_temp_directory(bool erasedOnReboot, SmallVectorImpl<char> &result);
341 
346 bool home_directory(SmallVectorImpl<char> &result);
347 
361 bool user_cache_directory(SmallVectorImpl<char> &Result, const Twine &Path1,
362  const Twine &Path2 = "", const Twine &Path3 = "");
363 
370 bool has_root_name(const Twine &path);
371 
378 bool has_root_directory(const Twine &path);
379 
386 bool has_root_path(const Twine &path);
387 
394 bool has_relative_path(const Twine &path);
395 
402 bool has_parent_path(const Twine &path);
403 
410 bool has_filename(const Twine &path);
411 
418 bool has_stem(const Twine &path);
419 
426 bool has_extension(const Twine &path);
427 
432 bool is_absolute(const Twine &path);
433 
438 bool is_relative(const Twine &path);
439 
444 StringRef remove_leading_dotslash(StringRef path);
445 
451 bool remove_dots(SmallVectorImpl<char> &path, bool remove_dot_dot = false);
452 
453 } // end namespace path
454 } // end namespace sys
455 } // end namespace llvm
456 
457 #endif
Definition: Path.inc:27
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
friend const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:163
ptrdiff_t operator-(const const_iterator &RHS) const
Difference in bytes between this and RHS.
Definition: Path.cpp:227
friend const_iterator begin(StringRef path)
Get begin iterator over path.
Definition: Path.cpp:155
Path iterator.
Definition: Path.h:50
Reverse path iterator.
Definition: Path.h:76
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:42