monotone

monotone Mtn Source Tree

Root/ui.hh

1#ifndef __UI_HH__
2#define __UI_HH__
3
4// copyright (C) 2002, 2003 graydon hoare <graydon@pobox.com>
5// all rights reserved.
6// licensed to the public under the terms of the GNU GPL (>= 2)
7// see the file COPYING for details
8
9// this file contains a couple utilities to deal with the user
10// interface. the global user_interface object 'ui' owns cerr, so
11// no writing to it directly!
12
13#include <map>
14#include <set>
15#include <string>
16#include <boost/format.hpp>
17
18struct user_interface;
19
20struct ticker
21{
22 size_t mod;
23 std::string name;
24 ticker(std::string const & n, size_t mod = 64);
25 void operator++();
26 void operator+=(size_t t);
27 ~ticker();
28};
29
30struct user_interface
31{
32public:
33 user_interface();
34 ~user_interface();
35 void warn(std::string const & warning);
36 void warn(boost::format const & fmt) { warn(fmt.str()); }
37 void inform(std::string const & line);
38 void inform(boost::format const & fmt) { inform(fmt.str()); }
39 void set_tick_trailer(std::string const & trailer);
40
41private:
42 bool last_write_was_a_tick;
43 size_t last_tick_len;
44 std::set<std::string> issued_warnings;
45 std::map<std::string,size_t> ticks;
46
47 void finish_ticking();
48 void write_ticks();
49 std::string tick_trailer;
50 friend struct ticker;
51};
52
53extern struct user_interface ui;
54
55
56#endif // __UI_HH__

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status