| Flutter Impeller |

validation.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_IMPELLER_BASE_VALIDATION_H_
6 #define FLUTTER_IMPELLER_BASE_VALIDATION_H_
7
8 #include <sstream>
9
10 namespace impeller {
11
12 class ValidationLog {
13 public:
14 ValidationLog();
15
16 ~ValidationLog();
17
18 std::ostream& GetStream();
19
20 private:
21 std::ostringstream stream_;
22
23 ValidationLog(const ValidationLog&) = delete;
24
25 ValidationLog(ValidationLog&&) = delete;
26
27 ValidationLog& operator=(const ValidationLog&) = delete;
28
29 ValidationLog& operator=(ValidationLog&&) = delete;
30 };
31
32 void ImpellerValidationBreak(const char* message);
33
34 void ImpellerValidationErrorsSetFatal(bool fatal);
35
36 bool ImpellerValidationErrorsAreFatal();
37
38 struct ScopedValidationDisable {
39 ScopedValidationDisable();
40
41 ~ScopedValidationDisable();
42
43 ScopedValidationDisable(const ScopedValidationDisable&) = delete;
44
45 ScopedValidationDisable& operator=(const ScopedValidationDisable&) = delete;
46 };
47
48 struct ScopedValidationFatal {
49 ScopedValidationFatal();
50
51 ~ScopedValidationFatal();
52
53 ScopedValidationFatal(const ScopedValidationFatal&) = delete;
54
55 ScopedValidationFatal& operator=(const ScopedValidationFatal&) = delete;
56 };
57
58 } // namespace impeller
59
60 //------------------------------------------------------------------------------
61 /// Get a stream to the log Impeller uses for all validation errors. The
62 /// behavior of these logs is as follows:
63 ///
64 /// * Validation error are completely ignored in the Flutter release
65 /// runtime-mode.
66 /// * In non-release runtime-modes, validation logs are redirected to the
67 /// Flutter `INFO` log. These logs typically show up when verbose logging is
68 /// enabled.
69 /// * If `ImpellerValidationErrorsSetFatal` is set to `true`, validation logs
70 /// are fatal. The runtime-mode restriction still applies. This usually
71 /// happens in test environments.
72 ///
73 #define VALIDATION_LOG ::impeller::ValidationLog{}.GetStream()
74
75 #endif // FLUTTER_IMPELLER_BASE_VALIDATION_H_
impeller::ImpellerValidationBreak
void ImpellerValidationBreak(const char *message)
Definition: validation.cc:48
impeller::ScopedValidationFatal::ScopedValidationFatal
ScopedValidationFatal()
Definition: validation.cc:28
impeller::ScopedValidationDisable::~ScopedValidationDisable
~ScopedValidationDisable()
Definition: validation.cc:24
impeller::ScopedValidationFatal::~ScopedValidationFatal
~ScopedValidationFatal()
Definition: validation.cc:32
impeller::ValidationLog::~ValidationLog
~ValidationLog()
Definition: validation.cc:38
impeller::ScopedValidationFatal::operator=
ScopedValidationFatal & operator=(const ScopedValidationFatal &)=delete
impeller::ValidationLog::ValidationLog
ValidationLog()
impeller::ScopedValidationDisable::ScopedValidationDisable
ScopedValidationDisable()
Definition: validation.cc:20
impeller::ValidationLog
Definition: validation.h:12
impeller::ImpellerValidationErrorsSetFatal
void ImpellerValidationErrorsSetFatal(bool fatal)
Definition: validation.cc:16
impeller::ImpellerValidationErrorsAreFatal
bool ImpellerValidationErrorsAreFatal()
Definition: validation.cc:63
impeller::ScopedValidationFatal
Definition: validation.h:48
impeller::ValidationLog::GetStream
std::ostream & GetStream()
Definition: validation.cc:44
impeller::ScopedValidationDisable::operator=
ScopedValidationDisable & operator=(const ScopedValidationDisable &)=delete
impeller::ScopedValidationDisable
Definition: validation.h:38
impeller
Definition: aiks_blur_unittests.cc:20