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.

118 lines
2.6 KiB

  1. /**********************************************************************/
  2. /** Microsoft LAN Manager **/
  3. /** Copyright(c) Microsoft Corp., 1987-1999 **/
  4. /**********************************************************************/
  5. /*
  6. lextable.hxx
  7. MIDL Compiler Lexeme Table Definition
  8. This class centralizes access to allocated strings throughout the
  9. compiler.
  10. */
  11. /*
  12. FILE HISTORY :
  13. DonnaLi 08-23-1990 Created.
  14. */
  15. #ifndef __LEXTABLE_HXX__
  16. #define __LEXTABLE_HXX__
  17. #include "common.hxx"
  18. #include "dict.hxx"
  19. /**********************************************************************\
  20. NAME: LexKey
  21. SYNOPSIS: Defines the key to the lexeme table.
  22. INTERFACE:
  23. CAVEATS:
  24. NOTES:
  25. HISTORY:
  26. Donnali 08-23-1990 Initial creation
  27. Donnali 12-04-1990 Port to Dov's generic dictionary
  28. \**********************************************************************/
  29. class LexKey
  30. {
  31. char *sz; // lexeme that serves as key to the LexTable
  32. public:
  33. LexKey() { sz = 0; }
  34. LexKey(char * psz) { sz = psz; }
  35. ~LexKey() { }
  36. char *GetString() { return sz; }
  37. void SetString(char * psz) { sz = psz; }
  38. void Print(void) { printf("%s", sz); }
  39. void * operator new ( size_t size )
  40. {
  41. return AllocateOnceNew( size );
  42. }
  43. void operator delete( void * ptr )
  44. {
  45. AllocateOnceDelete( ptr );
  46. }
  47. friend void PrintLexeme(void *);
  48. friend int CompareLexeme(void *, void *);
  49. };
  50. /**********************************************************************\
  51. NAME: LexTable
  52. SYNOPSIS: Defines the lexeme table.
  53. INTERFACE: LexTable ()
  54. Constructor.
  55. LexInsert ()
  56. Inserts a lexeme into the lexeme table.
  57. LexSearch ()
  58. Searches the lexeme table for a lexeme.
  59. CAVEATS: This implementation does not support deletion of strings
  60. from the lexeme table.
  61. NOTES:
  62. HISTORY:
  63. Donnali 08-23-1990 Initial creation
  64. \**********************************************************************/
  65. class LexTable
  66. #ifdef unique_lextable
  67. : public Dictionary
  68. #endif // unique_lextable
  69. {
  70. size_t BufferSize; // size of the current buffer
  71. size_t BufferNext; // next position for new lexeme
  72. char * pBuffer; // pointer to current buffer
  73. #ifdef unique_lextable
  74. LexKey SearchKey; // used to hold a search string
  75. #endif
  76. public:
  77. LexTable(
  78. size_t Size,
  79. int (* pfnCompare)(void *, void *) = CompareLexeme,
  80. void (* pfnPrint)(void *) = PrintLexeme
  81. );
  82. char * LexInsert(char * psz);
  83. char * LexSearch(char * psz);
  84. };
  85. #endif // __LEXTABLE_HXX__