don't let the GetObject macro rewrite the GetObject method, add a GetObj alias
This commit is contained in:
parent
3168d7c343
commit
d179facf90
@ -42,6 +42,15 @@ RAPIDJSON_DIAG_OFF(4244) // conversion from kXxxFlags to 'uint16_t', possible lo
|
|||||||
RAPIDJSON_DIAG_OFF(effc++)
|
RAPIDJSON_DIAG_OFF(effc++)
|
||||||
#endif // __GNUC__
|
#endif // __GNUC__
|
||||||
|
|
||||||
|
#ifdef GetObject
|
||||||
|
// see https://github.com/Tencent/rapidjson/issues/1448
|
||||||
|
// a former included windows.h might have defined a macro called GetObject, which affects
|
||||||
|
// GetObject defined here. This ensures the macro does not get applied
|
||||||
|
#pragma push_macro("GetObject")
|
||||||
|
#define RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED
|
||||||
|
#undef GetObject
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
|
#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
|
||||||
#include <iterator> // std::random_access_iterator_tag
|
#include <iterator> // std::random_access_iterator_tag
|
||||||
#endif
|
#endif
|
||||||
@ -1602,7 +1611,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Object GetObject() { RAPIDJSON_ASSERT(IsObject()); return Object(*this); }
|
Object GetObject() { RAPIDJSON_ASSERT(IsObject()); return Object(*this); }
|
||||||
|
Object GetObj() { RAPIDJSON_ASSERT(IsObject()); return Object(*this); }
|
||||||
ConstObject GetObject() const { RAPIDJSON_ASSERT(IsObject()); return ConstObject(*this); }
|
ConstObject GetObject() const { RAPIDJSON_ASSERT(IsObject()); return ConstObject(*this); }
|
||||||
|
ConstObject GetObj() const { RAPIDJSON_ASSERT(IsObject()); return ConstObject(*this); }
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
@ -3008,4 +3019,9 @@ private:
|
|||||||
RAPIDJSON_NAMESPACE_END
|
RAPIDJSON_NAMESPACE_END
|
||||||
RAPIDJSON_DIAG_POP
|
RAPIDJSON_DIAG_POP
|
||||||
|
|
||||||
|
#ifdef RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED
|
||||||
|
#pragma pop_macro("GetObject")
|
||||||
|
#undef RAPIDJSON_WINDOWS_GETOBJECT_WORKAROUND_APPLIED
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // RAPIDJSON_DOCUMENT_H_
|
#endif // RAPIDJSON_DOCUMENT_H_
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "rapidjson/document.h"
|
#include "rapidjson/document.h"
|
||||||
|
#undef GetObject
|
||||||
|
|
||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
|
|
||||||
@ -34,4 +35,6 @@ TEST(Platform, GetObject) {
|
|||||||
EXPECT_TRUE(o.IsObject());
|
EXPECT_TRUE(o.IsObject());
|
||||||
auto sub = o.GetObject();
|
auto sub = o.GetObject();
|
||||||
EXPECT_TRUE(sub.HasMember("pi"));
|
EXPECT_TRUE(sub.HasMember("pi"));
|
||||||
|
auto sub2 = o.GetObj();
|
||||||
|
EXPECT_TRUE(sub2.HasMember("pi"));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user