IDL compiler front-end library
MessageOut.h
Go to the documentation of this file.
1 /*
3 * Nirvana IDL front-end library.
4 *
5 * This is a part of the Nirvana project.
6 *
7 * Author: Igor Popov
8 *
9 * Copyright (c) 2021 Igor Popov.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
23 *
24 * Send comments and/or bug reports to:
25 * popov.nirvana@gmail.com
26 */
27 #ifndef IDLFE_BE_MESSAGEOUT_H_
28 #define IDLFE_BE_MESSAGEOUT_H_
29 #pragma once
30 
31 #include <string>
32 #include <iostream>
33 
34 namespace AST {
35 class Location;
36 }
37 
38 namespace BE {
39 
42 {
43 public:
50  MessageOut (std::ostream& out = std::cerr, unsigned max_err_cnt = 20);
51 
53  enum class MessageType
54  {
55  ERROR,
56  WARNING,
57  MESSAGE
58  };
59 
65  void message (const AST::Location& l, MessageType mt, const std::string& msg);
66 
70  void message (const std::exception& ex);
71 
73  unsigned error_count () const noexcept
74  {
75  return err_cnt_;
76  }
77 
78 private:
79  std::ostream out_;
80  const unsigned max_err_cnt_;
81  unsigned err_cnt_;
82 };
83 
84 }
85 
86 #endif
Stores the location information.
Definition: Location.h:43
Compiler messages output.
Definition: MessageOut.h:42
void message(const std::exception &ex)
void message(const AST::Location &l, MessageType mt, const std::string &msg)
MessageOut(std::ostream &out=std::cerr, unsigned max_err_cnt=20)
MessageType
Message types.
Definition: MessageOut.h:54
@ WARNING
Warning message.
@ MESSAGE
Informational message.
unsigned error_count() const noexcept
Definition: MessageOut.h:73
Abstract Syntax Tree namespace.
Definition: Array.h:34
Back-end support utility classes.
Definition: IndentedOut.h:36