| 1808 | */ |
| 1809 | template <typename Handler> |
| 1810 | bool Accept(Handler& handler) const { |
| 1811 | switch(GetType()) { |
| 1812 | case kNullType: return handler.Null(); |
| 1813 | case kFalseType: return handler.Bool(false); |
| 1814 | case kTrueType: return handler.Bool(true); |
| 1815 | |
| 1816 | case kObjectType: |
| 1817 | if (RAPIDJSON_UNLIKELY(!handler.StartObject())) |
| 1818 | return false; |
| 1819 | for (ConstMemberIterator m = MemberBegin(); m != MemberEnd(); ++m) { |
| 1820 | RAPIDJSON_ASSERT(m->name.IsString()); // User may change the type of name by MemberIterator. |
| 1821 | if (RAPIDJSON_UNLIKELY(!handler.Key(m->name.GetString(), m->name.GetStringLength(), (m->name.data_.f.flags & kCopyFlag) != 0))) |
| 1822 | return false; |
| 1823 | if (RAPIDJSON_UNLIKELY(!m->value.Accept(handler))) |
| 1824 | return false; |
| 1825 | } |
| 1826 | return handler.EndObject(data_.o.size); |
| 1827 | |
| 1828 | case kArrayType: |
| 1829 | if (RAPIDJSON_UNLIKELY(!handler.StartArray())) |
| 1830 | return false; |
| 1831 | for (const GenericValue* v = Begin(); v != End(); ++v) |
| 1832 | if (RAPIDJSON_UNLIKELY(!v->Accept(handler))) |
| 1833 | return false; |
| 1834 | return handler.EndArray(data_.a.size); |
| 1835 | |
| 1836 | case kStringType: |
| 1837 | return handler.String(GetString(), GetStringLength(), (data_.f.flags & kCopyFlag) != 0); |
| 1838 | |
| 1839 | default: |
| 1840 | RAPIDJSON_ASSERT(GetType() == kNumberType); |
| 1841 | if (IsDouble()) return handler.Double(data_.n.d); |
| 1842 | else if (IsInt()) return handler.Int(data_.n.i.i); |
| 1843 | else if (IsUint()) return handler.Uint(data_.n.u.u); |
| 1844 | else if (IsInt64()) return handler.Int64(data_.n.i64); |
| 1845 | else return handler.Uint64(data_.n.u64); |
| 1846 | } |
| 1847 | } |
| 1848 | |
| 1849 | private: |
| 1850 | template <typename, typename> friend class GenericValue; |
nothing calls this directly
no test coverage detected