MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_file_path_view.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_FILE_PATH_VIEW_H_1690714217
12#define INCGUARD_MGL_FILE_PATH_VIEW_H_1690714217
13
15
16namespace MGL::File
17{
20{
21public:
22 /* ------------------------------------------------------------------------- */
27 /* ------------------------------------------------------------------------- */
28 constexpr PathView(const char *path) noexcept
29 : _path(path)
30 {
31 }
32
33 /* ------------------------------------------------------------------------- */
38 /* ------------------------------------------------------------------------- */
39 PathView(const Path &path) noexcept
40 : _path(path.GetCString())
41 {
42 }
43
44 /* ------------------------------------------------------------------------- */
49 /* ------------------------------------------------------------------------- */
50 constexpr operator const char *() const noexcept
51 {
52 return _path;
53 }
54
55 /* ------------------------------------------------------------------------- */
60 /* ------------------------------------------------------------------------- */
61 [[nodiscard]] constexpr const char *GetCString() const noexcept
62 {
63 return _path;
64 }
65
66 [[nodiscard]] Path Append(const char *element) const noexcept;
67 [[nodiscard]] Path Concat(const char *string) const noexcept;
68 [[nodiscard]] Path Concat(char character) const noexcept;
69
70 /* ------------------------------------------------------------------------- */
76 /* ------------------------------------------------------------------------- */
77 [[nodiscard]] Path operator /=(const char *element) const noexcept
78 {
79 return Append(element);
80 }
81
82 /* ------------------------------------------------------------------------- */
88 /* ------------------------------------------------------------------------- */
89 [[nodiscard]] Path operator +=(const char *string) const noexcept
90 {
91 return Concat(string);
92 }
93
94 /* ------------------------------------------------------------------------- */
100 /* ------------------------------------------------------------------------- */
101 [[nodiscard]] Path operator +=(char character) const noexcept
102 {
103 return Concat(character);
104 }
105
106 [[nodiscard]] size_t GetLength() const noexcept;
107 [[nodiscard]] bool IsEmpty() const noexcept;
108
109 [[nodiscard]] Path GetRoot() const noexcept;
110 [[nodiscard]] Path GetMountName() const noexcept;
111 [[nodiscard]] Path GetRelativePath() const noexcept;
112 [[nodiscard]] Path GetParent() const noexcept;
113 [[nodiscard]] Path GetFilename() const noexcept;
114 [[nodiscard]] Path GetStem() const noexcept;
115 [[nodiscard]] Path GetExtension() const noexcept;
116
117private:
118 const char *_path;
119};
120
121} // namespace MGL::File
122
123#endif // INCGUARD_MGL_FILE_PATH_VIEW_H_1690714217
124
125// vim: et ts=4 sw=4 sts=4
ファイルパスクラス
Definition mgl_file_path.h:20
文字列の参照のみを行うファイルパスクラス
Definition mgl_file_path_view.h:20
Path Concat(const char *string) const noexcept
文字列の追加
Definition mgl_file_path_view.cc:46
Path GetStem() const noexcept
拡張子を除いたファイル名を取得
Definition mgl_file_path_view.cc:312
Path operator/=(const char *element) const noexcept
要素の追加
Definition mgl_file_path_view.h:77
constexpr PathView(const char *path) noexcept
コンストラクタ
Definition mgl_file_path_view.h:28
size_t GetLength() const noexcept
パスの長さを取得
Definition mgl_file_path_view.cc:75
constexpr const char * GetCString() const noexcept
C言語の文字列として取得
Definition mgl_file_path_view.h:61
Path GetMountName() const noexcept
マウント名の取得
Definition mgl_file_path_view.cc:145
Path operator+=(const char *string) const noexcept
文字列の追加
Definition mgl_file_path_view.h:89
Path GetParent() const noexcept
親ディレクトリのパスを取得
Definition mgl_file_path_view.cc:221
Path GetRelativePath() const noexcept
マウント名からの相対パスを取得
Definition mgl_file_path_view.cc:181
PathView(const Path &path) noexcept
コンストラクタ
Definition mgl_file_path_view.h:39
bool IsEmpty() const noexcept
パスが空であるかを取得
Definition mgl_file_path_view.cc:93
Path Append(const char *element) const noexcept
要素の追加
Definition mgl_file_path_view.cc:31
Path GetRoot() const noexcept
ルートパスの取得
Definition mgl_file_path_view.cc:114
Path GetFilename() const noexcept
ファイル名の取得
Definition mgl_file_path_view.cc:265
Path GetExtension() const noexcept
拡張子を取得
Definition mgl_file_path_view.cc:385
MGL ファイルパスクラス