Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
status.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_FML_STATUS_H_
6#define FLUTTER_FML_STATUS_H_
7
8#include <string_view>
9
10namespace fml {
11
31
32/// Class that represents the resolution of the execution of a procedure. This
33/// is used similarly to how exceptions might be used, typically as the return
34/// value to a synchronous procedure or an argument to an asynchronous callback.
35class Status final {
36 public:
37 /// Creates an 'ok' status.
38 Status();
39
40 Status(fml::StatusCode code, std::string_view message);
41
42 fml::StatusCode code() const;
43
44 /// A noop that helps with static analysis tools if you decide to ignore an
45 /// error.
46 void IgnoreError() const;
47
48 /// @return 'true' when the code is kOk.
49 bool ok() const;
50
51 std::string_view message() const;
52
53 private:
54 fml::StatusCode code_;
55 std::string_view message_;
56};
57
58inline Status::Status() : code_(fml::StatusCode::kOk), message_() {}
59
60inline Status::Status(fml::StatusCode code, std::string_view message)
61 : code_(code), message_(message) {}
62
64 return code_;
65}
66
67inline void Status::IgnoreError() const {
68 // noop
69}
70
71inline bool Status::ok() const {
72 return code_ == fml::StatusCode::kOk;
73}
74
75inline std::string_view Status::message() const {
76 return message_;
77}
78
79} // namespace fml
80
81#endif // FLUTTER_FML_STATUS_H_
Status()
Creates an 'ok' status.
Definition status.h:58
bool ok() const
Definition status.h:71
fml::StatusCode code() const
Definition status.h:63
void IgnoreError() const
Definition status.h:67
std::string_view message() const
Definition status.h:75
Win32Message message
StatusCode
Definition status.h:12