#ifndef __NASAL_ERR_H__ #define __NASAL_ERR_H__ #include #include #include // MSVC need this to use std::getline #include #ifdef _WIN32 #include // use SetConsoleTextAttribute #endif class fstreamline { protected: string file; std::vector res; public: void load(const string& f) { if(file==f) // don't need to load a loaded file return; file=f; res.clear(); std::ifstream fin(f,std::ios::binary); if(fin.fail()) { std::cerr<<"[src] cannot open file <"<\n"; std::exit(1); } string line; while(!fin.eof()) { std::getline(fin,line); res.push_back(line); } } void clear() { std::vector tmp; res.swap(tmp); } const string& operator[](usize n){return res[n];} const string& name(){return file;} usize size(){return res.size();} }; class nasal_err:public fstreamline { private: u32 error; void printstg(const char* stage) { #ifdef _WIN32 CONSOLE_SCREEN_BUFFER_INFO scrinfo; GetConsoleScreenBufferInfo(GetStdHandle(STD_ERROR_HANDLE),&scrinfo); SetConsoleTextAttribute(GetStdHandle(STD_ERROR_HANDLE),0x03); std::cerr<<"["; SetConsoleTextAttribute(GetStdHandle(STD_ERROR_HANDLE),0x0c); std::cerr<