Skip to content

Commit 4d6f5a4

Browse files
sbalujasbaluja
authored andcommitted
Add AccessB() function to Aws::Utils::ByteBuffer class for reference access
1 parent 64ae473 commit 4d6f5a4

File tree

7 files changed

+48
-0
lines changed

7 files changed

+48
-0
lines changed

generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/model/AttributeValue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ class AWS_DYNAMODB_API AttributeValue
6565

6666
/// returns the ByteBuffer if the value is specialized to this type, otherwise an empty Buffer
6767
const Aws::Utils::ByteBuffer GetB() const;
68+
/// returns a reference to the ByteBuffer if the value is specialized to this type, otherwise a reference to an empty Buffer
69+
const Aws::Utils::ByteBuffer& AccessB() const;
6870
/// if already specialized to a ByteBuffer, sets the value to this value
6971
/// if uninitialized, specializes the type to a ByteBuffer with the specified value
7072
/// if already specialized to another type then the behavior is undefined

generated/src/aws-cpp-sdk-dynamodb/include/aws/dynamodb/model/AttributeValueValue.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class AttributeValueValue
3232

3333
virtual const Aws::Utils::ByteBuffer GetB() const { return {}; }
3434

35+
virtual const Aws::Utils::ByteBuffer& AccessB() const {
36+
static const Aws::Utils::ByteBuffer empty;
37+
return empty;
38+
}
39+
3540
virtual const Aws::Vector<Aws::String> GetSS() const { return {}; }
3641

3742
virtual void AddSItem(const Aws::String& ) { assert(false); }
@@ -104,6 +109,7 @@ class AttributeValueByteBuffer final : public AttributeValueValue
104109
explicit AttributeValueByteBuffer(const Aws::Utils::ByteBuffer& value) : m_b(value) {}
105110
explicit AttributeValueByteBuffer(Aws::Utils::Json::JsonView jsonValue);
106111
const Aws::Utils::ByteBuffer GetB() const override { return m_b; }
112+
const Aws::Utils::ByteBuffer& AccessB() const override { return m_b; }
107113
bool IsDefault() const override { return m_b.GetLength() == 0; }
108114
bool operator == (const AttributeValueValue& other) const override { return GetType() == other.GetType() && m_b == other.GetB(); }
109115
Aws::Utils::Json::JsonValue Jsonize() const override;

generated/src/aws-cpp-sdk-dynamodb/source/model/AttributeValue.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ AttributeValue& AttributeValue::SetB(const ByteBuffer& b)
6666
return *this;
6767
}
6868

69+
const ByteBuffer& AttributeValue::AccessB() const
70+
{
71+
if (m_value)
72+
{
73+
return m_value->AccessB();
74+
}
75+
else
76+
{
77+
static const ByteBuffer empty;
78+
return empty;
79+
}
80+
}
81+
6982
const Aws::Vector<Aws::String> AttributeValue::GetSS() const
7083
{
7184
if (m_value)

tests/aws-cpp-sdk-dynamodb-integration-tests/TableOperationTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,7 @@ TEST_F(TableOperationTest, TestAttributeValues)
10581058
EXPECT_EQ("String Value", returnedItemCollection["String"].GetS());
10591059
EXPECT_EQ("1001", returnedItemCollection["Number"].GetN());
10601060
EXPECT_EQ(byteBuffer1, returnedItemCollection["ByteBuffer"].GetB()); // on the 3rd day of xmas...
1061+
EXPECT_EQ(byteBuffer1, returnedItemCollection["ByteBuffer"].AccessB());
10611062
}
10621063

10631064
// StringSet
@@ -1097,6 +1098,7 @@ TEST_F(TableOperationTest, TestAttributeValues)
10971098
EXPECT_EQ("String Value", returnedItemCollection["String"].GetS());
10981099
EXPECT_EQ("1001", returnedItemCollection["Number"].GetN());
10991100
EXPECT_EQ(byteBuffer1, returnedItemCollection["ByteBuffer"].GetB());
1101+
EXPECT_EQ(byteBuffer1, returnedItemCollection["ByteBuffer"].AccessB());
11001102
auto ss = returnedItemCollection["String Set"].GetSS();
11011103
EXPECT_EQ(2u, ss.size());
11021104
EXPECT_NE(ss.end(), std::find(ss.begin(), ss.end(), "test1"));
@@ -1140,6 +1142,7 @@ TEST_F(TableOperationTest, TestAttributeValues)
11401142
EXPECT_EQ("String Value", returnedItemCollection["String"].GetS());
11411143
EXPECT_EQ("1001", returnedItemCollection["Number"].GetN());
11421144
EXPECT_EQ(byteBuffer1, returnedItemCollection["ByteBuffer"].GetB());
1145+
EXPECT_EQ(byteBuffer1, returnedItemCollection["ByteBuffer"].AccessB());
11431146
auto ss = returnedItemCollection["String Set"].GetSS();
11441147
EXPECT_EQ(2u, ss.size());
11451148
EXPECT_NE(ss.end(), std::find(ss.begin(), ss.end(), "test1"));
@@ -1187,6 +1190,7 @@ TEST_F(TableOperationTest, TestAttributeValues)
11871190
EXPECT_EQ("String Value", returnedItemCollection["String"].GetS());
11881191
EXPECT_EQ("1001", returnedItemCollection["Number"].GetN());
11891192
EXPECT_EQ(byteBuffer1, returnedItemCollection["ByteBuffer"].GetB());
1193+
EXPECT_EQ(byteBuffer1, returnedItemCollection["ByteBuffer"].AccessB());
11901194
auto ss = returnedItemCollection["String Set"].GetSS();
11911195
EXPECT_EQ(2u, ss.size());
11921196
EXPECT_NE(ss.end(), std::find(ss.begin(), ss.end(), "test1"));
@@ -1240,6 +1244,7 @@ TEST_F(TableOperationTest, TestAttributeValues)
12401244
EXPECT_EQ("String Value", returnedItemCollection["String"].GetS());
12411245
EXPECT_EQ("1001", returnedItemCollection["Number"].GetN());
12421246
EXPECT_EQ(byteBuffer1, returnedItemCollection["ByteBuffer"].GetB());
1247+
EXPECT_EQ(byteBuffer1, returnedItemCollection["ByteBuffer"].AccessB());
12431248
auto ss = returnedItemCollection["String Set"].GetSS();
12441249
EXPECT_EQ(2u, ss.size());
12451250
EXPECT_NE(ss.end(), std::find(ss.begin(), ss.end(), "test1"));
@@ -1334,6 +1339,7 @@ TEST_F(TableOperationTest, TestAttributeValues)
13341339
EXPECT_EQ("String Value", returnedItemCollection["String"].GetS());
13351340
EXPECT_EQ("1001", returnedItemCollection["Number"].GetN());
13361341
EXPECT_EQ(byteBuffer1, returnedItemCollection["ByteBuffer"].GetB());
1342+
EXPECT_EQ(byteBuffer1, returnedItemCollection["ByteBuffer"].AccessB());
13371343
auto ss = returnedItemCollection["String Set"].GetSS();
13381344
EXPECT_EQ(2u, ss.size());
13391345
EXPECT_NE(ss.end(), std::find(ss.begin(), ss.end(), "test1"));

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public:
6262

6363
/// returns the ByteBuffer if the value is specialized to this type, otherwise an empty Buffer
6464
const Aws::Utils::ByteBuffer GetB() const;
65+
/// returns a reference to the ByteBuffer if the value is specialized to this type, otherwise a reference to an empty Buffer
66+
const Aws::Utils::ByteBuffer& AccessB() const;
6567
/// if already specialized to a ByteBuffer, sets the value to this value
6668
/// if uninitialized, specializes the type to a ByteBuffer with the specified value
6769
/// if already specialized to another type then the behavior is undefined

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ AttributeValue& AttributeValue::SetB(const ByteBuffer& b)
6363
return *this;
6464
}
6565

66+
const ByteBuffer& AttributeValue::AccessB() const
67+
{
68+
if (m_value)
69+
{
70+
return m_value->AccessB();
71+
}
72+
else
73+
{
74+
static const ByteBuffer empty;
75+
return empty;
76+
}
77+
}
78+
6679
const Aws::Vector<Aws::String> AttributeValue::GetSS() const
6780
{
6881
if (m_value)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public:
2929

3030
virtual const Aws::Utils::ByteBuffer GetB() const { return {}; }
3131

32+
virtual const Aws::Utils::ByteBuffer& AccessB() const {
33+
static const Aws::Utils::ByteBuffer empty;
34+
return empty;
35+
}
36+
3237
virtual const Aws::Vector<Aws::String> GetSS() const { return {}; }
3338

3439
virtual void AddSItem(const Aws::String& ) { assert(false); }
@@ -101,6 +106,7 @@ public:
101106
explicit AttributeValueByteBuffer(const Aws::Utils::ByteBuffer& value) : m_b(value) {}
102107
explicit AttributeValueByteBuffer(Aws::Utils::Json::JsonView jsonValue);
103108
const Aws::Utils::ByteBuffer GetB() const override { return m_b; }
109+
const Aws::Utils::ByteBuffer& AccessB() const override { return m_b; }
104110
bool IsDefault() const override { return m_b.GetLength() == 0; }
105111
bool operator == (const AttributeValueValue& other) const override { return GetType() == other.GetType() && m_b == other.GetB(); }
106112
Aws::Utils::Json::JsonValue Jsonize() const override;

0 commit comments

Comments
 (0)