ultimatepp/uppsrc/ide/clang/util.cpp
2022-08-13 18:43:56 +02:00

48 lines
1.2 KiB
C++

#include "clang.h"
bool IsCppSourceFile(const String& path)
{
String ext = ToLower(GetFileExt(path));
return findarg(ext, ".cpp", ".cc", ".cxx") >= 0;
}
bool IsSourceFile(const String& path)
{
String ext = ToLower(GetFileExt(path));
return findarg(ext, ".cpp", ".cc", ".cxx", ".icpp", ".c") >= 0;
}
bool IsHeaderFile(const String& path)
{
String ext = ToLower(GetFileExt(path));
return findarg(ext, ".h", ".hxx", ".hpp", ".hh") >= 0;
}
bool IsStruct(int kind)
{
return findarg(kind, CXCursor_StructDecl, CXCursor_UnionDecl, CXCursor_ClassDecl,
CXCursor_ClassTemplate) >= 0;
}
bool IsTemplate(int kind)
{
return findarg(kind, CXCursor_FunctionTemplate, CXCursor_ClassTemplate) >= 0;
}
bool IsFunction(int kind)
{
return findarg(kind, CXCursor_FunctionTemplate, CXCursor_FunctionDecl, CXCursor_Constructor,
CXCursor_Destructor, CXCursor_ConversionFunction, CXCursor_CXXMethod) >= 0;
}
bool IsVariable(int kind)
{
return findarg(kind, CXCursor_VarDecl, CXCursor_FieldDecl) >= 0;
}
int FindId(const String& s, const String& id) {
int q = s.Find(id);
return q < 0 ||
q > 0 && iscid(s[q - 1]) ||
q + id.GetCount() < s.GetCount() && iscid(s[q + id.GetCount()]) ? -1 : q;
};