acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
listing.h
1#pragma once
2
3
4//#include "path_array.h"
5
6
7namespace file
8{
9
10
11 class listing_base;
12 class enumerator;
13
14
15 struct CLASS_DECL_ACME LISTING
16 {
17
18
19 enumerator * m_penumerator = nullptr;
20 bool m_bFile = true;
21 bool m_bDir = true;
22 bool m_bRecursive = false;
23 enum_extract m_eextract = e_extract_first;
24
25
26 };
27
28
29 class CLASS_DECL_ACME listing_base:
30 // recursive fetchings should set a meaningful m_iRelative value at each returned path
32 public LISTING
33 {
34 protected:
35
36
37 using ::file::path_array_base::add;
38
39
40 public:
41
42
43 ::file::path m_pathUser;
44 ::file::path m_pathFinal;
45 ::file::path m_pathBasePath;
46 ::file::e_flag m_eflag;
47 ::enum_depth m_edepth;
48 string_array_base m_straPattern;
49 string_array_base m_straIgnoreName;
50 string_array_base m_straTitle;
51 ::e_status m_estatusListing;
52
53 ::particle_array m_particleaMetaData;
54
55
56 ::function < void(const ::file::path & path) > m_functionOnNewPath;
57
58
59 listing_base();
60 listing_base(const listing_base & listing_base);
61 listing_base(listing_base&& listing_base);
62 ~listing_base();
63
64
65
66 inline void fix_flag()
67 {
68
69 fix_file_listing_flag(m_eflag);
70
71 }
72
73
74 virtual bool on_start_enumerating(::file::enumerator * penumerator);
75
76
77 //bool succeeded() const
78 //{
79
80 // return m_estatus.succeeded();
81
82 //}
83
84 //bool failed() const
85 //{
86
87 // return m_estatus.failed();
88
89 //}
90
91 //operator bool() const
92 //{
93
94 // return m_estatus.succeeded();
95
96 //}
97
98 //bool operator !() const
99 //{
100
101 // return m_estatus.failed();
102
103 //}
104
105 //listing_base & operator = (const ::e_status & estatus) { m_estatus.set_error(estatus); return *this; }
106
107
108 //listing_base& operator = (const ::e_status & estatus) { return *this; }
109 template < prototype_container CONTAINER >
110 inline ::collection::index add_container(const CONTAINER & container)
111 {
112
113 auto iIndex = ::file::path_array_base::append_container(container);
114
115 return iIndex;
116
117 }
118
119
120 template < typename CONTAINER >
121 inline ::collection::index add_listing(const CONTAINER & container)
122 {
123
124 auto iIndex = ::file::path_array_base::append_container(container);
125
126 m_straTitle.append_container(container.m_straTitle);
127
128 return iIndex;
129
130 }
131
132 void operator()(const ::file::path& path)
133 {
134
135 m_pathUser = path;
136 m_pathFinal = path;
137
138 }
139
140
141 ::collection::index add_child(const ::file::path & path)
142 {
143
144 return add(m_pathUser / path);
145
146 }
147
148 ::file::path & add_child_get(const ::file::path & path)
149 {
150
151 return add_get(m_pathUser / path);
152
153 }
154
155
156 listing_base & ignore(const ::scoped_string & scopedstrName)
157 {
158
159 m_straIgnoreName.add(scopedstrName);
160
161 return *this;
162
163 }
164
165
166 //void clear_results() { m_straTitle.erase_all(); m_estatus.clear(); erase_all(); }
167 void clear_results() { m_straTitle.erase_all(); erase_all(); }
168
169
170 string title(::collection::index i);
171
172
173 string name(::collection::index i);
174
175
176 void to_name();
177
178
179 //listing_base & operator = (const listing_base & listing_base);
180
181
182 ::collection::index case_insensitive_name_find_first(const path & pcsz,::collection::index find = 0,::collection::index last = -1) const;
183
184 bool case_insensitive_name_move(const path & pcsz, ::collection::index iIndex);
185
186 bool preferred_name(const path & pcsz);
187
188
189 ::collection::count preferred_name(path_array_base & stra);
190
191
192 void defer_add(::file::path & path);
193
194
195 void set_listing(const ::file::path & path, enum_depth edepth = e_depth_none, ::file::e_flag eflag = ::file::e_flag_none)
196 {
197
198 m_penumerator = nullptr;
199
200 m_pathUser = path;
201
202 m_pathFinal.empty();
203
204 m_eflag = eflag;
205
206 m_edepth = edepth;
207
208 }
209
210
211 void set_folder_listing(const ::file::path & path, enum_depth edepth = e_depth_none)
212 {
213
214 set_listing(path, edepth, ::file::e_flag_folder);
215
216 }
217
218
219 void set_file_listing(const ::file::path & path, enum_depth edepth = e_depth_none)
220 {
221
222 set_listing(path, edepth, ::file::e_flag_file);
223
224 }
225
226
227 void set_pattern_listing(const ::file::path & path, const ::string_array_base & straPattern, enum_depth edepth = e_depth_none, ::file::e_flag eflag = ::file::e_flag_none)
228 {
229
230 m_straPattern = straPattern;
231
232 set_listing(path, edepth, eflag);
233
234 }
235
236
237 void set_pattern_folder_listing(const ::file::path & path, const ::string_array_base & straPattern, enum_depth edepth = e_depth_none)
238 {
239
240 set_pattern_listing(path, straPattern, edepth, ::file::e_flag_folder);
241
242 }
243
244
245 void set_pattern_file_listing(const ::file::path & path, const ::string_array_base & straPattern, enum_depth edepth = e_depth_none)
246 {
247
248 set_pattern_listing(path, straPattern, edepth, ::file::e_flag_file);
249
250 }
251
252 listing_base& operator=(const ::file::listing_base& array);
253
254 listing_base& operator=(::file::listing_base&& array);
255
256 };
257
258
259 class CLASS_DECL_ACME relative_name_listing :
260 virtual public listing_base
261 {
262 public:
263
264
265 relative_name_listing();
266 relative_name_listing(const relative_name_listing & listing_base);
267 virtual ~relative_name_listing();
268
269
270 };
271
272
273 using listing = ::array_particle < listing_base >;
274
275
276} // namespace file
277
278
279
280
281CLASS_DECL_ACME string normalize_wildcard_criteria(const ::scoped_string & scopedstrPattern);
282
283
284CLASS_DECL_ACME bool matches_wildcard_criteria(const string_array_base & straCriteria, const ::scoped_string & scopedstrValue);
285CLASS_DECL_ACME bool case_insensitive_matches_wildcard_criteria(const string_array_base & straCriteria, const ::scoped_string & scopedstrValue);
286
287
Definition e_status.h:30
Definition enumerator.h:14
Definition listing.h:33
Definition path_array.h:19
Definition path.h:52
Definition _template_forward_declaration.h:297
Definition filesystem.h:16
Definition listing.h:16