AWS SDK for C++

AWS SDK for C++ Version 1.11.853

Loading...
Searching...
No Matches
TraitMap.h
1#pragma once
2
3#include <aws/core/utils/memory/stl/AWSVector.h>
4#include <smithy/Smithy_EXPORTS.h>
5#include <smithy/client/schema/Trait.h>
6#include <smithy/client/schema/TraitKey.h>
7
8#include <memory>
9
10namespace smithy {
11namespace schema {
12class SMITHY_API TraitMap {
13 public:
14 TraitMap() = default;
15
16 template <typename T>
17 std::shared_ptr<const T> Get(const TraitKey<T>& key) const {
18 int idx = key.GetId();
19 if (idx >= static_cast<int>(m_values.size())) return nullptr;
20 return std::static_pointer_cast<const T>(m_values[idx]);
21 }
22
23 bool Has(const TraitKeyBase& key) const {
24 int idx = key.GetId();
25 if (idx >= static_cast<int>(m_values.size())) return false;
26 return m_values[idx] != nullptr;
27 }
28
29 void Set(const TraitKeyBase& key, std::shared_ptr<const Trait> trait) {
30 int idx = key.GetId();
31 if (idx >= static_cast<int>(m_values.size())) {
32 m_values.resize(idx + 1);
33 }
34 m_values[idx] = std::move(trait);
35 }
36
37 private:
39};
40} // namespace schema
41} // namespace smithy
std::shared_ptr< const T > Get(const TraitKey< T > &key) const
Definition TraitMap.h:17
bool Has(const TraitKeyBase &key) const
Definition TraitMap.h:23
void Set(const TraitKeyBase &key, std::shared_ptr< const Trait > trait)
Definition TraitMap.h:29
std::vector< T, Aws::Allocator< T > > Vector
Definition AWSVector.h:17