Doxygen
Loading...
Searching...
No Matches
dstring.h File Reference
#include <string>
#include <string_view>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <ostream>
#include "utf8.h"
Include dependency graph for dstring.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  DString
 A String class for use with Doxygen wrapping std::string and adding some additional functionality offered by QCString. More...
struct  std::hash< DString >

Namespaces

namespace  std

Macros

#define ASSERT(x)
#define HAS_IMPLICIT_CAST_TO_PLAIN_C_STRING   0
#define HAS_CHARACTER_APPEND_OPERATOR   1

Typedefs

using JavaCCString = std::basic_string<JAVACC_CHAR_TYPE>

Functions

char * dstrdup (const char *s)
void dstrfree (const char *s)
 Frees the memory allocated using dstrdup().
uint32_t dstrlen (const char *str)
 Returns the length of string str, or 0 if a null pointer is passed.
char * dstrcpy (char *dst, const char *src)
char * dstrncpy (char *dst, const char *src, size_t len)
bool disempty (const char *s)
int dstrcmp (const char *str1, const char *str2)
int dstrncmp (const char *str1, const char *str2, size_t len)
bool disspace (char c)
int dstricmp (const char *str1, const char *str2)
int dstricmp_sort (const char *str1, const char *str2)
int dstrnicmp (const char *str1, const char *str2, size_t len)
bool operator== (const DString &s1, const DString &s2)
bool operator== (const DString &s1, const char *s2)
bool operator== (const char *s1, const DString &s2)
bool operator!= (const DString &s1, const DString &s2)
bool operator!= (const DString &s1, const char *s2)
bool operator!= (const char *s1, const DString &s2)
bool operator< (const DString &s1, const DString &s2)
bool operator< (const DString &s1, const char *s2)
bool operator< (const char *s1, const DString &s2)
bool operator<= (const DString &s1, const char *s2)
bool operator<= (const char *s1, const DString &s2)
bool operator> (const DString &s1, const char *s2)
bool operator> (const char *s1, const DString &s2)
bool operator>= (const DString &s1, const char *s2)
bool operator>= (const char *s1, const DString &s2)
DString operator+ (const DString &s1, const DString &s2)
DString operator+ (const DString &s1, const char *s2)
DString operator+ (const char *s1, const DString &s2)
const char * qPrint (const char *s)
const char * qPrint (const DString &s)
const char * qPrint (const std::string &s)
std::string toStdString (const DString &s)
int dstrcmp (const DString &str1, const char *str2)
int dstrcmp (const char *str1, const DString &str2)
int dstrcmp (const DString &str1, const DString &str2)
int dstricmp (const DString &str1, const char *str2)
int dstricmp (const char *str1, const DString &str2)
int dstricmp (const DString &str1, const DString &str2)
int dstricmp_sort (const DString &str1, const char *str2)
int dstricmp_sort (const char *str1, const DString &str2)
int dstricmp_sort (const DString &str1, const DString &str2)
int dstrnicmp (const DString &str1, const char *str2, size_t len)
int dstrnicmp (const char *str1, const DString &str2, size_t len)
int dstrnicmp (const DString &str1, const DString &str2, size_t len)
DString substitute (const DString &str, const DString &find, const DString &replace)
 substitute all occurrences of src in s by dst
DString substitute (const DString &str, const char *find, const char *replace)
DString substitute (const DString &s, const DString &src, const DString &dst, int skip_seq)
 substitute all occurrences of src in s by dst, but skip each consecutive sequence of src where the number consecutive src matches skip_seq; if skip_seq is negative, skip any number of consecutive src
DString substitute (const DString &s, char srcChar, char dstChar)
std::ostream & operator<< (std::ostream &os, const DString &s)
void swap (DString &s1, DString &s2)

Macro Definition Documentation

◆ ASSERT

#define ASSERT ( x)
Value:
if ( !(x) )\
fprintf(stderr,"ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__)

Definition at line 29 of file dstring.h.

29#define ASSERT(x) if ( !(x) )\
30 fprintf(stderr,"ASSERT: \"%s\" in %s (%d)\n",#x,__FILE__,__LINE__)

Referenced by anonymous_namespace{tagreader.cpp}::TagFileParser::addIncludes(), addMembersToMemberGroup(), RTFGenerator::beginRTFDocument(), DirDefImpl::createNewDir(), FTVHelp::decContentsDepth(), DocCite::DocCite(), DocRef::DocRef(), DotInclDepGraph::DotInclDepGraph(), HtmlGenerator::endSection(), ManGenerator::endSection(), generateDEFForMember(), generateXMLForClass(), generateXMLForMember(), DotClassGraph::getBaseName(), DotClassGraph::getImgAltText(), RTFDocVisitor::getListTable(), DotClassGraph::getMapLabel(), DefinitionImpl::getSourceFileBase(), DocPara::handleHtmlEndTag(), DocPara::handleHtmlStartTag(), DocPara::handleXRefItem(), MemberDefImpl::isConstructor(), MemberDefImpl::isDestructor(), MemberDefImpl::isLinkableInProject(), matchArguments2(), MemberList::numDecMembers(), MemberList::numDocMembers(), DocbookDocVisitor::operator()(), HtmlDocVisitor::operator()(), LatexDocVisitor::operator()(), ManDocVisitor::operator()(), RTFDocVisitor::operator()(), XmlDocVisitor::operator()(), DocXRefItem::parse(), parseFilesMultiThreading(), parseFilesSingleThreading(), resolveRef(), setDotFontPath(), setOutput(), HtmlGenerator::startSection(), LatexGenerator::startSection(), ManGenerator::startSection(), RTFGenerator::startSection(), MemberDefImpl::writeDeclaration(), DotNode::writeDEF(), DotNode::writeDocbook(), writeMemberList(), writeObjCMethodCall(), VhdlDocGen::writeVHDLDeclaration(), and DotNode::writeXML().

◆ HAS_CHARACTER_APPEND_OPERATOR

#define HAS_CHARACTER_APPEND_OPERATOR   1

Definition at line 664 of file dstring.h.

◆ HAS_IMPLICIT_CAST_TO_PLAIN_C_STRING

#define HAS_IMPLICIT_CAST_TO_PLAIN_C_STRING   0

Definition at line 625 of file dstring.h.

Typedef Documentation

◆ JavaCCString

using JavaCCString = std::basic_string<JAVACC_CHAR_TYPE>

Definition at line 81 of file dstring.h.

Function Documentation

◆ disempty()

bool disempty ( const char * s)
inline

Definition at line 52 of file dstring.h.

53{ return s==nullptr || *s=='\0'; }

References disempty().

Referenced by disempty(), dstrcmp(), and dstrncmp().

◆ disspace()

◆ dstrcmp() [1/4]

int dstrcmp ( const char * str1,
const char * str2 )
inline

Definition at line 55 of file dstring.h.

56{ return (str1 && str2) ? strcmp(str1,str2) : // both non-empty
57 (disempty(str1) && disempty(str2)) ? 0 : // both empty
58 disempty(str1) ? -1 : 1; // one empty, other non-empty
59}
bool disempty(const char *s)
Definition dstring.h:52

References disempty(), and dstrcmp().

Referenced by convertMapFile(), dstrcmp(), dstrcmp(), dstrcmp(), dstrcmp(), dstricmp_sort(), KeywordHash::find(), operator!=(), operator!=(), operator<(), operator<(), operator<(), operator<=(), operator<=(), operator==(), operator==(), operator>(), operator>(), operator>=(), operator>=(), readConfiguration(), startFontClass(), startFontClass(), and startFontClass().

◆ dstrcmp() [2/4]

int dstrcmp ( const char * str1,
const DString & str2 )
inline

Definition at line 796 of file dstring.h.

797{
798 return dstrcmp(str1,str2.data());
799}
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:162
int dstrcmp(const char *str1, const char *str2)
Definition dstring.h:55

References DString::data(), and dstrcmp().

◆ dstrcmp() [3/4]

int dstrcmp ( const DString & str1,
const char * str2 )
inline

Definition at line 791 of file dstring.h.

792{
793 return dstrcmp(str1.data(),str2);
794}

References DString::data(), and dstrcmp().

◆ dstrcmp() [4/4]

int dstrcmp ( const DString & str1,
const DString & str2 )
inline

Definition at line 801 of file dstring.h.

802{
803 return dstrcmp(str1.data(),str2.data());
804}

References DString::data(), and dstrcmp().

◆ dstrcpy()

char * dstrcpy ( char * dst,
const char * src )
inline

Definition at line 47 of file dstring.h.

48{ return src ? strcpy(dst, src) : nullptr; }

References dstrcpy().

Referenced by dstrcpy(), SymbolResolver::Private::getResolvedTypeRec(), substitute(), and substitute().

◆ dstrdup()

char * dstrdup ( const char * s)

Returns a copy of a string s. Note that memory is passed to the caller, use dstrfree() to release.

Definition at line 415 of file dstring.cpp.

416{
417 if ( !str ) return nullptr;
418 char *dst = new char[dstrlen(str)+1];
419 return strcpy( dst, str );
420}
uint32_t dstrlen(const char *str)
Returns the length of string str, or 0 if a null pointer is passed.
Definition dstring.h:44

References dstrdup(), and dstrlen().

Referenced by dstrdup().

◆ dstrfree()

void dstrfree ( const char * s)

Frees the memory allocated using dstrdup().

Definition at line 422 of file dstring.cpp.

423{
424 delete [](str);
425}

References dstrfree().

Referenced by dstrfree().

◆ dstricmp() [1/4]

int dstricmp ( const char * str1,
const char * str2 )

Definition at line 435 of file dstring.cpp.

436{
437 if ( !s1 || !s2 )
438 {
439 return s1 == s2 ? 0 : static_cast<int>(s2 - s1);
440 }
441 int res = 0;
442 char c = 0;
443 for ( ; !(res = ((c=toLowerChar(*s1)) - toLowerChar(*s2))); s1++, s2++ )
444 {
445 if ( !c ) // strings are equal
446 {
447 break;
448 }
449 }
450 return res;
451}
char toLowerChar(char c)
Definition dstring.cpp:24

References dstricmp(), and toLowerChar().

Referenced by compareString(), dstricmp(), dstricmp(), dstricmp(), dstricmp(), dstricmp_sort(), VhdlDocGen::findAllArchitectures(), DocGroup::findExistingGroup(), FlowChart::findLabel(), VhdlDocGen::findVhdlClass(), readConfiguration(), stripFromPath(), transcodeCharacterBuffer(), transcodeCharacterStringToUTF8(), FlowChart::writeFlowLinks(), ClassDefImpl::writeIncludeFilesForSlice(), and VhdlDocGen::writeProcedureProto().

◆ dstricmp() [2/4]

int dstricmp ( const char * str1,
const DString & str2 )
inline

Definition at line 811 of file dstring.h.

812{
813 return dstricmp(str1,str2.data());
814}
int dstricmp(const char *s1, const char *s2)
Definition dstring.cpp:435

References DString::data(), and dstricmp().

◆ dstricmp() [3/4]

int dstricmp ( const DString & str1,
const char * str2 )
inline

Definition at line 806 of file dstring.h.

807{
808 return dstricmp(str1.data(),str2);
809}

References DString::data(), and dstricmp().

◆ dstricmp() [4/4]

int dstricmp ( const DString & str1,
const DString & str2 )
inline

Definition at line 816 of file dstring.h.

817{
818 return dstricmp(str1.data(),str2.data());
819}

References DString::data(), and dstricmp().

◆ dstricmp_sort() [1/4]

◆ dstricmp_sort() [2/4]

int dstricmp_sort ( const char * str1,
const DString & str2 )
inline

Definition at line 826 of file dstring.h.

827{
828 return dstricmp_sort(str1,str2.data());
829}
int dstricmp_sort(const char *str1, const char *str2)
Definition dstring.h:72

References DString::data(), and dstricmp_sort().

◆ dstricmp_sort() [3/4]

int dstricmp_sort ( const DString & str1,
const char * str2 )
inline

Definition at line 821 of file dstring.h.

822{
823 return dstricmp_sort(str1.data(),str2);
824}

References DString::data(), and dstricmp_sort().

◆ dstricmp_sort() [4/4]

int dstricmp_sort ( const DString & str1,
const DString & str2 )
inline

Definition at line 831 of file dstring.h.

832{
833 return dstricmp_sort(str1.data(),str2.data());
834}

References DString::data(), and dstricmp_sort().

◆ dstrlen()

uint32_t dstrlen ( const char * str)
inline

Returns the length of string str, or 0 if a null pointer is passed.

Definition at line 44 of file dstring.h.

45{ return str ? static_cast<uint32_t>(strlen(str)) : 0; }

References dstrlen().

Referenced by DString::contains(), dstrdup(), dstrlen(), DocParser::findDocsForMemberOrCompound(), getArg(), DString::insert(), VhdlDocGen::prepareComment(), DString::rfind_insensitive(), selectBlocks(), substituteKeywords(), writeClassTreeInsideNamespaceElement(), writeNamespaceIndex(), and writeNamespaceTreeElement().

◆ dstrncmp()

int dstrncmp ( const char * str1,
const char * str2,
size_t len )
inline

Definition at line 61 of file dstring.h.

62{ return (str1 && str2) ? strncmp(str1,str2,len) : // both non-empty
63 (disempty(str1) && disempty(str2)) ? 0 : // both empty
64 disempty(str1) ? -1 : 1; // one empty other non-empty
65}

References disempty(), and dstrncmp().

Referenced by checkBlocks(), DString::contains(), dstrncmp(), Markdown::Private::findEmphasisChar(), Markdown::Private::findEndOfLine(), literal_at(), literal_at(), Markdown::Private::processBlocks(), Markdown::Private::processQuotations(), Markdown::Private::processSpecialCommand(), removeIdsAndMarkers(), selectBlocks(), skipToEndMarker(), substitute(), and substituteKeywords().

◆ dstrncpy()

char * dstrncpy ( char * dst,
const char * src,
size_t len )

Definition at line 427 of file dstring.cpp.

428{
429 if ( !src ) return nullptr;
430 strncpy( dst, src, len );
431 if ( len > 0 ) dst[len-1] = '\0';
432 return dst;
433}

References dstrncpy().

Referenced by dstrncpy().

◆ dstrnicmp() [1/4]

int dstrnicmp ( const char * str1,
const char * str2,
size_t len )

Definition at line 453 of file dstring.cpp.

454{
455 if ( !s1 || !s2 )
456 {
457 return static_cast<int>(s2 - s1);
458 }
459 for ( ; len--; s1++, s2++ )
460 {
461 char c = toLowerChar(*s1);
462 int res = c-toLowerChar(*s2);
463 if ( res!=0 ) // strings are not equal
464 {
465 return res;
466 }
467 if ( c==0 ) // strings are equal
468 {
469 break;
470 }
471 }
472 return 0;
473}

References dstrnicmp(), and toLowerChar().

Referenced by DString::contains(), dstrnicmp(), dstrnicmp(), dstrnicmp(), dstrnicmp(), and DString::rfind_insensitive().

◆ dstrnicmp() [2/4]

int dstrnicmp ( const char * str1,
const DString & str2,
size_t len )
inline

Definition at line 842 of file dstring.h.

843{
844 return dstrnicmp(str1,str2.data(),len);
845}
int dstrnicmp(const char *s1, const char *s2, size_t len)
Definition dstring.cpp:453

References DString::data(), and dstrnicmp().

◆ dstrnicmp() [3/4]

int dstrnicmp ( const DString & str1,
const char * str2,
size_t len )
inline

Definition at line 837 of file dstring.h.

838{
839 return dstrnicmp(str1.data(),str2,len);
840}

References DString::data(), and dstrnicmp().

◆ dstrnicmp() [4/4]

int dstrnicmp ( const DString & str1,
const DString & str2,
size_t len )
inline

Definition at line 847 of file dstring.h.

848{
849 return dstrnicmp(str1.data(),str2.data(),len);
850}

References DString::data(), and dstrnicmp().

◆ operator!=() [1/3]

bool operator!= ( const char * s1,
const DString & s2 )
inline

Definition at line 719 of file dstring.h.

720{ return dstrcmp(s1,s2.data()) != 0; }

References DString::data(), dstrcmp(), and operator!=().

◆ operator!=() [2/3]

bool operator!= ( const DString & s1,
const char * s2 )
inline

Definition at line 716 of file dstring.h.

717{ return dstrcmp(s1.data(),s2) != 0; }

References DString::data(), dstrcmp(), and operator!=().

◆ operator!=() [3/3]

bool operator!= ( const DString & s1,
const DString & s2 )
inline

Definition at line 713 of file dstring.h.

714{ return s1.str() != s2.str(); }
const std::string & str() const
Definition dstring.h:634

References operator!=(), and DString::str().

◆ operator+() [1/3]

DString operator+ ( const char * s1,
const DString & s2 )
inline

Definition at line 762 of file dstring.h.

763{
764 DString tmp(s1);
765 tmp.append(s2);
766 return tmp;
767}
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:89

References DString::append(), and operator+().

◆ operator+() [2/3]

DString operator+ ( const DString & s1,
const char * s2 )
inline

Definition at line 755 of file dstring.h.

756{
757 DString tmp(s1);
758 tmp.append(s2);
759 return tmp;
760}

References DString::append(), and operator+().

◆ operator+() [3/3]

DString operator+ ( const DString & s1,
const DString & s2 )
inline

Definition at line 749 of file dstring.h.

750{
751 return DString(s1.str()+s2.str());
752}
DString()=default

References DString::DString(), operator+(), and DString::str().

Referenced by operator+(), operator+(), and operator+().

◆ operator<() [1/3]

bool operator< ( const char * s1,
const DString & s2 )
inline

Definition at line 728 of file dstring.h.

729{ return dstrcmp(s1,s2.data()) < 0; }

References DString::data(), dstrcmp(), and operator<().

◆ operator<() [2/3]

bool operator< ( const DString & s1,
const char * s2 )
inline

Definition at line 725 of file dstring.h.

726{ return dstrcmp(s1.data(),s2) < 0; }

References DString::data(), dstrcmp(), and operator<().

◆ operator<() [3/3]

bool operator< ( const DString & s1,
const DString & s2 )
inline

Definition at line 722 of file dstring.h.

723{ return dstrcmp(s1.data(),s2.data()) < 0; }

References DString::data(), dstrcmp(), and operator<().

Referenced by operator<(), operator<(), and operator<().

◆ operator<<()

std::ostream & operator<< ( std::ostream & os,
const DString & s )
inline

Definition at line 867 of file dstring.h.

868{
869 os << s.str();
870 return os;
871}

References operator<<(), and DString::str().

Referenced by operator<<().

◆ operator<=() [1/2]

bool operator<= ( const char * s1,
const DString & s2 )
inline

Definition at line 734 of file dstring.h.

735{ return dstrcmp(s1,s2.data()) <= 0; }

References DString::data(), dstrcmp(), and operator<=().

◆ operator<=() [2/2]

bool operator<= ( const DString & s1,
const char * s2 )
inline

Definition at line 731 of file dstring.h.

732{ return dstrcmp(s1.data(),s2) <= 0; }

References DString::data(), dstrcmp(), and operator<=().

Referenced by operator<=(), and operator<=().

◆ operator==() [1/3]

bool operator== ( const char * s1,
const DString & s2 )
inline

Definition at line 710 of file dstring.h.

711{ return dstrcmp(s1,s2.data()) == 0; }

References DString::data(), dstrcmp(), and operator==().

◆ operator==() [2/3]

bool operator== ( const DString & s1,
const char * s2 )
inline

Definition at line 707 of file dstring.h.

708{ return dstrcmp(s1.data(),s2) == 0; }

References DString::data(), dstrcmp(), and operator==().

◆ operator==() [3/3]

bool operator== ( const DString & s1,
const DString & s2 )
inline

Definition at line 704 of file dstring.h.

705{ return s1.str() == s2.str(); }

References operator==(), and DString::str().

◆ operator>() [1/2]

bool operator> ( const char * s1,
const DString & s2 )
inline

Definition at line 740 of file dstring.h.

741{ return dstrcmp(s1,s2.data()) > 0; }

References DString::data(), dstrcmp(), and operator>().

◆ operator>() [2/2]

bool operator> ( const DString & s1,
const char * s2 )
inline

Definition at line 737 of file dstring.h.

738{ return dstrcmp(s1.data(),s2) > 0; }

References DString::data(), dstrcmp(), and operator>().

Referenced by operator>(), and operator>().

◆ operator>=() [1/2]

bool operator>= ( const char * s1,
const DString & s2 )
inline

Definition at line 746 of file dstring.h.

747{ return dstrcmp(s1,s2.data()) >= 0; }

References DString::data(), dstrcmp(), and operator>=().

◆ operator>=() [2/2]

bool operator>= ( const DString & s1,
const char * s2 )
inline

Definition at line 743 of file dstring.h.

744{ return dstrcmp(s1.data(),s2) >= 0; }

References DString::data(), dstrcmp(), and operator>=().

Referenced by operator>=(), and operator>=().

◆ qPrint() [1/3]

const char * qPrint ( const char * s)
inline

Definition at line 769 of file dstring.h.

770{
771 if (s) return s; else return "";
772}

References qPrint().

Referenced by addIncludeFile(), ModuleDefImpl::addMemberToModule(), addModule(), addSubprogram(), DirDefImpl::addUsesDependency(), addVariable(), addXRefItemToEntry(), buildFileList(), Config::checkAndCorrect(), DocParser::checkArgumentName(), cleanupInlineGraph(), XMLCodeGenerator::codify(), codifyLines(), convertCppComments(), createCroppedEPS(), createCroppedPDF(), createDVIFile(), createEPSbboxFile(), createPNG(), createPostscriptFile(), createSVGFromPDF(), createSVGFromPDFviaInkscape(), DebugLex::DebugLex(), dumpDocNodeList(), encodeForOutput(), DocParser::errorHandleDefaultToken(), DocParser::findAndCopyImage(), findGlobalMember(), findMemberLink(), DocTokenizer::findSections(), VhdlDocGen::findVhdlClass(), generateClassMemberLink(), generateClassMemberLink(), generateClassOrGlobalLink(), generateClassOrGlobalLink(), generateFunctionLink(), generateFunctionLink(), generateMemberLink(), generatePHPVariableLink(), generateSqlite3ForClass(), generateSqlite3ForFile(), generateSqlite3ForMember(), DotGfxHierarchyTable::getBaseName(), getLink(), getLinkInScope(), handle_warn_as_error(), handleCommentBlock(), DocParser::handleRef(), handleToc(), mergeArguments(), PerlModDocVisitor::operator()(), PerlModDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), PrintDocVisitor::operator()(), ConfigImpl::parse(), DocMscFile::parse(), DocSecRefList::parse(), LayoutDocManager::parse(), CCodeParser::parseCode(), FortranCodeParser::parseCode(), LexCodeParser::parseCode(), PythonCodeParser::parseCode(), SQLCodeParser::parseCode(), VHDLCodeParser::parseCode(), XMLCodeParser::parseCode(), CommentScanner::parseCommentBlock(), COutlineParser::parseInput(), FortranOutlineParser::parseInput(), LexOutlineParser::parseInput(), parseInput(), PythonOutlineParser::parseInput(), popScope(), FlowChart::printNode(), Markdown::process(), Preprocessor::processFile(), pushBuffer(), pushScope(), qPrint(), qPrint(), qPrint(), readIncludeFile(), DotNode::renumberNodes(), SymbolResolver::resolveSymbol(), runHtmlHelpCompiler(), saveObjCContext(), scanner_abort(), setCallContextForVar(), setClassScope(), setTranslator(), startCodeLine(), stripClassName(), writeDiaGraphFromFile(), DirDefImpl::writeDocumentation(), ClassDiagram::writeFigure(), FileDefImpl::writeIncludedByGraph(), FileDefImpl::writeIncludeGraph(), writeMscGraphFromFile(), writeMultiLineCodeLink(), writeObjCMethodCall(), and DebugLex::~DebugLex().

◆ qPrint() [2/3]

const char * qPrint ( const DString & s)
inline

Definition at line 774 of file dstring.h.

775{
776 if (!s.empty()) return s.data(); else return "";
777}
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:153

References DString::data(), DString::empty(), and qPrint().

◆ qPrint() [3/3]

const char * qPrint ( const std::string & s)
inline

Definition at line 779 of file dstring.h.

780{
781 return s.c_str();
782}

References qPrint().

◆ substitute() [1/4]

DString substitute ( const DString & s,
char srcChar,
char dstChar )
inline

Definition at line 860 of file dstring.h.

861{
862 std::string ss = s.str();
863 std::replace(ss.begin(),ss.end(),srcChar,dstChar);
864 return DString(ss);
865}

References DString::DString(), DString::str(), and substitute().

◆ substitute() [2/4]

DString substitute ( const DString & s,
const DString & src,
const DString & dst,
int skip_seq )

substitute all occurrences of src in s by dst, but skip each consecutive sequence of src where the number consecutive src matches skip_seq; if skip_seq is negative, skip any number of consecutive src

Definition at line 517 of file dstring.cpp.

518{
519 if (s.empty() || src.empty()) return s;
520 const char *p = nullptr, *q = nullptr;
521 size_t srcLen = src.length();
522 size_t dstLen = dst.length();
523 size_t resLen = 0;
524 if (srcLen!=dstLen)
525 {
526 int count = 0;
527 for (p=s.data(); (q=strstr(p,src.data()))!=nullptr; p=q+srcLen) count++;
528 resLen = s.length()+count*(dstLen-srcLen);
529 }
530 else // result has same size as s
531 {
532 resLen = s.length();
533 }
534 DString result(resLen, DString::ExplicitSize);
535 char *r = result.rawData();
536 for (p = s.data(); (q=strstr(p,src.data()))!=nullptr; p=q+srcLen)
537 {
538 // search a consecutive sequence of src
539 int seq = 0, skip = 0;
540 if (skip_seq)
541 {
542 for (const char *n=q+srcLen; dstrncmp(n,src.data(),srcLen)==0; seq=1+skip, n+=srcLen)
543 ++skip; // number of consecutive src after the current one
544
545 // verify the allowed number of consecutive src to skip
546 if (skip_seq > 0 && skip_seq != seq)
547 seq = skip = 0;
548 }
549
550 // skip a consecutive sequence of src when necessary
551 int l = static_cast<int>((q + seq * srcLen)-p);
552 memcpy(r,p,l);
553 r+=l;
554
555 if (skip)
556 {
557 // skip only the consecutive src found after the current one
558 q += skip * srcLen;
559 // the next loop will skip the current src, aka (p=q+srcLen)
560 continue;
561 }
562
563 if (dstLen>0) memcpy(r,dst.data(),dstLen);
564 r+=dstLen;
565 }
566 dstrcpy(r,p);
567 result.resize(strlen(result.data()));
568 //printf("substitute(%s,%s,%s)->%s\n",s,src,dst,result.data());
569 return result;
570}
@ ExplicitSize
Definition dstring.h:136
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:156
char * dstrcpy(char *dst, const char *src)
Definition dstring.h:47
int dstrncmp(const char *str1, const char *str2, size_t len)
Definition dstring.h:61

References DString::data(), dstrcpy(), dstrncmp(), DString::empty(), DString::ExplicitSize, DString::length(), DString::rawData(), DString::resize(), and substitute().

◆ substitute() [3/4]

DString substitute ( const DString & str,
const char * find,
const char * replace )
inline

Definition at line 854 of file dstring.h.

855{
856 return substitute(str,DString(find),DString(replace));
857}
DString substitute(const DString &s, const DString &src, const DString &dst)
substitute all occurrences of src in s by dst
Definition dstring.cpp:476

References DString::DString(), and substitute().

◆ substitute() [4/4]

DString substitute ( const DString & str,
const DString & find,
const DString & replace )

substitute all occurrences of src in s by dst

Definition at line 476 of file dstring.cpp.

477{
478 if (s.empty() || src.empty()) return s;
479 const char *q = nullptr, *p = nullptr;
480 size_t srcLen = src.length();
481 size_t dstLen = dst.length();
482 size_t resLen = 0;
483 if (srcLen!=dstLen)
484 {
485 int count = 0;
486 for (p = s.data(); (q=strstr(p,src.data()))!=nullptr; p=q+srcLen) count++;
487 resLen = s.length()+count*(dstLen-srcLen);
488 }
489 else // result has same size as s
490 {
491 resLen = s.length();
492 }
493 DString result(resLen, DString::ExplicitSize);
494 char *r = result.rawData();
495 for (p = s.data(); (q=strstr(p,src.data()))!=nullptr; p=q+srcLen)
496 {
497 int l = static_cast<int>(q-p);
498 memcpy(r,p,l);
499 r+=l;
500
501 if (dstLen>0) memcpy(r,dst.data(),dstLen);
502 r+=dstLen;
503 }
504 if (r)
505 {
506 dstrcpy(r,p);
507 }
508 //printf("substitute(%s,%s,%s)->%s\n",s,src,dst,result.data());
509 return result;
510}

References DString::data(), dstrcpy(), DString::empty(), DString::ExplicitSize, DString::length(), DString::rawData(), and substitute().

Referenced by abbreviate(), addEnumValuesToEnums(), FlowChart::addFlowChart(), addFrom(), addGlobalFunction(), HtmlHelpIndex::addItem(), MemberDefImpl::addListReference(), addMemberFunction(), addMethodToClass(), addModule(), addPageToContext(), Markdown::Private::addStrEscapeUtf8Nbsp(), addVariable(), addVariableToClass(), buildListOfUsingDecls(), buildNamespaceList(), convertFileId2Var(), Portable::correctPath(), MemberDefImpl::displayDefinition(), findDirDocumentation(), DocParser::findDocsForMemberOrCompound(), findGroupScope(), findMember(), findUsingDeclarations(), findUsingDirectives(), fixSpaces(), format_warn(), generateClassOrGlobalLink(), generateClassOrGlobalLink(), generateJSLink(), generateJSNavTree(), RefList::generatePage(), VhdlDocGen::getClassName(), DocPara::handleStartCode(), HtmlGenerator::init(), linkifyText(), linkToText(), makeDisplayName(), makeDisplayName(), matchExcludedSymbols(), Markdown::process(), Markdown::Private::processLink(), resolveRef(), DotFilePatcher::run(), SearchIndex::setCurrentDoc(), stripIndentation(), substitute(), substitute(), substitute(), substitute(), substituteHtmlKeywords(), substituteLatexKeywords(), Portable::system(), ConfigImpl::takeStartComment(), ConfigImpl::takeStoreRepl(), ConfigImpl::takeUserComment(), unescapeCRef(), validatingParseDoc(), warn_line(), MemberDefImpl::warnIfUndocumented(), writeAlphabeticalClassList(), MemberDefImpl::writeDeclaration(), MemberList::writeDeclarations(), writeDefArgumentList(), writeDefaultLayoutFile(), MemberDefImpl::writeDocumentation(), writeJavaScriptSearchIndex(), HtmlGenerator::writeNavigationPath(), PlantumlManager::writePlantUMLSource(), HtmlGenerator::writeSearchData(), HtmlGenerator::writeSearchPage(), and VhdlDocGen::writeVHDLTypeDocumentation().

◆ swap()

void swap ( DString & s1,
DString & s2 )
inline

Definition at line 873 of file dstring.h.

874{
875 s1.swap(s2);
876}
void swap(DString &other)
Swaps the contents of this string with other.
Definition dstring.h:225

References DString::swap(), and swap().

Referenced by swap().

◆ toStdString()

std::string toStdString ( const DString & s)
inline

Definition at line 784 of file dstring.h.

785{
786 return s.str();
787}

References DString::str(), and toStdString().

Referenced by SectionRefs::add(), expandExpression(), replaceFunctionMacro(), and toStdString().