Skip to content

Commit b970990

Browse files
committed
remove get_ again
1 parent b7c4718 commit b970990

8 files changed

Lines changed: 47 additions & 30 deletions

File tree

src/odr/global_params.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@ void GlobalParams::set_pdf2htmlex_data_path(const std::string &path) {
6363
}
6464

6565
GlobalParams::GlobalParams()
66-
: m_odr_core_data_path{internal::project_info::get_odr_data_path()},
67-
m_fontconfig_data_path{
68-
internal::project_info::get_fontconfig_data_path()},
69-
m_poppler_data_path{internal::project_info::get_poppler_data_path()},
70-
m_pdf2htmlex_data_path{
71-
internal::project_info::get_pdf2htmlex_data_path()} {}
66+
: m_odr_core_data_path{internal::project_info::odr_data_path()},
67+
m_fontconfig_data_path{internal::project_info::fontconfig_data_path()},
68+
m_poppler_data_path{internal::project_info::poppler_data_path()},
69+
m_pdf2htmlex_data_path{internal::project_info::pdf2htmlex_data_path()} {}
7270

7371
} // namespace odr

src/odr/internal/git_info.cpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace odr::internal {
44

5-
const char *git_info::get_commit() noexcept { return "@GIT_HEAD_SHA1@"; }
5+
const char *git_info::commit_hash() noexcept { return "@GIT_HEAD_SHA1@"; }
66

77
bool git_info::is_dirty() noexcept { return @GIT_IS_DIRTY@; }
88

src/odr/internal/git_info.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace odr::internal::git_info {
44

5-
const char *get_commit() noexcept;
5+
const char *commit_hash() noexcept;
66
bool is_dirty() noexcept;
77

88
} // namespace odr::internal::git_info

src/odr/internal/project_info.cpp.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace odr::internal {
44

5-
const char *project_info::get_version() noexcept { return "${CMAKE_PROJECT_VERSION}"; }
5+
const char *project_info::version() noexcept { return "${CMAKE_PROJECT_VERSION}"; }
66

77
bool project_info::is_debug() noexcept {
88
#ifdef NDEBUG
@@ -28,19 +28,19 @@ bool project_info::has_pdf2htmlex() noexcept{
2828
#endif
2929
}
3030

31-
const char *project_info::get_odr_data_path() noexcept {
31+
const char *project_info::odr_data_path() noexcept {
3232
return "${ODR_DATA_PATH}";
3333
}
3434

35-
const char *project_info::get_fontconfig_data_path() noexcept {
35+
const char *project_info::fontconfig_data_path() noexcept {
3636
return "${FONTCONFIG_PATH}";
3737
}
3838

39-
const char *project_info::get_poppler_data_path() noexcept {
39+
const char *project_info::poppler_data_path() noexcept {
4040
return "${POPPLER_DATA_DIR}";
4141
}
4242

43-
const char *project_info::get_pdf2htmlex_data_path() noexcept{
43+
const char *project_info::pdf2htmlex_data_path() noexcept{
4444
return "${PDF2HTMLEX_DATA_DIR}";
4545
}
4646

src/odr/internal/project_info.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace odr::internal::project_info {
44

5-
const char *get_version() noexcept;
5+
const char *version() noexcept;
66
bool is_debug() noexcept;
77

88
bool has_wvware() noexcept;
99
bool has_pdf2htmlex() noexcept;
10-
const char *get_odr_data_path() noexcept;
11-
const char *get_fontconfig_data_path() noexcept;
12-
const char *get_poppler_data_path() noexcept;
13-
const char *get_pdf2htmlex_data_path() noexcept;
10+
const char *odr_data_path() noexcept;
11+
const char *fontconfig_data_path() noexcept;
12+
const char *poppler_data_path() noexcept;
13+
const char *pdf2htmlex_data_path() noexcept;
1414

1515
} // namespace odr::internal::project_info

src/odr/odr.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,22 @@
77
#include <odr/internal/git_info.hpp>
88
#include <odr/internal/project_info.hpp>
99

10-
std::string odr::get_version() noexcept {
11-
return internal::project_info::get_version();
10+
std::string odr::version() noexcept {
11+
return internal::project_info::version();
1212
}
1313

14-
std::string odr::get_commit() noexcept {
15-
return internal::git_info::get_commit();
14+
std::string odr::commit_hash() noexcept {
15+
return internal::git_info::commit_hash();
16+
}
17+
18+
bool odr::is_dirty() noexcept { return internal::git_info::is_dirty(); }
19+
20+
bool odr::is_debug() noexcept { return internal::project_info::is_debug(); }
21+
22+
std::string odr::identify() noexcept {
23+
return (version().empty() ? "unknown version" : version()) +
24+
(commit_hash().empty() ? "" : " (" + commit_hash() + ")") +
25+
(is_dirty() ? " [dirty]" : "") + (is_debug() ? " [debug]" : "");
1626
}
1727

1828
odr::FileType

src/odr/odr.hpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,21 @@ struct DecodePreference;
1212
class DecodedFile;
1313
enum class DocumentType;
1414

15-
/// @brief Get the version of the Open Document Reader library.
16-
/// @return The version of the Open Document Reader library.
17-
[[nodiscard]] std::string get_version() noexcept;
18-
/// @brief Get the commit hash of the Open Document Reader library.
19-
/// @return The commit hash of the Open Document Reader library.
20-
[[nodiscard]] std::string get_commit() noexcept;
15+
/// @brief Get the version of the library.
16+
/// @return The version of the library.
17+
[[nodiscard]] std::string version() noexcept;
18+
/// @brief Get the commit hash of the library.
19+
/// @return The commit hash of the library.
20+
[[nodiscard]] std::string commit_hash() noexcept;
21+
/// @brief Check if the library is dirty (i.e., has uncommitted changes).
22+
/// @return True if the library is dirty, false otherwise.
23+
[[nodiscard]] bool is_dirty() noexcept;
24+
/// @brief Check if the library is built in debug mode.
25+
/// @return True if the library is built in debug mode, false otherwise.
26+
[[nodiscard]] bool is_debug() noexcept;
27+
/// @brief Get the identification string of the library.
28+
/// @return The identification string of the library.
29+
[[nodiscard]] std::string identify() noexcept;
2130

2231
/// @brief Get the file type by the file extension.
2332
/// @param extension The file extension.

test/src/odr_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ using namespace odr;
88
using namespace odr::internal;
99
using namespace odr::test;
1010

11-
TEST(odr, version) { EXPECT_TRUE(odr::get_version().empty()); }
11+
TEST(odr, version) { EXPECT_TRUE(odr::version().empty()); }
1212

13-
TEST(odr, commit) { EXPECT_FALSE(odr::get_commit().empty()); }
13+
TEST(odr, commit) { EXPECT_FALSE(odr::commit_hash().empty()); }
1414

1515
TEST(odr, types_odt) {
1616
auto path = TestData::test_file_path("odr-public/odt/about.odt");

0 commit comments

Comments
 (0)