Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::string operator , (const std::string& s1, const char* s2)
- {
- return s1 + s2;
- }
- std::string operator , (const char* s1, const std::string& s2)
- {
- return s1 + s2;
- }
- #define TO_STRING_I(n) #n
- #define TO_STRING(n) TO_STRING_I(n)
- #define FILEPOS __FILE__ "(" TO_STRING(__LINE__) "): "
- #define THROW_IF(cond, type, msg, ...) if (cond) throw type((FILEPOS + std::string(msg), __VA_ARGS__).c_str())
- struct fatal_error : public std::runtime_error
- {
- fatal_error(const char* errormsg)
- : std::runtime_error(errormsg)
- {}
- };
- inline std::vector<char> read_file(const char* filename)
- {
- std::ifstream file(filename, std::ios::binary);
- THROW_IF(!file, fatal_error, "Could not open file: ", filename);
- file.seekg(0, std::ios::end);
- std::vector<char> buf(static_cast<std::vector<char>::size_type>(file.tellg()));
- file.seekg(0, std::ios::beg);
- file.read(&buf[0], buf.size());
- THROW_IF(!file, fatal_error, "Could not read file: ", filename);
- return buf;
- }
Add Comment
Please, Sign In to add comment