2013-08-20 19:19:28 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
|
|
|
#pragma once
|
2013-09-13 03:04:10 +00:00
|
|
|
#include "util/output_channel.h"
|
|
|
|
#include "util/sexpr/options.h"
|
2013-10-01 01:16:13 +00:00
|
|
|
#include "kernel/formatter.h"
|
2013-08-20 19:19:28 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
/**
|
|
|
|
\brief State provided to internal lean procedures that need to:
|
|
|
|
1- Access user defined options
|
|
|
|
2- Produce verbosity messages
|
|
|
|
3- Output results
|
|
|
|
4- Produce formatted output
|
|
|
|
*/
|
2013-11-21 23:51:29 +00:00
|
|
|
class io_state {
|
2013-08-20 19:19:28 +00:00
|
|
|
options m_options;
|
|
|
|
formatter m_formatter;
|
|
|
|
std::shared_ptr<output_channel> m_regular_channel;
|
|
|
|
std::shared_ptr<output_channel> m_diagnostic_channel;
|
|
|
|
public:
|
2014-01-02 21:37:50 +00:00
|
|
|
io_state(formatter const & fmt);
|
2013-11-21 23:51:29 +00:00
|
|
|
io_state(options const & opts, formatter const & fmt);
|
|
|
|
~io_state();
|
2013-08-20 19:19:28 +00:00
|
|
|
|
|
|
|
options get_options() const { return m_options; }
|
|
|
|
formatter get_formatter() const { return m_formatter; }
|
|
|
|
output_channel & get_regular_channel() const { return *m_regular_channel; }
|
|
|
|
output_channel & get_diagnostic_channel() const { return *m_diagnostic_channel; }
|
|
|
|
|
|
|
|
void set_regular_channel(std::shared_ptr<output_channel> const & out);
|
|
|
|
void set_diagnostic_channel(std::shared_ptr<output_channel> const & out);
|
|
|
|
void set_options(options const & opts);
|
|
|
|
void set_formatter(formatter const & f);
|
2013-08-20 20:55:31 +00:00
|
|
|
template<typename T> void set_option(name const & n, T const & v) {
|
|
|
|
set_options(get_options().update(n, v));
|
|
|
|
}
|
2013-08-20 19:19:28 +00:00
|
|
|
};
|
|
|
|
}
|