|
|
- #pragma once
- #include <string>
- #include <sstream>
- #include <chrono>
- #include <iostream>
-
- namespace display
- {
- inline std::string escape_csv(const std::string& value)
- {
- std::stringstream ret;
- ret<<"\"";
-
- for(auto v : value)
- {
- switch(v)
- {
- case '\n':
- ret << "\\n";
- break;
-
- case '\t':
- ret << "\\t";
- break;
-
- case '"':
- ret << "\\\"";
- break;
-
- default:
- ret << v;
- break;
- }
- }
-
- ret<<"\"";
- return ret.str();
- }
-
- inline std::string to_string(std::chrono::seconds v)
- {
- std::stringstream ret;
- ret << v.count() << " second" << (v.count()!=1?"s":"");
- return ret.str();
- }
-
- inline std::string to_string(std::chrono::minutes v)
- {
- std::stringstream ret;
- ret << v.count() << " minute" << (v.count()!=1?"s":"");
- return ret.str();
- }
-
- inline void header(std::string app_name)
- {
- std::cout << "\033[2J" << "\033[1;1H";
- std::cout << "Rigid Paradise's "<<app_name<<std::endl;
- }
-
- template<typename T>
- void pair_set(const T& value)
- {
- for(auto action : value)
- {
- std::cout << " [" << action.first << "]: " << action.second<<std::endl;
- }
- }
- }
|