mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
GitIgnore/GitIgnoreStack add copy constructors and assignment operators
Summary: GitIgnore and GitIgnoreStack encapsulate details of ignore files. Further changes (as part of this commit stack) require copy constructors and assignment operators. Also, compiler wants destructors in .cpp file (since otherwise, it cannot tell the object size).Keeping this as a separate commit to simplify review process. Reviewed By: simpkins Differential Revision: D8730299 fbshipit-source-id: 7cb443906143c80209278b85fc5ad4dc5ea0bf56
This commit is contained in:
parent
5fd3e0e6b9
commit
00ad72e97c
@ -21,6 +21,14 @@ namespace eden {
|
||||
|
||||
GitIgnore::GitIgnore() {}
|
||||
|
||||
GitIgnore::GitIgnore(GitIgnore const&) = default;
|
||||
GitIgnore& GitIgnore::operator=(GitIgnore const&) = default;
|
||||
GitIgnore::GitIgnore(GitIgnore&&) noexcept(
|
||||
std::is_nothrow_move_constructible<std::vector<GitIgnorePattern>>::value) =
|
||||
default;
|
||||
GitIgnore& GitIgnore::operator=(GitIgnore&&) noexcept(
|
||||
std::is_nothrow_move_assignable<std::vector<GitIgnorePattern>>::value) =
|
||||
default;
|
||||
GitIgnore::~GitIgnore() {}
|
||||
|
||||
void GitIgnore::loadFile(StringPiece contents) {
|
||||
|
@ -94,9 +94,10 @@ class GitIgnore {
|
||||
|
||||
GitIgnore();
|
||||
virtual ~GitIgnore();
|
||||
GitIgnore(GitIgnore&&) = default;
|
||||
GitIgnore(GitIgnore const&) = delete;
|
||||
GitIgnore& operator=(GitIgnore const&) = delete;
|
||||
GitIgnore(GitIgnore&&) noexcept(
|
||||
std::is_nothrow_move_constructible<std::vector<GitIgnorePattern>>::value);
|
||||
GitIgnore(GitIgnore const&);
|
||||
GitIgnore& operator=(GitIgnore const&);
|
||||
|
||||
/**
|
||||
* Move assignment operator.
|
||||
@ -105,7 +106,8 @@ class GitIgnore {
|
||||
* providing synchronization between this operation and anyone else using the
|
||||
* GitIgnore object from other threads.
|
||||
*/
|
||||
GitIgnore& operator=(GitIgnore&&) = default;
|
||||
GitIgnore& operator=(GitIgnore&&) noexcept(
|
||||
std::is_nothrow_move_assignable<std::vector<GitIgnorePattern>>::value);
|
||||
|
||||
/**
|
||||
* Parse the contents of a gitignore file.
|
||||
@ -159,6 +161,13 @@ class GitIgnore {
|
||||
PathComponentPiece basename,
|
||||
FileType fileType) const;
|
||||
|
||||
/**
|
||||
* @return true if there are no rules.
|
||||
*/
|
||||
bool empty() const {
|
||||
return rules_.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a human-readable description of a MatchResult enum value.
|
||||
*
|
||||
|
@ -38,6 +38,9 @@ class GitIgnorePattern {
|
||||
GitIgnorePattern(GitIgnorePattern&&) = default;
|
||||
GitIgnorePattern& operator=(GitIgnorePattern&&) = default;
|
||||
|
||||
GitIgnorePattern(GitIgnorePattern const&) = default;
|
||||
GitIgnorePattern& operator=(GitIgnorePattern const&) = default;
|
||||
|
||||
/**
|
||||
* Check to see if a pathname matches this pattern.
|
||||
*
|
||||
@ -86,9 +89,6 @@ class GitIgnorePattern {
|
||||
|
||||
GitIgnorePattern(uint32_t flags, GlobMatcher&& matcher);
|
||||
|
||||
GitIgnorePattern(GitIgnorePattern const&) = delete;
|
||||
GitIgnorePattern& operator=(GitIgnorePattern const&) = delete;
|
||||
|
||||
/**
|
||||
* A bit set of the Flags defined above.
|
||||
*/
|
||||
|
@ -62,6 +62,9 @@ class GitIgnoreStack {
|
||||
ignore_.loadFile(ignoreFileContents);
|
||||
}
|
||||
|
||||
GitIgnoreStack(const GitIgnoreStack* parent, GitIgnore ignore)
|
||||
: ignore_{std::move(ignore)}, parent_{parent} {}
|
||||
|
||||
/**
|
||||
* Get the MatchResult for a path.
|
||||
*/
|
||||
@ -69,6 +72,10 @@ class GitIgnoreStack {
|
||||
RelativePathPiece path,
|
||||
GitIgnore::FileType fileType) const;
|
||||
|
||||
bool empty() const {
|
||||
return ignore_.empty();
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* The GitIgnore info for this node on the stack
|
||||
|
@ -55,6 +55,8 @@ class GlobMatcher {
|
||||
~GlobMatcher();
|
||||
GlobMatcher(GlobMatcher&&) = default;
|
||||
GlobMatcher& operator=(GlobMatcher&&) = default;
|
||||
GlobMatcher(const GlobMatcher&) = default;
|
||||
GlobMatcher& operator=(const GlobMatcher&) = default;
|
||||
|
||||
/**
|
||||
* Create a GlobMatcher object from a glob pattern.
|
||||
|
Loading…
Reference in New Issue
Block a user