Debian Codegraph @

src/filesystem/dpathbuf.cpp

raw
1 // SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2 //
3 // SPDX-License-Identifier: LGPL-3.0-or-later
4
5 #include "dpathbuf.h"
6
7 /*!
8 \class Dtk::Core::DPathBuf
9 \inmodule dtkcore
10 \brief Dtk::Core::DPathBuf cat path friendly and supoort multiplatform.
11 \brief Dtk::Core::DPathBuf是一个用于跨平台拼接路径的辅助类.
12
13 它能够方便的写出链式结构的路径拼接代码。
14 \code
15 DPathBuf logPath(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first());
16 logPath = logPath / ".cache" / "deepin" / "deepin-test-dtk" / "deepin-test-dtk.log";
17 \endcode
18 */
19
20 DCORE_BEGIN_NAMESPACE
21
22 /*!
23 \fn DPathBuf DPathBuf::operator/(const QString &p) const
24 \brief join path with operator /
25 \a p is subpath
26 \return a new DPathBuf with subpath p
27 */
28
29 /*!
30 \fn DPathBuf &DPathBuf::operator/=(const QString &p)
31 \brief join path to self with operator /=
32 \a p is subpath to join
33 \return self object
34 */
35
36 /*!
37 \fn DPathBuf DPathBuf::operator/(const char *p) const
38 \brief join path with operator /
39 \a p is subpath
40 \return a new DPathBuf with subpath p
41 \sa Dtk::Core::DPathBuf::operator/(const QString &p)
42 */
43
44 /*!
45 \fn DPathBuf &DPathBuf::operator/=(const char *p)
46 \brief join path to self with operator /=
47 \a p is subpath to join
48 \return self object
49 \sa operator/=(const QString &p)
50 */
51
52 /*!
53 \fn DPathBuf &DPathBuf::join(const QString &p)
54 \brief join add subpath p to self
55 \a p is subpath to join
56 \return slef object with subpath joined
57 */
58
59 /*!
60 \fn QString DPathBuf::toString() const
61 \brief toString export native separators format string.
62 \return string with native separators
63 */
64
65 /*!
66 \brief Create Dtk::Core::DPathBuf from string.
67 \a path
68 */
69 DPathBuf::DPathBuf(const QString &path)
70 {
71 m_path = QDir(path).absolutePath();
72 }
73
74 DPathBuf::DPathBuf()
75 : DPathBuf(QString())
76 {
77
78 }
79
80 DCORE_END_NAMESPACE