Last active
October 2, 2024 23:50
-
-
Save philip82148/9684321c37ba6ae18fb101b586a7bd00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bitset> | |
#include <complex> | |
#include <iostream> | |
#include <map> | |
#include <optional> | |
#include <queue> | |
#include <set> | |
#include <stack> | |
#include <string> | |
#include <tuple> | |
#include <utility> | |
#include <variant> | |
#include <vector> | |
#include "../cpp-dump.hpp" | |
namespace cp = cpp_dump; | |
int main() { | |
// Use more colors | |
CPP_DUMP_SET_OPTION(es_value.log, "\x1b[38;2;0;16;128m"); // log: | |
CPP_DUMP_SET_OPTION(es_value.expression, "\x1b[38;2;0;0;255m"); // expression: | |
CPP_DUMP_SET_OPTION(es_value.reserved, "\x1b[38;2;0;0;255m"); // reserved: | |
CPP_DUMP_SET_OPTION(es_value.number, "\x1b[38;2;9;134;88m"); // number: | |
CPP_DUMP_SET_OPTION(es_value.character, "\x1b[38;2;163;21;21m"); // character: | |
CPP_DUMP_SET_OPTION(es_value.escaped_char, "\x1b[38;2;238;0;0m"); // escaped_char: | |
CPP_DUMP_SET_OPTION(es_value.op, "\x1b[38;2;0;0;0m"); // op: | |
CPP_DUMP_SET_OPTION(es_value.identifier, "\x1b[38;2;38;127;153m"); // identifier: | |
CPP_DUMP_SET_OPTION(es_value.member, "\x1b[38;2;141;94;38m"); // member: | |
CPP_DUMP_SET_OPTION(es_value.unsupported, "\x1b[31m"); // unsupported: | |
CPP_DUMP_SET_OPTION( | |
es_value.bracket_by_depth, | |
(std::vector<std::string>{ | |
"\x1b[38;2;109;147;49m", // bracket_by_depth[0]: | |
"\x1b[38;2;123;56;20m", // bracket_by_depth[1]: | |
"\x1b[38;2;4;49;250m", // bracket_by_depth[2]: | |
}) | |
); | |
CPP_DUMP_SET_OPTION(es_value.class_op, "\x1b[38;2;0;0;0m"); // class_op: | |
CPP_DUMP_SET_OPTION(es_value.member_op, "\x1b[38;2;0;0;255m"); // member_op: | |
CPP_DUMP_SET_OPTION(es_value.number_op, "\x1b[38;2;0;0;0m"); // number_op: | |
// Use the 'class_op'/'member_op'/'number_op' color for operators | |
// in class names, members, and numbers (::, <>, (), -, +, etc...). | |
CPP_DUMP_SET_OPTION(detailed_class_es, true); | |
CPP_DUMP_SET_OPTION(detailed_member_es, true); | |
CPP_DUMP_SET_OPTION(detailed_number_es, true); | |
// Use a color scheme closer to standard syntax highlighting. | |
CPP_DUMP_SET_OPTION(es_style, cp::types::es_style_t::by_syntax); | |
bool my_bool = true; | |
double my_double = 3.141592; | |
int my_int = 65; | |
char my_char = 'a', LF_char = '\n'; | |
std::string my_string = "This is a string."; | |
int *int_ptr = &my_int; | |
void *void_ptr = &my_int; | |
std::vector<std::vector<int>> my_vector{{3, 5, 8, 9, 7}, {9, 3, 2, 3, 8}}; | |
std::set<char> my_set{'A', 'p', 'p', 'l', 'e'}; | |
std::map<int, int> my_map{{2, 6}, {4, 6}, {5, 3}}; | |
std::multiset<char> my_multiset{'A', 'p', 'p', 'l', 'e'}; | |
std::multimap<int, int> my_multimap{{2, 4}, {4, 6}, {5, 3}, {4, 7}}; | |
std::pair<int, char> my_pair{8, 'a'}; | |
std::tuple<int, double, std::string> my_tuple{7, 4.5, "This is a string."}; | |
std::queue<int> my_queue; | |
std::priority_queue<int> my_priority_queue; | |
std::stack<int> my_stack; | |
for (auto v : {1, 2, 3, 4, 5}) my_queue.push(v), my_priority_queue.push(v), my_stack.push(v); | |
std::bitset<8> my_bitset(0x3a); | |
std::complex<double> my_complex{1.0, -1.0}; | |
std::optional<int> my_optional{15}; | |
std::variant<int, std::string> my_variant{"This is a string."}; | |
std::vector<std::pair<int, std::string>> vector_of_pairs{{1, "apple"}, {3, "banana"}}; | |
std::clog << "\n// Basic Type" << std::endl; | |
cpp_dump(my_bool, my_double, my_int), cpp_dump(my_string, my_char, LF_char); | |
cpp_dump(int_ptr, void_ptr, nullptr); | |
std::clog << "\n// Container" << std::endl; | |
cpp_dump(my_vector); | |
std::clog << "\n// Set/Map" << std::endl; | |
cpp_dump(my_set), cpp_dump(my_map); | |
std::clog << "\n// Multiset/Multimap" << std::endl; | |
cpp_dump(my_multiset), cpp_dump(my_multimap); | |
std::clog << "\n// Tuple" << std::endl; | |
cpp_dump(my_tuple), cpp_dump(my_pair); | |
std::clog << "\n// FIFO/LIFO" << std::endl; | |
cpp_dump(my_queue), cpp_dump(my_priority_queue), cpp_dump(my_stack); | |
std::clog << "\n// Other" << std::endl; | |
cpp_dump(my_bitset), cpp_dump(my_complex); | |
cpp_dump(my_optional, std::nullopt), cpp_dump(my_variant); | |
std::clog << "\n// Combination" << std::endl; | |
cpp_dump(vector_of_pairs); | |
std::clog << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment