| 2447 | template <typename Encoding, typename Allocator> |
| 2448 | template <typename SourceAllocator> |
| 2449 | inline |
| 2450 | GenericValue<Encoding,Allocator>::GenericValue(const GenericValue<Encoding,SourceAllocator>& rhs, Allocator& allocator) |
| 2451 | { |
| 2452 | switch (rhs.GetType()) { |
| 2453 | case kObjectType: |
| 2454 | case kArrayType: { // perform deep copy via SAX Handler |
| 2455 | GenericDocument<Encoding,Allocator> d(&allocator); |
| 2456 | rhs.Accept(d); |
| 2457 | RawAssign(*d.stack_.template Pop<GenericValue>(1)); |
| 2458 | } |
| 2459 | break; |
| 2460 | case kStringType: |
| 2461 | if (rhs.data_.f.flags == kConstStringFlag) { |
| 2462 | data_.f.flags = rhs.data_.f.flags; |
| 2463 | data_ = *reinterpret_cast<const Data*>(&rhs.data_); |
| 2464 | } else { |
| 2465 | SetStringRaw(StringRef(rhs.GetString(), rhs.GetStringLength()), allocator); |
| 2466 | } |
| 2467 | break; |
| 2468 | default: |
| 2469 | data_.f.flags = rhs.data_.f.flags; |
| 2470 | data_ = *reinterpret_cast<const Data*>(&rhs.data_); |
| 2471 | break; |
| 2472 | } |
| 2473 | } |
| 2474 | |
| 2475 | //! Helper class for accessing Value of array type. |
| 2476 | /*! |
nothing calls this directly
no test coverage detected