File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -2612,6 +2612,7 @@ class GenericArray {
2612
2612
GenericArray& operator =(const GenericArray& rhs) { value_ = rhs.value_ ; return *this ; }
2613
2613
~GenericArray () {}
2614
2614
2615
+ operator ValueType&() const { return value_; }
2615
2616
SizeType Size () const { return value_.Size (); }
2616
2617
SizeType Capacity () const { return value_.Capacity (); }
2617
2618
bool Empty () const { return value_.Empty (); }
@@ -2667,6 +2668,7 @@ class GenericObject {
2667
2668
GenericObject& operator =(const GenericObject& rhs) { value_ = rhs.value_ ; return *this ; }
2668
2669
~GenericObject () {}
2669
2670
2671
+ operator ValueType&() const { return value_; }
2670
2672
SizeType MemberCount () const { return value_.MemberCount (); }
2671
2673
SizeType MemberCapacity () const { return value_.MemberCapacity (); }
2672
2674
bool ObjectEmpty () const { return value_.ObjectEmpty (); }
Original file line number Diff line number Diff line change @@ -1529,6 +1529,38 @@ TEST(Pointer, Ambiguity) {
1529
1529
}
1530
1530
}
1531
1531
1532
+ TEST (Pointer, ResolveOnObject) {
1533
+ Document d;
1534
+ EXPECT_FALSE (d.Parse (" {\" a\" : 123}" ).HasParseError ());
1535
+
1536
+ {
1537
+ Value::ConstObject o = static_cast <const Document&>(d).GetObject ();
1538
+ EXPECT_EQ (123 , Pointer (" /a" ).Get (o)->GetInt ());
1539
+ }
1540
+
1541
+ {
1542
+ Value::Object o = d.GetObject ();
1543
+ Pointer (" /a" ).Set (o, 456 , d.GetAllocator ());
1544
+ EXPECT_EQ (456 , Pointer (" /a" ).Get (o)->GetInt ());
1545
+ }
1546
+ }
1547
+
1548
+ TEST (Pointer, ResolveOnArray) {
1549
+ Document d;
1550
+ EXPECT_FALSE (d.Parse (" [1, 2, 3]" ).HasParseError ());
1551
+
1552
+ {
1553
+ Value::ConstArray a = static_cast <const Document&>(d).GetArray ();
1554
+ EXPECT_EQ (2 , Pointer (" /1" ).Get (a)->GetInt ());
1555
+ }
1556
+
1557
+ {
1558
+ Value::Array a = d.GetArray ();
1559
+ Pointer (" /1" ).Set (a, 123 , d.GetAllocator ());
1560
+ EXPECT_EQ (123 , Pointer (" /1" ).Get (a)->GetInt ());
1561
+ }
1562
+ }
1563
+
1532
1564
TEST (Pointer, LessThan) {
1533
1565
static const struct {
1534
1566
const char *str;
You can’t perform that action at this time.
0 commit comments