Changeset 19:49b39ac77cad in rrlib_uri


Ignore:
Timestamp:
06.01.2022 00:58:10 (5 months ago)
Author:
Max Reichardt <max.reichardt@…>
Branch:
17.03
Phase:
public
Tags:
tip
Message:

Adds a std::ostream stream operator for tStringRange as well as typedefs and minor tweaks to tPath::tConstIterator (so that std::iterator_traits return a valid result). This e.g. enables using the latter with rrlib::util::Join.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tPath.h

    r17 r19  
    304304  public: 
    305305 
    306     tConstIterator(const tPath& path, size_t element_index) : 
     306    typedef long int difference_type; 
     307    typedef const tElement value_type; 
     308    typedef const tElement* pointer; 
     309    typedef const tElement& reference; 
     310    typedef std::bidirectional_iterator_tag iterator_category; 
     311 
     312    tConstIterator(const tPath& path, long int element_index) : 
    307313      path(&path), 
    308314      element_index(element_index), 
     
    340346      return temp; 
    341347    } 
    342     friend size_t operator+(const tConstIterator& lhs, const tConstIterator& rhs) 
     348    inline tConstIterator& operator--() 
     349    { 
     350      element_index--; 
     351      UpdateElement(); 
     352      return *this; 
     353    } 
     354    inline tConstIterator operator -- (int) 
     355    { 
     356      tConstIterator temp(*this); 
     357      operator--(); 
     358      return temp; 
     359    } 
     360    friend long int operator+(const tConstIterator& lhs, const tConstIterator& rhs) 
    343361    { 
    344362      return lhs.element_index + rhs.element_index; 
    345363    } 
    346     friend size_t operator-(const tConstIterator& lhs, const tConstIterator& rhs) 
     364    friend long int operator-(const tConstIterator& lhs, const tConstIterator& rhs) 
    347365    { 
    348366      return lhs.element_index - rhs.element_index; 
    349367    } 
    350     friend tConstIterator operator+(const tConstIterator& lhs, size_t rhs) 
     368    friend tConstIterator operator+(const tConstIterator& lhs, long int rhs) 
    351369    { 
    352370      return tConstIterator(*lhs.path, lhs.element_index + rhs); 
    353371    } 
    354     friend tConstIterator operator-(const tConstIterator& lhs, size_t rhs) 
     372    friend tConstIterator operator-(const tConstIterator& lhs, long int rhs) 
    355373    { 
    356374      return tConstIterator(*lhs.path, lhs.element_index - rhs); 
     
    360378 
    361379    const tPath* path; 
    362     size_t element_index; 
     380    long int element_index; 
    363381    tElement element; 
    364382 
    365383    void UpdateElement() 
    366384    { 
    367       element = element_index >= path->element_count ? tStringRange() : (*path)[element_index]; 
     385      element = static_cast<unsigned long int>(element_index) >= path->element_count ? tStringRange() : (*path)[element_index]; 
    368386    } 
    369387  }; 
  • tStringRange.h

    r0 r19  
    129129} 
    130130 
     131inline std::ostream& operator << (std::ostream& stream, const tStringRange& string_range) 
     132{ 
     133  stream.write(string_range.CharPointer(), string_range.Length()); 
     134  return stream; 
     135} 
     136 
    131137//---------------------------------------------------------------------- 
    132138// End of namespace declaration 
Note: See TracChangeset for help on using the changeset viewer.