AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
ClearBehavior.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 ACSDKAUDIOPLAYER_CLEARBEHAVIOR_H_
17 #define ACSDKAUDIOPLAYER_CLEARBEHAVIOR_H_
18 
19 #include <ostream>
20 
23 
24 namespace alexaClientSDK {
25 namespace acsdkAudioPlayer {
26 
28 enum class ClearBehavior {
31 
33  CLEAR_ALL
34 };
35 
43  switch (clearBehavior) {
45  return "CLEAR_ENQUEUED";
47  return "CLEAR_ALL";
48  }
49  return "unknown ClearBehavior";
50 }
51 
59 inline bool stringToClearBehavior(const std::string& text, ClearBehavior* clearBehavior) {
60  if (nullptr == clearBehavior) {
61  return false;
63  *clearBehavior = ClearBehavior::CLEAR_ENQUEUED;
64  return true;
65  } else if (clearBehaviorToString(ClearBehavior::CLEAR_ALL) == text) {
66  *clearBehavior = ClearBehavior::CLEAR_ALL;
67  return true;
68  }
69  return false;
70 }
71 
79 inline std::ostream& operator<<(std::ostream& stream, const ClearBehavior& clearBehavior) {
80  return stream << clearBehaviorToString(clearBehavior);
81 }
82 
90 inline bool convertToValue(const rapidjson::Value& documentNode, ClearBehavior* clearBehavior) {
91  std::string text;
92  if (!avsCommon::utils::json::jsonUtils::convertToValue(documentNode, &text)) {
93  return false;
94  }
95  return stringToClearBehavior(text, clearBehavior);
96 }
97 
98 } // namespace acsdkAudioPlayer
99 } // namespace alexaClientSDK
100 
101 #endif // ACSDKAUDIOPLAYER_CLEARBEHAVIOR_H_
std::string clearBehaviorToString(ClearBehavior clearBehavior)
Definition: ClearBehavior.h:42
bool convertToValue(const rapidjson::Value &documentNode, ClearBehavior *clearBehavior)
Definition: ClearBehavior.h:90
::std::string string
Definition: gtest-port.h:1097
bool stringToClearBehavior(const std::string &text, ClearBehavior *clearBehavior)
Definition: ClearBehavior.h:59
std::ostream & operator<<(std::ostream &stream, const ClearBehavior &clearBehavior)
Definition: ClearBehavior.h:79
ClearBehavior
Used to determine clear queue behavior.
Definition: ClearBehavior.h:28
bool Value(const T &value, M matcher)
Definition: gmock-matchers.h:4347
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
bool convertToValue(const rapidjson::Value &documentNode, std::string *value)
Clears the queue and continues to play the currently playing stream.
Clears the entire playback queue and stops the currently playing stream (if applicable).

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