| 3 | using Row_t = Table::Row_t; |
| 4 | |
| 5 | int main() { |
| 6 | Table class_diagram; |
| 7 | |
| 8 | // Global styling |
| 9 | class_diagram.format().font_style({FontStyle::bold}).font_align(FontAlign::center).width(60); |
| 10 | |
| 11 | // Animal class |
| 12 | Table animal; |
| 13 | animal.add_row(Row_t{"Animal"}); |
| 14 | animal[0].format().font_align(FontAlign::center); |
| 15 | |
| 16 | // Animal properties nested table |
| 17 | Table animal_properties; |
| 18 | animal_properties.format().width(20); |
| 19 | animal_properties.add_row(Row_t{"+age: Int"}); |
| 20 | animal_properties.add_row(Row_t{"+gender: String"}); |
| 21 | animal_properties[1].format().hide_border_top(); |
| 22 | |
| 23 | // Animal methods nested table |
| 24 | Table animal_methods; |
| 25 | animal_methods.format().width(20); |
| 26 | animal_methods.add_row(Row_t{"+isMammal()"}); |
| 27 | animal_methods.add_row(Row_t{"+mate()"}); |
| 28 | animal_methods[1].format().hide_border_top(); |
| 29 | |
| 30 | animal.add_row(Row_t{animal_properties}); |
| 31 | animal.add_row(Row_t{animal_methods}); |
| 32 | animal[2].format().hide_border_top(); |
| 33 | |
| 34 | class_diagram.add_row(Row_t{animal}); |
| 35 | |
| 36 | // Add rows in the class diagram for the up-facing arrow |
| 37 | // THanks to center alignment, these will align just fine |
| 38 | class_diagram.add_row(Row_t{"▲"}); |
| 39 | class_diagram[1][0].format().hide_border_top().multi_byte_characters(true); |
| 40 | class_diagram.add_row(Row_t{"|"}); |
| 41 | class_diagram[2].format().hide_border_top(); |
| 42 | class_diagram.add_row(Row_t{"|"}); |
| 43 | class_diagram[3].format().hide_border_top(); |
| 44 | |
| 45 | // Duck class |
| 46 | Table duck; |
| 47 | duck.add_row(Row_t{"Duck"}); |
| 48 | duck[0].format().font_align(FontAlign::center); |
| 49 | |
| 50 | // Duck proeperties nested table |
| 51 | Table duck_properties; |
| 52 | duck_properties.format().width(40); |
| 53 | duck_properties.add_row(Row_t{"+beakColor: String = \"yellow\""}); |
| 54 | |
| 55 | // Duck methods nested table |
| 56 | Table duck_methods; |
| 57 | duck_methods.format().width(40); |
| 58 | duck_methods.add_row(Row_t{"+swim()"}); |
| 59 | duck_methods.add_row(Row_t{"+quack()"}); |
| 60 | duck_methods[1].format().hide_border_top(); |
| 61 | |
| 62 | duck.add_row(Row_t{duck_properties}); |