AWS News Blog

Developer Preview of AWS SDK for C++ is Now Available

My colleague Jonathan Henson has great news for C++ developers who would like to use AWS.

Jeff;


I am happy to announce that the AWS SDK for C++ is now available as a developer preview. Last fall, we released the SDK in an experimental state to gather feedback and improve the APIs. Since then, we have received more than 100 issues and pull requests on GitHub. Many excited developers in the open source community gave valuable feedback that helped to improve the stability and expand the features of this SDK.

Changes and Additions
Here are some additions we’ve made since our experimental release:

  • Full service coverage parity with the rest of the SDKs.
  • Visual Studio 2015 support.
  • OS X El Capitan support.
  • Presigned URL support.
  • Expansion of and improvements to the Amazon S3 TransferClient.
  • Inline documentation improvements.
  • More integration for custom memory management.
  • Forward-compatible enumeration support.
  • Improvements to our CMake exports to simplify consumer builds.
  • Unicode support.
  • Several service client fixes and improvements.
  • Ability to build only the clients you need.
  • Custom signed regions and endpoints.
  • Common Crypto support for Apple platforms (OpenSSL is no longer required on iOS and OS X).
  • Several stability updates related to multi-threading in our Curl interface on Unix and Linux.
  • The Service Client Generator is now open sourced and integrated into the build process.

Also, NSURL support for Apple platforms will be committed within a week or so. After that, Curl will no longer be required on iOS or OS X.

The team would like to to thank those who have been involved in improving this SDK over the past six months. Please continue contributing and leaving feedback on our GitHub Issues page.

Before we move to General Availability, we would like to receive another round of feedback to help us pin down the API with a stable 1.0 release. If you are a C++ developer, please feel free to give this new SDK a try and let us know what you think.

In Other News
Here are a few other things that you may find interesting:

  • We have moved our GitHub repository from the awslabs organization to aws/aws-sdk-cpp.
  • We are now providing new releases for new services and features with the rest of the AWS SDKs.
  • We now have a C++ developer blog. We’ll post tutorials and samples there throughout the year. We’ll also announce improvements and features there, so stay tuned!
  • We will distribute pre-built binaries for our most popular platforms in the near future. We’ll let you know when they go live.

Sample Code
Here is some sample code that writes some data to a Kinesis stream and then consumes the data:

#include <aws/kinesis/model/PutRecordsRequest.h>
#include <aws/kinesis/KinesisClient.h>
#include <aws/core/utils/Outcome.h>

using namespace Aws::Utils;
using namespace Aws::Kinesis;
using namespace Aws::Kinesis::Model;

class KinesisProducer
{
public:
    KinesisProducer(const Aws::String& streamName, const Aws::String& partition) : m_partition(partition), m_streamName(streamName)
    {}

    void StreamData(const Aws::Vector& data)
    {
        PutRecordsRequest putRecordsRequest;
        putRecordsRequest.SetStreamName(m_streamName);

        for(auto& datum : data)
        {
            PutRecordsRequestEntry putRecordsRequestEntry;
            putRecordsRequestEntry.WithData(datum)
                    .WithPartitionKey(m_partition);

            putRecordsRequest.AddRecords(putRecordsRequestEntry);
        }

        m_client.PutRecordsAsync(putRecordsRequest,
               std::bind(&KinesisProducer::OnPutRecordsAsyncOutcomeReceived, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
    }

private:
    void OnPutRecordsAsyncOutcomeReceived(const KinesisClient*, const Model::PutRecordsRequest&,
                                          const Model::PutRecordsOutcome& outcome, const std::shared_ptr&)
    {
        if(outcome.IsSuccess())
        {
            std::cout << "Records Put Successfully " << std::endl;
        }
        else
        {
            std::cout << "Put Records Failed with error " << outcome.GetError().GetMessage() << std::endl;
        }
    }

    KinesisClient m_client;
    Aws::String m_partition;
    Aws::String m_streamName;
};

int main()
{
    KinesisProducer producer("kinesis-sample", "announcements");

    while(true)
    {
        Aws::String annoucement1("AWS SDK for C++");
        Aws::String annoucement2("Is Now in Developer Preview");

        producer.StreamData( {
                                     ByteBuffer((unsigned char*)annoucement1.c_str(), annoucement1.length()),
                                     ByteBuffer((unsigned char*)annoucement2.c_str(), annoucement2.length())
                             });

        std::this_thread::sleep_for(std::chrono::milliseconds(5));
    }

    return 0;
}

Jonathan Henson, Software Development Engineer (SDE)

Jeff Barr

Jeff Barr

Jeff Barr is Chief Evangelist for AWS. He started this blog in 2004 and has been writing posts just about non-stop ever since.