Current Version: 1.0.10
Project Name: csspp
error.h
Go to the documentation of this file.
1 #ifndef CSSPP_ERROR_H
2 #define CSSPP_ERROR_H
3 // CSS Preprocessor
4 // Copyright (C) 2015-2016 Made to Order Software Corp.
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #include "csspp/position.h"
21 
22 #include <istream>
23 #include <sstream>
24 
25 namespace csspp
26 {
27 
28 enum class error_mode_t
29 {
31  ERROR_DEC,
34  ERROR_HEX,
35  ERROR_INFO,
37 };
38 
39 typedef uint32_t error_count_t;
40 
41 class error
42 {
43 public:
44  error();
45 
46  static error & instance();
47  std::ostream & get_error_stream() const;
48  void set_error_stream(std::ostream & err_stream);
49 
50  void set_count_warnings_as_errors(bool warnings_as_errors);
51 
53  void set_error_count(error_count_t count);
55  void set_warning_count(error_count_t count);
56 
57  void set_hide_all(bool show_debug);
58  void set_show_debug(bool show_debug);
59 
60  void set_verbose(bool status);
61 
62  error & operator << (position const & pos);
64  error & operator << (std::string const & msg);
65  error & operator << (char const * msg);
66  error & operator << (int32_t value);
67  error & operator << (int64_t value);
68  error & operator << (double value);
69 
70 private:
71  void reset();
72 
74  std::stringstream f_message;
75  std::ostream * f_error = nullptr;
78  bool f_warnings_as_errors = false;
79  bool f_hide_all = false;
80  bool f_show_debug = false;
81  bool f_verbose = false;
82 };
83 
85 {
86 public:
87  safe_error_t();
88  ~safe_error_t();
89 
90 private:
93 };
94 
96 {
97 public:
98  safe_error_stream_t(std::ostream & err_stream);
100 
101 private:
102  std::ostream * f_error = nullptr;
103 };
104 
106 {
107 public:
109 
110  bool error_happened() const;
111  bool warning_happened() const;
112 
113 private:
116 };
117 
118 } // namespace csspp
119 
120 std::ostream & operator << (std::ostream & out, csspp::error_mode_t const type);
121 
122 #endif
123 // #ifndef CSSPP_LEXER_H
124 
125 // Local Variables:
126 // mode: cpp
127 // indent-tabs-mode: nil
128 // c-basic-offset: 4
129 // tab-width: 4
130 // End:
131 
132 // vim: ts=4 sw=4 et
std::ostream * f_error
Definition: error.h:75
void set_warning_count(error_count_t count)
Definition: error.cpp:121
bool warning_happened() const
Definition: error.cpp:290
std::ostream & get_error_stream() const
Definition: error.cpp:91
void set_error_count(error_count_t count)
Definition: error.cpp:111
uint32_t error_count_t
Definition: error.h:39
void set_hide_all(bool show_debug)
Definition: error.cpp:126
error_count_t f_warning_count
Definition: error.h:77
bool f_verbose
Definition: error.h:81
std::ostream & operator<<(std::ostream &out, csspp::error_mode_t const type)
Definition: error.cpp:297
error_mode_t
Definition: error.h:28
bool f_hide_all
Definition: error.h:79
void reset()
Definition: error.cpp:249
error_count_t f_error_count
Definition: error.h:91
bool f_show_debug
Definition: error.h:80
safe_error_stream_t(std::ostream &err_stream)
Definition: error.cpp:268
void set_show_debug(bool show_debug)
Definition: error.cpp:131
bool f_warnings_as_errors
Definition: error.h:78
error & operator<<(position const &pos)
Definition: error.cpp:141
error_count_t get_warning_count() const
Definition: error.cpp:116
error_count_t f_error_count
Definition: error.h:114
error_count_t f_error_count
Definition: error.h:76
void set_verbose(bool status)
Definition: error.cpp:136
error_count_t f_warning_count
Definition: error.h:115
void set_error_stream(std::ostream &err_stream)
Definition: error.cpp:96
std::stringstream f_message
Definition: error.h:74
error_count_t get_error_count() const
Definition: error.cpp:106
error_count_t f_warning_count
Definition: error.h:92
static error & instance()
Definition: error.cpp:78
std::ostream * f_error
Definition: error.h:102
bool error_happened() const
Definition: error.cpp:285
position f_position
Definition: error.h:73
void set_count_warnings_as_errors(bool warnings_as_errors)
Definition: error.cpp:101

Documentation of CSS Preprocessor.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.