StreamHelper.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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 Js
  7. {
  8. //
  9. // Helper class to implement stream reader/writer. Note that this stream helper class
  10. // maintains its own stream position and ensures the stream position fits scaposition_t.
  11. //
  12. class StreamHelper: public ScriptContextHolder
  13. {
  14. private:
  15. HostStream *m_stream;
  16. protected:
  17. HostStream* GetStream() const
  18. {
  19. return m_stream;
  20. }
  21. void ThrowOverflow() const
  22. {
  23. ::Math::DefaultOverflowPolicy();
  24. }
  25. public:
  26. StreamHelper(ScriptContext* scriptContext, HostStream* stream)
  27. : ScriptContextHolder(scriptContext),
  28. m_stream(stream)
  29. {
  30. }
  31. };
  32. }