source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/include/Messenger.h@ 829

Last change on this file since 829 was 829, checked in by イグトランス (egtra), 12 years ago

svn:eol-styleとsvn:mime-type(文字コード指定含む)の設定

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/plain; charset=Shift_JIS
File size: 2.4 KB
Line 
1#pragma once
2
3class Messenger
4{
5public:
6 void Output( const std::string &message );
7 int GetNextErrorLine();
8};
9
10class ErrorInfo
11{
12 int errorCode;
13 std::string keyword;
14 std::string sourceFilePath;
15 int sourceLineNum;
16 int errorLineNum;
17
18public:
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};
90typedef std::vector<ErrorInfo> ErrorInfos;
91
92class ErrorMessenger
93 : public Messenger
94{
95 ErrorInfos errorInfos;
96 Jenga::Common::Strings synonymKeyWords;
97
98public:
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
114private:
115 ErrorMessenger(ErrorMessenger const&);
116 ErrorMessenger& operator =(ErrorMessenger const&);
117};
Note: See TracBrowser for help on using the repository browser.