Browse Source

unordered_map

master
alistair 3 years ago
parent
commit
ad2509f3c0
  1. 6
      CMakeLists.txt
  2. 54
      main.cpp
  3. 8
      markdown.cpp
  4. 8
      markdown.h
  5. 56
      templater.hpp
  6. 6
      util.cpp
  7. 15
      util.h

6
CMakeLists.txt

@ -8,13 +8,10 @@ set(CMAKE_CXX_EXTENSIONS OFF) @@ -8,13 +8,10 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(BUILD_SHARED_LIBS OFF)
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_EXE_LINKER_FLAGS "-static")
set(CMAKE_CXX_FLAGS "-static -static-libstdc++ -static-libgcc")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif ()
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -fno-omit-frame-pointer -fsanitize=address")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
@ -49,7 +46,6 @@ if(NOT TARGET spdlog) @@ -49,7 +46,6 @@ if(NOT TARGET spdlog)
find_package(spdlog REQUIRED)
endif()
ADD_EXECUTABLE(stgen3 util.cpp darkhttpd.c duktape/src/duktape.c markdown.cpp main.cpp)
target_include_directories(stgen3 PRIVATE include duktape/src)

54
main.cpp

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
#include <type_traits>
#include <ranges>
#include <stack>
#include <map>
#include <unordered_map>
#include <thread>
#include <queue>
@ -255,13 +255,13 @@ namespace stgen { @@ -255,13 +255,13 @@ namespace stgen {
class builder {
mmd::markdown_parser parser;
std::map<std::string, std::string> default_templates;
std::map<std::string, std::string> properties;
std::unordered_map<std::string, std::string> default_templates;
std::unordered_map<std::string, std::string> properties;
templater *templr;
templater *textsub_templr;
templater *s2_templr;
std::map<fs::path, time_t> last_build;
std::unordered_map<fs::path, time_t, pathHash> last_build;
duk::duktape dukengine {};
@ -580,9 +580,9 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -580,9 +580,9 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
* 3. recurse for each folder
*
*/
void build_recursive(std::map<std::string, std::string> page_templates,
std::map<std::string, std::string> properties,
std::map<fs::path, blog_item> &compile_jobs,
void build_recursive(std::unordered_map<std::string, std::string> page_templates,
std::unordered_map<std::string, std::string> properties,
std::unordered_map<fs::path, blog_item, pathHash> &compile_jobs,
const fs::path &directory) {
@ -591,7 +591,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -591,7 +591,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
properties["current_directory"] = directory;
// update the properties map if there is a new cconfig file
// update the properties unordered_map if there is a new cconfig file
// and not in testing mode
fs::path confname = fs::path(directory) / SITE_CONFIG_FNAME;
@ -600,7 +600,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -600,7 +600,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
std::ifstream conffile (confname);
conffile >> parse_json;
// dump json into properties map
// dump json into properties unordered_map
for (json::iterator it = parse_json.begin(); it != parse_json.end(); ++it) {
if (!settings.readonly_properties.count(it.key()))
properties[it.key()] = it.value();
@ -680,7 +680,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -680,7 +680,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
// create a copy to prevent inheritance
std::map<std::string, std::string> article_properties (properties);
std::unordered_map<std::string, std::string> article_properties (properties);
article_properties["current_file"] = entry.string();
article_properties["page_url"] = compute_url(entry.string(), article_properties);
@ -785,7 +785,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -785,7 +785,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
if (ext == "md" || ext == "markdown") {
text = parser.parse_to_html(text);
text = postprocess_math(text);
//text = postprocess_math(text);
}
@ -797,14 +797,14 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -797,14 +797,14 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
/* write content into template */
std::map<std::string, std::string> sub_content_keys {{"body", text}};
std::unordered_map<std::string, std::string> sub_content_keys {{"body", text}};
textsub_templr->run_substitution_plugins_once(new_page, sub_content_keys);
article_properties["body"] = new_page;
notify_file_write(target);
compile_jobs[target] = {job_t, entry, std::map<std::string, std::string>(article_properties), article_last_update};
compile_jobs[target] = {job_t, entry, std::unordered_map<std::string, std::string>(article_properties), article_last_update};
continue;
}
@ -812,7 +812,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -812,7 +812,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
// else just copy
auto target = compute_target(entry, article_properties);
notify_file_write(target);
compile_jobs[target] = {job_type::COPY_FILE, entry, std::map<std::string, std::string>(article_properties), dir_last_update_time};
compile_jobs[target] = {job_type::COPY_FILE, entry, std::unordered_map<std::string, std::string>(article_properties), dir_last_update_time};
// build
@ -835,13 +835,13 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -835,13 +835,13 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
}
compile_jobs[compute_target(directory, properties)] = {job_type::MAKE_DIR, directory, std::map<std::string, std::string>(properties), dir_last_update_time};
compile_jobs[compute_target(directory, properties)] = {job_type::MAKE_DIR, directory, std::unordered_map<std::string, std::string>(properties), dir_last_update_time};
// recurse
for (auto d : next_directories) {
build_recursive(std::map<std::string, std::string>(page_templates),
std::map<std::string, std::string>(properties), compile_jobs, d);
build_recursive(std::unordered_map<std::string, std::string>(page_templates),
std::unordered_map<std::string, std::string>(properties), compile_jobs, d);
}
if (directory.string() != properties.at("source_root")) {
@ -871,7 +871,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -871,7 +871,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
json default_properties {};
in >> default_properties;
std::map<std::string,std::string> m2 = default_properties;
std::unordered_map<std::string,std::string> m2 = default_properties;
// update properties
properties.merge(m2);
@ -903,8 +903,9 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -903,8 +903,9 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
}
public:
builder(std::map<std::string, std::string> m) : properties(m)
builder(std::unordered_map<std::string, std::string> m)
{
properties = m;
templr = new templater({new variable_transclude_plugin{}, new file_index_plugin{{SITE_CONFIG_FNAME, "index.md", "html.template"}}, new ifdef_plugin{}, new ifndef_plugin{}, new file_transclude_plugin{}, new mmd_snippet_transclude_plugin{}},
{new rss_feed_plugin{}, new microblog_plugin{}});
@ -939,7 +940,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -939,7 +940,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
}
void
write_build(std::map<fs::path, blog_item> &compile_jobs)
write_build(std::unordered_map<fs::path, blog_item, pathHash> &compile_jobs)
{
time_t now = to_time_t(std::chrono::system_clock::now());
@ -999,6 +1000,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -999,6 +1000,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
void
build()
{
@ -1019,11 +1021,11 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -1019,11 +1021,11 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
}
}
std::map<fs::path, blog_item> compile_jobs {};
std::unordered_map<fs::path, blog_item, pathHash> compile_jobs {};
build_recursive(
default_templates,
std::map<std::string, std::string>(properties),
std::unordered_map<std::string, std::string>(properties),
compile_jobs,
start_dir
);
@ -1125,7 +1127,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -1125,7 +1127,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
}
/*
* Defaults have to be imported into the properties map first
* Defaults have to be imported into the properties unordered_map first
*/
void dump_default_site_template() {
@ -1160,7 +1162,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document, @@ -1160,7 +1162,7 @@ lxb_html_document_parse_fragment(lxb_html_document_t *document,
};
std::map<std::string, std::string> parse_options (int argc, char **argv) {
std::unordered_map<std::string, std::string> parse_options (int argc, char **argv) {
cxxopts::Options options("stgen3", "A tiny C++ static site generator.\n\r");
@ -1186,7 +1188,7 @@ std::map<std::string, std::string> parse_options (int argc, char **argv) { @@ -1186,7 +1188,7 @@ std::map<std::string, std::string> parse_options (int argc, char **argv) {
auto result = options.parse(argc, argv);
std::map<std::string, std::string> parsed_opts {};
std::unordered_map<std::string, std::string> parsed_opts {};
if (result.count("documentation")) {
const std::string documentation = std::string{(char *)default_templates_documentation_md, default_templates_documentation_md_len};
@ -1236,7 +1238,7 @@ std::map<std::string, std::string> parse_options (int argc, char **argv) { @@ -1236,7 +1238,7 @@ std::map<std::string, std::string> parse_options (int argc, char **argv) {
std::ifstream conffile (confname);
conffile >> parse_json;
// dump json into properties map
// dump json into properties unordered_map
for (json::iterator it = parse_json.begin(); it != parse_json.end(); ++it) {
parsed_opts[it.key()] = it.value();
}

8
markdown.cpp

@ -4,7 +4,7 @@ using namespace mmd; @@ -4,7 +4,7 @@ using namespace mmd;
int instances = 0;
std::map<std::string, std::string> markdown_parser::get_all_metavalues(mmd_engine *engine) {
std::unordered_map<std::string, std::string> markdown_parser::get_all_metavalues(mmd_engine *engine) {
char *key_cstr = mmd_engine_metadata_keys(engine);
if (!key_cstr) {
@ -15,7 +15,7 @@ std::map<std::string, std::string> markdown_parser::get_all_metavalues(mmd_engin @@ -15,7 +15,7 @@ std::map<std::string, std::string> markdown_parser::get_all_metavalues(mmd_engin
std::string_view key_str (key_cstr);
std::istringstream keyss (key_cstr);
std::map<std::string, std::string> keys;
std::unordered_map<std::string, std::string> keys;
for (std::string key; std::getline(keyss, key); ) {
char *value = mmd_engine_metavalue_for_key(engine, key.c_str());
@ -97,7 +97,7 @@ std::optional<std::string> markdown_parser::get_property(std::string const &file @@ -97,7 +97,7 @@ std::optional<std::string> markdown_parser::get_property(std::string const &file
}
}
std::map<std::string, std::string> markdown_parser::get_all_metavalues() {
std::unordered_map<std::string, std::string> markdown_parser::get_all_metavalues() {
assert(engine);
if (!engine) {
spdlog::error("get_all_metavalues: No Engine");
@ -107,7 +107,7 @@ std::map<std::string, std::string> markdown_parser::get_all_metavalues() { @@ -107,7 +107,7 @@ std::map<std::string, std::string> markdown_parser::get_all_metavalues() {
return get_all_metavalues(engine);
}
std::map<std::string, std::string> markdown_parser::get_all_metavalues(std::string const &file_text) {
std::unordered_map<std::string, std::string> markdown_parser::get_all_metavalues(std::string const &file_text) {
mmd_engine *e = mmd_engine_create_with_string(file_text.c_str(), extensions);
auto values = get_all_metavalues(e);
mmd_engine_free(e,true);

8
markdown.h

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#include <ranges>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <string>
#include <filesystem>
@ -30,7 +30,7 @@ class markdown_parser{ @@ -30,7 +30,7 @@ class markdown_parser{
unsigned long language = ENGLISH;
mmd_engine *engine = nullptr;
std::map<std::string, std::string> get_all_metavalues(mmd_engine *engine);
std::unordered_map<std::string, std::string> get_all_metavalues(mmd_engine *engine);
public:
markdown_parser();
@ -49,10 +49,10 @@ class markdown_parser{ @@ -49,10 +49,10 @@ class markdown_parser{
std::optional<std::string> get_property(std::string const &file, std::string const &key) ;
std::map<std::string, std::string> get_all_metavalues() ;
std::unordered_map<std::string, std::string> get_all_metavalues() ;
std::map<std::string, std::string> get_all_metavalues(std::string const &file_text);
std::unordered_map<std::string, std::string> get_all_metavalues(std::string const &file_text);
std::string cut_frontmatter(std::string const &text);
};

56
templater.hpp

@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
#include <map>
#include <ranges>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <string>
#include <filesystem>
@ -17,6 +18,7 @@ namespace fs = std::filesystem; @@ -17,6 +18,7 @@ namespace fs = std::filesystem;
const std::string TEMPLATE_CODE_START = "{{";
const std::string TEMPLATE_CODE_END = "}}";
enum job_type {
COPY_FILE = 1,
MARKDOWN = 1 << 1,
@ -31,7 +33,7 @@ enum job_type { @@ -31,7 +33,7 @@ enum job_type {
struct blog_item {
job_type type;
fs::path src;
std::map<std::string, std::string> properties;
std::unordered_map<std::string, std::string> properties;
time_t post_date;
};
@ -48,7 +50,7 @@ class substitution_plugin { @@ -48,7 +50,7 @@ class substitution_plugin {
/* Must return lengh of replaced text */
virtual int perform_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties) = 0;
const std::unordered_map<std::string, std::string> &properties) = 0;
virtual ~substitution_plugin() = default;
};
@ -59,7 +61,7 @@ class s2_substitution_plugin : public substitution_plugin { @@ -59,7 +61,7 @@ class s2_substitution_plugin : public substitution_plugin {
int
perform_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties) override
const std::unordered_map<std::string, std::string> &properties) override
{
return 0;
}
@ -68,8 +70,8 @@ class s2_substitution_plugin : public substitution_plugin { @@ -68,8 +70,8 @@ class s2_substitution_plugin : public substitution_plugin {
virtual int
perform_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties,
const std::map<fs::path, blog_item> & pages) = 0;
const std::unordered_map<std::string, std::string> &properties,
const std::unordered_map<fs::path, blog_item, pathHash> & pages) = 0;
};
/*
@ -121,7 +123,7 @@ class file_transclude_plugin : public substitution_plugin { @@ -121,7 +123,7 @@ class file_transclude_plugin : public substitution_plugin {
int perform_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties) override {
const std::unordered_map<std::string, std::string> &properties) override {
auto args = get_arguments(invocation, 1);
std::string filename {args.at(1)};
@ -154,7 +156,7 @@ class mmd_snippet_transclude_plugin : public substitution_plugin { @@ -154,7 +156,7 @@ class mmd_snippet_transclude_plugin : public substitution_plugin {
int perform_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties) override {
const std::unordered_map<std::string, std::string> &properties) override {
auto args = get_arguments(invocation, 1);
fs::path path;
@ -177,7 +179,7 @@ class variable_transclude_plugin final : public substitution_plugin { @@ -177,7 +179,7 @@ class variable_transclude_plugin final : public substitution_plugin {
int perform_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties) override {
const std::unordered_map<std::string, std::string> &properties) override {
auto args = get_arguments(invocation, 1);
@ -214,7 +216,7 @@ class ifdef_plugin : public substitution_plugin { @@ -214,7 +216,7 @@ class ifdef_plugin : public substitution_plugin {
do_replace should_substitute(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties) {
const std::unordered_map<std::string, std::string> &properties) {
do_replace val {};
val.first = invocation.find(":") + 1;
@ -247,7 +249,7 @@ class ifdef_plugin : public substitution_plugin { @@ -247,7 +249,7 @@ class ifdef_plugin : public substitution_plugin {
int perform_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties) override {
const std::unordered_map<std::string, std::string> &properties) override {
do_replace val = should_substitute(start, end, invocation, file_text, properties);
@ -274,7 +276,7 @@ class comment_plugin : public substitution_plugin { @@ -274,7 +276,7 @@ class comment_plugin : public substitution_plugin {
int perform_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties) override {
const std::unordered_map<std::string, std::string> &properties) override {
std::string subst_text = "\n";
@ -293,7 +295,7 @@ class ifndef_plugin : public ifdef_plugin { @@ -293,7 +295,7 @@ class ifndef_plugin : public ifdef_plugin {
int perform_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties) override {
const std::unordered_map<std::string, std::string> &properties) override {
do_replace val = should_substitute(start, end, invocation, file_text, properties);
@ -334,13 +336,13 @@ class file_index_plugin : public substitution_plugin { @@ -334,13 +336,13 @@ class file_index_plugin : public substitution_plugin {
file_index_plugin(std::set<std::string> exclude) : exclude_filenames(exclude) {}
/**
* Recursively get a sorted map of directories.
* Recursively get a sorted unordered_map of directories.
*
* Directory must exist. Does not handle any errors.
*
*/
std::multimap<time_t, post_entry> get_directory_list(const fs::path &dir,
const std::map<std::string, std::string> &properties) {
const std::unordered_map<std::string, std::string> &properties) {
// todo support custom depth
@ -425,7 +427,7 @@ class file_index_plugin : public substitution_plugin { @@ -425,7 +427,7 @@ class file_index_plugin : public substitution_plugin {
int perform_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties) override {
const std::unordered_map<std::string, std::string> &properties) override {
int rval = 0;
@ -659,7 +661,7 @@ class feed_builder { @@ -659,7 +661,7 @@ class feed_builder {
std::multimap<time_t, blog_item> get_sorted_post_list(const std::string &cs_directories,
const std::map<std::string, std::string> &properties, const std::map<fs::path, blog_item> & pages) {
const std::unordered_map<std::string, std::string> &properties, const std::unordered_map<fs::path, blog_item, pathHash> & pages) {
std::vector<fs::path> paths;
@ -722,7 +724,7 @@ class rss_feed_plugin : public s2_substitution_plugin { @@ -722,7 +724,7 @@ class rss_feed_plugin : public s2_substitution_plugin {
int perform_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties, const std::map<fs::path, blog_item> & pages) override {
const std::unordered_map<std::string, std::string> &properties, const std::unordered_map<fs::path, blog_item, pathHash> & pages) override {
auto args = get_arguments(invocation, 2);
@ -780,7 +782,7 @@ class microblog_plugin : public s2_substitution_plugin { @@ -780,7 +782,7 @@ class microblog_plugin : public s2_substitution_plugin {
int perform_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties, const std::map<fs::path, blog_item> & pages) override {
const std::unordered_map<std::string, std::string> &properties, const std::unordered_map<fs::path, blog_item, pathHash> & pages) override {
auto args = get_arguments(invocation, 1);
std::string relpath = args.at(1);
@ -830,8 +832,8 @@ class microblog_plugin : public s2_substitution_plugin { @@ -830,8 +832,8 @@ class microblog_plugin : public s2_substitution_plugin {
class templater {
std::map<std::string, substitution_plugin *> substitution_commands {};
std::map<std::string, s2_substitution_plugin *> s2_substitution_commands {};
std::unordered_map<std::string, substitution_plugin *> substitution_commands {};
std::unordered_map<std::string, s2_substitution_plugin *> s2_substitution_commands {};
public:
@ -869,8 +871,8 @@ class templater { @@ -869,8 +871,8 @@ class templater {
done_subtitution_options
do_substitution(int start, int end, const std::string &invocation,
std::string &file_text,
const std::map<std::string, std::string> &properties,
std::optional<const std::map<fs::path, blog_item>> pages)
const std::unordered_map<std::string, std::string> &properties,
std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> pages)
{
std::string command_name = invocation.substr(0, invocation.find(":"));
@ -899,21 +901,21 @@ class templater { @@ -899,21 +901,21 @@ class templater {
void
run_substitution_plugins(std::string &text,
const std::map<std::string, std::string> &properties)
const std::unordered_map<std::string, std::string> &properties)
{
run_substitution_plugins(text, properties, {}, true);
}
void
run_substitution_plugins_once(std::string &text,
const std::map<std::string, std::string> &properties)
const std::unordered_map<std::string, std::string> &properties)
{
run_substitution_plugins(text, properties, {}, false);
}
void
run_substitution_plugins(std::string &text,
const std::map<std::string, std::string> &properties, std::optional<const std::map<fs::path, blog_item>> pages) {
const std::unordered_map<std::string, std::string> &properties, std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> pages) {
run_substitution_plugins(text, properties,pages,true);
}
@ -921,7 +923,7 @@ class templater { @@ -921,7 +923,7 @@ class templater {
void
run_substitution_plugins(std::string &text,
const std::map<std::string, std::string> &properties, std::optional<const std::map<fs::path, blog_item>> pages, bool allow_recursion)
const std::unordered_map<std::string, std::string> &properties, std::optional<const std::unordered_map<fs::path, blog_item, pathHash>> pages, bool allow_recursion)
{
std::string::size_type next = text.find(TEMPLATE_CODE_START, 0);

6
util.cpp

@ -23,7 +23,7 @@ std::string read_file(std::string const &fpath) { @@ -23,7 +23,7 @@ std::string read_file(std::string const &fpath) {
}
std::string
reformat_date(const std::string& date_time, const std::map<std::string, std::string> &properties)
reformat_date(const std::string& date_time, const std::unordered_map<std::string, std::string> &properties)
{
std::istringstream in {date_time};
date::sys_seconds timepoint;
@ -53,7 +53,7 @@ void write_file(std::string const &fpath, std::string const &content) { @@ -53,7 +53,7 @@ void write_file(std::string const &fpath, std::string const &content) {
namespace stgen {
fs::path
compute_target(fs::path fpath, std::map<std::string, std::string> &properties)
compute_target(fs::path fpath, std::unordered_map<std::string, std::string> &properties)
{
std::string ext = file_ext(fpath);
@ -80,7 +80,7 @@ compute_target(fs::path fpath, std::map<std::string, std::string> &properties) @@ -80,7 +80,7 @@ compute_target(fs::path fpath, std::map<std::string, std::string> &properties)
std::string
compute_url(fs::path path, std::map<std::string, std::string> properties)
compute_url(fs::path path, std::unordered_map<std::string, std::string> properties)
{
fs::path target = compute_target(path, properties);

15
util.h

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#include <ranges>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <string>
#include <filesystem>
@ -40,14 +40,14 @@ std::string read_file(std::string const &fpath); @@ -40,14 +40,14 @@ std::string read_file(std::string const &fpath);
void write_file(std::string const &fpath, std::string const &content);
std::string
reformat_date(const std::string& date_time, const std::map<std::string, std::string> &properties);
reformat_date(const std::string& date_time, const std::unordered_map<std::string, std::string> &properties);
namespace stgen {
fs::path
compute_target(fs::path fpath, std::map<std::string, std::string> &properties);
compute_target(fs::path fpath, std::unordered_map<std::string, std::string> &properties);
std::string
compute_url(fs::path path, std::map<std::string, std::string> properties);
compute_url(fs::path path, std::unordered_map<std::string, std::string> properties);
};
@ -71,7 +71,12 @@ class server { @@ -71,7 +71,12 @@ class server {
~server();
};
class pathHash {
public:
size_t operator()(const fs::path &k) const{
return std::hash<std::string>{}(k.string());
}
};
#endif

Loading…
Cancel
Save