[829] | 1 | #pragma once
|
---|
| 2 |
|
---|
| 3 | class Messenger
|
---|
| 4 | {
|
---|
| 5 | public:
|
---|
| 6 | void Output( const std::string &message );
|
---|
| 7 | int GetNextErrorLine();
|
---|
| 8 | };
|
---|
| 9 |
|
---|
| 10 | class ErrorInfo
|
---|
| 11 | {
|
---|
| 12 | int errorCode;
|
---|
| 13 | std::string keyword;
|
---|
| 14 | std::string sourceFilePath;
|
---|
| 15 | int sourceLineNum;
|
---|
| 16 | int errorLineNum;
|
---|
| 17 |
|
---|
| 18 | public:
|
---|
| 19 | ErrorInfo( int errorCode, const std::string &keyword, const std::string &sourceFilePath, int sourceLineNum )
|
---|
| 20 | : errorCode( errorCode )
|
---|
| 21 | , keyword( keyword )
|
---|
| 22 | , sourceFilePath( sourceFilePath )
|
---|
| 23 | , sourceLineNum( sourceLineNum )
|
---|
| 24 | {
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | ErrorInfo( int errorCode, const std::string &keyword, int sourceIndex );
|
---|
| 28 |
|
---|
| 29 | ErrorInfo(ErrorInfo&& y)
|
---|
| 30 | : errorCode(std::move(y.errorCode))
|
---|
| 31 | , keyword(std::move(y.keyword))
|
---|
| 32 | , sourceFilePath(std::move(y.sourceFilePath))
|
---|
| 33 | , sourceLineNum(std::move(y.sourceLineNum))
|
---|
| 34 | , errorLineNum(std::move(y.errorLineNum))
|
---|
| 35 | {
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | ErrorInfo(ErrorInfo const& y)
|
---|
| 39 | : errorCode(y.errorCode)
|
---|
| 40 | , keyword(y.keyword)
|
---|
| 41 | , sourceFilePath(y.sourceFilePath)
|
---|
| 42 | , sourceLineNum(y.sourceLineNum)
|
---|
| 43 | , errorLineNum(y.errorLineNum)
|
---|
| 44 | {
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | ErrorInfo& operator =(ErrorInfo&& y)
|
---|
| 48 | {
|
---|
| 49 | errorCode = std::move(y.errorCode);
|
---|
| 50 | keyword = std::move(y.keyword);
|
---|
| 51 | sourceFilePath = std::move(y.sourceFilePath);
|
---|
| 52 | sourceLineNum = std::move(y.sourceLineNum);
|
---|
| 53 | errorLineNum = std::move(y.errorLineNum);
|
---|
| 54 | return *this;
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | ErrorInfo& operator =(ErrorInfo const& y)
|
---|
| 58 | {
|
---|
| 59 | return *this = std::move(ErrorInfo(y));
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | int GetErrorCode() const
|
---|
| 63 | {
|
---|
| 64 | return errorCode;
|
---|
| 65 | }
|
---|
| 66 | bool IsWarning() const
|
---|
| 67 | {
|
---|
| 68 | return ( errorCode < -100 );
|
---|
| 69 | }
|
---|
| 70 | const std::string &GetKeyword() const
|
---|
| 71 | {
|
---|
| 72 | return keyword;
|
---|
| 73 | }
|
---|
| 74 | const std::string &GetSourceFilePath() const
|
---|
| 75 | {
|
---|
| 76 | return sourceFilePath;
|
---|
| 77 | }
|
---|
| 78 | int GetSourceLineNum() const
|
---|
| 79 | {
|
---|
| 80 | return sourceLineNum;
|
---|
| 81 | }
|
---|
| 82 | int GetErrorLineNum() const
|
---|
| 83 | {
|
---|
| 84 | return errorLineNum;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | std::string GetMessageString() const;
|
---|
| 88 | std::string GetFullMessageString() const;
|
---|
| 89 | };
|
---|
| 90 | typedef std::vector<ErrorInfo> ErrorInfos;
|
---|
| 91 |
|
---|
| 92 | class ErrorMessenger
|
---|
| 93 | : public Messenger
|
---|
| 94 | {
|
---|
| 95 | ErrorInfos errorInfos;
|
---|
| 96 | Jenga::Common::Strings synonymKeyWords;
|
---|
| 97 |
|
---|
| 98 | public:
|
---|
| 99 | ErrorMessenger() {}
|
---|
| 100 |
|
---|
| 101 | void Output( const ErrorInfo &errorInfo );
|
---|
| 102 | void Output( int errorCode, const std::string &keyword, int sourceIndex = -1 );
|
---|
| 103 | void Output( int errorCode, const char *keyword, int sourceIndex = -1 );
|
---|
| 104 | void OutputFatalError();
|
---|
| 105 |
|
---|
| 106 | void ClearSynonymKeyWords();
|
---|
| 107 |
|
---|
| 108 | int GetErrorCount() const;
|
---|
| 109 | bool HasError() const;
|
---|
| 110 | int GetWarningCount() const;
|
---|
| 111 |
|
---|
| 112 | void ShowErrorLine( int errorLineNum );
|
---|
| 113 |
|
---|
| 114 | private:
|
---|
| 115 | ErrorMessenger(ErrorMessenger const&);
|
---|
| 116 | ErrorMessenger& operator =(ErrorMessenger const&);
|
---|
| 117 | };
|
---|