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.

96 lines
2.6 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // snmpoid.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // Declares the class SnmpOid.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 09/10/1998 Original version.
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #ifndef _SNMPOID_H_
  19. #define _SNMPOID_H_
  20. #if _MSC_VER >= 1000
  21. #pragma once
  22. #endif
  23. #include <snmp.h>
  24. ///////////////////////////////////////////////////////////////////////////////
  25. //
  26. // CLASS
  27. //
  28. // SnmpOid
  29. //
  30. // DESCRIPTION
  31. //
  32. // Wrapper around an AsnObjectIdentifier struct.
  33. //
  34. ///////////////////////////////////////////////////////////////////////////////
  35. class SnmpOid
  36. {
  37. public:
  38. // Constructor.
  39. SnmpOid(AsnObjectIdentifier& a) throw ()
  40. : oid(a)
  41. { }
  42. // Assignment operator.
  43. SnmpOid& operator=(const AsnObjectIdentifier& a);
  44. // Returns the number of ID's forming the OID.
  45. ULONG length() const throw ()
  46. { return oid.idLength; }
  47. // Access an individual ID. Count is from the back. Does not check for
  48. // underflow.
  49. const UINT id(UINT pos) const throw ()
  50. { return oid.ids[oid.idLength - 1 - pos]; }
  51. UINT& id(UINT pos) throw ()
  52. { return oid.ids[oid.idLength - 1 - pos]; }
  53. // Returns true if this is a child of 'parent'.
  54. bool isChildOf(const AsnObjectIdentifier& parent) const throw ();
  55. // Changes the length of the OID.
  56. void resize(UINT newLength);
  57. // Cast operators allows this to be used with C API's.
  58. operator AsnObjectIdentifier*() const throw ()
  59. { return const_cast<AsnObjectIdentifier*>(&oid); }
  60. operator AsnObjectIdentifier&() const throw ()
  61. { return const_cast<AsnObjectIdentifier&>(oid); }
  62. // Comparison operators.
  63. bool SnmpOid::operator<(const AsnObjectIdentifier& a) const throw ()
  64. { return SnmpUtilOidCmp(*this, const_cast<AsnObjectIdentifier*>(&a)) < 0; }
  65. bool SnmpOid::operator<=(const AsnObjectIdentifier& a) const throw ()
  66. { return SnmpUtilOidCmp(*this, const_cast<AsnObjectIdentifier*>(&a)) <= 0; }
  67. bool SnmpOid::operator==(const AsnObjectIdentifier& a) const throw ()
  68. { return SnmpUtilOidCmp(*this, const_cast<AsnObjectIdentifier*>(&a)) == 0; }
  69. bool SnmpOid::operator>=(const AsnObjectIdentifier& a) const throw ()
  70. { return SnmpUtilOidCmp(*this, const_cast<AsnObjectIdentifier*>(&a)) >= 0; }
  71. bool SnmpOid::operator>(const AsnObjectIdentifier& a) const throw ()
  72. { return SnmpUtilOidCmp(*this, const_cast<AsnObjectIdentifier*>(&a)) > 0; }
  73. protected:
  74. AsnObjectIdentifier& oid;
  75. private:
  76. // Not implemented.
  77. SnmpOid(const SnmpOid&);
  78. };
  79. #endif // _SNMPOID_H_