This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
pxz-hos-client-cpp-module/support/aws-sdk-cpp-master/aws-cpp-sdk-iotevents/source/model/Event.cpp

98 lines
1.9 KiB
C++

/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/iotevents/model/Event.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <utility>
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
namespace Aws
{
namespace IoTEvents
{
namespace Model
{
Event::Event() :
m_eventNameHasBeenSet(false),
m_conditionHasBeenSet(false),
m_actionsHasBeenSet(false)
{
}
Event::Event(JsonView jsonValue) :
m_eventNameHasBeenSet(false),
m_conditionHasBeenSet(false),
m_actionsHasBeenSet(false)
{
*this = jsonValue;
}
Event& Event::operator =(JsonView jsonValue)
{
if(jsonValue.ValueExists("eventName"))
{
m_eventName = jsonValue.GetString("eventName");
m_eventNameHasBeenSet = true;
}
if(jsonValue.ValueExists("condition"))
{
m_condition = jsonValue.GetString("condition");
m_conditionHasBeenSet = true;
}
if(jsonValue.ValueExists("actions"))
{
Array<JsonView> actionsJsonList = jsonValue.GetArray("actions");
for(unsigned actionsIndex = 0; actionsIndex < actionsJsonList.GetLength(); ++actionsIndex)
{
m_actions.push_back(actionsJsonList[actionsIndex].AsObject());
}
m_actionsHasBeenSet = true;
}
return *this;
}
JsonValue Event::Jsonize() const
{
JsonValue payload;
if(m_eventNameHasBeenSet)
{
payload.WithString("eventName", m_eventName);
}
if(m_conditionHasBeenSet)
{
payload.WithString("condition", m_condition);
}
if(m_actionsHasBeenSet)
{
Array<JsonValue> actionsJsonList(m_actions.size());
for(unsigned actionsIndex = 0; actionsIndex < actionsJsonList.GetLength(); ++actionsIndex)
{
actionsJsonList[actionsIndex].AsObject(m_actions[actionsIndex].Jsonize());
}
payload.WithArray("actions", std::move(actionsJsonList));
}
return payload;
}
} // namespace Model
} // namespace IoTEvents
} // namespace Aws