-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
838c9d6
commit 9ceaae5
Showing
16 changed files
with
501 additions
and
429 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module; | ||
#include <string> | ||
#include <vector> | ||
export module Tools.Files; | ||
export namespace Riddle { | ||
class Files { | ||
//我们应该增加一个缓存吗 | ||
public: | ||
/// @brief 递归获取某个路径下的所有文件 | ||
/// @param path 路径 | ||
/// @return 递归路径下的所有文件 | ||
static std::vector<std::string> getTreeFile(const std::string &path); | ||
/// @brief 递归获取某个路经下的所有源文件 | ||
/// @param path 路径 | ||
/// @return 递归路径下的所有源文件 | ||
static std::vector<std::string> getTreeSource(const std::string &path); | ||
/// @brief 获取某个路径下的所有文件 | ||
/// @param path 路径 | ||
/// @return 路径下的所有文件 | ||
static std::vector<std::string> getFiles(const std::string &path); | ||
/// @brief 获取某个路径下的所有源文件 | ||
/// @param path 路径 | ||
/// @return 路径下的所有源文件 | ||
static std::vector<std::string> getSources(const std::string &path); | ||
/// @brief 读取某个文件中的所有内容 | ||
/// @param path 文件路径 | ||
/// @return 文件内容 | ||
static std::vector<std::string> getFileTextLine(const std::string &path); | ||
/// @brief 获取某个文件的第一行 | ||
/// @param path 文件路径 | ||
/// @return 文件第一行 | ||
static std::string getFileFirstLine(const std::string &path); | ||
/// @brief 检查某个文件是否为空 | ||
/// @param path 文件路径 | ||
/// @return 文件是否为空 | ||
static bool isFileEmpty(const std::string &path); | ||
/// @brief 获取文件名称,也就是去除路径 | ||
/// @param path 文件路径 | ||
/// @return 文件名称 | ||
static std::string getFileName(const std::string &path); | ||
}; | ||
}// namespace Riddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module; | ||
#include <stdexcept> | ||
#include <string> | ||
#include <vector> | ||
export module Tools.Options; | ||
import Tools.Files; | ||
export namespace Riddle { | ||
class Options { | ||
public: | ||
std::string source; | ||
std::string output; | ||
bool isMultiThread = false; | ||
Options() = default; | ||
explicit Options(std::vector<std::string>&args) { | ||
if (args.empty()) { | ||
return; | ||
} | ||
// 解析 args | ||
bool isExpect = false; | ||
std::string pre; | ||
for (const auto& arg : args) { | ||
if(isExpect) { | ||
if(pre == "--source" || pre == "-s") { | ||
source = arg; | ||
pre = ""; | ||
} | ||
else if (pre == "--output" || pre == "-o") { | ||
output = arg; | ||
pre = ""; | ||
} | ||
isExpect = false; | ||
} | ||
if(arg[0]=='-') { | ||
isExpect = true; | ||
} | ||
if(arg == "-m" || arg == "--multi-thread") { | ||
isMultiThread = true; | ||
isExpect = false; | ||
pre = ""; | ||
} | ||
if(source.empty()) { | ||
source = arg; | ||
} | ||
pre = arg; | ||
|
||
} | ||
// 自动补全 | ||
if(source.empty()) { | ||
throw std::invalid_argument("Options source is empty"); | ||
} | ||
if(output.empty()) { | ||
output = Files::getFileName(source); | ||
} | ||
} | ||
}; | ||
} // namespace Riddle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters