Represents an SNMP object identifier (OID). More...
#include <Oid.hpp>
Inherits QVector< quint32 >.
Public Member Functions | |
Oid (std::string id="") | |
Initialize an Oid object with an OID in string format. More... | |
Oid (const Oid &o, std::string id) | |
Initialize an Oid object with another Oid plus a subid. More... | |
Oid (const Oid &o, quint32 id) | |
Initialize an Oid object with another Oid plus a subid. More... | |
Oid & | operator= (const Oid &o) |
Assignment operator. More... | |
bool | operator< (const Oid &o) const |
The less-than operator. More... | |
bool | operator<= (const Oid &o) const |
The less-than-or-equal operator. More... | |
bool | operator== (const Oid &o) const |
The equal-operator. More... | |
bool | operator!= (const Oid &o) const |
The not-equal-operator for OIDs. More... | |
bool | operator> (const Oid &o) const |
The greater-than operator. More... | |
bool | operator>= (const Oid &o) const |
The greater-than-or-equal operator. More... | |
Oid | operator+ (quint32 subid) const |
Concatenation. More... | |
Oid | operator+ (const Oid &o) const |
Concatenation. More... | |
Oid & | operator+= (const Oid &o) |
Concatenation. More... | |
bool | contains (const Oid &id) const |
Checks whether the given Oid is in the subtree of this Oid. More... | |
Public Attributes | |
const Oid | iso_oid ("1") |
The 'iso' OID according to RFC 1155. More... | |
const Oid | ccitt_oid ("0") |
The 'ccitt' OID according to RFC 1155. More... | |
const Oid | joint_iso_ccitt_oid ("2") |
The 'joint.iso.ccitt' OID according to RFC 1155. More... | |
const Oid | org_oid (iso_oid,"3") |
The 'iso.org' OID according to RFC 1155. More... | |
const Oid | dod_oid (org_oid,"6") |
The 'iso.org.dod' OID according to RFC 1155. More... | |
const Oid | internet_oid (dod_oid,"1") |
The 'iso.org.dod.internet' OID according to RFC 1155. More... | |
const Oid | directory_oid (internet_oid,"1") |
The 'iso.org.dod.internet.directory' OID according to RFC 1155. More... | |
const Oid | mgmt_oid (internet_oid,"2") |
The 'iso.org.dod.internet.mgmt' OID according to RFC 1155. More... | |
const Oid | experimental_oid (internet_oid,"3") |
The 'iso.org.dod.internet.experimental' OID according to RFC 1155. More... | |
const Oid | private_oid (internet_oid,"4") |
The 'iso.org.dod.internet.private' OID according to RFC 1155. More... | |
const Oid | enterprises_oid (private_oid,"1") |
The 'iso.org.dod.internet.private.enterprises' OID according to RFC 1155. More... | |
const Oid | snmpMIBObjects_oid (internet_oid,"6.3.1.1") |
The 'snmpMIBObjects' OID according to RFC 1907. More... | |
const Oid | snmpTrapOID_oid (snmpMIBObjects_oid,"4.1") |
The 'snmpTrapOID' OID according to RFC 1907. More... | |
const Oid | sysUpTime_oid (mgmt_oid,"1.1.3") |
The sysUpTime_oid OID according to RFC 1907. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const Oid &o) |
The output operator for the Oid class. More... | |
Represents an SNMP object identifier (OID).
This class represents an OID. OID's are sequences of sub-identifiers, which are integers.
This class provides constructors taking a string which contains an OID. For example, this works:
Also a constructor is provided which takes an Oid and a string and concatenates them, so this works also:
In addition, some common Oid's are provided as constants, e.g. 'enterprises_oid', so the following will also work:
The string given to the constructors must have a valid syntax. If a malformed string is provided, inval_param is thrown and the object is not constructed. For example, the following strings are malformed:
However, the following strings are accepted:
This class inherits from QVector<quint32>, which means that an Oid object can be manipulated the same way as a QVector<> can be manipulated:
Oid::Oid | ( | std::string | id = "" | ) |
Initialize an Oid object with an OID in string format.
This constructor takes a string and initializes the Oid object with the OID contained within this string. The format of the string is described above.
id | The initial object identifier. |
inval_param | If the string is malformed. |
Oid::Oid | ( | const Oid & | o, |
std::string | id | ||
) |
Initialize an Oid object with another Oid plus a subid.
All subid's are copied from 'o'. Then, the OID contained within the string 'id' is appended. The format of the string is described in the documentation of this class.
o | The starting OID. |
id | The OID to append. |
inval_param | If the string is malformed. |
Oid::Oid | ( | const Oid & | o, |
quint32 | id | ||
) |
bool Oid::contains | ( | const Oid & | id | ) | const |
|
inline |
The not-equal-operator for OIDs.
See operator<() for a more detailed description about comparing OIDs.
o | The OID to compare to. |
|
inline |
bool Oid::operator< | ( | const Oid & | o | ) | const |
The less-than operator.
An OID is less than another OID if either the first not-identical part is lesser or if all parts are identical and it has lesser parts.
Example:
1.3.6.1.4.1.42.3.3.1
is less than
1.3.6.1.4.1.42.3.4.1
Note the next to last number.
Also,
1.3.6.1.4.1.42.3.3.1
is less than
1.3.6.1.4.1.42.3.3.1.1
because it is shorter.
However,
1.3.6.1.4.1.42.3.3.1
is greater than
1.3.6.1.4.1.42.3.2.1.1
because the 9th number is greater (although the first OID has less numbers than the second).
o | The OID to compare to. |
|
inline |
The less-than-or-equal operator.
See operator<() for a more detailed description about comparing OIDs.
o | The OID to compare to. |
Assignment operator.
Copies all data from 'o' into this OID.
o | The OID to copy from. |
bool Oid::operator== | ( | const Oid & | o | ) | const |
The equal-operator.
See operator<() for a more detailed description about comparing OIDs.
o | The OID to compare to. |
|
inline |
The greater-than operator.
See operator<() for a more detailed description about comparing OIDs.
o | The OID to compare to. |
|
inline |
The greater-than-or-equal operator.
See operator<() for a more detailed description about comparing OIDs.
o | The OID to compare to. |
|
friend |
The output operator for the Oid class.
Object identifiers (Oid objects) can be output as follows:
The last line will output "LED state OID: .1.3.6.1.4.1.3.3.1".
out | The stream to which to write the output. |
o | The OID to output. |
const Oid ccitt_oid("0") |
The 'ccitt' OID according to RFC 1155.
const Oid directory_oid(internet_oid,"1") |
The 'iso.org.dod.internet.directory' OID according to RFC 1155.
const Oid enterprises_oid(private_oid,"1") |
The 'iso.org.dod.internet.private.enterprises' OID according to RFC 1155.
const Oid experimental_oid(internet_oid,"3") |
The 'iso.org.dod.internet.experimental' OID according to RFC 1155.
const Oid iso_oid("1") |
The 'iso' OID according to RFC 1155.
const Oid joint_iso_ccitt_oid("2") |
The 'joint.iso.ccitt' OID according to RFC 1155.
const Oid mgmt_oid(internet_oid,"2") |
The 'iso.org.dod.internet.mgmt' OID according to RFC 1155.
const Oid private_oid(internet_oid,"4") |
The 'iso.org.dod.internet.private' OID according to RFC 1155.
const Oid snmpMIBObjects_oid(internet_oid,"6.3.1.1") |
The 'snmpMIBObjects' OID according to RFC 1907.
const Oid snmpTrapOID_oid(snmpMIBObjects_oid,"4.1") |
The 'snmpTrapOID' OID according to RFC 1907.