0.6.3
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Classes | Functions
clanguml::generators Namespace Reference

Classes

class  clang_tool
 Custom ClangTool implementation to enable better error handling. More...
 
class  clang_tool_exception
 
struct  diagnostic
 
class  diagnostic_consumer
 

Functions

std::string to_string (const clanguml::generators::diagnostic &d)
 
void to_json (nlohmann::json &j, const diagnostic &a)
 

Function Documentation

◆ to_json()

void clanguml::generators::to_json ( nlohmann::json &  j,
const diagnostic a 
)

Definition at line 69 of file clang_tool.cc.

70{
71 j["level"] = a.level;
72 j["description"] = logging::escape_json(a.description);
73 if (a.location) {
74 j["location"]["file"] = a.location.value().file();
75 j["location"]["line"] = a.location.value().line();
76 j["location"]["column"] = a.location.value().column();
77 }
78}

◆ to_string()

std::string clanguml::generators::to_string ( const clanguml::generators::diagnostic d)

Definition at line 54 of file clang_tool.cc.

55{
56 if (!d.location) {
57 return fmt::format("[{}] {}", d.level, d.description);
58 }
59
60 std::string filepath = d.location->file_relative().empty()
61 ? d.location->file()
62 : d.location->file_relative();
63 auto line = d.location->line();
64
65 return fmt::format(
66 "[{}] {}:{}: {}", d.level, filepath, line, d.description);
67}