#ifndef NEW_YORK_TRANSIT_LINE_ALOTALOT_H #define NEW_YORK_TRANSIT_LINE_ALOTALOT_H /* A little of this, a little of that * DO NOT EXPORT THIS FILE */ #include #include namespace nytl { template using uptr = std::unique_ptr; class FUp : public std::exception{ std::string WHAT; public: FUp(const std::string &err, const std::string &file, const std::string &func, int line); const char *what() const noexcept override; }; std::string prettyprint_errno(const std::string& pref); #define THROW(err) throw FUp(err, __FILE__, __func__, __LINE__) #define THROW_on_errno(err) THROW(prettyprint_errno(err)) #define THROW_on_errno_pl() THROW(prettyprint_errno("")) #define ASSERT(cond, err) do { if (!(cond)) { THROW(err); } } while (0); #define ASSERT_pl(cond) ASSERT(cond, "Failed assertion `" #cond "`") #define ASSERT_on_iret(iret, err) ASSERT((iret) >= 0, prettyprint_errno(err)); #define ASSERT_on_iret_pl(iret) ASSERT(iret >= 0, prettyprint_errno("")); bool endsIn(const std::string& a, const std::string& b); std::string throwout_postfix(const std::string& a, size_t bsz); bool isALPHA(char ch); bool isNUM(char ch); bool isUNCHAR(char ch); bool isSPACE(char ch); bool isUname(const std::string& str) noexcept; } #endif