本文整理汇总了C++中std::filesystem::path::stem方法的典型用法代码示例。如果您正苦于以下问题:C++ path::stem方法的具体用法?C++ path::stem怎么用?C++ path::stem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::filesystem::path
的用法示例。
在下文中一共展示了path::stem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _parse_query_file
void FileBasedBenchmarkItemRunner::_parse_query_file(
const std::filesystem::path& query_file_path, const std::optional<std::unordered_set<std::string>>& query_subset) {
std::ifstream file(query_file_path);
// The names of queries from, e.g., "queries/TPCH-7.sql" will be prefixed with "TPCH-7."
const auto item_name_prefix = query_file_path.stem().string();
std::string content{std::istreambuf_iterator<char>(file), {}};
/**
* A file can contain multiple SQL statements, and each statement may cover one or more lines.
* We use the SQLParser to split up the content of the file into the individual SQL statements.
*/
hsql::SQLParserResult parse_result;
hsql::SQLParser::parse(content, &parse_result);
Assert(parse_result.isValid(), create_sql_parser_error_message(content, parse_result));
std::vector<Query> queries_in_file{parse_result.size()};
size_t sql_string_offset{0u};
for (auto statement_idx = size_t{0}; statement_idx < parse_result.size(); ++statement_idx) {
const auto item_name = item_name_prefix + '.' + std::to_string(statement_idx);
const auto statement_string_length = parse_result.getStatement(statement_idx)->stringLength;
const auto statement_string = boost::trim_copy(content.substr(sql_string_offset, statement_string_length));
sql_string_offset += statement_string_length;
queries_in_file[statement_idx] = {item_name, statement_string};
}
// Remove ".0" from the end of the query name if there is only one file
if (queries_in_file.size() == 1) {
queries_in_file.front().name.erase(queries_in_file.front().name.end() - 2, queries_in_file.front().name.end());
}
/**
* Add queries to _queries and _item_names, if query_subset allows it
*/
for (const auto& query : queries_in_file) {
if (!query_subset || query_subset->count(query.name)) {
_queries.emplace_back(query);
}
}
}