Doxygen
Loading...
Searching...
No Matches
codefragment.cpp File Reference
#include <mutex>
#include <unordered_map>
#include <map>
#include "codefragment.h"
#include "util.h"
#include "doxygen.h"
#include "parserintf.h"
#include "outputlist.h"
#include "clangparser.h"
#include "trace.h"
#include "fileinfo.h"
#include "filedef.h"
#include "portable.h"
#include "message.h"
+ Include dependency graph for codefragment.cpp:

Go to the source code of this file.

Classes

struct  CodeFragmentManager::Private
 
struct  CodeFragmentManager::Private::BlockMarker
 
struct  CodeFragmentManager::Private::FragmentInfo
 

Functions

static QCString readTextFileByName (const QCString &file)
 

Function Documentation

◆ readTextFileByName()

static QCString readTextFileByName ( const QCString & file)
static

Definition at line 193 of file codefragment.cpp.

194{
195 AUTO_TRACE("file={}",file);
196 if (Portable::isAbsolutePath(file))
197 {
198 FileInfo fi(file.str());
199 if (fi.exists())
200 {
201 return fileToString(file,Config_getBool(FILTER_SOURCE_FILES));
202 }
203 }
204 const StringVector &examplePathList = Config_getList(EXAMPLE_PATH);
205 for (const auto &s : examplePathList)
206 {
207 std::string absFileName = s+(Portable::pathSeparator()+file).str();
208 FileInfo fi(absFileName);
209 if (fi.exists())
210 {
211 return fileToString(QCString(absFileName),Config_getBool(FILTER_SOURCE_FILES));
212 }
213 }
214
215 // as a fallback we also look in the exampleNameDict
216 bool ambig=false;
218 if (fd)
219 {
220 if (ambig)
221 {
222 err("included file name '%s' is ambiguous.\nPossible candidates:\n%s\n",qPrint(file),
224 );
225 }
226 return fileToString(fd->absFilePath(),Config_getBool(FILTER_SOURCE_FILES));
227 }
228 else
229 {
230 err("included file %s is not found. Check your EXAMPLE_PATH\n",qPrint(file));
231 }
232 return QCString();
233}
static FileNameLinkedMap * exampleNameLinkedMap
Definition doxygen.h:103
A model of a file symbol.
Definition filedef.h:99
virtual QCString absFilePath() const =0
Minimal replacement for QFileInfo.
Definition fileinfo.h:23
This is an alternative implementation of QCString.
Definition qcstring.h:101
const std::string & str() const
Definition qcstring.h:526
#define Config_getList(name)
Definition config.h:38
#define Config_getBool(name)
Definition config.h:33
std::vector< std::string > StringVector
Definition containers.h:33
#define AUTO_TRACE(...)
Definition docnode.cpp:46
#define err(fmt,...)
Definition message.h:84
bool isAbsolutePath(const QCString &fileName)
Definition portable.cpp:514
QCString pathSeparator()
Definition portable.cpp:391
const char * qPrint(const char *s)
Definition qcstring.h:661
QCString showFileDefMatches(const FileNameLinkedMap *fnMap, const QCString &n)
Definition util.cpp:3388
QCString fileToString(const QCString &name, bool filter, bool isSourceCode)
Definition util.cpp:1414
FileDef * findFileDef(const FileNameLinkedMap *fnMap, const QCString &n, bool &ambig)
Definition util.cpp:3262

References FileDef::absFilePath(), AUTO_TRACE, Config_getBool, Config_getList, err, Doxygen::exampleNameLinkedMap, FileInfo::exists(), fileToString(), findFileDef(), Portable::isAbsolutePath(), Portable::pathSeparator(), qPrint(), showFileDefMatches(), and QCString::str().

Referenced by CodeFragmentManager::parseCodeFragment().