# t00069 - Coroutine methods in class diagrams
## Config
```yaml
diagrams:
  t00069_class:
    type: class
    glob:
      - t00069.cc
    include:
      namespaces:
        - clanguml::t00069
    using_namespace: clanguml::t00069
```
## Source code
File `tests/t00069/t00069.cc`
```cpp
#include <coroutine>
#include <optional>

namespace clanguml {
namespace t00069 {

template <typename T> struct generator {
    struct promise_type;
    using handle_type = std::coroutine_handle<promise_type>;

    generator(handle_type h)
        : h_(h)
    {
    }

    ~generator() { h_.destroy(); }

    struct promise_type {
        T value_;
        std::exception_ptr exception_;

        generator get_return_object()
        {
            return generator(handle_type::from_promise(*this));
        }
        std::suspend_always initial_suspend() { return {}; }

        std::suspend_always final_suspend() noexcept { return {}; }

        void unhandled_exception() { exception_ = std::current_exception(); }

        template <std::convertible_to<T> From>
        std::suspend_always yield_value(From &&from)
        {
            value_ = std::forward<From>(from);
            return {};
        }

        void return_void() { }
    };

    handle_type h_;

private:
    bool full_ = false;
};

class A {
public:
    generator<unsigned long> iota() { co_yield counter_++; }

    generator<unsigned long> seed()
    {
        counter_ = 42;
        co_return;
    }

private:
    unsigned long counter_;
};

} // namespace t00069
} // namespace clanguml

```
## Generated PlantUML diagrams
![t00069_class](./t00069_class.svg "Coroutine methods in class diagrams")
## Generated Mermaid diagrams
![t00069_class](./t00069_class_mermaid.svg "Coroutine methods in class diagrams")
## Generated JSON models
```json
{
  "diagram_type": "class",
  "elements": [
    {
      "bases": [],
      "display_name": "generator<T>",
      "id": "2142496233889685657",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": true,
      "is_template": true,
      "is_union": false,
      "members": [
        {
          "access": "public",
          "is_static": false,
          "name": "h_",
          "source_location": {
            "column": 17,
            "file": "t00069.cc",
            "line": 42,
            "translation_unit": "t00069.cc"
          },
          "type": "handle_type"
        },
        {
          "access": "private",
          "is_static": false,
          "name": "full_",
          "source_location": {
            "column": 10,
            "file": "t00069.cc",
            "line": 45,
            "translation_unit": "t00069.cc"
          },
          "type": "bool"
        }
      ],
      "methods": [
        {
          "access": "public",
          "is_const": false,
          "is_consteval": false,
          "is_constexpr": false,
          "is_constructor": true,
          "is_copy_assignment": false,
          "is_coroutine": false,
          "is_defaulted": false,
          "is_deleted": false,
          "is_move_assignment": false,
          "is_noexcept": false,
          "is_operator": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "generator",
          "parameters": [
            {
              "name": "h",
              "type": "handle_type"
            }
          ],
          "source_location": {
            "column": 5,
            "file": "t00069.cc",
            "line": 11,
            "translation_unit": "t00069.cc"
          },
          "type": "void"
        },
        {
          "access": "public",
          "is_const": false,
          "is_consteval": false,
          "is_constexpr": false,
          "is_constructor": false,
          "is_copy_assignment": false,
          "is_coroutine": false,
          "is_defaulted": false,
          "is_deleted": false,
          "is_move_assignment": false,
          "is_noexcept": false,
          "is_operator": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "~generator",
          "parameters": [],
          "source_location": {
            "column": 5,
            "file": "t00069.cc",
            "line": 16,
            "translation_unit": "t00069.cc"
          },
          "type": "void"
        }
      ],
      "name": "generator",
      "namespace": "clanguml::t00069",
      "source_location": {
        "column": 30,
        "file": "t00069.cc",
        "line": 7,
        "translation_unit": "t00069.cc"
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "template_type",
          "name": "T",
          "template_parameters": []
        }
      ],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "generator::promise_type",
      "id": "721812727497968117",
      "is_abstract": false,
      "is_nested": true,
      "is_struct": true,
      "is_template": false,
      "is_union": false,
      "members": [
        {
          "access": "public",
          "is_static": false,
          "name": "value_",
          "source_location": {
            "column": 11,
            "file": "t00069.cc",
            "line": 19,
            "translation_unit": "t00069.cc"
          },
          "type": "T"
        },
        {
          "access": "public",
          "is_static": false,
          "name": "exception_",
          "source_location": {
            "column": 28,
            "file": "t00069.cc",
            "line": 20,
            "translation_unit": "t00069.cc"
          },
          "type": "std::exception_ptr"
        }
      ],
      "methods": [
        {
          "access": "public",
          "is_const": false,
          "is_consteval": false,
          "is_constexpr": false,
          "is_constructor": false,
          "is_copy_assignment": false,
          "is_coroutine": false,
          "is_defaulted": false,
          "is_deleted": false,
          "is_move_assignment": false,
          "is_noexcept": false,
          "is_operator": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "get_return_object",
          "parameters": [],
          "source_location": {
            "column": 19,
            "file": "t00069.cc",
            "line": 22,
            "translation_unit": "t00069.cc"
          },
          "type": "generator<T>"
        },
        {
          "access": "public",
          "is_const": false,
          "is_consteval": false,
          "is_constexpr": false,
          "is_constructor": false,
          "is_copy_assignment": false,
          "is_coroutine": false,
          "is_defaulted": false,
          "is_deleted": false,
          "is_move_assignment": false,
          "is_noexcept": false,
          "is_operator": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "initial_suspend",
          "parameters": [],
          "source_location": {
            "column": 29,
            "file": "t00069.cc",
            "line": 26,
            "translation_unit": "t00069.cc"
          },
          "type": "std::suspend_always"
        },
        {
          "access": "public",
          "is_const": false,
          "is_consteval": false,
          "is_constexpr": false,
          "is_constructor": false,
          "is_copy_assignment": false,
          "is_coroutine": false,
          "is_defaulted": false,
          "is_deleted": false,
          "is_move_assignment": false,
          "is_noexcept": true,
          "is_operator": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "final_suspend",
          "parameters": [],
          "source_location": {
            "column": 29,
            "file": "t00069.cc",
            "line": 28,
            "translation_unit": "t00069.cc"
          },
          "type": "std::suspend_always"
        },
        {
          "access": "public",
          "is_const": false,
          "is_consteval": false,
          "is_constexpr": false,
          "is_constructor": false,
          "is_copy_assignment": false,
          "is_coroutine": false,
          "is_defaulted": false,
          "is_deleted": false,
          "is_move_assignment": false,
          "is_noexcept": false,
          "is_operator": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "unhandled_exception",
          "parameters": [],
          "source_location": {
            "column": 14,
            "file": "t00069.cc",
            "line": 30,
            "translation_unit": "t00069.cc"
          },
          "type": "void"
        },
        {
          "access": "public",
          "is_const": false,
          "is_consteval": false,
          "is_constexpr": false,
          "is_constructor": false,
          "is_copy_assignment": false,
          "is_coroutine": false,
          "is_defaulted": false,
          "is_deleted": false,
          "is_move_assignment": false,
          "is_noexcept": false,
          "is_operator": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "return_void",
          "parameters": [],
          "source_location": {
            "column": 14,
            "file": "t00069.cc",
            "line": 39,
            "translation_unit": "t00069.cc"
          },
          "type": "void"
        },
        {
          "access": "public",
          "is_const": false,
          "is_consteval": false,
          "is_constexpr": false,
          "is_constructor": false,
          "is_copy_assignment": false,
          "is_coroutine": false,
          "is_defaulted": false,
          "is_deleted": false,
          "is_move_assignment": false,
          "is_noexcept": false,
          "is_operator": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "yield_value",
          "parameters": [
            {
              "name": "from",
              "type": "From &&"
            }
          ],
          "type": "std::suspend_always"
        }
      ],
      "name": "generator::promise_type",
      "namespace": "clanguml::t00069",
      "source_location": {
        "column": 12,
        "file": "t00069.cc",
        "line": 18,
        "translation_unit": "t00069.cc"
      },
      "template_parameters": [],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "generator<unsigned long>",
      "id": "1604358347140526608",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": true,
      "is_union": false,
      "members": [],
      "methods": [],
      "name": "generator",
      "namespace": "clanguml::t00069",
      "source_location": {
        "column": 30,
        "file": "t00069.cc",
        "line": 7,
        "translation_unit": "t00069.cc"
      },
      "template_parameters": [
        {
          "is_variadic": false,
          "kind": "argument",
          "template_parameters": [],
          "type": "unsigned long"
        }
      ],
      "type": "class"
    },
    {
      "bases": [],
      "display_name": "A",
      "id": "2160142503252767290",
      "is_abstract": false,
      "is_nested": false,
      "is_struct": false,
      "is_template": false,
      "is_union": false,
      "members": [
        {
          "access": "private",
          "is_static": false,
          "name": "counter_",
          "source_location": {
            "column": 19,
            "file": "t00069.cc",
            "line": 59,
            "translation_unit": "t00069.cc"
          },
          "type": "unsigned long"
        }
      ],
      "methods": [
        {
          "access": "public",
          "is_const": false,
          "is_consteval": false,
          "is_constexpr": false,
          "is_constructor": false,
          "is_copy_assignment": false,
          "is_coroutine": true,
          "is_defaulted": false,
          "is_deleted": false,
          "is_move_assignment": false,
          "is_noexcept": false,
          "is_operator": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "iota",
          "parameters": [],
          "source_location": {
            "column": 30,
            "file": "t00069.cc",
            "line": 50,
            "translation_unit": "t00069.cc"
          },
          "type": "clanguml::t00069::generator<unsigned long>"
        },
        {
          "access": "public",
          "is_const": false,
          "is_consteval": false,
          "is_constexpr": false,
          "is_constructor": false,
          "is_copy_assignment": false,
          "is_coroutine": true,
          "is_defaulted": false,
          "is_deleted": false,
          "is_move_assignment": false,
          "is_noexcept": false,
          "is_operator": false,
          "is_pure_virtual": false,
          "is_static": false,
          "is_virtual": false,
          "name": "seed",
          "parameters": [],
          "source_location": {
            "column": 30,
            "file": "t00069.cc",
            "line": 52,
            "translation_unit": "t00069.cc"
          },
          "type": "clanguml::t00069::generator<unsigned long>"
        }
      ],
      "name": "A",
      "namespace": "clanguml::t00069",
      "source_location": {
        "column": 7,
        "file": "t00069.cc",
        "line": 48,
        "translation_unit": "t00069.cc"
      },
      "template_parameters": [],
      "type": "class"
    }
  ],
  "name": "t00069_class",
  "package_type": "namespace",
  "relationships": [
    {
      "access": "public",
      "destination": "2142496233889685657",
      "source": "721812727497968117",
      "type": "containment"
    },
    {
      "access": "public",
      "destination": "2142496233889685657",
      "source": "1604358347140526608",
      "type": "instantiation"
    },
    {
      "access": "public",
      "destination": "1604358347140526608",
      "source": "2160142503252767290",
      "type": "dependency"
    }
  ],
  "using_namespace": "clanguml::t00069"
}
```
