binkey.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
  24. /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
  25. /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
  26. /*%% (c) Copyright 1993, 1994 Novell, Inc. */
  27. /*%% $XConsortium: binkey.h /main/3 1995/10/20 16:25:01 rswiston $ */
  28. /*
  29. *
  30. * binkey.h
  31. *
  32. * Simple class for manipulating 16-byte keys.
  33. * This class simply encapsulates the storage and (lexical) comparison
  34. * of 16-byte binary keys. Generally, _Tt_db_key is the class to
  35. * use to hold and manipulate keys; only code which depends on the
  36. * lexical ordering of keys (which should only be the inspect-and-
  37. * repair tools) should use this class.
  38. *
  39. * Copyright (c) 1991 by Sun Microsystems, Inc.
  40. */
  41. #ifndef _BINKEY_H
  42. #define _BINKEY_H
  43. #include "tt_const.h"
  44. #include "util/tt_object.h"
  45. #include "util/tt_string.h"
  46. #include "db/tt_db_key.h"
  47. #include "db/tt_db_key_utils.h"
  48. #include <stdio.h>
  49. #include <memory.h>
  50. class Binkey : public _Tt_object {
  51. private:
  52. unsigned char _binkey[OID_KEY_LENGTH];
  53. _Tt_db_key_ptr _key;
  54. public:
  55. static Binkey smallest;
  56. static Binkey largest;
  57. Binkey();
  58. Binkey(const unsigned char *);
  59. ~Binkey() {};
  60. operator _Tt_string() const {return _key->string();};
  61. operator char*() const {return (char *)_binkey;};
  62. _Tt_db_key_ptr key() const {return _key;};
  63. friend int operator==(const Binkey &a, const Binkey &b);
  64. friend int operator!=(const Binkey &a, const Binkey &b) {
  65. return !(a==b);};
  66. friend int operator==(const Binkey &a, const _Tt_db_key &b);
  67. friend int operator!=(const Binkey &a, const _Tt_db_key &b) {
  68. return !(a==b);};
  69. friend int operator<(const Binkey &a, const Binkey &b);
  70. friend int operator>(const Binkey &a, const Binkey &b);
  71. Binkey &operator=(const Binkey &k);
  72. Binkey &operator=(const unsigned char *);
  73. virtual void print(FILE *f = stdout) const;
  74. };
  75. declare_list_of(Binkey)
  76. #endif /* _BINKEY_H */