oxedyne/fe2o3/fe2o3_text/tests/detect_corpus/cpp/canonical.txt
1.3 KiB, 1 run
created by r1870400018:11944, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | #include <iostream> |
| 2 | #include <vector> |
| 3 | #include <string> |
| 4 | #include <algorithm> |
| 5 | |
| 6 | class Logger { |
| 7 | public: |
| 8 | enum class Level { Debug, Info, Warn, Error }; |
| 9 | |
| 10 | explicit Logger(std::string name) |
| 11 | : name_(std::move(name)) {} |
| 12 | |
| 13 | void log(Level level, const std::string& message) const { |
| 14 | std::cout << "[" << level_str(level) << "] " |
| 15 | << name_ << ": " << message << "\n"; |
| 16 | } |
| 17 | |
| 18 | void debug(const std::string& msg) const { log(Level::Debug, msg); } |
| 19 | void info(const std::string& msg) const { log(Level::Info, msg); } |
| 20 | void warn(const std::string& msg) const { log(Level::Warn, msg); } |
| 21 | void error(const std::string& msg) const { log(Level::Error, msg); } |
| 22 | |
| 23 | private: |
| 24 | std::string name_; |
| 25 | |
| 26 | static const char* level_str(Level l) { |
| 27 | switch (l) { |
| 28 | case Level::Debug: return "DEBUG"; |
| 29 | case Level::Info: return "INFO"; |
| 30 | case Level::Warn: return "WARN"; |
| 31 | case Level::Error: return "ERROR"; |
| 32 | } |
| 33 | return "UNKNOWN"; |
| 34 | } |
| 35 | }; |
| 36 | |
| 37 | int main() { |
| 38 | Logger log("main"); |
| 39 | log.info("starting up"); |
| 40 | |
| 41 | std::vector<int> values = {5, 3, 8, 1, 9, 2, 7}; |
| 42 | std::sort(values.begin(), values.end()); |
| 43 | |
| 44 | for (const auto& v : values) { |
| 45 | std::cout << v << " "; |
| 46 | } |
| 47 | std::cout << std::endl; |
| 48 | |
| 49 | log.info("done"); |
| 50 | return 0; |
| 51 | } |