Skip to content

Commit

Permalink
Refactoring: move qcstring and remove qtools
Browse files Browse the repository at this point in the history
  • Loading branch information
doxygen committed Mar 25, 2021
1 parent d03499a commit 1e77368
Show file tree
Hide file tree
Showing 25 changed files with 1,683 additions and 1,790 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ add_subdirectory(liblodepng)
add_subdirectory(libmscgen)
add_subdirectory(libversion)
add_subdirectory(libxml)
add_subdirectory(qtools)
add_subdirectory(vhdlparser)
add_subdirectory(src)

Expand Down
2 changes: 0 additions & 2 deletions addon/doxyapp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include_directories(
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/libversion
${GENERATED_SRC}
${PROJECT_SOURCE_DIR}/qtools
${ICONV_INCLUDE_DIR}
${CLANG_INCLUDEDIR}
)
Expand Down Expand Up @@ -36,7 +35,6 @@ endif()

target_link_libraries(doxyapp
doxymain
qtools
md5
xml
lodepng
Expand Down
5 changes: 2 additions & 3 deletions addon/doxyapp/doxyapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
*/

#include <stdlib.h>
#include <qfile.h>
#include <qdir.h>
#include "dir.h"
#include "doxygen.h"
#include "outputgen.h"
#include "parserintf.h"
Expand Down Expand Up @@ -297,7 +296,7 @@ int main(int argc,char **argv)
}

// clean up after us
QDir().rmdir("/tmp/doxygen");
Dir().rmdir("/tmp/doxygen");

while (1)
{
Expand Down
2 changes: 0 additions & 2 deletions addon/doxyparse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include_directories(
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/libversion
${GENERATED_SRC}
${PROJECT_SOURCE_DIR}/qtools
${ICONV_INCLUDE_DIR}
${CLANG_INCLUDEDIR}
)
Expand All @@ -24,7 +23,6 @@ endif()

target_link_libraries(doxyparse
doxymain
qtools
md5
xml
lodepng
Expand Down
9 changes: 4 additions & 5 deletions addon/doxyparse/doxyparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
#include <cstdlib>
#include <sstream>
#include <map>
#include <qdir.h>
#include <qcstring.h>
#include "qcstring.h"
#include "namespacedef.h"
#include "portable.h"

Expand Down Expand Up @@ -521,12 +520,12 @@ int main(int argc,char **argv) {
}
}

QDir thisDir;
Dir thisDir;
// remove temporary files
if (!Doxygen::filterDBFileName.isEmpty()) thisDir.remove(Doxygen::filterDBFileName);
if (!Doxygen::filterDBFileName.isEmpty()) thisDir.remove(Doxygen::filterDBFileName.str());

// clean up after us
thisDir.rmdir(Config_getString(OUTPUT_DIRECTORY));
thisDir.rmdir(Config_getString(OUTPUT_DIRECTORY).str());

startYamlDocument();
listSymbols();
Expand Down
4 changes: 1 addition & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# vim:ts=4:sw=4:expandtab:autoindent:

include_directories(
${PROJECT_SOURCE_DIR}/qtools
${PROJECT_SOURCE_DIR}/filesystem
${PROJECT_SOURCE_DIR}/libmd5
${PROJECT_SOURCE_DIR}/liblodepng
Expand Down Expand Up @@ -286,6 +285,7 @@ add_library(doxymain STATIC
pagedef.cpp
perlmodgen.cpp
plantuml.cpp
qcstring.cpp
qhp.cpp
qhpxmlwriter.cpp
reflist.cpp
Expand Down Expand Up @@ -352,7 +352,6 @@ endif()
target_link_libraries(doxygen PRIVATE
doxymain
doxycfg
qtools
md5
lodepng
mscgen
Expand All @@ -372,7 +371,6 @@ set_project_warnings(doxycfg)
set_project_warnings(doxymain)
set_project_warnings(doxygen)

set_project_coverage(qtools)
set_project_coverage(doxycfg)
set_project_coverage(doxymain)
set_project_coverage(doxygen)
Expand Down
334 changes: 165 additions & 169 deletions src/commentscan.l

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/defargs.l
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
//#include <iostream.h>
#include <assert.h>
#include <ctype.h>
#include <qcstringlist.h>

#include "defargs.h"
#include "entry.h"
Expand Down
3 changes: 2 additions & 1 deletion src/dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ bool Dir::exists(const std::string &path,bool acceptsAbsPath) const

bool Dir::exists() const
{
return exists(p->path.string());
FileInfo fi(p->path);
return fi.exists() && fi.isDir();
}

bool Dir::isRelative() const
Expand Down
17 changes: 10 additions & 7 deletions src/docparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include <qcstring.h>
#include <ctype.h>
#include <qcstringlist.h>

#include "regex.h"
#include "doxygen.h"
Expand Down Expand Up @@ -5060,24 +5059,28 @@ void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t)
doctokenizerYYsetStateOptions();
tok=doctokenizerYYlex();
doctokenizerYYsetStatePara();
QCStringList optList=QCStringList::split(",",g_token->name);
if (t==DocInclude::Include && optList.contains("lineno"))
StringVector optList=split(g_token->name.str(),",");
auto contains = [&optList](const char *kw)
{
return std::find(optList.begin(),optList.end(),kw)!=optList.end();
};
if (t==DocInclude::Include && contains("lineno"))
{
t = DocInclude::IncWithLines;
}
else if (t==DocInclude::Snippet && optList.contains("lineno"))
else if (t==DocInclude::Snippet && contains("lineno"))
{
t = DocInclude::SnipWithLines;
}
else if (t==DocInclude::DontInclude && optList.contains("lineno"))
else if (t==DocInclude::DontInclude && contains("lineno"))
{
t = DocInclude::DontIncWithLines;
}
else if (t==DocInclude::Include && optList.contains("doc"))
else if (t==DocInclude::Include && contains("doc"))
{
t = DocInclude::IncludeDoc;
}
else if (t==DocInclude::Snippet && optList.contains("doc"))
else if (t==DocInclude::Snippet && contains("doc"))
{
t = DocInclude::SnippetDoc;
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4428,7 +4428,7 @@ static void writeIndex(OutputList &ol)
ol.popGeneratorState();
}

static QArray<bool> indexWritten;
static std::vector<bool> indexWritten;

static void writeIndexHierarchyEntries(OutputList &ol,const LayoutNavEntryList &entries)
{
Expand Down
123 changes: 0 additions & 123 deletions qtools/qcstring.cpp → src/qcstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@

#include "qcstring.h"

#include <qstring.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>
//#include <qregexp.h>
#include <qdatastream.h>

QCString &QCString::sprintf( const char *format, ... )
{
Expand Down Expand Up @@ -86,15 +83,6 @@ int QCString::find( const QCString &str, int index, bool cs ) const
return find(str.data(),index,cs);
}

#if 0
int QCString::find( const QRegExp &rx, int index ) const
{
if ( index < 0 )
index += length();
return rx.match( data(), index );
}
#endif

int QCString::findRev( char c, int index, bool cs) const
{
const char *b = data();
Expand Down Expand Up @@ -147,22 +135,6 @@ int QCString::findRev( const char *str, int index, bool cs) const
return -1;
}

#if 0
int QCString::findRev( const QRegExp &rx, int index ) const
{
if ( index < 0 ) // neg index ==> start from end
index += length();
if ( (uint)index > length() ) // bad index
return -1;
while( index >= 0 ) {
if ( rx.match( data(), index ) == index )
return index;
index--;
}
return -1;
}
#endif

int QCString::contains( char c, bool cs ) const
{
if (length()==0) return 0;
Expand Down Expand Up @@ -205,25 +177,6 @@ int QCString::contains( const char *str, bool cs ) const
return count;
}

#if 0
int QCString::contains( const QRegExp &rx ) const
{
if ( isEmpty() )
return rx.match( data() ) < 0 ? 0 : 1;
int count = 0;
int index = -1;
int len = length();
while ( index < len-1 ) { // count overlapping matches
index = rx.match( data(), index+1 );
if ( index < 0 )
break;
count++;
}
return count;
}
#endif


QCString QCString::simplifyWhiteSpace() const
{
if ( isEmpty() ) // nothing to do
Expand Down Expand Up @@ -258,29 +211,6 @@ QCString &QCString::replace( uint index, uint len, const char *s)
return *this;
}

#if 0
QCString &QCString::replace( const QRegExp &rx, const char *str )
{
if ( isEmpty() )
return *this;
int index = 0;
int slen = qstrlen(str);
int len;
while ( index < (int)length() ) {
index = rx.match( data(), index, &len, FALSE );
if ( index >= 0 ) {
replace( index, len, str );
index += slen;
if ( !len )
break; // Avoid infinite loop on 0-length matches, e.g. [a-z]*
}
else
break;
}
return *this;
}
#endif

static bool ok_in_base( char c, int base )
{
if ( base <= 10 )
Expand Down Expand Up @@ -487,7 +417,6 @@ char *qstrdup( const char *str )
if ( !str )
return 0;
char *dst = new char[qstrlen(str)+1];
CHECK_PTR( dst );
return strcpy( dst, str );
}

Expand Down Expand Up @@ -532,58 +461,6 @@ int qstrnicmp( const char *str1, const char *str2, uint len )
return 0;
}

#ifndef QT_NO_DATASTREAM

QDataStream &operator<<( QDataStream &s, const QByteArray &a )
{
return s.writeBytes( a.data(), a.size() );
}

QDataStream &operator>>( QDataStream &s, QByteArray &a )
{
Q_UINT32 len;
s >> len; // read size of array
if ( len == 0 || s.eof() ) { // end of file reached
a.resize( 0 );
return s;
}
if ( !a.resize( (uint)len ) ) { // resize array
#if defined(CHECK_NULL)
qWarning( "QDataStream: Not enough memory to read QByteArray" );
#endif
len = 0;
}
if ( len > 0 ) // not null array
s.readRawBytes( a.data(), (uint)len );
return s;
}

QDataStream &operator<<( QDataStream &s, const QCString &str )
{
return s.writeBytes( str.data(), str.size() );
}

QDataStream &operator>>( QDataStream &s, QCString &str )
{
Q_UINT32 len;
s >> len; // read size of string
if ( len == 0 || s.eof() ) { // end of file reached
str.resize( 0 );
return s;
}
if ( !str.resize( (uint)len )) {// resize string
#if defined(CHECK_NULL)
qWarning( "QDataStream: Not enough memory to read QCString" );
#endif
len = 0;
}
if ( len > 0 ) // not null array
s.readRawBytes( str.rawData(), (uint)len );
return s;
}

#endif //QT_NO_DATASTREAM

/// substitute all occurrences of \a src in \a s by \a dst
QCString substitute(const QCString &s,const QCString &src,const QCString &dst)
{
Expand Down
Loading

0 comments on commit 1e77368

Please sign in to comment.