AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Namespaces | Typedefs | Functions
alexaClientSDK::codecUtils Namespace Reference

Binary codec utilities. More...

Namespaces

 test
 Test cases for CodecUtils.
 

Typedefs

typedef unsigned char Byte
 Byte data type. More...
 
typedef std::vector< ByteBytes
 Byte data block. More...
 

Functions

bool encodeBase64 (const Bytes &binary, std::string &base64String) noexcept
 Encodes binary data into string using Base64. More...
 
bool decodeBase64 (const std::string &base64String, Bytes &binary) noexcept
 Decodes binary data from string using Base64. More...
 
bool encodeHex (const Bytes &binary, std::string &hexString) noexcept
 
bool decodeHex (const std::string &hexString, Bytes &binary) noexcept
 Decodes binary data from string using hex. More...
 

Detailed Description

Binary codec utilities.

See also
CodecUtils

Typedef Documentation

◆ Byte

typedef unsigned char alexaClientSDK::codecUtils::Byte

Byte data type.

◆ Bytes

Byte data block.

Function Documentation

◆ decodeBase64()

bool alexaClientSDK::codecUtils::decodeBase64 ( const std::string &  base64String,
Bytes binary 
)
noexcept

Decodes binary data from string using Base64.

This method decodes binary data from string using Base64. Whitespace, newline, and carriage return characters are ignored.

The method converts 4 input characters (excluding ignorable whitespace) into 3 output bytes. If the method encounters unsupported character (other than A-Z,a-z,0-9,"+", "/", "=" at the end, or ignorable whitespace), the operation fails.

Parameters
[in]base64StringData to decode in base64 form.
[in,out]binaryDecoded data. The method appends data to the container.
Returns
True, if operation succeeds. If operation fails, the contents of binary is unmodified.
See also
encodeBase64()

◆ decodeHex()

bool alexaClientSDK::codecUtils::decodeHex ( const std::string &  hexString,
Bytes binary 
)
noexcept

Decodes binary data from string using hex.

Method decodes input from hexadecimal string. Whitespace, newline, and carriage return characters are ignored.

The method converts every 2 input characters (excluding ignorable whitespace) into single output byte. If the method encounters unsupported character (other than A-F,a-f,0-9, or ignorable whitespace), the operation fails.

Parameters
[in]hexStringData to decode in hex form.
[in,out]binaryContainer to store decoded data. The decoded contents is appended to container.
Returns
True, if operation succeeds. If operation fails, the contents of binary is unmodified.
See also
encodeHex()

◆ encodeBase64()

bool alexaClientSDK::codecUtils::encodeBase64 ( const Bytes binary,
std::string &  base64String 
)
noexcept

Encodes binary data into string using Base64.

This method encodes binary data into printable form using Base64 encoding. The output uses characters A-Z,a-z,0-9, "+", "/". Every three bytes of data are converted into four bytes of output. If the input is not a multiple of 3 bytes, the output will be padded with "=" characters (one or two).

Parameters
[in]binaryBinary data to encode.
[in,out]base64StringDestination container. The method appends data to the container.
Returns
True, if operation succeeds. If operation fails, the contents of base64String is unmodified.
See also
decodeBase64()

◆ encodeHex()

bool alexaClientSDK::codecUtils::encodeHex ( const Bytes binary,
std::string &  hexString 
)
noexcept

Encode binary data into string using hex encoding.

Method encodes binary data into hexadecimal printable form. Every input byte is represented by two output bytes. The method uses number characters 0-9 and lowercase letters a-f to represent hexadecimal values.

Method appends data to destination container.

Parameters
[in]binaryBinary data to encode.
[in,out]hexStringContainer to store encoded data. The data is appended to container.
Returns
True, if operation succeeds. If operation fails, the contents of hexString is unmodified.
See also
decodeHex()

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