AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
AttachmentWriter.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_AVS_INCLUDE_AVSCOMMON_AVS_ATTACHMENT_ATTACHMENTWRITER_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_ATTACHMENT_ATTACHMENTWRITER_H_
18 
19 #include <chrono>
20 #include <cstddef>
21 #include <ostream>
22 
23 namespace alexaClientSDK {
24 namespace avsCommon {
25 namespace avs {
26 namespace attachment {
27 
32 public:
36  enum class WriteStatus {
38  OK,
40  CLOSED,
49  TIMEDOUT
50  };
51 
55  virtual ~AttachmentWriter() = default;
56 
68  virtual std::size_t write(
69  const void* buf,
70  std::size_t numBytes,
71  WriteStatus* writeStatus,
72  std::chrono::milliseconds timeout = std::chrono::milliseconds(0)) = 0;
73 
78  virtual void close() = 0;
79 };
80 
88 inline std::ostream& operator<<(std::ostream& stream, const AttachmentWriter::WriteStatus& status) {
89  switch (status) {
91  stream << "OK";
92  break;
94  stream << "CLOSED";
95  break;
97  stream << "OK_BUFFER_FULL";
98  break;
100  stream << "ERROR_BYTES_LESS_THAN_WORD_SIZE";
101  break;
103  stream << "ERROR_INTERNAL";
104  break;
106  stream << "TIMEDOUT";
107  break;
108  }
109  return stream;
110 }
111 
112 } // namespace attachment
113 } // namespace avs
114 } // namespace avsCommon
115 } // namespace alexaClientSDK
116 
117 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_ATTACHMENT_ATTACHMENTWRITER_H_
The write could not succeed due to the underlying buffer being full.
The write timed out. This is only possible if the writer policy is BLOCKING.
The underlying data representation is no longer writeable.
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::ostream & operator<<(std::ostream &stream, const AttachmentReader::ReadStatus &status)
Definition: AttachmentReader.h:119
virtual std::size_t write(const void *buf, std::size_t numBytes, WriteStatus *writeStatus, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))=0

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