54 if (str.
empty()) str =
"CP1250";
58 term(
"unsupported character conversion for CHM_INDEX_ENCODING: '{}'->'UTF-8'\n", str);
73 size_t oSize = iSize*4;
77 const char *iPtr = s.
data();
83 output.
at(oSize)=
'\0';
123 bool hasLink,
bool reversed);
157 static const reg::Ex re(R
"(@\d+)");
167 key_anchor += anchor;
169 m_map.
add(key_anchor,key,url,anchor,hasLink,reversed);
191 size_t maxExpandedLen = maxLen+50;
193 if (result.
length()>maxExpandedLen)
197 while (maxLen>0 && result.
length()>maxExpandedLen)
238 std::stable_sort(std::begin(
m_map),
240 [](
const auto &e1,
const auto &e2) {
return dstricmp_sort(e1->name,e2->name)<0; }
243 bool level2Started=
false;
244 for (
auto it = std::begin(
m_map); it!=std::end(
m_map); ++it)
250 level1 = f->name.
left(i);
251 level2 = f->name.
mid(i+1);
259 if (level2Started) t <<
" </UL>\n";
270 auto it_next = std::next(it);
271 if (it_next!=std::end(
m_map))
273 auto &fnext = *it_next;
274 size_t j = fnext->name.find(
'?');
276 nextLevel1 = fnext->name.
left(j);
278 if (!(level1 == prevLevel1 || level1 == nextLevel1))
287 t <<
" <LI><OBJECT type=\"text/sitemap\">";
288 t <<
"<param name=\"Local\" value=\"" <<
field2URL(f.get(),
false);
297 t <<
" <LI><OBJECT type=\"text/sitemap\">";
298 t <<
"<param name=\"Local\" value=\"" <<
field2URL(f.get(),
true);
305 t <<
" <LI><OBJECT type=\"text/sitemap\">";
312 if (!level2Started && !level2.
empty())
317 else if (level2Started && level2.
empty())
324 t <<
" <LI><OBJECT type=\"text/sitemap\">";
325 t <<
"<param name=\"Local\" value=\"" <<
field2URL(f.get(),
false);
331 if (level2Started) t <<
" </UL>\n";
368 p->recoder.initialize();
373 if (!
p->cts.is_open())
375 term(
"Could not open file {} for writing\n",fName);
378 p->cts <<
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n"
379 "<HTML><HEAD></HEAD><BODY>\n"
380 "<OBJECT type=\"text/site properties\">\n"
381 "<param name=\"FrameName\" value=\"right\">\n"
388 if (!
p->kts.is_open())
390 term(
"Could not open file {} for writing\n",fName);
393 p->kts <<
"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n"
394 "<HTML><HEAD></HEAD><BODY>\n"
395 "<OBJECT type=\"text/site properties\">\n"
396 "<param name=\"FrameName\" value=\"right\">\n"
413 if (!hhkPresent) hhkFile =
"";
423 t <<
"Compiled file=index.chm\n";
425 t <<
"Compatibility=1.1\n"
426 "Full-text search=Yes\n";
428 t <<
"Default Window=main\n"
429 "Default topic=" << indexName <<
"\n";
430 if (hhkPresent) t <<
"Index file=" +
hhkFileName +
"\n";
451 << hhkFile <<
",\"" << indexName <<
"\",\"" <<
452 indexName <<
"\",,,,,0x23520,,0x70387e,,,,,,,,0\n\n";
457 << hhkFile <<
",\"" << indexName <<
"\",\"" <<
458 indexName <<
"\",,,,,0x23520,,0x10387e,,,,,,,,0\n\n";
478 err(
"Could not open file {} for writing\n",fName);
484 p->indexFiles.insert(s.
str());
495 p->cts <<
"</BODY>\n";
496 p->cts <<
"</HTML>\n";
499 p->index.writeFields(
p->kts);
503 p->kts <<
"</BODY>\n";
504 p->kts <<
"</HTML>\n";
507 p->createProjectFile();
509 p->recoder.finalize();
518 for (
int i=0; i<
p->dc+1; i++)
p->cts <<
" ";
529 for (
int i=0; i<
p->dc; i++)
p->cts <<
" ";
555 p->ctsItemPresent =
true;
556 for (
int i=0; i<
p->dc; i++)
p->cts <<
" ";
557 p->cts <<
"<LI><OBJECT type=\"text/sitemap\">";
558 p->cts <<
"<param name=\"Name\" value=\"" <<
convertToHtml(
p->recoder.recode(name),
true) <<
"\">";
561 if (file[0]==
'!' || file[0]==
'^')
563 p->cts <<
"<param name=\"";
564 if (file[0]==
'^')
p->cts <<
"URL";
else p->cts <<
"Local";
565 p->cts <<
"\" value=\"";
574 p->cts <<
"<param name=\"Local\" value=\"";
577 if (
p->prevFile == currFile &&
p->prevAnc.empty() && currAnc.
empty())
581 if (!currAnc.
empty())
p->cts <<
"#" << currAnc;
583 p->prevFile = currFile;
584 p->prevAnc = currAnc;
587 p->cts <<
"<param name=\"ImageNumber\" value=\"";
594 p->cts <<
static_cast<int>(
TEXT);
597 p->cts <<
"</OBJECT>\n";
612 p->index.addItem(level1,level2,cfname,anchor,
true,
false);
613 p->index.addItem(level2,level1,cfname,anchor,
true,
true);
624 p->styleFiles.insert(fileName.
str());
629 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.