AWS SDK for C++

AWS SDK for C++ Version 1.11.810

Loading...
Searching...
No Matches
AWSMap.h
1
6#pragma once
7
8#include <aws/core/Core_EXPORTS.h>
9
10#include <aws/core/utils/memory/stl/AWSAllocator.h>
11
12#include <map>
13#include <unordered_map>
14#include <cstring>
15#include <functional>
16
17namespace Aws
18{
19
20template< typename K, typename V > using Map = std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > >;
21template< typename K, typename V > using UnorderedMap = std::unordered_map< K, V, std::hash< K >, std::equal_to< K >, Aws::Allocator< std::pair< const K, V > > >;
22template< typename K, typename V > using MultiMap = std::multimap< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > >;
23
25{
26 bool operator()(const char* a, const char* b) const
27 {
28 return std::strcmp(a, b) < 0;
29 }
30};
31
32template<typename V> using CStringMap = std::map<const char*, V, CompareStrings, Aws::Allocator<std::pair<const char*, V> > >;
33
34template<typename Key, typename SourceValue, typename DestinationValue>
37 std::function<DestinationValue (const SourceValue&)> mappingFunc)
38{
39 for (const auto& srcPair: src)
40 {
41 dst.emplace(srcPair.first, mappingFunc(srcPair.second));
42 }
43}
44
45template<typename K, typename V>
46V GetWithDefault(const Aws::Map<K,V> &map, const K &key, V &&defaultValue) {
47 typename Aws::Map<K,V>::const_iterator it = map.find(key);
48 if ( it == map.end() ) {
49 return std::forward<V>(defaultValue);
50 }
51 return it->second;
52}
53
54} // namespace Aws
V GetWithDefault(const Aws::Map< K, V > &map, const K &key, V &&defaultValue)
Definition AWSMap.h:46
std::allocator< T > Allocator
std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > Map
Definition AWSMap.h:20
void TransformAndInsert(const Aws::UnorderedMap< Key, SourceValue > &src, Aws::Map< Key, DestinationValue > &dst, std::function< DestinationValue(const SourceValue &)> mappingFunc)
Definition AWSMap.h:35
std::map< const char *, V, CompareStrings, Aws::Allocator< std::pair< const char *, V > > > CStringMap
Definition AWSMap.h:32
std::multimap< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > MultiMap
Definition AWSMap.h:22
std::unordered_map< K, V, std::hash< K >, std::equal_to< K >, Aws::Allocator< std::pair< const K, V > > > UnorderedMap
Definition AWSMap.h:21
bool operator()(const char *a, const char *b) const
Definition AWSMap.h:26