stamenStatic Menu Generator |
git clone git://git.dimitrijedobrota.com/stamen.git |
Log | Files | Refs | README | LICENSE | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING | |
example_cpp.cpp (1103B)
1 #include <cstddef> 2 #include <iostream> 3 4 #include "demo_menu.hpp" 5 6 namespace example { 7 8 int menu_t::visit(const menu_t& menu) 9 { 10 std::cout << menu.title << '\n'; 11 for (auto i = 0UL; i < menu.items.size(); i++) 12 { 13 std::cout << i + 1 << ": " << menu.items[i].prompt << '\n'; 14 } 15 std::cout << "Auto calling option 1...\n"; 16 menu.items[1].callback(1); 17 return 0; 18 } 19 20 int operation1(std::size_t /* unused */) // NOLINT 21 { 22 std::cout << "operation 1\n\n"; 23 std::cout << "Some operation is done\n\n"; 24 std::cout << std::flush; 25 return 1; 26 } 27 28 int operation2(std::size_t /* unused */) // NOLINT 29 { 30 std::cout << "operation 2\n"; 31 std::cout << "Some other operation is done\n"; 32 std::cout << std::flush; 33 return 1; 34 } 35 36 int operation3(std::size_t /* unused */) // NOLINT 37 { 38 std::cout << "operation 3\n"; 39 std::cout << "Yet another operation is done\n"; 40 std::cout << std::flush; 41 return 1; 42 } 43 44 int finish(std::size_t /* unused */) // NOLINT 45 { 46 std::cout << "finishing...\n"; 47 std::cout << std::flush; 48 exit(0); 49 } 50 51 } // namespace example 52 53 int main() 54 { 55 example::menu_main(0); 56 return 0; 57 }