Sha256: aa73eb3d1d2e1e74085d120c19fb8dad25d4a44fe6367cdf59097e423566af4f

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

/* Copyright (c) 2024 Julian Benda
 *
 * This file is part of inkCPP which is released under MIT license.
 * See file LICENSE.txt or go to
 * https://github.com/JBenda/inkcpp for full license details.
 */
#pragma once

#include "compilation_results.h"
#include <sstream>

namespace ink::compiler::internal
{
	class error_strbuf : public std::stringbuf
	{
	public:
		// start a new error message to be outputted to a given list
		void start(error_list* list);

		// If set, the next sync will throw an exception
		void throw_on_sync(bool);
	protected:
		virtual int sync() override;

	private:
		error_list* _list = nullptr;
		bool _throw = false;
	};

	class reporter
	{
	protected:
		reporter();
		virtual ~reporter() { }

		// sets the results pointer for this reporter
		void set_results(compilation_results*);

		// clears the results pointer
		void clear_results();

		// report warning
		std::ostream& warn();

		// report error
		std::ostream& err();
		
		// report critical error
		std::ostream& crit();
	private:
		compilation_results* _results;
		error_strbuf _buffer;
		std::ostream _stream;
	};
  } // namespace ink::compiler::internal

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
inkcpp_rb-0.1.3 ext/inkcpp_rb/inkcpp/inkcpp_compiler/reporter.h
inkcpp_rb-0.1.2 ext/inkcpp_rb/inkcpp/inkcpp_compiler/reporter.h
inkcpp_rb-0.1.1 ext/inkcpp_rb/inkcpp/inkcpp_compiler/reporter.h
inkcpp_rb-0.1.0 ext/inkcpp_rb/inkcpp/inkcpp_compiler/reporter.h