Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
3.4 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: MemDeSer.cxx
  7. //
  8. // History: 29-Jul-94 KyleP Created
  9. //
  10. //--------------------------------------------------------------------------
  11. #include <pch.cxx>
  12. #pragma hdrstop
  13. #include <qmemdes.hxx>
  14. BYTE CQMemDeSerStream::GetByte()
  15. {
  16. BYTE b = *_pbCurrent;
  17. _pbCurrent += 1;
  18. return(b);
  19. }
  20. void CQMemDeSerStream::SkipByte()
  21. {
  22. _pbCurrent += 1;
  23. }
  24. void CQMemDeSerStream::GetChar( char * pc, ULONG cc )
  25. {
  26. memcpy( pc, _pbCurrent, cc );
  27. _pbCurrent += cc;
  28. }
  29. void CQMemDeSerStream::SkipChar( ULONG cc )
  30. {
  31. _pbCurrent += cc;
  32. }
  33. void CQMemDeSerStream::GetWChar( WCHAR * pwc, ULONG cc )
  34. {
  35. WCHAR * pwcTemp = AlignWCHAR(_pbCurrent);
  36. memcpy( pwc, pwcTemp, cc * sizeof(WCHAR) );
  37. _pbCurrent = (BYTE *)(pwcTemp + cc);
  38. }
  39. void CQMemDeSerStream::SkipWChar( ULONG cc )
  40. {
  41. WCHAR * pwcTemp = AlignWCHAR(_pbCurrent);
  42. _pbCurrent = (BYTE *)(pwcTemp + cc);
  43. }
  44. USHORT CQMemDeSerStream::GetUShort()
  45. {
  46. USHORT * pus = AlignUSHORT(_pbCurrent);
  47. _pbCurrent = (BYTE *)(pus + 1);
  48. return( *pus );
  49. }
  50. void CQMemDeSerStream::SkipUShort()
  51. {
  52. USHORT * pus = AlignUSHORT(_pbCurrent);
  53. _pbCurrent = (BYTE *)(pus + 1);
  54. }
  55. ULONG CQMemDeSerStream::GetULong()
  56. {
  57. ULONG * pul = AlignULONG(_pbCurrent);
  58. _pbCurrent = (BYTE *)(pul + 1);
  59. return( *pul );
  60. }
  61. void CQMemDeSerStream::SkipULong()
  62. {
  63. ULONG * pul = AlignULONG(_pbCurrent);
  64. _pbCurrent = (BYTE *)(pul + 1);
  65. }
  66. long CQMemDeSerStream::GetLong()
  67. {
  68. long * pl = AlignLong(_pbCurrent);
  69. _pbCurrent = (BYTE *)(pl + 1);
  70. return( *pl );
  71. }
  72. void CQMemDeSerStream::SkipLong()
  73. {
  74. long * pl = AlignLong(_pbCurrent);
  75. _pbCurrent = (BYTE *)(pl + 1);
  76. }
  77. float CQMemDeSerStream::GetFloat()
  78. {
  79. float * pf = AlignFloat(_pbCurrent);
  80. _pbCurrent = (BYTE *)(pf + 1);
  81. return( *pf );
  82. }
  83. void CQMemDeSerStream::SkipFloat()
  84. {
  85. float * pf = AlignFloat(_pbCurrent);
  86. _pbCurrent = (BYTE *)(pf + 1);
  87. }
  88. double CQMemDeSerStream::GetDouble()
  89. {
  90. double * pd = AlignDouble(_pbCurrent);
  91. _pbCurrent = (BYTE *)(pd + 1);
  92. return( *pd );
  93. }
  94. void CQMemDeSerStream::SkipDouble()
  95. {
  96. double * pd = AlignDouble(_pbCurrent);
  97. _pbCurrent = (BYTE *)(pd + 1);
  98. }
  99. ULONG CQMemDeSerStream::PeekULong()
  100. {
  101. ULONG * pul = AlignULONG(_pbCurrent);
  102. return( *pul );
  103. }
  104. char * CQMemDeSerStream::GetString()
  105. {
  106. ULONG * pul = AlignULONG(_pbCurrent);
  107. ULONG len = *pul;
  108. _pbCurrent = (BYTE *)(pul + 1);
  109. char * psz = new char[len+1];
  110. memcpy(psz, _pbCurrent, len);
  111. _pbCurrent += len;
  112. psz[len] = 0;
  113. return(psz);
  114. }
  115. WCHAR * CQMemDeSerStream::GetWString()
  116. {
  117. ULONG * pul = AlignULONG(_pbCurrent);
  118. ULONG len = *pul;
  119. WCHAR * pwsz = new WCHAR[len + 1];
  120. _pbCurrent = (BYTE *)(pul + 1);
  121. memcpy(pwsz, _pbCurrent, len * sizeof(WCHAR) );
  122. _pbCurrent += len * sizeof(WCHAR);
  123. pwsz[len] = 0;
  124. return(pwsz);
  125. }
  126. void CQMemDeSerStream::GetBlob( BYTE * pb, ULONG cb )
  127. {
  128. memcpy( pb, _pbCurrent, cb );
  129. _pbCurrent += cb;
  130. }
  131. void CQMemDeSerStream::SkipBlob( ULONG cb )
  132. {
  133. _pbCurrent += cb;
  134. }
  135. void CQMemDeSerStream::GetGUID( GUID & guid )
  136. {
  137. GUID * pguid = (GUID *)AlignGUID(_pbCurrent);
  138. memcpy( &guid, pguid, sizeof(guid) );
  139. _pbCurrent = (BYTE *)(pguid + 1);
  140. }
  141. void CQMemDeSerStream::SkipGUID()
  142. {
  143. GUID * pguid = (GUID *)AlignGUID(_pbCurrent);
  144. _pbCurrent = (BYTE *)(pguid + 1);
  145. }