Doxygen
Toggle main menu visibility
Loading...
Searching...
No Matches
types.cpp
Go to the documentation of this file.
1
/******************************************************************************
2
*
3
* Copyright (C) 1997-2026 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
#include "
types.h
"
17
#include "
util.h
"
18
19
EntryType
EntryType::guessSection
(
const
DString
&name)
20
{
21
DString
n=name.
lower
();
22
static
const
std::unordered_set<std::string> sourceExt = {
23
"c"
,
"cc"
,
"cxx"
,
"cpp"
,
"c++"
,
"cppm"
,
"ccm"
,
"cxxm"
,
"c++m"
,
// C/C++
24
"java"
,
// Java
25
"cs"
,
// C#
26
"m"
,
"mm"
,
// Objective-C
27
"ii"
,
"ixx"
,
"ipp"
,
"i++"
,
"inl"
,
// C/C++ inline
28
"xml"
,
"lex"
,
"sql"
// others
29
};
30
static
const
std::unordered_set<std::string> headerExt = {
31
"h"
,
"hh"
,
"hxx"
,
"hpp"
,
"h++"
,
"ixx"
,
// C/C++ header
32
"idl"
,
"ddl"
,
"pidl"
,
"ice"
// IDL like
33
};
34
size_t
lastDot = n.
rfind
(
'.'
);
35
if
(lastDot!=
DString::npos
)
36
{
37
DString
extension = n.
mid
(lastDot+1);
// part after the last dot
38
if
(sourceExt.find(extension.
str
())!=sourceExt.end())
39
{
40
return
EntryType::makeSource();
41
}
42
if
(headerExt.find(extension.
str
())!=headerExt.end())
43
{
44
return
EntryType::makeHeader();
45
}
46
}
47
else
48
{
49
if
(
getLanguageFromFileName
(name,SrcLangExt::Unknown) == SrcLangExt::Cpp)
return
EntryType::makeHeader();
50
}
51
return
EntryType::makeEmpty();
52
}
53
DString
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition
dstring.h:89
DString::rfind
size_t rfind(char c, size_t pos=npos) const
Definition
dstring.h:249
DString::mid
DString mid(size_t index, size_t len=npos) const
Definition
dstring.h:323
DString::lower
DString lower() const
Definition
dstring.h:331
DString::npos
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
Definition
dstring.h:183
DString::str
const std::string & str() const
Definition
dstring.h:634
EntryType::guessSection
static EntryType guessSection(const DString &name)
Definition
types.cpp:19
EntryType::EntryType
constexpr EntryType(int t) noexcept
Definition
types.h:904
types.h
This file contains a number of basic enums and types.
getLanguageFromFileName
SrcLangExt getLanguageFromFileName(const DString &fileName, SrcLangExt defLang)
Definition
util.cpp:4536
util.h
A bunch of utility functions.
src
types.cpp
Generated by
1.19.0