0.6.0
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 61 of file clang_tool.cc.

62{
63 j["level"] = a.level;
64 j["description"] = logging::escape_json(a.description);
65 if (a.location) {
66 j["location"]["file"] = a.location.value().file();
67 j["location"]["line"] = a.location.value().line();
68 j["location"]["column"] = a.location.value().column();
69 }
70}

◆ to_string()

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

Definition at line 46 of file clang_tool.cc.

47{
48 if (!d.location) {
49 return fmt::format("[{}] {}", d.level, d.description);
50 }
51
52 std::string filepath = d.location->file_relative().empty()
53 ? d.location->file()
54 : d.location->file_relative();
55 auto line = d.location->line();
56
57 return fmt::format(
58 "[{}] {}:{}: {}", d.level, filepath, line, d.description);
59}