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
// own header
17
#include "
types.h
"
18
19
// other includes
20
#include "
util.h
"
21
22
EntryType
EntryType::guessSection
(
const
DString
&name)
23
{
24
DString
n=name.
lower
();
25
static
const
std::unordered_set<std::string> sourceExt = {
26
"c"
,
"cc"
,
"cxx"
,
"cpp"
,
"c++"
,
"cppm"
,
"ccm"
,
"cxxm"
,
"c++m"
,
// C/C++
27
"java"
,
// Java
28
"cs"
,
// C#
29
"m"
,
"mm"
,
// Objective-C
30
"ii"
,
"ixx"
,
"ipp"
,
"i++"
,
"inl"
,
// C/C++ inline
31
"xml"
,
"lex"
,
"sql"
// others
32
};
33
static
const
std::unordered_set<std::string> headerExt = {
34
"h"
,
"hh"
,
"hxx"
,
"hpp"
,
"h++"
,
"ixx"
,
// C/C++ header
35
"idl"
,
"ddl"
,
"pidl"
,
"ice"
// IDL like
36
};
37
size_t
lastDot = n.
rfind
(
'.'
);
38
if
(lastDot!=
DString::npos
)
39
{
40
DString
extension = n.
mid
(lastDot+1);
// part after the last dot
41
if
(sourceExt.find(extension.
str
())!=sourceExt.end())
42
{
43
return
EntryType::makeSource();
44
}
45
if
(headerExt.find(extension.
str
())!=headerExt.end())
46
{
47
return
EntryType::makeHeader();
48
}
49
}
50
else
51
{
52
if
(
getLanguageFromFileName
(name,SrcLangExt::Unknown) == SrcLangExt::Cpp)
return
EntryType::makeHeader();
53
}
54
return
EntryType::makeEmpty();
55
}
56
DString
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition
dstring.h:84
DString::rfind
size_t rfind(char c, size_t pos=npos) const
Definition
dstring.h:244
DString::mid
DString mid(size_t index, size_t len=npos) const
Definition
dstring.h:318
DString::lower
DString lower() const
Definition
dstring.h:326
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:178
DString::str
const std::string & str() const
Definition
dstring.h:645
EntryType::guessSection
static EntryType guessSection(const DString &name)
Definition
types.cpp:22
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:4168
util.h
A bunch of utility functions.
src
types.cpp
Generated by
1.19.0