📄 qerr.h
字号:
// ------------------------------------------------------------------// qerr.h//// This file contains the definition of the class QMG:Error, which is// used for throwing exceptions. Also QMG::Error_Message and QMG::Error_Task// Matlab version// ------------------------------------------------------------------// Author: Stephen A. Vavasis// Copyright (c) 1999 by Cornell University. All rights reserved.// // See the accompanying file 'Copyright' for authorship information,// the terms of the license governing this software, and disclaimers// concerning this software.// ------------------------------------------------------------------// This file is part of the QMG software. // Version 2.0 of QMG, release date September 3, 1999.// ------------------------------------------------------------------#ifndef QERR_H#define QERR_H#include "qnamesp.h"// ------------------------------------------------------------------// Class QMG::Error_Message// This class sets up an error message object. The object holds// a message that will get printed if throw_error is called.// Usage:// Error_Message errmsg;// errmsg("hello");// Then later, if "throw_error" called, the error handler will print// 'hello' (until errmsg is destroyed). class QMG::Error_Message {private: string s_; Error_Message* next_; static Error_Message* base_;public: Error_Message(); ~Error_Message(); void set_string(const string& s1) { s_ = s1;} static void init_error_message_list(); static void put_error_messages_into_stream(ostream& os);};// ------------------------------------------------------------------// Class QMG::Error_Task// This class is holds a task to be executed if there is an error.// This class is an abstract base class.class QMG::Error_Task {private: Error_Task* next_; static Error_Task* base_; virtual void on_error_do(const string&) { };public: Error_Task(); virtual ~Error_Task(); static void init_error_task_list(); friend void QMG::throw_error(const string& s);};// ------------------------------------------------------------------// Class QMG::Error// This class is thrown by exceptions if exceptions enabled.namespace QMG { const int ERROR_BUF_LEN = 2000;}class QMG::Error {private: char concatenated_error_messages_[ERROR_BUF_LEN]; // Only throw_error can create this explicit Error(const string& msg);public: Error(const Error& e); ~Error(); const char* get_error_messages() { return concatenated_error_messages_; }; friend void QMG::throw_error(const string& s);};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -