Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Jan 8, 2025
1 parent 01b7907 commit ef1697c
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 14 deletions.
51 changes: 51 additions & 0 deletions src/odr/global_params.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <odr/global_params.hpp>

#include <odr/internal/project_info.hpp>

namespace odr {

GlobalParams &GlobalParams::instance() {
static GlobalParams instance;
return instance;
}

const std::string &GlobalParams::odr_core_data_path() {
return instance().m_odr_core_data_path;
}

const std::string &GlobalParams::fontforge_data_path() {
return instance().m_fontforge_data_path;
}

const std::string &GlobalParams::poppler_data_path() {
return instance().m_poppler_data_path;
}

const std::string &GlobalParams::pdf2htmlex_data_path() {
return instance().m_pdf2htmlex_data_path;
}

void GlobalParams::set_odr_core_data_path(const std::string &path) {
instance().m_odr_core_data_path = path;
}

void GlobalParams::set_fontforge_data_path(const std::string &path) {
instance().m_fontforge_data_path = path;
}

void GlobalParams::set_poppler_data_path(const std::string &path) {
instance().m_poppler_data_path = path;
}

void GlobalParams::set_pdf2htmlex_data_path(const std::string &path) {
instance().m_pdf2htmlex_data_path = path;
}

GlobalParams::GlobalParams() {
m_odr_core_data_path = ""; // TODO
m_fontforge_data_path = internal::project_info::fontconfig_data_path();
m_poppler_data_path = internal::project_info::poppler_data_path();
m_pdf2htmlex_data_path = internal::project_info::pdf2htmlex_data_path();
}

} // namespace odr
30 changes: 30 additions & 0 deletions src/odr/global_params.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include <string>

namespace odr {

class GlobalParams {
public:
static const std::string &odr_core_data_path();
static const std::string &fontforge_data_path();
static const std::string &poppler_data_path();
static const std::string &pdf2htmlex_data_path();

static void set_odr_core_data_path(const std::string &path);
static void set_fontforge_data_path(const std::string &path);
static void set_poppler_data_path(const std::string &path);
static void set_pdf2htmlex_data_path(const std::string &path);

private:
static GlobalParams &instance();

GlobalParams();

std::string m_odr_core_data_path;
std::string m_fontforge_data_path;
std::string m_poppler_data_path;
std::string m_pdf2htmlex_data_path;
};

} // namespace odr
7 changes: 0 additions & 7 deletions src/odr/html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <odr/internal/html/wvware_wrapper.hpp>
#include <odr/internal/oldms_wvware/wvware_oldms_file.hpp>
#include <odr/internal/pdf_poppler/poppler_pdf_file.hpp>
#include <odr/internal/project_info.hpp>

#include <filesystem>

Expand All @@ -26,12 +25,6 @@ namespace fs = std::filesystem;

namespace odr {

HtmlConfig::HtmlConfig() {
fontforge_data_path = internal::project_info::fontconfig_data_path();
poppler_data_path = internal::project_info::poppler_data_path();
pdf2htmlex_data_path = internal::project_info::pdf2htmlex_data_path();
}

Html::Html(FileType file_type, HtmlConfig config, std::vector<HtmlPage> pages)
: m_file_type{file_type}, m_config{std::move(config)},
m_pages{std::move(pages)} {}
Expand Down
7 changes: 0 additions & 7 deletions src/odr/html.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ struct HtmlConfig {
// formatting
bool format_html{false};
std::uint8_t html_indent{2};

// pdf2htmlex
std::string fontforge_data_path;
std::string poppler_data_path;
std::string pdf2htmlex_data_path;

HtmlConfig();
};

/// @brief HTML output.
Expand Down

0 comments on commit ef1697c

Please sign in to comment.