-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLineCounter.h
More file actions
33 lines (23 loc) · 881 Bytes
/
Copy pathLineCounter.h
File metadata and controls
33 lines (23 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include <string>
#include <mutex>
#include <filesystem>
#include <future>
#include "LineCountStatistic.h"
class LineCounter
{
public:
void ProcessFile(const std::filesystem::directory_entry& entry);
void ProcessDirectory(const std::string& root_folder);
void ProcessFileConcurrently(const std::filesystem::directory_entry& entry, std::vector<std::future<void>>& tasks);
void ProcessDirectoryConcurrently(const std::string& root_folder);
void SaveToStream(std::ostream& os, std::chrono::duration<double>);
LineCountStatistic get_total_line_count() { return m_total_line_counts; }
private:
LineCountStatistic m_total_line_counts;
size_t m_total_files = 0;
std::mutex m_mutex;
void CountLinesInFile(const std::string& file_path);
bool static IsCppOrCFile(const std::string& extension);
bool CheckForSingleFile(const std::string& root_folder);
};