MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_file_path.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_FILE_PATH_H_1690354479
12#define INCGUARD_MGL_FILE_PATH_H_1690354479
13
15
16namespace MGL::File
17{
19class Path
20{
21public:
22 Path(size_t reserveSize = 0) noexcept;
23 Path(const char *path) noexcept;
24 Path(const char *path, size_t reserveSize) noexcept;
25
26 /* ------------------------------------------------------------------------- */
31 /* ------------------------------------------------------------------------- */
32 operator const char *() const noexcept
33 {
34 return _path.c_str();
35 }
36
37 /* ------------------------------------------------------------------------- */
42 /* ------------------------------------------------------------------------- */
43 [[nodiscard]] const char *GetCString() const noexcept
44 {
45 return _path.c_str();
46 }
47
48 Path &Append(const char *element) noexcept;
49 Path &Concat(const char *string) noexcept;
50 Path &Concat(char character) noexcept;
51
52 /* ------------------------------------------------------------------------- */
58 /* ------------------------------------------------------------------------- */
59 Path &operator/=(const char *element) noexcept
60 {
61 return Append(element);
62 }
63
64 /* ------------------------------------------------------------------------- */
70 /* ------------------------------------------------------------------------- */
71 Path &operator+=(const char *string) noexcept
72 {
73 return Concat(string);
74 }
75
76 /* ------------------------------------------------------------------------- */
82 /* ------------------------------------------------------------------------- */
83 Path &operator+=(char character) noexcept
84 {
85 return Concat(character);
86 }
87
88 /* ------------------------------------------------------------------------- */
93 /* ------------------------------------------------------------------------- */
94 [[nodiscard]] size_t GetLength() const noexcept
95 {
96 return _path.length();
97 }
98
99 /* ------------------------------------------------------------------------- */
105 /* ------------------------------------------------------------------------- */
106 [[nodiscard]] bool IsEmpty() const noexcept
107 {
108 return _path.empty();
109 }
110
111 [[nodiscard]] Path GetRoot() const noexcept;
112 [[nodiscard]] Path GetMountName() const noexcept;
113 [[nodiscard]] Path GetRelativePath() const noexcept;
114 [[nodiscard]] Path GetParent() const noexcept;
115 [[nodiscard]] Path GetFilename() const noexcept;
116 [[nodiscard]] Path GetStem() const noexcept;
117 [[nodiscard]] Path GetExtension() const noexcept;
118
119 /* ------------------------------------------------------------------------- */
123 /* ------------------------------------------------------------------------- */
124 void Clear() noexcept
125 {
126 _path.clear();
127 }
128
129 /* ------------------------------------------------------------------------- */
134 /* ------------------------------------------------------------------------- */
135 void Set(const char *path) noexcept
136 {
137 _path = path;
138 }
139
140private:
141 MGL::STL::string _path;
142};
143
144} // namespace MGL::File
145
146#endif // INCGUARD_MGL_FILE_PATH_H_1690354479
147
148// vim: et ts=4 sw=4 sts=4
ファイルパスクラス
Definition mgl_file_path.h:20
bool IsEmpty() const noexcept
パスが空であるかを取得
Definition mgl_file_path.h:106
Path GetExtension() const noexcept
拡張子を取得
Definition mgl_file_path.cc:186
Path & operator/=(const char *element) noexcept
要素の追加
Definition mgl_file_path.h:59
void Set(const char *path) noexcept
パスを設定
Definition mgl_file_path.h:135
Path GetRoot() const noexcept
ルートパスの取得
Definition mgl_file_path.cc:114
const char * GetCString() const noexcept
C言語の文字列として取得
Definition mgl_file_path.h:43
Path & Concat(const char *string) noexcept
文字列の追加
Definition mgl_file_path.cc:85
size_t GetLength() const noexcept
パスの長さを取得
Definition mgl_file_path.h:94
Path & operator+=(const char *string) noexcept
文字列の追加
Definition mgl_file_path.h:71
void Clear() noexcept
要素を削除
Definition mgl_file_path.h:124
Path GetFilename() const noexcept
ファイル名の取得
Definition mgl_file_path.cc:162
Path & Append(const char *element) noexcept
要素の追加
Definition mgl_file_path.cc:65
Path GetStem() const noexcept
拡張子を除いたファイル名を取得
Definition mgl_file_path.cc:174
Path & operator+=(char character) noexcept
文字の追加
Definition mgl_file_path.h:83
Path GetMountName() const noexcept
マウント名の取得
Definition mgl_file_path.cc:126
Path GetRelativePath() const noexcept
ルートまたはマウントからの相対パスを取得
Definition mgl_file_path.cc:138
Path(size_t reserveSize=0) noexcept
コンストラクタ
Definition mgl_file_path.cc:34
Path GetParent() const noexcept
親ディレクトリのパスを取得
Definition mgl_file_path.cc:150
MGL STL文字列クラスの代替
basic_string< char > string
std::stringの代替
Definition mgl_stl_string.h:25