![]() |
AlexaClientSDK
3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
|
#include <Writer.h>
Classes | |
struct | Error |
Public Types | |
using | Policy = WriterPolicy |
Specifies the policy to use for writing to the stream. More... | |
Public Member Functions | |
Writer (Policy policy, std::shared_ptr< BufferLayout > bufferLayout) | |
~Writer () | |
This destructor detaches the Writer from a BufferLayout . More... | |
ssize_t | write (const void *buf, size_t nWords, std::chrono::milliseconds timeout=std::chrono::milliseconds(0)) |
Index | tell () const |
void | close () |
size_t | getWordSize () const |
Static Public Member Functions | |
static std::string | errorToString (Error error) |
This is a nested class in SharedDataStream
which provides an interface for writing (producing) data to the stream.
Writer
as a whole is thread-safe in the sense that Writer
and Readers
can all live in different threads, but individual member functions of a Writer
instance should not be called from multiple threads except where specifically noted in function documentation below. using alexaClientSDK::avsCommon::utils::sds::SharedDataStream::Writer< T >::Policy = WriterPolicy |
Specifies the policy to use for writing to the stream.
alexaClientSDK::avsCommon::utils::sds::SharedDataStream::Writer< T >::Writer | ( | Policy | policy, |
std::shared_ptr< BufferLayout > | bufferLayout | ||
) |
Constructs a new Writer
which produces data for the provided SharedDataStream
.
policy | The policy to use for reading from the stream. |
stream | The BufferLayout to use for writing stream data. |
alexaClientSDK::avsCommon::utils::sds::SharedDataStream::Writer< T >::~Writer | ( | ) |
This destructor detaches the Writer
from a BufferLayout
.
void alexaClientSDK::avsCommon::utils::sds::SharedDataStream::Writer< T >::close | ( | ) |
|
static |
Returns the text of an error code.
size_t alexaClientSDK::avsCommon::utils::sds::SharedDataStream::Writer< T >::getWordSize | ( | ) | const |
This function returns the word size (in bytes). All SharedDataStream
operations that work with data or position in the stream are quantified in words.
Writer's
SharedDataStream
. SharedDataStream< T >::Index alexaClientSDK::avsCommon::utils::sds::SharedDataStream::Writer< T >::tell | ( | ) | const |
ssize_t alexaClientSDK::avsCommon::utils::sds::SharedDataStream::Writer< T >::write | ( | const void * | buf, |
size_t | nWords, | ||
std::chrono::milliseconds | timeout = std::chrono::milliseconds(0) |
||
) |
This function adds new data to the stream by copying it from the provided buffer.
buf | A buffer to copy the data from. |
nWords | The maximum number of wordSize words to copy. |
timeout | The maximum time to wait (if policy is BLOCKING ) for space to write into. If this parameter is zero, there is no timeout and blocking writes will wait forever. If policy is not BLOCKING, this parameter is ignored. |
wordSize
words copied, or zero if the stream has closed, or a negative Error
code if the stream is still open, but no data could be written.Writer
if Writer::close()
has been called.policy
is BLOCKING
and timeout
is 0, this function will only unblock when a Reader
read()s
some data or seek()s
forward. Applications which use this combination of parameters must use Readers
to drain some data from the SharedDataStream
if they need to unblock the Writer
. AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0