FastLED 3.10.8
Loading...
Searching...
No Matches
type_conversion_result.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/string.h"
4#include "fl/stl/vector.h"
5#include "fl/stl/stdint.h"
6#include "fl/stl/noexcept.h"
7
8namespace fl {
9
10// =============================================================================
11// TypeConversionResult - Warning/Error tracking for type conversions
12// =============================================================================
13
15public:
17
21
24 result.mWarnings.push_back(msg);
25 return result;
26 }
27
30 result.mHasError = true;
31 result.mErrorMessage = msg;
32 return result;
33 }
34
35 bool ok() const FL_NO_EXCEPT { return !mHasError; }
36 bool hasWarning() const FL_NO_EXCEPT { return !mWarnings.empty(); }
37 bool hasError() const FL_NO_EXCEPT { return mHasError; }
38
41
43 mWarnings.push_back(msg);
44 }
45
46 void setError(const fl::string& msg) FL_NO_EXCEPT {
47 mHasError = true;
48 mErrorMessage = msg;
49 }
50
51 // Merge another result into this one
53 for (fl::size i = 0; i < other.mWarnings.size(); i++) {
54 mWarnings.push_back(other.mWarnings[i]);
55 }
56 if (other.mHasError) {
57 mHasError = true;
58 mErrorMessage = other.mErrorMessage;
59 }
60 }
61
62private:
66};
67
68} // namespace fl
void setError(const fl::string &msg) FL_NO_EXCEPT
bool hasError() const FL_NO_EXCEPT
static TypeConversionResult error(const fl::string &msg) FL_NO_EXCEPT
void merge(const TypeConversionResult &other) FL_NO_EXCEPT
void addWarning(const fl::string &msg) FL_NO_EXCEPT
bool hasWarning() const FL_NO_EXCEPT
const fl::vector< fl::string > & warnings() const FL_NO_EXCEPT
const fl::string & errorMessage() const FL_NO_EXCEPT
fl::vector< fl::string > mWarnings
static TypeConversionResult warning(const fl::string &msg) FL_NO_EXCEPT
static TypeConversionResult success() FL_NO_EXCEPT
bool ok() const FL_NO_EXCEPT
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
Base definition for an LED controller.
Definition crgb.hpp:179