Get rid of find::scan_path_matches_t typdef

This is (now) just a std::vector of find::match_t records.
This commit is contained in:
Allan Odgaard
2014-08-18 21:40:58 +02:00
parent c7346421ce
commit a3d085a44f
4 changed files with 15 additions and 17 deletions

View File

@@ -339,7 +339,7 @@ OAK_DEBUG_VAR(Find_FolderSearch);
BOOL scannerIsStopped = !scanner->is_running();
find::scan_path_matches_t const& matches = scanner->accept_matches();
std::vector<find::match_t> const& matches = scanner->accept_matches();
if(!matches.empty())
{
[self willChangeValueForKey:@"countOfMatches"];

View File

@@ -128,10 +128,10 @@ namespace find
return is_running_flag;
}
scan_path_matches_t scan_path_t::accept_matches ()
std::vector<match_t> scan_path_t::accept_matches ()
{
pthread_mutex_lock(&mutex);
scan_path_matches_t res;
std::vector<match_t> res;
res.swap(matches);
pthread_mutex_unlock(&mutex);
return res;

View File

@@ -35,8 +35,6 @@ namespace find
bool binary;
};
typedef std::vector<match_t> scan_path_matches_t;
// NOTE: This class is public _only_ for use in testing
struct PUBLIC scan_path_t
{
@@ -65,7 +63,7 @@ namespace find
// while running, probe it to see if it is still running, periodically accept results, and update the folder it shows as being scanned
bool is_running () const;
scan_path_matches_t accept_matches ();
std::vector<match_t> accept_matches ();
std::string get_current_path () const;
std::string const& get_string () const { return string; };
folder_scan_settings_t const& folder_options () const { return search; };
@@ -83,7 +81,7 @@ namespace find
folder_scan_settings_t search;
std::string current_path;
scan_path_matches_t matches;
std::vector<match_t> matches;
volatile bool is_running_flag, should_stop_flag;
size_t scanned_file_count;

View File

@@ -20,7 +20,7 @@ void test_simple ()
scanner.set_folder_options(folder_scan_settings_t(jail.path()));
run_scanner(scanner);
scan_path_matches_t matches = scanner.accept_matches();
std::vector<match_t> matches = scanner.accept_matches();
OAK_ASSERT_EQ(matches.size(), 1);
OAK_ASSERT_EQ(scanner.get_scanned_file_count(), 2);
OAK_ASSERT_EQ(matches.front().document->path(), jail.path("matches"));
@@ -38,7 +38,7 @@ void test_globs ()
scanner.set_folder_options(folder_scan_settings_t(jail.path(), "*.{x,z}"));
run_scanner(scanner);
scan_path_matches_t matches = scanner.accept_matches();
std::vector<match_t> matches = scanner.accept_matches();
OAK_ASSERT_EQ(matches.size(), 1);
OAK_ASSERT_EQ(scanner.get_scanned_file_count(), 2);
OAK_ASSERT_EQ(matches.front().document->path(), jail.path("text.x"));
@@ -60,7 +60,7 @@ void test_exclude_globs ()
scanner.set_folder_options(folder_scan_settings_t(jail.path(), globs));
run_scanner(scanner);
scan_path_matches_t matches = scanner.accept_matches();
std::vector<match_t> matches = scanner.accept_matches();
OAK_ASSERT_EQ(scanner.get_scanned_file_count(), 2);
OAK_ASSERT_EQ(matches.size(), 2);
OAK_ASSERT_EQ(matches[0].document->path(), jail.path("text.x"));
@@ -73,7 +73,7 @@ void test_ignore_hidden ()
jail.set_content("visible", "text");
jail.set_content(".hidden/hidden", "text");
scan_path_matches_t matches;
std::vector<match_t> matches;
folder_scan_settings_t search(jail.path());
scan_path_t scanner;
@@ -103,7 +103,7 @@ void test_follow_links ()
jail.set_content("linked/match.txt", "text");
jail.ln("start/link", "linked");
scan_path_matches_t matches;
std::vector<match_t> matches;
folder_scan_settings_t search(jail.path("start"));
scan_path_t scanner;
@@ -137,7 +137,7 @@ void test_file_links_are_skipped ()
scanner.set_folder_options(folder_scan_settings_t(jail.path()));
run_scanner(scanner);
scan_path_matches_t matches = scanner.accept_matches();
std::vector<match_t> matches = scanner.accept_matches();
OAK_ASSERT_EQ(matches.size(), 1);
OAK_ASSERT_EQ(scanner.get_scanned_file_count(), 1);
}
@@ -156,7 +156,7 @@ void test_duplicate_links ()
scanner.set_folder_options(search);
run_scanner(scanner);
scan_path_matches_t matches = scanner.accept_matches();
std::vector<match_t> matches = scanner.accept_matches();
OAK_ASSERT_EQ(matches.size(), 1);
OAK_ASSERT_EQ(scanner.get_scanned_file_count(), 1);
}
@@ -171,7 +171,7 @@ void test_file_lf ()
scanner.set_folder_options(folder_scan_settings_t(jail.path()));
run_scanner(scanner);
scan_path_matches_t matches = scanner.accept_matches();
std::vector<match_t> matches = scanner.accept_matches();
OAK_ASSERT_EQ(matches.size(), 4);
OAK_ASSERT_EQ(matches[0].range.min().line, 0);
@@ -190,7 +190,7 @@ void test_file_cr ()
scanner.set_folder_options(folder_scan_settings_t(jail.path()));
run_scanner(scanner);
scan_path_matches_t matches = scanner.accept_matches();
std::vector<match_t> matches = scanner.accept_matches();
OAK_ASSERT_EQ(matches.size(), 4);
OAK_ASSERT_EQ(matches[0].range.min().line, 0);
@@ -209,7 +209,7 @@ void test_file_crlf ()
scanner.set_folder_options(folder_scan_settings_t(jail.path()));
run_scanner(scanner);
scan_path_matches_t matches = scanner.accept_matches();
std::vector<match_t> matches = scanner.accept_matches();
OAK_ASSERT_EQ(matches.size(), 4);
OAK_ASSERT_EQ(matches[0].range.min().line, 0);