Current Version: 1.0.33
Project Name: csspp
error.h
Go to the documentation of this file.
1// Copyright (c) 2015-2025 Made to Order Software Corp. All Rights Reserved
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation; either version 2 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License along
14// with this program; if not, write to the Free Software Foundation, Inc.,
15// 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16#pragma once
17
18// self
19//
20#include "csspp/position.h"
21
22
23// C++
24//
25#include <istream>
26#include <sstream>
27
28
29namespace csspp
30{
31
42
43typedef uint32_t error_count_t;
44
45// the bare pointer is problematic with effective c++
46#pragma GCC diagnostic push
47#pragma GCC diagnostic ignored "-Weffc++"
48class error
49{
50public:
51 error();
52
53 static error & instance();
54 std::ostream & get_error_stream() const;
55 void set_error_stream(std::ostream & err_stream);
56
57 void set_count_warnings_as_errors(bool warnings_as_errors);
58
63
64 void set_hide_all(bool show_debug);
65 void set_show_debug(bool show_debug);
66
67 void set_verbose(bool status);
68
69 error & operator << (position const & pos);
71 error & operator << (std::string const & msg);
72 error & operator << (char const * msg);
73 error & operator << (int32_t value);
74 error & operator << (int64_t value);
75 error & operator << (double value);
76
77private:
78 void reset();
79
81 std::stringstream f_message = std::stringstream();
82 std::ostream * f_error = nullptr;
86 bool f_hide_all = false;
87 bool f_show_debug = false;
88 bool f_verbose = false;
89};
90#pragma GCC diagnostic pop
91
93{
94public:
97
98private:
101};
102
103
105{
106public:
107 safe_error_stream_t(std::ostream & err_stream);
110
112
113private:
114 std::ostream * f_error = nullptr;
115};
116
117
119{
120public:
122
123 bool error_happened() const;
124 bool warning_happened() const;
125
126private:
129};
130
131} // namespace csspp
132
133std::ostream & operator << (std::ostream & out, csspp::error_mode_t const type);
134
135// vim: ts=4 sw=4 et
bool error_happened() const
Definition error.cpp:286
bool warning_happened() const
Definition error.cpp:291
error_count_t f_error_count
Definition error.h:127
error_count_t f_warning_count
Definition error.h:128
bool f_warnings_as_errors
Definition error.h:85
std::ostream * f_error
Definition error.h:82
void set_warning_count(error_count_t count)
Definition error.cpp:120
void set_verbose(bool status)
Definition error.cpp:135
static error & instance()
Definition error.cpp:77
void reset()
Definition error.cpp:250
error_count_t f_warning_count
Definition error.h:84
bool f_verbose
Definition error.h:88
void set_show_debug(bool show_debug)
Definition error.cpp:130
void set_count_warnings_as_errors(bool warnings_as_errors)
Definition error.cpp:100
std::stringstream f_message
Definition error.h:81
void set_hide_all(bool show_debug)
Definition error.cpp:125
std::ostream & get_error_stream() const
Definition error.cpp:90
position f_position
Definition error.h:80
bool f_hide_all
Definition error.h:86
error_count_t get_warning_count() const
Definition error.cpp:115
void set_error_count(error_count_t count)
Definition error.cpp:110
bool f_show_debug
Definition error.h:87
error & operator<<(position const &pos)
Definition error.cpp:140
error_count_t get_error_count() const
Definition error.cpp:105
error_count_t f_error_count
Definition error.h:83
void set_error_stream(std::ostream &err_stream)
Definition error.cpp:95
safe_error_stream_t(safe_error_stream_t const &rhs)=delete
safe_error_stream_t & operator=(safe_error_stream_t const &rhs)=delete
std::ostream * f_error
Definition error.h:114
error_count_t f_warning_count
Definition error.h:100
error_count_t f_error_count
Definition error.h:99
std::ostream & operator<<(std::ostream &out, csspp::error_mode_t const type)
Definition error.cpp:298
The namespace of all the classes in the CSS Preprocessor.
Definition csspp.h:48
uint32_t error_count_t
Definition error.h:43
error_mode_t
Definition error.h:33

Documentation of CSS Preprocessor.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.