- Aldebaran documentation |
- C++ Libraries |
- index

libqi-api 2.8.7.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
path.hpp
Go to the documentation of this file.
1 #pragma once
2 /*
3 * Copyright (c) 2012, 2014 Aldebaran Robotics. All rights reserved.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the COPYING file.
6 */
7
8 #ifndef _QI_PATH_HPP_
9 # define _QI_PATH_HPP_
10
11 # include <memory>
12 # include <string>
13 # include <vector>
14 # include <locale>
15 # include <iosfwd>
16 # include <qi/api.hpp>
17
18 namespace boost { namespace filesystem {
19 class path;
20 }}
21
22 namespace qi
23 {
24
25 class PrivatePath;
26 class Path;
27 using PathVector = std::vector<Path>;
28
34 class QI_API Path {
35 public:
38 Path(const std::string& unicodePath = std::string());
39
41 Path(const char* unicodePath);
42
44 Path(const Path& path);
45
47 Path(const boost::filesystem::path& path);
48
50 ~Path();
51
53 bool isEmpty() const;
54
56 bool exists() const;
57
59 bool isDir() const;
60
62 bool isRegularFile() const;
63
65 bool isSymlink() const;
66
68 std::string filename() const;
69
71 std::string extension() const;
72
74 Path parent() const;
75
77 Path absolute() const;
78
80 PathVector files() const;
81
83 PathVector recursiveFiles() const;
84
86 PathVector dirs() const;
87
89 explicit operator std::string() const;
90
92 std::string str() const;
93
95 operator boost::filesystem::path() const;
96
98 const boost::filesystem::path& bfsPath() const;
99
101 static Path fromNative(const char* nativeCharsPath);
102
104 static Path fromNative(const wchar_t* nativeCharsPath);
105
107 static Path fromNative(const std::string& nativeCharsPath);
108
110 static Path fromNative(const std::wstring& nativeCharsPath);
111
113 Path operator/(const qi::Path& rhs) const;
114
116 const Path& operator/=(const qi::Path& rhs) const;
117
119 const Path& operator=(const qi::Path& rhs) const;
120
121 bool operator==(const qi::Path& rhs) const;
122 bool operator!=(const qi::Path& rhs) const;
123
125 friend std::ostream& operator<<(std::ostream& output, const qi::Path& path)
126 {
127 output << path.str();
128 return output;
129 }
130
131 private:
132 std::unique_ptr<PrivatePath> _p;
133 };
134
135
137 namespace path
138 {
141 class QI_API ScopedDir
142 {
143 public:
148 ScopedDir(qi::Path path = qi::Path());
150 ~ScopedDir();
151
153 operator qi::Path() const;
154
156 const qi::Path& path() const;
157
158 private:
162 void removeAll(int retry);
163
164 qi::Path _path;
165 };
166
170 class QI_API ScopedFile
171 {
172 public:
178 ScopedFile(qi::Path filePath = qi::Path());
179 ~ScopedFile();
180
182 const qi::Path& path() const;
183
184 private:
185 qi::path::ScopedDir _dir;
186 qi::Path _path;
187 };
188
194 QI_API std::string sdkPrefix();
195
199 namespace detail {
200
205 QI_API std::vector<std::string> getSdkPrefixes();
206
217 QI_API void addOptionalSdkPrefix(const char* prefix);
218
226 QI_API void clearOptionalSdkPrefix();
227
233 QI_API void setWritablePath(const std::string &path);
234
239 QI_API Path normalize(const Path& path);
240 }
241
256 QI_API std::string findBin(const std::string& name, bool searchInPath=false);
257
274 QI_API std::string findLib(const std::string& name);
275
276
300 QI_API std::string findConf(const std::string& applicationName,
301 const std::string& filename,
302 bool excludeUserWritablePath = false);
303
332 QI_API std::string findData(const std::string& applicationName,
333 const std::string& filename,
334 bool excludeUserWritablePath = false);
335
336
369 QI_API std::vector<std::string> listData(const std::string& applicationName,
370 const std::string& pattern="*",
371 bool excludeUserWritablePath = false);
372
375 QI_API std::vector<std::string> listLib(const std::string& subfolder,
376 const std::string& pattern="*");
377
391 QI_API std::vector<std::string> confPaths(const std::string& applicationName="",
392 bool excludeUserWritablePath = false);
393
417 QI_API std::vector<std::string> dataPaths(const std::string& applicationName="",
418 bool excludeUserWritablePath = false);
419
431 QI_API std::vector<std::string> binPaths();
432
444 QI_API std::vector<std::string> libPaths();
445
465 QI_API std::string userWritableDataPath(const std::string& applicationName,
466 const std::string& filename);
467
487 QI_API std::string userWritableConfPath(const std::string& applicationName,
488 const std::string& filename="");
489
500 QI_API std::string convertToDosPath(const std::string &pathString);
501
508 QI_API QI_API_DEPRECATED_MSG(Use 'detail::setWritablePath' instead)
509 void setWritablePath(const std::string &path);
510 }
511
518 using codecvt_type = std::codecvt<wchar_t, char, std::mbstate_t>;
519
529 QI_API codecvt_type &unicodeFacet();
530 }
531
532 #endif // _QI_PATH_HPP_
qi::path::confPaths
std::vector< std::string > confPaths(const std::string &applicationName="", bool excludeUserWritablePath=false)
Get the list of directories used when searching for configuration files for the given application nam...
qi::path::findBin
std::string findBin(const std::string &name, bool searchInPath=false)
Look for a binary.
qi::unicodeFacet
codecvt_type & unicodeFacet()
UTF-8 facet object getter.
qi::path::detail::setWritablePath
void setWritablePath(const std::string &path)
Set the writable files path for users.
qi::path::detail::getSdkPrefixes
std::vector< std::string > getSdkPrefixes()
Return the SDK prefixes list. It's always complete, native paths.
qi::path::detail::addOptionalSdkPrefix
void addOptionalSdkPrefix(const char *prefix)
Add a new SDK prefix to the list of searchable prefixes.
QI_API
#define QI_API
Definition: api.hpp:33
qi::path::listLib
std::vector< std::string > listLib(const std::string &subfolder, const std::string &pattern="*")
qi::PathVector
std::vector< Path > PathVector
Definition: path.hpp:27
qi::Path::operator<<
friend std::ostream & operator<<(std::ostream &output, const qi::Path &path)
Standard output stream operator for logging.
Definition: path.hpp:125
api.hpp
dll import/export and compiler message
qi::path::findConf
std::string findConf(const std::string &applicationName, const std::string &filename, bool excludeUserWritablePath=false)
Look for a configuration file.
qi::path::findLib
std::string findLib(const std::string &name)
Look for a library.
qi::path::ScopedDir
Definition: path.hpp:141
qi::path::libPaths
std::vector< std::string > libPaths()
Get the list of directories used when searching for libraries.
qi::Path::str
std::string str() const
qi::path::listData
std::vector< std::string > listData(const std::string &applicationName, const std::string &pattern="*", bool excludeUserWritablePath=false)
List data files matching the given pattern in all dataPaths(applicationName) directories. For each match, return the occurence from the first dataPaths prefix. Directories are discarded.
qi::path::convertToDosPath
std::string convertToDosPath(const std::string &pathString)
Convert given path into DOS 8.3 path if it exists, else returns empty string (Windows only)...
qi::operator==
bool operator==(const Signature &lhs, const Signature &rhs)
QI_API_DEPRECATED_MSG
#define QI_API_DEPRECATED_MSG(msg__)
Compiler flags to mark a function as deprecated. It will generate a compiler warning.
Definition: macro.hpp:55
qi::Path
The Path class allow handling filesystem path in a cross-platform maner. <includename>qi/path.hpp</includename> The class assume that all string are encoded in UTF-8 if not specified otherwise.
Definition: path.hpp:34
qi::path::detail::normalize
Path normalize(const Path &path)
qi::path::userWritableDataPath
std::string userWritableDataPath(const std::string &applicationName, const std::string &filename)
Get the writable data files path for users.
qi::path::ScopedFile
Definition: path.hpp:170
qi::path::binPaths
std::vector< std::string > binPaths()
Get the list of directories used when searching for binaries.
qi::path::findData
std::string findData(const std::string &applicationName, const std::string &filename, bool excludeUserWritablePath=false)
Look for a file in all dataPaths(applicationName) directories, return the first match.
qi::path::sdkPrefix
std::string sdkPrefix()
Return the default SDK prefix path.
qi::log::env::QI_DEFAULT_LOGHANDLER::name
char const *const name
qi::path::userWritableConfPath
std::string userWritableConfPath(const std::string &applicationName, const std::string &filename="")
Get the writable configuration files path for users.
qi::path::dataPaths
std::vector< std::string > dataPaths(const std::string &applicationName="", bool excludeUserWritablePath=false)
Get the list of directories used when searching for data files for the given application name...
qi::path::detail::clearOptionalSdkPrefix
void clearOptionalSdkPrefix()
Reset the list of additional SDK prefixes.
qi::codecvt_type
std::codecvt< wchar_t, char, std::mbstate_t > codecvt_type
Standard std::codecvt type accepted by STL and boost.
Definition: path.hpp:518
qi::operator!=
bool operator!=(const Signature &lhs, const Signature &rhs)
Definition: signature.hpp:157