52 if (str.
empty()) str =
"CP1250";
56 term(
"unsupported character conversion for CHM_INDEX_ENCODING: '{}'->'UTF-8'\n", str);
71 size_t oSize = iSize*4;
75 const char *iPtr = s.
data();
81 output.
at(oSize)=
'\0';
121 bool hasLink,
bool reversed);
155 static const reg::Ex re(R
"(@\d+)");
165 key_anchor += anchor;
167 m_map.
add(key_anchor,key,url,anchor,hasLink,reversed);
189 size_t maxExpandedLen = maxLen+50;
191 if (result.
length()>maxExpandedLen)
195 while (maxLen>0 && result.
length()>maxExpandedLen)
236 std::stable_sort(std::begin(
m_map),
238 [](
const auto &e1,
const auto &e2) {
return dstricmp_sort(e1->name,e2->name)<0; }
241 bool level2Started=
false;
242 for (
auto it = std::begin(
m_map); it!=std::end(
m_map); ++it)
248 level1 = f->name.
left(i);
249 level2 = f->name.
mid(i+1);
257 if (level2Started) t <<
" </UL>\n";
268 auto it_next = std::next(it);
269 if (it_next!=std::end(
m_map))
271 auto &fnext = *it_next;
272 size_t j = fnext->name.find(
'?');
274 nextLevel1 = fnext->name.
left(j);
276 if (!(level1 == prevLevel1 || level1 == nextLevel1))
285 t <<
" <LI><OBJECT type=\"text/sitemap\">";
286 t <<
"<param name=\"Local\" value=\"" <<
field2URL(f.get(),
false);
295 t <<
" <LI><OBJECT type=\"text/sitemap\">";
296 t <<
"<param name=\"Local\" value=\"" <<
field2URL(f.get(),
true);
303 t <<
" <LI><OBJECT type=\"text/sitemap\">";
310 if (!level2Started && !level2.
empty())
315 else if (level2Started && level2.
empty())
322 t <<
" <LI><OBJECT type=\"text/sitemap\">";
323 t <<
"<param name=\"Local\" value=\"" <<
field2URL(f.get(),
false);
329 if (level2Started) t <<
" </UL>\n";
366 p->recoder.initialize();
371 if (!
p->cts.is_open())
373 term(
"Could not open file {} for writing\n",fName);
376 p->cts <<
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n"
377 "<HTML><HEAD></HEAD><BODY>\n"
378 "<OBJECT type=\"text/site properties\">\n"
379 "<param name=\"FrameName\" value=\"right\">\n"
386 if (!
p->kts.is_open())
388 term(
"Could not open file {} for writing\n",fName);
391 p->kts <<
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n"
392 "<HTML><HEAD></HEAD><BODY>\n"
393 "<OBJECT type=\"text/site properties\">\n"
394 "<param name=\"FrameName\" value=\"right\">\n"
411 if (!hhkPresent) hhkFile =
"";
421 t <<
"Compiled file=index.chm\n";
423 t <<
"Compatibility=1.1\n"
424 "Full-text search=Yes\n";
426 t <<
"Default Window=main\n"
427 "Default topic=" << indexName <<
"\n";
428 if (hhkPresent) t <<
"Index file=" +
hhkFileName +
"\n";
449 << hhkFile <<
",\"" << indexName <<
"\",\"" <<
450 indexName <<
"\",,,,,0x23520,,0x70387e,,,,,,,,0\n\n";
455 << hhkFile <<
",\"" << indexName <<
"\",\"" <<
456 indexName <<
"\",,,,,0x23520,,0x10387e,,,,,,,,0\n\n";
476 err(
"Could not open file {} for writing\n",fName);
482 p->indexFiles.insert(s.
str());
493 p->cts <<
"</BODY>\n";
494 p->cts <<
"</HTML>\n";
497 p->index.writeFields(
p->kts);
501 p->kts <<
"</BODY>\n";
502 p->kts <<
"</HTML>\n";
505 p->createProjectFile();
507 p->recoder.finalize();
516 for (
int i=0; i<
p->dc+1; i++)
p->cts <<
" ";
527 for (
int i=0; i<
p->dc; i++)
p->cts <<
" ";
553 p->ctsItemPresent =
true;
554 for (
int i=0; i<
p->dc; i++)
p->cts <<
" ";
555 p->cts <<
"<LI><OBJECT type=\"text/sitemap\">";
556 p->cts <<
"<param name=\"Name\" value=\"" <<
convertToHtml(
p->recoder.recode(name),
true) <<
"\">";
559 if (file[0]==
'!' || file[0]==
'^')
561 p->cts <<
"<param name=\"";
562 if (file[0]==
'^')
p->cts <<
"URL";
else p->cts <<
"Local";
563 p->cts <<
"\" value=\"";
572 p->cts <<
"<param name=\"Local\" value=\"";
575 if (
p->prevFile == currFile &&
p->prevAnc.empty() && currAnc.
empty())
579 if (!currAnc.
empty())
p->cts <<
"#" << currAnc;
581 p->prevFile = currFile;
582 p->prevAnc = currAnc;
585 p->cts <<
"<param name=\"ImageNumber\" value=\"";
592 p->cts <<
static_cast<int>(
TEXT);
595 p->cts <<
"</OBJECT>\n";
610 p->index.addItem(level1,level2,cfname,anchor,
true,
false);
611 p->index.addItem(level2,level1,cfname,anchor,
true,
true);
622 p->styleFiles.insert(fileName.
str());
627 p->imageFiles.insert(fileName.
str());
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
void resize(size_t newlen)
DString mid(size_t index, size_t len=npos) const
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
char * rawData()
Returns a writable pointer to the data.
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
char & at(size_t i)
Returns a reference to the character at index i.
DString left(size_t len) const
const std::string & str() const
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
size_t length() const
Returns the length of the string, not counting the 0-terminator.
The common base class of all entity definitions found in the sources.
virtual const DString & name() const =0
virtual bool hasDocumentation() const =0
virtual DString anchor() const =0
virtual DString getOutputFileBase() const =0
static DString htmlFileExtension
void addIndexItem(const Definition *context, const MemberDef *md, const DString §ionAnchor, const DString &title)
void addImageFile(const DString &)
static const DString hhkFileName
static const DString hhpFileName
std::unique_ptr< Private > p
static const DString hhcFileName
void addContentsItem(bool isDir, const DString &name, const DString &ref, const DString &file, const DString &anchor, bool separateIndex, bool addToNavIndex, const Definition *def, const DString &nameAsHtml)
void addIndexFile(const DString &name)
void addStyleSheetFile(const DString &)
A helper class for HtmlHelp that manages a two level index in alphabetical order.
HtmlHelpRecoder & m_recoder
void writeFields(std::ostream &t)
HtmlHelpIndex(HtmlHelpRecoder &recoder)
LinkedMap< IndexField > m_map
void addItem(const DString &first, const DString &second, const DString &url, const DString &anchor, bool hasLink, bool reversed)
Helper class to deal with recoding the UTF8 encoded text back to the native encoding specified by CHM...
DString recode(const DString &s)
Container class representing a vector of objects with keys.
T * add(const char *k, Args &&... args)
A model of a class/file/namespace member symbol.
virtual DString argsString() const =0
virtual DString getLanguageString()=0
language codes for Html help
Class representing a regular expression.
#define Config_getBool(name)
#define Config_getString(name)
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
std::set< std::string > StringSet
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
int dstricmp_sort(const char *str1, const char *str2)
static DString convertToHtmlAndTruncate(const DString &s)
static DString field2URL(const IndexField *f, bool checkReversed)
Translator * theTranslator
std::ofstream openOutputStream(const DString &name, bool append=false)
bool search(std::string_view str, Match &match, const Ex &re, size_t pos)
Search in a given string str starting at position pos for a match against regular expression re.
Portable versions of functions that are platform dependent.
int portable_iconv_close(void *cd)
size_t portable_iconv(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
void * portable_iconv_open(const char *tocode, const char *fromcode)
Class representing a field in the HTML help index.
IndexField(const DString &k, const DString &n, const DString &u, const DString &a, bool l, bool r)
DString convertToHtml(const DString &s, bool keepEntities)
void addHtmlExtensionIfMissing(DString &fName)
DString externalRef(const DString &relPath, const DString &ref)
A bunch of utility functions.