diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-11-30 23:28:07 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-11-30 23:28:07 +0000 |
commit | a42cf73c779fe4210cedce0a7a0b2ada2085b55b (patch) | |
tree | eff4e99d7db5a9672f24b36ee230abff15cce1af /include | |
parent | 63c133b67d61b0c457ff46c957aed2b8d90b599c (diff) | |
download | external_llvm-a42cf73c779fe4210cedce0a7a0b2ada2085b55b.zip external_llvm-a42cf73c779fe4210cedce0a7a0b2ada2085b55b.tar.gz external_llvm-a42cf73c779fe4210cedce0a7a0b2ada2085b55b.tar.bz2 |
Support/PathV2: Implement reverse iteration and parent_path.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120496 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Support/PathV2.h | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/include/llvm/Support/PathV2.h b/include/llvm/Support/PathV2.h index fcdeff9..e1b0a1d 100644 --- a/include/llvm/Support/PathV2.h +++ b/include/llvm/Support/PathV2.h @@ -81,16 +81,21 @@ public: typedef value_type *pointer; typedef std::bidirectional_iterator_tag iterator_category; - reference operator*() const; - pointer operator->() const; + reference operator*() const { return Component; } + pointer operator->() const { return &Component; } const_iterator &operator++(); // preincrement const_iterator &operator++(int); // postincrement const_iterator &operator--(); // predecrement const_iterator &operator--(int); // postdecrement bool operator==(const const_iterator &RHS) const; bool operator!=(const const_iterator &RHS) const; + + /// @brief Difference in bytes between this and RHS. + ptrdiff_t operator-(const const_iterator &RHS) const; }; +typedef std::reverse_iterator<const_iterator> reverse_iterator; + /// @brief Get begin iterator over \a path. /// @param path Input path. /// @returns Iterator initialized with the first component of \a path. @@ -101,6 +106,20 @@ const_iterator begin(const StringRef &path); /// @returns Iterator initialized to the end of \a path. const_iterator end(const StringRef &path); +/// @brief Get reverse begin iterator over \a path. +/// @param path Input path. +/// @returns Iterator initialized with the first reverse component of \a path. +inline reverse_iterator rbegin(const StringRef &path) { + return reverse_iterator(end(path)); +} + +/// @brief Get reverse end iterator over \a path. +/// @param path Input path. +/// @returns Iterator initialized to the reverse end of \a path. +inline reverse_iterator rend(const StringRef &path) { + return reverse_iterator(begin(path)); +} + /// @} /// @name Lexical Modifiers /// @{ |