EPUBPath.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libepubgen project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef INCLUDED_EPUBPATH_H
00011 #define INCLUDED_EPUBPATH_H
00012 
00013 #include <string>
00014 #include <vector>
00015 
00016 namespace libepubgen
00017 {
00018 
00021 class EPUBPath
00022 {
00023   friend bool operator==(const EPUBPath &left, const EPUBPath &right);
00024 
00025 public:
00026   class Relative
00027   {
00028     friend class EPUBPath;
00029 
00030   public:
00031     const std::string str() const;
00032 
00033   private:
00034     explicit Relative(const std::vector<std::string> &components);
00035 
00036   private:
00037     std::vector<std::string> m_components;
00038   };
00039 
00040   explicit EPUBPath(const std::string &path);
00041 
00042   void swap(EPUBPath &other);
00043 
00044   void append(const EPUBPath &subpath);
00045   void appendComponent(const std::string &pathComponent);
00046 
00047   const std::string str() const;
00048 
00049   const Relative relativeTo(const EPUBPath &base) const;
00050 
00051   void appendTitle(const std::string &title);
00052   std::string getTitle() const;
00053 
00054 private:
00055   std::vector<std::string> m_components;
00056   std::string m_title;
00057 };
00058 
00059 bool operator==(const EPUBPath &left, const EPUBPath &right);
00060 bool operator!=(const EPUBPath &left, const EPUBPath &right);
00061 
00062 const EPUBPath operator/(const EPUBPath &base, const EPUBPath &subpath);
00063 const EPUBPath operator/(const EPUBPath &base, const std::string &pathComponent);
00064 
00065 void swap(EPUBPath &left, EPUBPath &right);
00066 
00067 }
00068 
00069 #endif // INCLUDED_EPUBPATH
00070 
00071 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */