AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
SuccessResult.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_ERROR_SUCCESSRESULT_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_ERROR_SUCCESSRESULT_H_
18 
19 #include "Result.h"
20 
21 namespace alexaClientSDK {
22 namespace avsCommon {
23 namespace utils {
24 namespace error {
25 
31 template <typename TValue>
32 class SuccessResult : public utils::error::Result<bool, TValue> {
33 public:
40  inline static SuccessResult<TValue> success(TValue value);
41 
47  inline static SuccessResult<TValue> failure();
48 
55  inline SuccessResult(bool succeeded, TValue value);
56 
62  inline bool isSucceeded();
63 
64 protected:
70  explicit inline SuccessResult(bool succeeded);
71 };
72 
73 template <typename TValue>
74 SuccessResult<TValue>::SuccessResult(bool succeeded) : Result<bool, TValue>(succeeded) {
75 }
76 
77 template <typename TValue>
78 SuccessResult<TValue>::SuccessResult(bool succeeded, TValue value) : Result<bool, TValue>(succeeded, value) {
79 }
80 
81 template <typename TValue>
84 }
85 
86 template <typename TValue>
88  return SuccessResult(false);
89 }
90 
91 template <typename TValue>
93  return SuccessResult<TValue>(true, value);
94 }
95 
96 } // namespace error
97 } // namespace utils
98 } // namespace avsCommon
99 } // namespace alexaClientSDK
100 
101 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_ERROR_SUCCESSRESULT_H_
bool isSucceeded()
Definition: SuccessResult.h:82
static SuccessResult< TValue > failure()
Definition: SuccessResult.h:87
TStatus status()
Definition: Result.h:84
static SuccessResult< TValue > success(TValue value)
Definition: SuccessResult.h:92
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
SuccessResult(bool succeeded, TValue value)
Definition: SuccessResult.h:78

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0