Doxygen
filename.h
浏览该文件的文档.
1 /******************************************************************************
2  *
3  * Copyright (C) 1997-2020 by Dimitri van Heesch.
4  *
5  * Permission to use, copy, modify, and distribute this software and its
6  * documentation under the terms of the GNU General Public License is hereby
7  * granted. No representations are made about the suitability of this software
8  * for any purpose. It is provided "as is" without express or implied warranty.
9  * See the GNU General Public License for more details.
10  *
11  * Documents produced by Doxygen are derivative works derived from the
12  * input used in their production; they are not affected by this license.
13  *
14  */
15 
16 #ifndef FILENAME_H
17 #define FILENAME_H
18 
19 #include <memory>
20 #include <vector>
21 
22 #include "linkedmap.h"
23 #include "config.h"
24 
25 class FileDef;
26 
27 /** Class representing all files with a certain base name */
28 class FileName : public std::vector< std::unique_ptr<FileDef> >
29 {
30  public:
31  FileName(const QCString &nm,const QCString &fn) : m_name(nm), m_fName(fn), m_pathName("tmp") {}
32  QCString fileName() const { return m_name; }
33  QCString fullName() const { return m_fName; }
34  QCString path() const { return m_pathName; }
35 
36  private:
40 };
41 
42 //! Custom combined key compare and hash functor that uses a lower case string in
43 //! case CASE_SENSE_NAMES is set to NO.
45 {
46  public:
47  //! used as hash function
48  std::size_t operator()(const std::string& input) const noexcept
49  {
50  return std::hash<std::string>()(searchKey(input));
51  }
52  //! used as equal operator
53  bool operator() (const std::string &t1, const std::string &t2) const
54  {
55  return searchKey(t1) == searchKey(t2);
56  }
57  private:
58  std::string searchKey(std::string input) const
59  {
60  std::string key = input;
61  if (!Config_getBool(CASE_SENSE_NAMES))
62  {
63  // convert key to lower case
64  std::transform(key.begin(),key.end(),key.begin(),
65  [](char c){ return (char)std::tolower(c); });
66  }
67  return key;
68  }
69 };
70 
71 /** Ordered dictionary of FileName objects. */
72 class FileNameLinkedMap : public LinkedMap<FileName,FileNameFn,FileNameFn,
73  std::unordered_multimap<std::string,FileName*,FileNameFn,FileNameFn> >
74 {
75 };
76 
77 #endif
FileName::FileName
FileName(const QCString &nm, const QCString &fn)
Definition: filename.h:31
FileNameFn
Custom combined key compare and hash functor that uses a lower case string in case CASE_SENSE_NAMES i...
Definition: filename.h:44
FileName
Class representing all files with a certain base name
Definition: filename.h:28
FileName::m_name
QCString m_name
Definition: filename.h:37
FileName::m_fName
QCString m_fName
Definition: filename.h:38
FileNameFn::searchKey
std::string searchKey(std::string input) const
Definition: filename.h:58
FileNameFn::operator()
std::size_t operator()(const std::string &input) const noexcept
used as hash function
Definition: filename.h:48
linkedmap.h
FileName::m_pathName
QCString m_pathName
Definition: filename.h:39
FileNameLinkedMap
Ordered dictionary of FileName objects.
Definition: filename.h:72
FileName::fullName
QCString fullName() const
Definition: filename.h:33
FileName::path
QCString path() const
Definition: filename.h:34
Config_getBool
#define Config_getBool(name)
Definition: config.h:33
config.h
FileDef
A model of a file symbol.
Definition: filedef.h:73
LinkedMap
Container class representing a vector of objects with keys.
Definition: linkedmap.h:35
FileName::fileName
QCString fileName() const
Definition: filename.h:32
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108