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.

100 lines
2.6 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. strtchar.hxx
  7. String classes for formatted output - definitions
  8. This file defines the class TCHAR_STR.
  9. Q.v. string.hxx and strnumer.hxx.
  10. FILE HISTORY:
  11. beng 25-Feb-1992 Created
  12. */
  13. #ifndef _STRTCHAR_HXX_
  14. #define _STRTCHAR_HXX_
  15. #include "base.hxx"
  16. #include "string.hxx"
  17. /*************************************************************************
  18. NAME: TCHAR_STR_IMPL
  19. SYNOPSIS: Private to implementation of TCHAR_STR class
  20. INTERFACE: TCHAR_STR_IMPL() - ctor. Takes the character to render.
  21. NOTES:
  22. Alas, cfront 2.0 does not implement nested types.
  23. CAVEATS:
  24. Ignore this class - it is private to class TCHAR_STR.
  25. HISTORY:
  26. beng 25-Feb-1992 Created
  27. **************************************************************************/
  28. DLL_CLASS TCHAR_STR_IMPL // Private to implementation of TCHAR_STR
  29. {
  30. public:
  31. TCHAR _szStorage[2];
  32. TCHAR_STR_IMPL( TCHAR ch )
  33. {
  34. _szStorage[0] = ch;
  35. _szStorage[1] = 0;
  36. }
  37. };
  38. /*************************************************************************
  39. NAME: TCHAR_STR
  40. SYNOPSIS: String formatted as a single character
  41. INTERFACE: TCHAR_STR() - ctor. Takes the character to render.
  42. PARENT: FORWARDING_BASE
  43. USES: TCHAR_STR_IMPL
  44. NOTES:
  45. This class responds as an ALIAS_STR, although it doesn't inherit
  46. from it. It exists only to copy elsewhere, into some other string
  47. or formatted string. Its unusual implementation serves to
  48. minimize allocation overhead (I boil with rage when imagining
  49. allocating a two-TCHAR string in order to format a character)
  50. while eliminating the compound nature of existing ALLOC_STR forms,
  51. which would not work well within a FORMATTED_STR::Format expression.
  52. HISTORY:
  53. beng 25-Feb-1992 Created
  54. **************************************************************************/
  55. DLL_CLASS TCHAR_STR: public FORWARDING_BASE
  56. {
  57. private:
  58. TCHAR_STR_IMPL _impl;
  59. ALIAS_STR _nlsStorage;
  60. public:
  61. TCHAR_STR( TCHAR ch )
  62. : FORWARDING_BASE(&_nlsStorage), // yes, not yet constructed
  63. _impl(ch),
  64. _nlsStorage(_impl._szStorage) {}
  65. operator const ALIAS_STR &()
  66. { return _nlsStorage; }
  67. };
  68. #endif // _STRTCHAR_HXX_ - end of file