JSONStack.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace JSON
  7. {
  8. class StrictEqualsObjectComparer
  9. {
  10. public:
  11. static bool Equals(Js::Var x, Js::Var y);
  12. };
  13. class JSONStack
  14. {
  15. private:
  16. SList<Js::Var> jsObjectStack; // Consider: key-only dictionary here
  17. typedef JsUtil::List<Js::Var, ArenaAllocator, false, Js::CopyRemovePolicy,
  18. SpecializedComparer<Js::Var, JSON::StrictEqualsObjectComparer>::TComparerType> DOMObjectStack;
  19. DOMObjectStack *domObjectStack;
  20. ArenaAllocator *alloc;
  21. Js::ScriptContext *scriptContext;
  22. public:
  23. JSONStack(ArenaAllocator *allocator, Js::ScriptContext *context);
  24. static bool Equals(Js::Var x, Js::Var y);
  25. bool Has(Js::Var data, bool bJsObject = true) const;
  26. bool Push(Js::Var data, bool bJsObject = true);
  27. void Pop(bool bJsObject = true);
  28. private:
  29. void EnsuresDomObjectStack(void);
  30. };
  31. } // namespace JSON