Leaked source code of windows server 2003
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.

73 lines
1.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1997
  6. //
  7. // File: parmiox.h
  8. //
  9. //--------------------------------------------------------------------------
  10. //////////////////////////////////////////////////////////////////////////////////
  11. //
  12. // PARMIOX.H: Parameter file I/O routines extended for older classes
  13. //
  14. //////////////////////////////////////////////////////////////////////////////////
  15. #ifndef _PARMIOX_H_
  16. #define _PARMIOX_H_
  17. #include "parmio.h"
  18. template<class _T> inline
  19. PARMOUTSTREAM& operator << (PARMOUTSTREAM & ofs, const RG<_T> & rgt )
  20. {
  21. UINT c = rgt.Celem();
  22. ofs << CH_DELM_OPEN;
  23. ofs << c;
  24. ofs << CH_PREAMBLE;
  25. for ( UINT i = 0; i < c; )
  26. {
  27. ofs << rgt[i];
  28. if ( ++i != c )
  29. ofs << ',' ;
  30. }
  31. ofs << CH_DELM_CLOSE;
  32. return ofs;
  33. }
  34. template<class _T> inline
  35. PARMINSTREAM& operator >> (PARMINSTREAM & ifs, RG<_T> & rgt )
  36. {
  37. char ch;
  38. ifs >> ch;
  39. if (ch != CH_DELM_OPEN)
  40. _THROW1(runtime_error("invalid block (1)"));
  41. UINT l;
  42. ifs >> l;
  43. ifs >> ch;
  44. if (ch != CH_PREAMBLE)
  45. _THROW1(runtime_error("invalid block (2)"));
  46. rgt.BxResize(l);
  47. for ( UINT i = 0 ; i < l; )
  48. {
  49. _T it;
  50. ifs >> it;
  51. rgt[i] = it;
  52. if ( ++i < l )
  53. {
  54. ifs >> ch;
  55. if (ch != CH_SEP)
  56. break;
  57. }
  58. }
  59. if ( i != l )
  60. _THROW1(runtime_error("invalid block (3)"));
  61. ifs >> ch;
  62. if (ch != CH_DELM_CLOSE)
  63. _THROW1(runtime_error("invalid block (4)"));
  64. return ifs;
  65. }
  66. #endif // _PARMIOX_H_