Skip to content

Commit e22ec4b

Browse files
committed
Forward-declare XmlTraits in Schema.h
1 parent 941821f commit e22ec4b

4 files changed

Lines changed: 15 additions & 21 deletions

File tree

src/aws-cpp-sdk-core/include/smithy/client/schema/Schema.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#pragma once
22

33
#include <aws/core/utils/memory/stl/AWSString.h>
4-
#include <smithy/client/schema/XmlTraits.h>
54

65
#include <cstdint>
76

87
namespace smithy {
98
namespace schema {
109

10+
struct XmlTraits;
11+
1112
enum class ShapeType : uint8_t {
1213
Boolean,
1314
Byte,
@@ -49,10 +50,8 @@ class Schema {
4950

5051
uint16_t GetMemberCount() const { return m_memberCount; }
5152

52-
// XML traits accessor
5353
const XmlTraits* GetXmlTraits() const { return m_xmlTraits; }
5454

55-
// Builder-style setter for XML traits pointer (used by codegen)
5655
Schema& WithXmlTraits(const XmlTraits* traits) {
5756
m_xmlTraits = traits;
5857
return *this;

src/aws-cpp-sdk-core/include/smithy/client/schema/XmlTraits.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,16 @@
99
namespace smithy {
1010
namespace schema {
1111

12-
/**
13-
* XML-specific traits for a Schema member.
14-
* Instances should be declared as static const and referenced via pointer from Schema.
15-
* Zero cost for non-XML services (Schema just holds a null pointer).
16-
*/
1712
struct XmlTraits {
18-
Aws::String xmlName; // @xmlName override (empty = use member name)
19-
Aws::String listItemName; // element name for list items (default: "member")
20-
Aws::String mapEntryName; // element name for map entries (default: "entry")
21-
Aws::String mapKeyName; // element name for map keys (default: "key")
22-
Aws::String mapValueName; // element name for map values (default: "value")
23-
Aws::String namespaceUri; // @xmlNamespace URI
24-
Aws::String namespacePrefix; // @xmlNamespace prefix (empty = default namespace)
25-
bool flattened = false; // @xmlFlattened
26-
bool isAttribute = false; // @xmlAttribute
13+
Aws::String xmlName;
14+
Aws::String listItemName;
15+
Aws::String mapEntryName;
16+
Aws::String mapKeyName;
17+
Aws::String mapValueName;
18+
Aws::String namespaceUri;
19+
Aws::String namespacePrefix;
20+
bool flattened = false;
21+
bool isAttribute = false;
2722
};
2823

2924
} // namespace schema

src/aws-cpp-sdk-core/source/smithy/client/schema/XmlShapeSerializer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <aws/core/utils/StringUtils.h>
77
#include <aws/core/utils/memory/stl/AWSArray.h>
88
#include <smithy/client/schema/XmlShapeSerializer.h>
9+
#include <smithy/client/schema/XmlTraits.h>
910

1011
using namespace smithy::schema;
1112
using namespace Aws::Utils;
@@ -49,8 +50,6 @@ void WriteXmlEscaped(Aws::String& buf, const Aws::String& value) {
4950
}
5051
}
5152

52-
// Get the effective XML element name for a schema.
53-
// If XmlTraits is present and has an xmlName, use it; otherwise fall back to memberName.
5453
Aws::String GetXmlName(const Schema& schema) {
5554
const auto* traits = schema.GetXmlTraits();
5655
if (traits && !traits->xmlName.empty()) {

tests/aws-cpp-sdk-core-tests/smithy/client/schema/XmlShapeSerializerTest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,9 @@ TEST_F(XmlShapeSerializerTest, XmlNameOverridesMemberName) {
393393
s.BeginStructure(root);
394394
s.WriteString(member, "hello");
395395
s.EndStructure();
396-
EXPECT_NE(s.GetPayload().find("<ExternalName>hello</ExternalName>"), Aws::String::npos);
397-
EXPECT_EQ(s.GetPayload().find("<internalName>"), Aws::String::npos);
396+
auto payload = s.GetPayload();
397+
EXPECT_NE(payload.find("<ExternalName>hello</ExternalName>"), Aws::String::npos);
398+
EXPECT_EQ(payload.find("<internalName>"), Aws::String::npos);
398399
}
399400

400401
TEST_F(XmlShapeSerializerTest, XmlNameOnStructure) {

0 commit comments

Comments
 (0)