217 lines
6.4 KiB
Markdown
217 lines
6.4 KiB
Markdown
# t20028 - Conditional (ternary) '?:' operator test case
|
|
## Config
|
|
```yaml
|
|
compilation_database_dir: ..
|
|
output_directory: diagrams
|
|
diagrams:
|
|
t20028_sequence:
|
|
type: sequence
|
|
glob:
|
|
- ../../tests/t20028/t20028.cc
|
|
include:
|
|
namespaces:
|
|
- clanguml::t20028
|
|
exclude:
|
|
namespaces:
|
|
- clanguml::t20028::detail
|
|
using_namespace:
|
|
- clanguml::t20028
|
|
from:
|
|
- function: "clanguml::t20028::tmain()"
|
|
```
|
|
## Source code
|
|
File t20028.cc
|
|
```cpp
|
|
namespace clanguml {
|
|
namespace t20028 {
|
|
|
|
struct A {
|
|
int a() { return 0; }
|
|
int b() { return 1; }
|
|
int c() { return 2; }
|
|
int d() { return 3; }
|
|
};
|
|
|
|
namespace detail {
|
|
struct B {
|
|
int e() { return 4; }
|
|
};
|
|
} // namespace detail
|
|
|
|
int tmain()
|
|
{
|
|
A a;
|
|
detail::B b;
|
|
|
|
int result{};
|
|
|
|
result = b.e() ? b.e() : 12;
|
|
|
|
result += a.a() ? a.b() + a.c() : a.d();
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
```
|
|
## Generated PlantUML diagrams
|
|
 '?:' operator test case")
|
|
## Generated Mermaid diagrams
|
|
 '?:' operator test case")
|
|
## Generated JSON models
|
|
```json
|
|
{
|
|
"diagram_type": "sequence",
|
|
"metadata": {
|
|
"clang_uml_version": "0.3.9-23-g7e22b0b",
|
|
"llvm_version": "Ubuntu clang version 16.0.1 (++20230328073357+42d1b276f779-1~exp1~20230328073502.65)",
|
|
"schema_version": 1
|
|
},
|
|
"name": "t20028_sequence",
|
|
"participants": [
|
|
{
|
|
"id": "1347206662193933194",
|
|
"name": "clanguml::t20028::tmain()",
|
|
"source_location": {
|
|
"column": 5,
|
|
"file": "../../tests/t20028/t20028.cc",
|
|
"line": 17,
|
|
"translation_unit": "../../tests/t20028/t20028.cc"
|
|
},
|
|
"type": "function"
|
|
},
|
|
{
|
|
"id": "2073479923903128898",
|
|
"name": "clanguml::t20028::A",
|
|
"source_location": {
|
|
"column": 8,
|
|
"file": "../../tests/t20028/t20028.cc",
|
|
"line": 4,
|
|
"translation_unit": "../../tests/t20028/t20028.cc"
|
|
},
|
|
"type": "class"
|
|
}
|
|
],
|
|
"sequences": [
|
|
{
|
|
"messages": [
|
|
{
|
|
"activity_id": "1347206662193933194",
|
|
"branches": [
|
|
{
|
|
"messages": [
|
|
{
|
|
"from": {
|
|
"activity_id": "1347206662193933194",
|
|
"activity_name": "clanguml::t20028::tmain()",
|
|
"participant_id": "1347206662193933194",
|
|
"participant_name": "clanguml::t20028::tmain()"
|
|
},
|
|
"name": "a()",
|
|
"return_type": "int",
|
|
"scope": "condition",
|
|
"source_location": {
|
|
"column": 15,
|
|
"file": "../../tests/t20028/t20028.cc",
|
|
"line": 26,
|
|
"translation_unit": "../../tests/t20028/t20028.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "666210834901940781",
|
|
"activity_name": "clanguml::t20028::A::a()",
|
|
"participant_id": "2073479923903128898"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "1347206662193933194",
|
|
"activity_name": "clanguml::t20028::tmain()",
|
|
"participant_id": "1347206662193933194",
|
|
"participant_name": "clanguml::t20028::tmain()"
|
|
},
|
|
"name": "b()",
|
|
"return_type": "int",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 23,
|
|
"file": "../../tests/t20028/t20028.cc",
|
|
"line": 26,
|
|
"translation_unit": "../../tests/t20028/t20028.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "793793464184037795",
|
|
"activity_name": "clanguml::t20028::A::b()",
|
|
"participant_id": "2073479923903128898"
|
|
},
|
|
"type": "message"
|
|
},
|
|
{
|
|
"from": {
|
|
"activity_id": "1347206662193933194",
|
|
"activity_name": "clanguml::t20028::tmain()",
|
|
"participant_id": "1347206662193933194",
|
|
"participant_name": "clanguml::t20028::tmain()"
|
|
},
|
|
"name": "c()",
|
|
"return_type": "int",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 31,
|
|
"file": "../../tests/t20028/t20028.cc",
|
|
"line": 26,
|
|
"translation_unit": "../../tests/t20028/t20028.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "1582152567698110078",
|
|
"activity_name": "clanguml::t20028::A::c()",
|
|
"participant_id": "2073479923903128898"
|
|
},
|
|
"type": "message"
|
|
}
|
|
],
|
|
"type": "consequent"
|
|
},
|
|
{
|
|
"messages": [
|
|
{
|
|
"from": {
|
|
"activity_id": "1347206662193933194",
|
|
"activity_name": "clanguml::t20028::tmain()",
|
|
"participant_id": "1347206662193933194",
|
|
"participant_name": "clanguml::t20028::tmain()"
|
|
},
|
|
"name": "d()",
|
|
"return_type": "int",
|
|
"scope": "normal",
|
|
"source_location": {
|
|
"column": 39,
|
|
"file": "../../tests/t20028/t20028.cc",
|
|
"line": 26,
|
|
"translation_unit": "../../tests/t20028/t20028.cc"
|
|
},
|
|
"to": {
|
|
"activity_id": "1178268687951492696",
|
|
"activity_name": "clanguml::t20028::A::d()",
|
|
"participant_id": "2073479923903128898"
|
|
},
|
|
"type": "message"
|
|
}
|
|
],
|
|
"type": "alternative"
|
|
}
|
|
],
|
|
"name": "conditional",
|
|
"type": "alt"
|
|
}
|
|
],
|
|
"start_from": {
|
|
"id": 1347206662193933194,
|
|
"location": "clanguml::t20028::tmain()"
|
|
}
|
|
}
|
|
],
|
|
"using_namespace": "clanguml::t20028"
|
|
}
|
|
```
|