| 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 #ifndef IMPELLER_ENABLE_VALIDATION
9 #ifdef IMPELLER_DEBUG
10 #define IMPELLER_ENABLE_VALIDATION 1
11 #endif
12 #endif
13
14 #include <sstream>
15
16 namespace impeller {
17
18 class ValidationLog {
19 public:
20 ValidationLog();
21
22 ~ValidationLog();
23
24 std::ostream& GetStream();
25
26 private:
27 std::ostringstream stream_;
28
29 ValidationLog(const ValidationLog&) = delete;
30
31 ValidationLog(ValidationLog&&) = delete;
32
33 ValidationLog& operator=(const ValidationLog&) = delete;
34
35 ValidationLog& operator=(ValidationLog&&) = delete;
36 };
37
38 void ImpellerValidationBreak(const char* message);
39
40 void ImpellerValidationErrorsSetFatal(bool fatal);
41
42 struct ScopedValidationDisable {
43 ScopedValidationDisable();
44
45 ~ScopedValidationDisable();
46
47 ScopedValidationDisable(const ScopedValidationDisable&) = delete;
48
49 ScopedValidationDisable& operator=(const ScopedValidationDisable&) = delete;
50 };
51
52 } // namespace impeller
53
54 //------------------------------------------------------------------------------
55 /// Get a stream to the log Impeller uses for all validation errors. The
56 /// behavior of these logs is as follows:
57 ///
58 /// * Validation error are completely ignored in the Flutter release
59 /// runtime-mode.
60 /// * In non-release runtime-modes, validation logs are redirected to the
61 /// Flutter `INFO` log. These logs typically show up when verbose logging is
62 /// enabled.
63 /// * If `ImpellerValidationErrorsSetFatal` is set to `true`, validation logs
64 /// are fatal. The runtime-mode restriction still applies. This usually
65 /// happens in test environments.
66 ///
67 #define VALIDATION_LOG ::impeller::ValidationLog{}.GetStream()
68
69 #endif // FLUTTER_IMPELLER_BASE_VALIDATION_H_
impeller::ImpellerValidationBreak
void ImpellerValidationBreak(const char *message)
Definition: validation.cc:40
impeller::ScopedValidationDisable::~ScopedValidationDisable
~ScopedValidationDisable()
Definition: validation.cc:24
impeller::ValidationLog::~ValidationLog
~ValidationLog()
Definition: validation.cc:30
impeller::ValidationLog::ValidationLog
ValidationLog()
impeller::ScopedValidationDisable::ScopedValidationDisable
ScopedValidationDisable()
Definition: validation.cc:20
impeller::ValidationLog
Definition: validation.h:18
impeller::ImpellerValidationErrorsSetFatal
void ImpellerValidationErrorsSetFatal(bool fatal)
Definition: validation.cc:16
impeller::ValidationLog::GetStream
std::ostream & GetStream()
Definition: validation.cc:36
impeller::ScopedValidationDisable::operator=
ScopedValidationDisable & operator=(const ScopedValidationDisable &)=delete
impeller::ScopedValidationDisable
Definition: validation.h:42
impeller
Definition: aiks_context.cc:10