cpp-mate  0.7
Helpful library for C++.
Path.hpp
1 /*
2  * Copyright (C) 2020 Alexander Kornilov (akornilov.82@gmail.com)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CPP_MATE_PATH_HPP
18 #define CPP_MATE_PATH_HPP
19 
20 #include <string>
21 #include <vector>
22 
23 namespace CppMate {
24 
28 class Path final
29 {
30 public:
31 
36  explicit Path(const std::string& path);
37 
42  bool isAbsolute() const { return _isAbsolute; }
43 
48  bool hasTrailingSlash() const { return _hasTrailingSlash; }
49 
54  std::string getPath() const { return _path; }
55 
60  std::string getParent() const { return _parent; }
61 
66  std::string getName() const { return _name; }
67 
72  std::string getBaseName() const { return _baseName; }
73 
78  std::string getSuffix() const { return _suffix; }
79 
84  std::string getDriveLetter() const { return _driveLetter; }
85 
90  std::vector<std::string>::const_iterator begin() const { return _parts.begin(); }
91 
96  std::vector<std::string>::const_iterator end() const { return _parts.end(); }
97 
98 private:
99  bool _isAbsolute;
100  bool _hasTrailingSlash;
101  std::string _path;
102  std::string _parent;
103  std::string _name;
104  std::string _baseName;
105  std::string _suffix;
106  std::string _driveLetter;
107  std::vector<std::string> _parts;
108 };
109 
110 } // namespace CppMate
111 
112 #endif // CPP_MATE_PATH_HPP
Represents path.
Definition: Path.hpp:29
std::string getParent() const
Returns path without name.
Definition: Path.hpp:60
bool hasTrailingSlash() const
Indicates that path has trailing slash.
Definition: Path.hpp:48
std::string getPath() const
Returns orginal string representation of the path.
Definition: Path.hpp:54
Path(const std::string &path)
Constructor.
std::vector< std::string >::const_iterator end() const
Returns end iterator.
Definition: Path.hpp:96
std::string getName() const
Returns name without path with suffix.
Definition: Path.hpp:66
std::string getDriveLetter() const
Returns drive letter if present or empty string otherwise.
Definition: Path.hpp:84
std::vector< std::string >::const_iterator begin() const
Returns begin iterator.
Definition: Path.hpp:90
bool isAbsolute() const
Indicates that path is absolute.
Definition: Path.hpp:42
std::string getSuffix() const
Returns suffix of name.
Definition: Path.hpp:78
std::string getBaseName() const
Returns base name without path and suffix.
Definition: Path.hpp:72
Definition: BinaryData.hpp:28