| 971 | //---------------------------------------------------------- |
| 972 | |
| 973 | inline |
| 974 | bool |
| 975 | equal( |
| 976 | value const& lhs, |
| 977 | value const& rhs) |
| 978 | { |
| 979 | if(lhs.kind() != rhs.kind()) |
| 980 | return false; |
| 981 | switch(lhs.kind()) |
| 982 | { |
| 983 | case kind::object: |
| 984 | { |
| 985 | auto const& obj1 = |
| 986 | lhs.get_object(); |
| 987 | auto const& obj2 = |
| 988 | rhs.get_object(); |
| 989 | auto n = obj1.size(); |
| 990 | if(obj2.size() != n) |
| 991 | return false; |
| 992 | auto it1 = obj1.begin(); |
| 993 | auto it2 = obj2.begin(); |
| 994 | while(n--) |
| 995 | { |
| 996 | if( it1->key() != |
| 997 | it2->key()) |
| 998 | return false; |
| 999 | if(! equal( |
| 1000 | it1->value(), |
| 1001 | it2->value())) |
| 1002 | return false; |
| 1003 | ++it1; |
| 1004 | ++it2; |
| 1005 | } |
| 1006 | return true; |
| 1007 | } |
| 1008 | |
| 1009 | case kind::array: |
| 1010 | { |
| 1011 | auto const& arr1 = |
| 1012 | lhs.get_array(); |
| 1013 | auto const& arr2 = |
| 1014 | rhs.get_array(); |
| 1015 | auto n = arr1.size(); |
| 1016 | if(arr2.size() != n) |
| 1017 | return false; |
| 1018 | auto it1 = arr1.begin(); |
| 1019 | auto it2 = arr2.begin(); |
| 1020 | while(n--) |
| 1021 | if(! equal(*it1++, *it2++)) |
| 1022 | return false; |
| 1023 | return true; |
| 1024 | } |
| 1025 | |
| 1026 | case kind::string: |
| 1027 | return |
| 1028 | lhs.get_string() == |
| 1029 | rhs.get_string(); |
| 1030 |
no test coverage detected