MCPcopy Create free account
hub / github.com/p-ranav/tabulate / main

Function main

samples/universal_constants.cpp:5–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3using Row_t = Table::Row_t;
4
5int main() {
6
7 Table universal_constants;
8
9 universal_constants.add_row(Row_t{"Quantity", "Value"});
10 universal_constants.add_row(Row_t{"Characteristic impedance of vacuum", "376.730 313 461... Ω"});
11 universal_constants.add_row(
12 {"Electric constant (permittivity of free space)", "8.854 187 817... × 10⁻¹²F·m⁻¹"});
13 universal_constants.add_row(Row_t{"Magnetic constant (permeability of free space)",
14 "4π × 10⁻⁷ N·A⁻² = 1.2566 370 614... × 10⁻⁶ N·A⁻²"});
15 universal_constants.add_row(Row_t{"Gravitational constant (Newtonian constant of gravitation)",
16 "6.6742(10) × 10⁻¹¹m³·kg⁻¹·s⁻²"});
17 universal_constants.add_row(Row_t{"Planck's constant", "6.626 0693(11) × 10⁻³⁴ J·s"});
18 universal_constants.add_row(Row_t{"Dirac's constant", "1.054 571 68(18) × 10⁻³⁴ J·s"});
19 universal_constants.add_row(Row_t{"Speed of light in vacuum", "299 792 458 m·s⁻¹"});
20
21 // Table.format() will apply styles for the whole table
22 universal_constants.format()
23 .font_style({FontStyle::bold})
24 .border_top(" ")
25 .border_bottom(" ")
26 .border_left(" ")
27 .border_right(" ")
28 .corner(" ");
29
30 // Table[index] is used to access a particular row
31 // You can use this to access and format a specific row
32 universal_constants[0]
33 .format()
34 .padding_top(1)
35 .padding_bottom(1)
36 .font_align(FontAlign::center)
37 .font_style({FontStyle::underline})
38 .font_background_color(Color::red);
39
40 // Table.column(index) is used to access a particular column
41 // You can use this to access and format a specific column
42 universal_constants.column(1).format().font_color(Color::yellow);
43
44 universal_constants[0][1].format().font_background_color(Color::blue).font_color(Color::white);
45
46 std::cout << universal_constants << std::endl;
47}

Callers

nothing calls this directly

Calls 3

add_rowMethod · 0.45
formatMethod · 0.45
columnMethod · 0.45

Tested by

no test coverage detected