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.

56 lines
1.2 KiB

  1. /***
  2. * ostrulng.cpp - definitions for ostream class operator<<(unsigned long) funct
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Contains the member function definition for ostream
  8. * operator<<(unsigned long).
  9. *
  10. *Revision History:
  11. * 09-23-91 KRS Created. Split out from ostream.cxx for granularity.
  12. * 06-14-95 CFW Comment cleanup.
  13. *
  14. *******************************************************************************/
  15. #include <cruntime.h>
  16. #include <internal.h>
  17. #include <stdio.h>
  18. #include <iostream.h>
  19. #pragma hdrstop
  20. ostream& ostream::operator<<(unsigned long n)
  21. {
  22. _WINSTATIC char obuffer[12];
  23. _WINSTATIC char fmt[4] = "%lu";
  24. _WINSTATIC char leader[4] = "\0\0";
  25. if (opfx()) {
  26. if (n)
  27. {
  28. if (x_flags & (hex|oct))
  29. {
  30. if (x_flags & hex)
  31. {
  32. if (x_flags & uppercase)
  33. fmt[2] = 'X';
  34. else
  35. fmt[2] = 'x';
  36. leader[1] = fmt[2]; // 0x or 0X (or \0X)
  37. }
  38. else
  39. fmt[2] = 'o';
  40. if (x_flags & showbase)
  41. leader[0] = '0';
  42. }
  43. else if (x_flags & showpos)
  44. {
  45. leader[0] = '+';
  46. }
  47. }
  48. sprintf(obuffer,fmt,n);
  49. writepad(leader,obuffer);
  50. osfx();
  51. }
  52. return *this;
  53. }