Skip to content

Commit cabb20c

Browse files
committed
Move Directory method implementations to source file
1 parent 3ba449e commit cabb20c

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

cpp/src/arrow/filesystem/mockfs.cc

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Status ValidatePath(std::string_view s) {
5454
////////////////////////////////////////////////////////////////////////////
5555
// Filesystem structure
5656

57+
struct Directory;
5758
class Entry;
5859

5960
struct File {
@@ -80,38 +81,19 @@ struct Directory {
8081
TimePoint mtime;
8182
std::map<std::string, std::unique_ptr<Entry>> entries;
8283

83-
Directory(std::string name, TimePoint mtime) : name(std::move(name)), mtime(mtime) {}
84-
Directory(Directory&& other) noexcept
85-
: name(std::move(other.name)),
86-
mtime(other.mtime),
87-
entries(std::move(other.entries)) {}
84+
Directory(std::string name, TimePoint mtime);
85+
Directory(Directory&& other) noexcept;
8886

89-
Directory& operator=(Directory&& other) noexcept {
90-
name = std::move(other.name);
91-
mtime = other.mtime;
92-
entries = std::move(other.entries);
93-
return *this;
94-
}
87+
Directory& operator=(Directory&& other) noexcept;
9588

96-
Entry* Find(const std::string& s) {
97-
auto it = entries.find(s);
98-
if (it != entries.end()) {
99-
return it->second.get();
100-
} else {
101-
return nullptr;
102-
}
103-
}
89+
Entry* Find(const std::string& s);
10490

105-
bool CreateEntry(const std::string& s, std::unique_ptr<Entry> entry) {
106-
DCHECK(!s.empty());
107-
auto p = entries.emplace(s, std::move(entry));
108-
return p.second;
109-
}
91+
bool CreateEntry(const std::string& s, std::unique_ptr<Entry> entry);
11092

11193
void AssignEntry(const std::string& s, std::unique_ptr<Entry> entry);
11294

113-
bool DeleteEntry(const std::string& s) { return entries.erase(s) > 0; }
114-
95+
bool DeleteEntry(const std::string& s);
96+
11597
private:
11698
ARROW_DISALLOW_COPY_AND_ASSIGN(Directory);
11799
};
@@ -120,7 +102,7 @@ struct Directory {
120102
using EntryBase = std::variant<std::nullptr_t, File, Directory>;
121103

122104
class Entry : public EntryBase {
123-
public:
105+
public:
124106
Entry(Entry&&) = default;
125107
Entry& operator=(Entry&&) = default;
126108
explicit Entry(Directory&& v) : EntryBase(std::move(v)) {}
@@ -180,15 +162,45 @@ class Entry : public EntryBase {
180162
}
181163
}
182164

183-
private:
165+
private:
184166
ARROW_DISALLOW_COPY_AND_ASSIGN(Entry);
185167
};
186168

169+
Directory::Directory(std::string name, TimePoint mtime) : name(std::move(name)), mtime(mtime) {}
170+
Directory::Directory(Directory&& other) noexcept
171+
: name(std::move(other.name)),
172+
mtime(other.mtime),
173+
entries(std::move(other.entries)) {}
174+
175+
Directory& Directory::operator=(Directory&& other) noexcept {
176+
name = std::move(other.name);
177+
mtime = other.mtime;
178+
entries = std::move(other.entries);
179+
return *this;
180+
}
181+
182+
Entry* Directory::Find(const std::string& s) {
183+
auto it = entries.find(s);
184+
if (it != entries.end()) {
185+
return it->second.get();
186+
} else {
187+
return nullptr;
188+
}
189+
}
190+
191+
bool Directory::CreateEntry(const std::string& s, std::unique_ptr<Entry> entry) {
192+
DCHECK(!s.empty());
193+
auto p = entries.emplace(s, std::move(entry));
194+
return p.second;
195+
}
196+
187197
void Directory::AssignEntry(const std::string& s, std::unique_ptr<Entry> entry) {
188198
DCHECK(!s.empty());
189199
entries[s] = std::move(entry);
190200
}
191201

202+
bool Directory::DeleteEntry(const std::string& s) { return entries.erase(s) > 0; }
203+
192204
////////////////////////////////////////////////////////////////////////////
193205
// Streams
194206

0 commit comments

Comments
 (0)