aboutsummaryrefslogtreecommitdiffstats
path: root/src/utility/path.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utility/path.hpp')
-rw-r--r--src/utility/path.hpp124
1 files changed, 124 insertions, 0 deletions
diff --git a/src/utility/path.hpp b/src/utility/path.hpp
new file mode 100644
index 00000000..bc980889
--- /dev/null
+++ b/src/utility/path.hpp
@@ -0,0 +1,124 @@
+//
+// VMime library (http://vmime.sourceforge.net)
+// Copyright (C) 2002-2004 Vincent Richard <[email protected]>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+
+#ifndef VMIME_UTILITY_PATH_HPP_INCLUDED
+#define VMIME_UTILITY_PATH_HPP_INCLUDED
+
+
+#include <vector>
+
+#include "../types.hpp"
+#include "../word.hpp"
+
+
+namespace vmime {
+namespace utility {
+
+
+/** Abstract representation of a path (filesystem, mailbox, etc).
+ */
+
+class path
+{
+public:
+
+ typedef vmime::word component;
+ typedef std::vector <component> list;
+
+ // Construct a path
+ path();
+ path(const component& c);
+ path(const path& p);
+ path(const string& s);
+
+ // Append a component to a path
+ path operator/(const path& p) const;
+ path operator/(const component& c) const;
+
+ path& operator/=(const path& p);
+ path& operator/=(const component& c);
+
+ // Return the parent path
+ path parent() const;
+
+ // Assignment
+ path& operator=(const path& p);
+ path& operator=(const component& c);
+
+ // Path comparison
+ const bool operator==(const path& p) const;
+ const bool operator!=(const path& p) const;
+
+ /** Test whether this path is empty (root).
+ *
+ * @return true if the path is empty (no components = root)
+ */
+ const bool empty() const;
+
+ /** Return the last component of this path (const version).
+ *
+ * @return last component
+ */
+ const component last() const;
+
+ /** Return the last component of this path (non-const version).
+ *
+ * @return last component
+ */
+ component& last();
+
+ /** Return the number of components in this path.
+ *
+ * @return number of components
+ */
+ const int size() const;
+
+ /** Return the specified component of the path (const version).
+ *
+ * @param x index of the component
+ * @return component at the specified index
+ */
+ const component& operator[](const int x) const;
+
+ /** Return the specified component of the path (non-const version).
+ *
+ * @param x index of the component
+ * @return component at the specified index
+ */
+ component& operator[](const int x);
+
+ /** Test whether this path is a direct parent of another one.
+ *
+ * @param p other path
+ * @return true if the specified path is a child (direct or
+ * indirect) of this path, false otherwise
+ */
+ const bool isDirectParentOf(const path& p) const;
+
+private:
+
+ list m_list;
+};
+
+
+} // utility
+} // vmime
+
+
+#endif // VMIME_UTILITY_PATH_HPP_INCLUDED