Skip to content

Commit 350c412

Browse files
committed
fixup! Introduce helper function isFrontArticle
1 parent 5911a98 commit 350c412

File tree

5 files changed

+21
-35
lines changed

5 files changed

+21
-35
lines changed

src/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ common_sources = [
3535
'writer/clusterWorker.cpp',
3636
'writer/titleListingHandler.cpp',
3737
'writer/counterHandler.cpp',
38-
'writer/tools.cpp',
3938
'suggestion.cpp',
4039
'suggestion_iterator.cpp',
4140
'version.cpp'

src/tools.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "tools.h"
2323
#include "zim/tools.h"
2424
#include "fs.h"
25+
#include "writer/_dirent.h"
2526

2627
#include <sys/types.h>
2728
#include <string.h>
@@ -218,6 +219,20 @@ zim::MimeCounterType zim::parseMimetypeCounter(const std::string& counterData)
218219
return counters;
219220
}
220221

222+
bool zim::writer::isFrontArticle(const zim::writer::Dirent* dirent, const zim::writer::Hints& hints)
223+
{
224+
// By definition, dirent not in `C` namespace are not FRONT_ARTICLE
225+
if (dirent->getNamespace() != NS::C) {
226+
return false;
227+
}
228+
try {
229+
return bool(hints.at(FRONT_ARTICLE));
230+
} catch(std::out_of_range&) {
231+
return false;
232+
}
233+
}
234+
235+
221236
// Xapian based tools
222237
#if defined(ENABLE_XAPIAN)
223238

src/tools.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "config.h"
3030

3131
#include <zim/item.h>
32+
#include "zim/writer/item.h"
3233

3334
#if defined(ENABLE_XAPIAN)
3435
namespace Xapian {
@@ -70,6 +71,11 @@ namespace zim {
7071
return count;
7172
}
7273

74+
namespace writer {
75+
class Dirent;
76+
bool isFrontArticle(const Dirent* dirent, const Hints& hints);
77+
}
78+
7379
// Xapian based tools
7480
#if defined(ENABLE_XAPIAN)
7581
std::string LIBZIM_PRIVATE_API removeAccents(const std::string& text);

src/writer/tools.cpp

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/writer/tools.h

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)