Files
clang-uml/docs/test_cases/t20023.md
2023-03-26 00:24:04 +01:00

6.2 KiB

t20023 - Try/catch statement sequence diagram test case

Config

compilation_database_dir: ..
output_directory: puml
diagrams:
  t20023_sequence:
    type: sequence
    glob:
      - ../../tests/t20023/t20023.cc
    include:
      namespaces:
        - clanguml::t20023
    using_namespace:
      - clanguml::t20023
    start_from:
      - function: "clanguml::t20023::tmain()"

Source code

File t20023.cc

#include <stdexcept>

namespace clanguml {
namespace t20023 {

struct A {
    int a1() { return 1; }
    int a2() { return 2; }
    int a3() { return 3; }
    int a4() { return 3; }

    int a()
    {
        try {
            return a1();
        }
        catch (std::runtime_error &) {
            return a2();
        }
        catch (std::logic_error &) {
            return a3();
        }
        catch (...) {
            return a4();
        }
    }
};

int tmain()
{
    A a;

    int result{};

    result = a.a();

    return result;
}
}
}

Generated UML diagrams

t20023_sequence

Generated JSON models

{
  "diagram_type": "sequence",
  "name": "t20023_sequence",
  "participants": [
    {
      "id": "761552264135157511",
      "name": "clanguml::t20023::tmain()",
      "source_location": {
        "file": "../../tests/t20023/t20023.cc",
        "line": 29
      },
      "type": "function"
    },
    {
      "id": "750638294800359616",
      "name": "clanguml::t20023::A",
      "source_location": {
        "file": "../../tests/t20023/t20023.cc",
        "line": 6
      },
      "type": "class"
    }
  ],
  "sequences": [
    {
      "messages": [
        {
          "from": {
            "activity_id": "761552264135157511",
            "activity_name": "clanguml::t20023::tmain()",
            "participant_id": "761552264135157511",
            "participant_name": "clanguml::t20023::tmain()"
          },
          "name": "a()",
          "return_type": "int",
          "scope": "normal",
          "source_location": {
            "file": "../../tests/t20023/t20023.cc",
            "line": 35
          },
          "to": {
            "activity_id": "530651320277188697",
            "activity_name": "clanguml::t20023::A::a()",
            "participant_id": "750638294800359616"
          },
          "type": "message"
        },
        {
          "activity_id": "530651320277188697",
          "branches": [
            {
              "messages": [
                {
                  "from": {
                    "activity_id": "530651320277188697",
                    "activity_name": "clanguml::t20023::A::a()",
                    "participant_id": "750638294800359616"
                  },
                  "name": "a1()",
                  "return_type": "int",
                  "scope": "normal",
                  "source_location": {
                    "file": "../../tests/t20023/t20023.cc",
                    "line": 15
                  },
                  "to": {
                    "activity_id": "94135113932519208",
                    "activity_name": "clanguml::t20023::A::a1()",
                    "participant_id": "750638294800359616"
                  },
                  "type": "message"
                }
              ],
              "type": "main"
            },
            {
              "messages": [
                {
                  "from": {
                    "activity_id": "530651320277188697",
                    "activity_name": "clanguml::t20023::A::a()",
                    "participant_id": "750638294800359616"
                  },
                  "name": "a2()",
                  "return_type": "int",
                  "scope": "normal",
                  "source_location": {
                    "file": "../../tests/t20023/t20023.cc",
                    "line": 18
                  },
                  "to": {
                    "activity_id": "2060438178899014465",
                    "activity_name": "clanguml::t20023::A::a2()",
                    "participant_id": "750638294800359616"
                  },
                  "type": "message"
                }
              ],
              "type": "catch"
            },
            {
              "messages": [
                {
                  "from": {
                    "activity_id": "530651320277188697",
                    "activity_name": "clanguml::t20023::A::a()",
                    "participant_id": "750638294800359616"
                  },
                  "name": "a3()",
                  "return_type": "int",
                  "scope": "normal",
                  "source_location": {
                    "file": "../../tests/t20023/t20023.cc",
                    "line": 21
                  },
                  "to": {
                    "activity_id": "1776927259621603017",
                    "activity_name": "clanguml::t20023::A::a3()",
                    "participant_id": "750638294800359616"
                  },
                  "type": "message"
                }
              ],
              "type": "catch"
            },
            {
              "messages": [
                {
                  "from": {
                    "activity_id": "530651320277188697",
                    "activity_name": "clanguml::t20023::A::a()",
                    "participant_id": "750638294800359616"
                  },
                  "name": "a4()",
                  "return_type": "int",
                  "scope": "normal",
                  "source_location": {
                    "file": "../../tests/t20023/t20023.cc",
                    "line": 24
                  },
                  "to": {
                    "activity_id": "1082587698374248813",
                    "activity_name": "clanguml::t20023::A::a4()",
                    "participant_id": "750638294800359616"
                  },
                  "type": "message"
                }
              ],
              "type": "catch"
            }
          ],
          "name": "try",
          "type": "break"
        }
      ],
      "start_from": {
        "id": 761552264135157511,
        "location": "clanguml::t20023::tmain()"
      }
    }
  ],
  "using_namespace": "clanguml::t20023"
}