4 * @brief Declarations of PathInfo and PathContext
8 #include "UnicodeString.h"
12 class PathContextIterator;
15 * @brief Information for one path.
17 * Path is stored in normalized format (no trailing slash).
21 friend class PathContext;
24 PathInfo(const PathInfo &pi);
26 String GetPath(bool bNormalized = true) const;
27 String& GetRef() { return m_sPath; }
28 void SetPath(const TCHAR *path);
29 void SetPath(const String & path);
33 String m_sPath; /**< Directory / file path */
38 * @param [in] sPath New path for item.
40 inline void PathInfo::SetPath(const TCHAR *sPath)
45 inline void PathInfo::SetPath(const String & sPath)
51 * @brief Holds path information of compared files/directories.
56 typedef PathContextIterator const_iterator;
59 explicit PathContext(const String& sLeft);
60 PathContext(const String& sLeft, const String& sRight);
61 PathContext(const String& sLeft, const String& sMiddle, const String& sRight);
62 PathContext(const PathContext &paths);
63 explicit PathContext(const std::vector<String>& paths);
65 String GetAt(int nIndex) const;
66 String& GetElement(int nIndex);
67 void SetAt(int nIndex, const String& newElement);
68 String operator[](int nIndex) const { return GetAt(nIndex); }
69 String& operator[](int nIndex) { return GetElement(nIndex); }
71 String GetLeft(bool bNormalized = true) const;
72 String GetRight(bool bNormalized = true) const;
73 String GetMiddle(bool bNormalized = true) const;
74 String GetPath(int index, bool bNormalized = true) const;
75 void SetLeft(const String& path, bool bNormalized = true);
76 void SetRight(const String& path, bool bNormalized = true);
77 void SetMiddle(const String& path, bool bNormalized = true);
78 void SetPath(int index, const String& path, bool bNormalized = true);
79 void SetSize(int nFiles);
82 void Swap(int nFromIndex, int nToIndex);
84 const_iterator begin() const;
85 const_iterator end() const;
88 PathInfo m_path[3]; /**< First, second, third path (left path at start) */
92 * @brief set number of files.
94 inline void PathContext::SetSize(int nFiles)
100 * @brief Return number of files.
102 inline int PathContext::GetSize() const
107 class PathContextIterator : public std::iterator<std::forward_iterator_tag, String>
110 explicit PathContextIterator(const PathContext *pPathContext) : m_pPathContext(pPathContext)
112 m_sel = (pPathContext->GetSize() == 0) ? -1 : 0;
115 PathContextIterator() : m_pPathContext(nullptr), m_sel(-1)
119 ~PathContextIterator() {}
121 PathContextIterator& operator=(const PathContextIterator& it)
124 m_pPathContext = it.m_pPathContext;
128 PathContextIterator& operator++()
131 if (m_sel >= m_pPathContext->GetSize())
138 return m_pPathContext->GetAt(m_sel);
141 bool operator==(const PathContextIterator& it) const
143 return m_sel == it.m_sel;
146 bool operator!=(const PathContextIterator& it) const
148 return m_sel != it.m_sel;
152 const PathContext *m_pPathContext;
156 inline PathContextIterator PathContext::begin() const
158 return PathContextIterator(this);
161 inline PathContextIterator PathContext::end() const
163 return PathContextIterator();