Biorbd Release_1.13.0
Loading...
Searching...
No Matches
Path.h
1#ifndef BIORBD_UTILS_PATH_H
2#define BIORBD_UTILS_PATH_H
3
4#include <memory>
5#ifdef _WIN32
6#include <string>
7#endif
8#include "biorbdConfig.h"
9
10namespace BIORBD_NAMESPACE {
11namespace utils {
12class String;
16class BIORBD_API Path {
17 public:
21 Path();
22
27 Path(const char* path);
28
33 Path(const String& path);
34
39 Path(const std::basic_string<char>& path);
40
45 Path DeepCopy() const;
46
51 void DeepCopy(const Path& other);
52
60 static void parseFileName(
61 const String& path,
65
66#ifndef SWIG
71 bool isFileExist() const;
72
78 static bool isFileExist(const Path& path);
79#endif
80
86 static bool isFileExist(const String& path);
87
92 bool isFileReadable() const;
93
94#ifndef SWIG
99 bool isFolderExist() const;
100
106 static bool isFolderExist(const Path& path);
107#endif
108
114 static bool isFolderExist(const String& path);
115
119 void createFolder() const;
120
125 static String currentDir();
126
131 String relativePath() const;
132
133#ifndef SWIG
139 String relativePath(const String& relativeTo) const;
140
147 static String relativePath(const Path& path, const String& relativeTo);
148
157 static String absoluteFolder(const Path& path);
158
163 String absoluteFolder() const;
164
165#endif
166
171 String absolutePath() const;
172
178 static String toUnixFormat(const String& path);
179
185 static String toWindowsFormat(const String& path);
186
191 const String& originalPath() const;
192
197 void setFolder(const String& folder);
198
203 const String& folder() const;
204
209 void setFilename(const String& name);
210
215 const String& filename() const;
216
221 void setExtension(const String& ext);
222
227 const String& extension() const;
228
229 protected:
233 void setIsFolderAbsolute();
234
235 std::shared_ptr<String>
237 std::shared_ptr<String> m_folder;
238 std::shared_ptr<bool> m_isFolderAbsolute;
239 std::shared_ptr<String> m_filename;
240 std::shared_ptr<String> m_extension;
241};
242
243} // namespace utils
244} // namespace BIORBD_NAMESPACE
245
246#endif // BIORBD_UTILS_PATH_H
void setFolder(const String &folder)
Set the folder of the file.
Definition Path.cpp:312
void setIsFolderAbsolute()
Set if folder is absolute.
Definition Path.cpp:327
void createFolder() const
To create folder on the computer.
Definition Path.cpp:361
const String & originalPath() const
Return original path as it was at constructor time.
Definition Path.cpp:308
String absolutePath() const
Return the absolute path relative to root.
Definition Path.cpp:265
Path()
Construct path.
Definition Path.cpp:22
bool isFileReadable() const
Test if file exist on the computer and is accessible.
Definition Path.cpp:92
std::shared_ptr< String > m_folder
The folder.
Definition Path.h:237
bool isFileExist() const
Test if file exist on the computer.
Definition Path.cpp:73
const String & filename() const
Return the filename.
Definition Path.cpp:321
bool isFolderExist() const
Test if folder exists on the computer.
Definition Path.cpp:105
static String currentDir()
Definition Path.cpp:349
String relativePath() const
Return relative path to current working directory.
Definition Path.cpp:169
static void parseFileName(const String &path, String &folder, String &filename, String &extension)
Parse a path in folder, filename and extension.
Definition Path.cpp:134
static String toUnixFormat(const String &path)
Return the path to Unix format.
Definition Path.cpp:277
std::shared_ptr< String > m_originalPath
The original path at construction time.
Definition Path.h:236
std::shared_ptr< bool > m_isFolderAbsolute
If folder is absolute.
Definition Path.h:238
static String absoluteFolder(const Path &path)
Return the absolute path relative to root.
Definition Path.cpp:235
const String & folder() const
Return the folder of the file.
Definition Path.cpp:317
std::shared_ptr< String > m_filename
The filename.
Definition Path.h:239
void setExtension(const String &ext)
Set the extension.
Definition Path.cpp:323
const String & extension() const
Return the extension of the file.
Definition Path.cpp:325
std::shared_ptr< String > m_extension
The extension.
Definition Path.h:240
static String toWindowsFormat(const String &path)
Return the path to Windows format.
Definition Path.cpp:298
void setFilename(const String &name)
Set the filename.
Definition Path.cpp:319
Path DeepCopy() const
Deep copy of path.
Definition Path.cpp:59
Wrapper around the std::string class with augmented functionality.
Definition String.h:18