Skip to content

Commit 7342500

Browse files
committed
fix header argument for list arguemnts
1 parent 375778b commit 7342500

File tree

14 files changed

+89
-55
lines changed

14 files changed

+89
-55
lines changed

generated/src/aws-cpp-sdk-s3-crt/source/model/GetObjectAttributesRequest.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <aws/core/utils/memory/stl/AWSStringStream.h>
1111

1212
#include <utility>
13+
#include <numeric>
1314

1415
using namespace Aws::S3Crt::Model;
1516
using namespace Aws::Utils::Xml;
@@ -122,12 +123,13 @@ Aws::Http::HeaderValueCollection GetObjectAttributesRequest::GetRequestSpecificH
122123

123124
if(m_objectAttributesHasBeenSet)
124125
{
125-
for(const auto& item : m_objectAttributes)
126-
{
127-
ss << ObjectAttributesMapper::GetNameForObjectAttributes(item);
128-
headers.emplace("x-amz-object-attributes", ss.str());
129-
ss.str("");
130-
}
126+
headers.emplace("x-amz-object-attributes", std::accumulate(std::begin(m_objectAttributes),
127+
std::end(m_objectAttributes),
128+
Aws::String{},
129+
[](const Aws::String &acc, const ObjectAttributes &item) -> Aws::String {
130+
const auto headerValue = ObjectAttributesMapper::GetNameForObjectAttributes(item);
131+
return acc.empty() ? headerValue : acc + "," + headerValue;
132+
}));
131133
}
132134

133135
return headers;

generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectVersionsRequest.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <aws/core/utils/memory/stl/AWSStringStream.h>
1111

1212
#include <utility>
13+
#include <numeric>
1314

1415
using namespace Aws::S3Crt::Model;
1516
using namespace Aws::Utils::Xml;
@@ -121,12 +122,13 @@ Aws::Http::HeaderValueCollection ListObjectVersionsRequest::GetRequestSpecificHe
121122

122123
if(m_optionalObjectAttributesHasBeenSet)
123124
{
124-
for(const auto& item : m_optionalObjectAttributes)
125-
{
126-
ss << OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item);
127-
headers.emplace("x-amz-optional-object-attributes", ss.str());
128-
ss.str("");
129-
}
125+
headers.emplace("x-amz-optional-object-attributes", std::accumulate(std::begin(m_optionalObjectAttributes),
126+
std::end(m_optionalObjectAttributes),
127+
Aws::String{},
128+
[](const Aws::String &acc, const OptionalObjectAttributes &item) -> Aws::String {
129+
const auto headerValue = OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item);
130+
return acc.empty() ? headerValue : acc + "," + headerValue;
131+
}));
130132
}
131133

132134
return headers;

generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectsRequest.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <aws/core/utils/memory/stl/AWSStringStream.h>
1111

1212
#include <utility>
13+
#include <numeric>
1314

1415
using namespace Aws::S3Crt::Model;
1516
using namespace Aws::Utils::Xml;
@@ -113,12 +114,13 @@ Aws::Http::HeaderValueCollection ListObjectsRequest::GetRequestSpecificHeaders()
113114

114115
if(m_optionalObjectAttributesHasBeenSet)
115116
{
116-
for(const auto& item : m_optionalObjectAttributes)
117-
{
118-
ss << OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item);
119-
headers.emplace("x-amz-optional-object-attributes", ss.str());
120-
ss.str("");
121-
}
117+
headers.emplace("x-amz-optional-object-attributes", std::accumulate(std::begin(m_optionalObjectAttributes),
118+
std::end(m_optionalObjectAttributes),
119+
Aws::String{},
120+
[](const Aws::String &acc, const OptionalObjectAttributes &item) -> Aws::String {
121+
const auto headerValue = OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item);
122+
return acc.empty() ? headerValue : acc + "," + headerValue;
123+
}));
122124
}
123125

124126
return headers;

generated/src/aws-cpp-sdk-s3-crt/source/model/ListObjectsV2Request.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <aws/core/utils/memory/stl/AWSStringStream.h>
1111

1212
#include <utility>
13+
#include <numeric>
1314

1415
using namespace Aws::S3Crt::Model;
1516
using namespace Aws::Utils::Xml;
@@ -130,12 +131,13 @@ Aws::Http::HeaderValueCollection ListObjectsV2Request::GetRequestSpecificHeaders
130131

131132
if(m_optionalObjectAttributesHasBeenSet)
132133
{
133-
for(const auto& item : m_optionalObjectAttributes)
134-
{
135-
ss << OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item);
136-
headers.emplace("x-amz-optional-object-attributes", ss.str());
137-
ss.str("");
138-
}
134+
headers.emplace("x-amz-optional-object-attributes", std::accumulate(std::begin(m_optionalObjectAttributes),
135+
std::end(m_optionalObjectAttributes),
136+
Aws::String{},
137+
[](const Aws::String &acc, const OptionalObjectAttributes &item) -> Aws::String {
138+
const auto headerValue = OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item);
139+
return acc.empty() ? headerValue : acc + "," + headerValue;
140+
}));
139141
}
140142

141143
return headers;

generated/src/aws-cpp-sdk-s3/source/model/GetObjectAttributesRequest.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <aws/core/utils/memory/stl/AWSStringStream.h>
1111

1212
#include <utility>
13+
#include <numeric>
1314

1415
using namespace Aws::S3::Model;
1516
using namespace Aws::Utils::Xml;
@@ -122,12 +123,13 @@ Aws::Http::HeaderValueCollection GetObjectAttributesRequest::GetRequestSpecificH
122123

123124
if(m_objectAttributesHasBeenSet)
124125
{
125-
for(const auto& item : m_objectAttributes)
126-
{
127-
ss << ObjectAttributesMapper::GetNameForObjectAttributes(item);
128-
headers.emplace("x-amz-object-attributes", ss.str());
129-
ss.str("");
130-
}
126+
headers.emplace("x-amz-object-attributes", std::accumulate(std::begin(m_objectAttributes),
127+
std::end(m_objectAttributes),
128+
Aws::String{},
129+
[](const Aws::String &acc, const ObjectAttributes &item) -> Aws::String {
130+
const auto headerValue = ObjectAttributesMapper::GetNameForObjectAttributes(item);
131+
return acc.empty() ? headerValue : acc + "," + headerValue;
132+
}));
131133
}
132134

133135
return headers;

generated/src/aws-cpp-sdk-s3/source/model/ListObjectVersionsRequest.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <aws/core/utils/memory/stl/AWSStringStream.h>
1111

1212
#include <utility>
13+
#include <numeric>
1314

1415
using namespace Aws::S3::Model;
1516
using namespace Aws::Utils::Xml;
@@ -121,12 +122,13 @@ Aws::Http::HeaderValueCollection ListObjectVersionsRequest::GetRequestSpecificHe
121122

122123
if(m_optionalObjectAttributesHasBeenSet)
123124
{
124-
for(const auto& item : m_optionalObjectAttributes)
125-
{
126-
ss << OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item);
127-
headers.emplace("x-amz-optional-object-attributes", ss.str());
128-
ss.str("");
129-
}
125+
headers.emplace("x-amz-optional-object-attributes", std::accumulate(std::begin(m_optionalObjectAttributes),
126+
std::end(m_optionalObjectAttributes),
127+
Aws::String{},
128+
[](const Aws::String &acc, const OptionalObjectAttributes &item) -> Aws::String {
129+
const auto headerValue = OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item);
130+
return acc.empty() ? headerValue : acc + "," + headerValue;
131+
}));
130132
}
131133

132134
return headers;

generated/src/aws-cpp-sdk-s3/source/model/ListObjectsRequest.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <aws/core/utils/memory/stl/AWSStringStream.h>
1111

1212
#include <utility>
13+
#include <numeric>
1314

1415
using namespace Aws::S3::Model;
1516
using namespace Aws::Utils::Xml;
@@ -113,12 +114,13 @@ Aws::Http::HeaderValueCollection ListObjectsRequest::GetRequestSpecificHeaders()
113114

114115
if(m_optionalObjectAttributesHasBeenSet)
115116
{
116-
for(const auto& item : m_optionalObjectAttributes)
117-
{
118-
ss << OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item);
119-
headers.emplace("x-amz-optional-object-attributes", ss.str());
120-
ss.str("");
121-
}
117+
headers.emplace("x-amz-optional-object-attributes", std::accumulate(std::begin(m_optionalObjectAttributes),
118+
std::end(m_optionalObjectAttributes),
119+
Aws::String{},
120+
[](const Aws::String &acc, const OptionalObjectAttributes &item) -> Aws::String {
121+
const auto headerValue = OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item);
122+
return acc.empty() ? headerValue : acc + "," + headerValue;
123+
}));
122124
}
123125

124126
return headers;

generated/src/aws-cpp-sdk-s3/source/model/ListObjectsV2Request.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <aws/core/utils/memory/stl/AWSStringStream.h>
1111

1212
#include <utility>
13+
#include <numeric>
1314

1415
using namespace Aws::S3::Model;
1516
using namespace Aws::Utils::Xml;
@@ -130,12 +131,13 @@ Aws::Http::HeaderValueCollection ListObjectsV2Request::GetRequestSpecificHeaders
130131

131132
if(m_optionalObjectAttributesHasBeenSet)
132133
{
133-
for(const auto& item : m_optionalObjectAttributes)
134-
{
135-
ss << OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item);
136-
headers.emplace("x-amz-optional-object-attributes", ss.str());
137-
ss.str("");
138-
}
134+
headers.emplace("x-amz-optional-object-attributes", std::accumulate(std::begin(m_optionalObjectAttributes),
135+
std::end(m_optionalObjectAttributes),
136+
Aws::String{},
137+
[](const Aws::String &acc, const OptionalObjectAttributes &item) -> Aws::String {
138+
const auto headerValue = OptionalObjectAttributesMapper::GetNameForOptionalObjectAttributes(item);
139+
return acc.empty() ? headerValue : acc + "," + headerValue;
140+
}));
139141
}
140142

141143
return headers;

tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/cpp/CppViewHelper.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,9 @@ public static String checkForCollision(
481481
.map(__ -> prefix + cppType)
482482
.orElse(functionName);
483483
}
484+
485+
public static boolean hasListMemberUsedForHeader(final Shape shape) {
486+
return shape.getMembers().values().stream()
487+
.anyMatch(shapeMember -> shapeMember.getShape().isList() && shapeMember.isUsedForHeader());
488+
}
484489
}

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/ModelClassHeaderMembersSource.vm

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,17 @@
3838
${spaces} ss.str("");
3939
${spaces}}
4040
#elseif($member.shape.list)
41-
${spaces}for(const auto& item : $memberVarName)
42-
${spaces}{
41+
${spaces}headers.emplace("${locationName}", std::accumulate(std::begin($memberVarName),
42+
${spaces} std::end($memberVarName),
43+
${spaces} Aws::String{},
44+
${spaces} [](const Aws::String &acc, const ${member.shape.listMember.shape.name} &item) -> Aws::String {
4345
#if($member.shape.listMember.shape.enum)
44-
${spaces} ss << ${member.shape.listMember.shape.name}Mapper::GetNameFor${member.shape.listMember.shape.name}(item);
46+
${spaces} const auto headerValue = ${member.shape.listMember.shape.name}Mapper::GetNameFor${member.shape.listMember.shape.name}(item);
4547
#else
46-
${spaces} ss << item;
48+
${spaces} const auto headerValue = item;
4749
#end
48-
${spaces} headers.emplace("${locationName}", ss.str());
49-
${spaces} ss.str("");
50-
${spaces}}
50+
${spaces} return acc.empty() ? headerValue : acc + "," + headerValue;
51+
${spaces} }));
5152
#else
5253
${spaces}ss << m_${lowerCaseVarName};
5354
${spaces}headers.emplace("${locationName}", #if($member.requiresHeaderEncoding())URI::URLEncodePath(ss.str())#else ss.str()#end);

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/StreamRequestSource.vm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#end
1414

1515
\#include <utility>
16+
#if(${CppViewHelper.hasListMemberUsedForHeader($shape)})
17+
\#include <numeric>
18+
#end
1619

1720
using namespace ${rootNamespace}::${serviceNamespace}::Model;
1821
using namespace Aws::Utils::Stream;

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/json/JsonRequestSource.vm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#end
1717

1818
\#include <utility>
19+
#if(${CppViewHelper.hasListMemberUsedForHeader($shape)})
20+
\#include <numeric>
21+
#end
1922

2023
using namespace ${rootNamespace}::${serviceNamespace}::Model;
2124
using namespace Aws::Utils::Json;

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/s3/PutBucketNotificationConfigurationRequest.vm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
#end
1515

1616
\#include <utility>
17+
#if(${CppViewHelper.hasListMemberUsedForHeader($shape)})
18+
\#include <numeric>
19+
#end
1720

1821
using namespace ${rootNamespace}::${serviceNamespace}::Model;
1922
using namespace Aws::Utils::Xml;

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/xml/XmlRequestSource.vm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#end
2020

2121
\#include <utility>
22+
#if(${CppViewHelper.hasListMemberUsedForHeader($shape)})
23+
\#include <numeric>
24+
#end
2225

2326
using namespace ${rootNamespace}::${serviceNamespace}::Model;
2427
using namespace Aws::Utils::Xml;

0 commit comments

Comments
 (0)