diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-11-29 22:28:51 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-11-29 22:28:51 +0000 |
commit | dffde9964480f946d4308ce936b667b6c37b1059 (patch) | |
tree | 11cddd0a2725d0fd441afa52cf8e5c7c92e3ae01 /include/llvm | |
parent | 44c1bc14570e77630b5e6711ed42886aad848086 (diff) | |
download | external_llvm-dffde9964480f946d4308ce936b667b6c37b1059.zip external_llvm-dffde9964480f946d4308ce936b667b6c37b1059.tar.gz external_llvm-dffde9964480f946d4308ce936b667b6c37b1059.tar.bz2 |
Support: Add PathV2 implementation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120329 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Support/PathV2.h | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/include/llvm/Support/PathV2.h b/include/llvm/Support/PathV2.h index ab9f077..9417e4c 100644 --- a/include/llvm/Support/PathV2.h +++ b/include/llvm/Support/PathV2.h @@ -24,6 +24,9 @@ // //===----------------------------------------------------------------------===// +#ifndef LLVM_SYSTEM_PATHV2_H +#define LLVM_SYSTEM_PATHV2_H + #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/DataTypes.h" @@ -64,13 +67,20 @@ namespace path { /// class const_iterator { StringRef Path; //< The entire path. - StringRef Component; //< The current component. + StringRef Component; //< The current component. Not necessarily in Path. + size_t Position; //< The iterators current position within Path. + + // An end iterator has Position = Path.size() + 1. + friend const_iterator begin(const StringRef &path); + friend const_iterator end(const StringRef &path); public: typedef const StringRef value_type; + typedef ptrdiff_t difference_type; typedef value_type &reference; typedef value_type *pointer; typedef std::bidirectional_iterator_tag iterator_category; + reference operator*() const; pointer operator->() const; const_iterator &operator++(); // preincrement @@ -79,11 +89,18 @@ public: const_iterator &operator--(int); // postdecrement bool operator==(const const_iterator &RHS) const; bool operator!=(const const_iterator &RHS) const; - - const_iterator(); //< Default construct end iterator. - const_iterator(const StringRef &path); }; +/// @brief Get begin iterator over \a path. +/// @param path Input path. +/// @returns Iterator initialized with the first component of \a path. +const_iterator begin(const StringRef &path); + +/// @brief Get end iterator over \a path. +/// @param path Input path. +/// @returns Iterator initialized to the end of \a path. +const_iterator end(const StringRef &path); + /// @} /// @name Lexical Modifiers /// @{ @@ -136,7 +153,10 @@ error_code replace_extension(SmallVectorImpl<char> &path, /// @param component The component to be appended to \a path. /// @returns errc::success if \a component has been appended to \a path, /// otherwise a platform specific error_code. -error_code append(SmallVectorImpl<char> &path, const Twine &component); +error_code append(SmallVectorImpl<char> &path, const Twine &a, + const Twine &b = "", + const Twine &c = "", + const Twine &d = ""); /// @brief Append to path. /// @@ -978,3 +998,5 @@ public: } // end namespace fs } // end namespace sys } // end namespace llvm + +#endif |