/indra/llcommon/llmemorystream.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 70 lines · 29 code · 10 blank · 31 comment · 1 complexity · 20a35e20d8d4cc55f7a4c4faf8daed43 MD5 · raw file

  1. /**
  2. * @file llmemorystream.cpp
  3. * @author Phoenix
  4. * @date 2005-06-03
  5. * @brief Buffer and stream for a fixed linear memory segment.
  6. *
  7. * $LicenseInfo:firstyear=2005&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. #include "linden_common.h"
  29. #include "llmemorystream.h"
  30. LLMemoryStreamBuf::LLMemoryStreamBuf(const U8* start, S32 length)
  31. {
  32. reset(start, length);
  33. }
  34. LLMemoryStreamBuf::~LLMemoryStreamBuf()
  35. {
  36. }
  37. void LLMemoryStreamBuf::reset(const U8* start, S32 length)
  38. {
  39. setg((char*)start, (char*)start, (char*)start + length);
  40. }
  41. int LLMemoryStreamBuf::underflow()
  42. {
  43. //lldebugs << "LLMemoryStreamBuf::underflow()" << llendl;
  44. if(gptr() < egptr())
  45. {
  46. return *gptr();
  47. }
  48. return EOF;
  49. }
  50. /**
  51. * @class LLMemoryStreamBuf
  52. */
  53. LLMemoryStream::LLMemoryStream(const U8* start, S32 length) :
  54. std::istream(&mStreamBuf),
  55. mStreamBuf(start, length)
  56. {
  57. }
  58. LLMemoryStream::~LLMemoryStream()
  59. {
  60. }