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 195 of file codefragment.cpp.

196{
197 AUTO_TRACE("file={}",file);
198 if (Portable::isAbsolutePath(file))
199 {
200 FileInfo fi(file.str());
201 if (fi.exists())
202 {
203 return fileToString(file,Config_getBool(FILTER_SOURCE_FILES));
204 }
205 }
206 const StringVector &examplePathList = Config_getList(EXAMPLE_PATH);
207 for (const auto &s : examplePathList)
208 {
209 std::string absFileName = s+(Portable::pathSeparator()+file).str();
210 FileInfo fi(absFileName);
211 if (fi.exists())
212 {
213 return fileToString(QCString(absFileName),Config_getBool(FILTER_SOURCE_FILES));
214 }
215 }
216
217 // as a fallback we also look in the exampleNameDict
218 bool ambig=false;
220 if (fd)
221 {
222 if (ambig)
223 {
224 err("included file name '{}' is ambiguous.\nPossible candidates:\n{}\n",file,
226 );
227 }
228 return fileToString(fd->absFilePath(),Config_getBool(FILTER_SOURCE_FILES));
229 }
230 else
231 {
232 err("included file {} is not found. Check your EXAMPLE_PATH\n",file);
233 }
234 return QCString();
235}
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:537
#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:127
bool isAbsolutePath(const QCString &fileName)
Definition portable.cpp:514
QCString pathSeparator()
Definition portable.cpp:391
QCString showFileDefMatches(const FileNameLinkedMap *fnMap, const QCString &n)
Definition util.cpp:3474
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:3348

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

Referenced by CodeFragmentManager::parseCodeFragment().