mirror of
https://github.com/siemens-mobile-hacks/doxygen.git
synced 2026-11-26 06:37:51 +00:00
This commit changes the following in relation to string use - The implicit convert from 'QCString' to 'const char *' is removed - Strings parameters use 'const QCString &' as much as possible in favor over 'const char *' - 'if (s)' where s is a QCString has been replaced by 'if(!s.isEmpty())' - data() now always returns a valid C-string and not a 0-pointer. - when passing a string 's' to printf and related functions 'qPrint(s)' is used instead of 's.data()' - for empty string arguments 'QCString()' is used instead of '0' - The copy() operation has been removed - Where possible 'qstrcmp(a,b)==0' has been replaces by 'a==b' and 'qstrcmp(a,b)<0' has been replaced by 'a<b' - Parameters of string type that were default initialized with '= 0' are no initialized with '= QCString()'
141 lines
3.6 KiB
C++
141 lines
3.6 KiB
C++
/******************************************************************************
|
|
*
|
|
* Copyright (C) 1997-2020 by Dimitri van Heesch.
|
|
*
|
|
* Permission to use, copy, modify, and distribute this software and its
|
|
* documentation under the terms of the GNU General Public License is hereby
|
|
* granted. No representations are made about the suitability of this software
|
|
* for any purpose. It is provided "as is" without express or implied warranty.
|
|
* See the GNU General Public License for more details.
|
|
*
|
|
* Documents produced by Doxygen are derivative works derived from the
|
|
* input used in their production; they are not affected by this license.
|
|
*
|
|
*/
|
|
|
|
#include <stdarg.h>
|
|
#include <algorithm>
|
|
#include <stdio.h>
|
|
#include <map>
|
|
#include <string>
|
|
#include <chrono>
|
|
|
|
#include "debug.h"
|
|
#include "message.h"
|
|
#include "qcstring.h"
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
static std::map< std::string, Debug::DebugMask > s_labels =
|
|
{
|
|
{ "findmembers", Debug::FindMembers },
|
|
{ "functions", Debug::Functions },
|
|
{ "variables", Debug::Variables },
|
|
{ "preprocessor", Debug::Preprocessor },
|
|
{ "nolineno", Debug::NoLineNo },
|
|
{ "classes", Debug::Classes },
|
|
{ "commentcnv", Debug::CommentCnv },
|
|
{ "commentscan", Debug::CommentScan },
|
|
{ "validate", Debug::Validate },
|
|
{ "printtree", Debug::PrintTree },
|
|
{ "time", Debug::Time },
|
|
{ "extcmd", Debug::ExtCmd },
|
|
{ "markdown", Debug::Markdown },
|
|
{ "filteroutput", Debug::FilterOutput },
|
|
{ "lex", Debug::Lex },
|
|
{ "plantuml", Debug::Plantuml },
|
|
{ "fortranfixed2free", Debug::FortranFixed2Free },
|
|
{ "cite", Debug::Cite }
|
|
};
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
Debug::DebugMask Debug::curMask = Debug::Quiet;
|
|
int Debug::curPrio = 0;
|
|
|
|
void Debug::print(DebugMask mask,int prio,const char *fmt,...)
|
|
{
|
|
if ((curMask&mask) && prio<=curPrio)
|
|
{
|
|
va_list args;
|
|
va_start(args,fmt);
|
|
vfprintf(stdout, fmt, args);
|
|
va_end(args);
|
|
}
|
|
}
|
|
|
|
static char asciiToLower(char in) {
|
|
if (in <= 'Z' && in >= 'A')
|
|
return in - ('Z' - 'z');
|
|
return in;
|
|
}
|
|
|
|
static int labelToEnumValue(const QCString &l)
|
|
{
|
|
std::string s = l.str();
|
|
std::transform(s.begin(),s.end(),s.begin(),asciiToLower);
|
|
auto it = s_labels.find(s);
|
|
return (it!=s_labels.end()) ? it->second : 0;
|
|
}
|
|
|
|
int Debug::setFlag(const QCString &lab)
|
|
{
|
|
int retVal = labelToEnumValue(lab);
|
|
curMask = (DebugMask)(curMask | retVal);
|
|
return retVal;
|
|
}
|
|
|
|
void Debug::clearFlag(const QCString &lab)
|
|
{
|
|
curMask = (DebugMask)(curMask & ~labelToEnumValue(lab));
|
|
}
|
|
|
|
void Debug::setPriority(int p)
|
|
{
|
|
curPrio = p;
|
|
}
|
|
|
|
bool Debug::isFlagSet(DebugMask mask)
|
|
{
|
|
return (curMask & mask)!=0;
|
|
}
|
|
|
|
void Debug::printFlags()
|
|
{
|
|
for (const auto &v : s_labels)
|
|
{
|
|
msg("\t%s\n",v.first.c_str());
|
|
}
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
class Timer
|
|
{
|
|
public:
|
|
void start()
|
|
{
|
|
m_startTime = std::chrono::system_clock::now();
|
|
}
|
|
double elapsedTimeS()
|
|
{
|
|
return (std::chrono::duration_cast<
|
|
std::chrono::microseconds>(
|
|
std::chrono::system_clock::now() - m_startTime).count()) / 1000000.0;
|
|
}
|
|
private:
|
|
std::chrono::time_point<std::chrono::system_clock> m_startTime;
|
|
};
|
|
|
|
static Timer g_runningTime;
|
|
|
|
void Debug::startTimer()
|
|
{
|
|
g_runningTime.start();
|
|
}
|
|
|
|
double Debug::elapsedTime()
|
|
{
|
|
return g_runningTime.elapsedTimeS();
|
|
}
|
|
|