/contrib/groff/src/include/symbol.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 83 lines · 50 code · 13 blank · 20 comment · 6 complexity · 61615aff2cbe2c2d4b602b4daac2196f MD5 · raw file

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
  3. Free Software Foundation, Inc.
  4. Written by James Clark (jjc@jclark.com)
  5. This file is part of groff.
  6. groff is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License as published by the Free
  8. Software Foundation; either version 2, or (at your option) any later
  9. version.
  10. groff is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. for more details.
  14. You should have received a copy of the GNU General Public License along
  15. with groff; see the file COPYING. If not, write to the Free Software
  16. Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
  17. #define DONT_STORE 1
  18. #define MUST_ALREADY_EXIST 2
  19. class symbol {
  20. static const char **table;
  21. static int table_used;
  22. static int table_size;
  23. static char *block;
  24. static int block_size;
  25. const char *s;
  26. public:
  27. symbol(const char *p, int how = 0);
  28. symbol();
  29. unsigned long hash() const;
  30. int operator ==(symbol) const;
  31. int operator !=(symbol) const;
  32. const char *contents() const;
  33. int is_null() const;
  34. int is_empty() const;
  35. };
  36. extern const symbol NULL_SYMBOL;
  37. extern const symbol EMPTY_SYMBOL;
  38. inline symbol::symbol() : s(0)
  39. {
  40. }
  41. inline int symbol::operator==(symbol p) const
  42. {
  43. return s == p.s;
  44. }
  45. inline int symbol::operator!=(symbol p) const
  46. {
  47. return s != p.s;
  48. }
  49. inline unsigned long symbol::hash() const
  50. {
  51. return (unsigned long)s;
  52. }
  53. inline const char *symbol::contents() const
  54. {
  55. return s;
  56. }
  57. inline int symbol::is_null() const
  58. {
  59. return s == 0;
  60. }
  61. inline int symbol::is_empty() const
  62. {
  63. return s != 0 && *s == 0;
  64. }
  65. symbol concat(symbol, symbol);
  66. extern symbol default_symbol;