5 //=============================================================================
9 * This class is fully contained and does not rely on or any other
10 * SNMP libraries. This class is portable across any platform
11 * which supports C++. Ported to ACE by Mike MacFaden mrm@cisco.com
12 * and modified for MT. Some API cleanup: collapse constructors,
13 * add suboid() method remove unnecessary overload, and update a few
14 * names and types to improve clarity.
16 * @author Peter E Mellquist
18 //=============================================================================
20 /*===================================================================
22 Hewlett-Packard Company
24 ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
25 Permission to use, copy, modify, distribute and/or sell this software
26 and/or its documentation is hereby granted without fee. User agrees
27 to display the above copyright notice and this license notice in all
28 copies of the software and any documentation of the software. User
29 agrees to assume all liability for the use of the software; Hewlett-Packard
30 makes no representations about the suitability of this software for any
31 purpose. It is provided "AS-IS without warranty of any kind,either express
32 or implied. User hereby grants a royalty-free license to any and all
33 derivatives based upon this software code base.
34 =====================================================================*/
36 //----------[ extern C libraries Needed ]---------------------------------
37 #include "ace/config-all.h"
39 #if !defined (ACE_LACKS_PRAGMA_ONCE)
41 #endif /* ACE_LACKS_PRAGMA_ONCE */
43 #include "asnmp/smival.h" // derived class for all values
48 * @brief Implement RFC 1155 Object Identifier (OID) datatype
50 class ASNMP_Export Oid
: public SnmpSyntax
53 /// constructor using a dotted string
54 Oid( const char * dotted_oid_string
= "", size_t size
= unsigned(-1) );
56 /// constructor using another oid object
57 Oid ( const Oid
&oid
);
59 /// constructor from raw form
60 Oid(const unsigned long *raw_oid
, size_t oid_len
);
66 SmiUINT32
get_syntax();
68 /// assignment to another oid object overloaded
69 Oid
& operator=( const Oid
&oid
);
71 /// equal operator overloaded
72 friend ASNMP_Export
bool operator==( const Oid
&lhs
,const Oid
&rhs
);
74 /// not equal operator overloaded
75 friend ASNMP_Export
bool operator!=( const Oid
&lhs
,const Oid
&rhs
);
77 /// less than < overloaded
78 friend ASNMP_Export
bool operator<( const Oid
&lhs
,const Oid
&rhs
);
80 /// less than <= overloaded
81 friend ASNMP_Export
bool operator<=( const Oid
&lhs
,const Oid
&rhs
);
83 /// greater than > overloaded
84 friend ASNMP_Export
bool operator>( const Oid
&lhs
,const Oid
&rhs
);
86 /// greater than >= overloaded
87 friend ASNMP_Export
bool operator>=( const Oid
&lhs
,const Oid
&rhs
);
89 /// append operator, appends a string
90 Oid
& operator+=( const char *a
);
93 Oid
& operator+=( const unsigned long i
);
96 Oid
& operator+=( const Oid
&o
);
98 /// allows element access
99 unsigned long & operator[]( size_t position
);
101 /// return the WinSnmp oid part
104 /// reset the data from raw 1 byte format
105 void set_data( const char *dotted_oid_string
);
107 /// reset the data from raw 4byte integer format
108 void set_data( const unsigned long *raw_oid
, const size_t oid_len
);
110 /// return the len of the oid
111 size_t length() const;
113 /// trim off the n rightmost values of an oid
114 void trim( const size_t how_many
= 1);
116 /// the equivalent of a substr(new_str, 0, 1)
117 int suboid(Oid
& oid
, size_t start
= 0, size_t how_many
= size_t (-1));
120 * compare the n leftmost bytes (left-to-right)
125 int left_comparison( const unsigned long n
, const Oid
&o
) const;
129 * compare the n rightmost bytes (right-to-left)
134 int right_comparison( const unsigned long n
, const Oid
&o
) const;
136 /// is the Oid object valid
139 /// return dotted string value from the right
140 /// where the user specifies how many positions to print
141 const char *to_string();
143 /// create a new instance of this Value
144 SnmpSyntax
*clone() const;
146 /// copy an instance of this Value
147 SnmpSyntax
& operator=( SnmpSyntax
&val
);
150 /// used for returning oid string
153 /// convert a string to an smi oid
154 int StrToOid( const char *string
, SmiLPOID dstOid
, size_t& how_many_bytes
);
157 int OidCopy( SmiLPOID srcOid
, SmiLPOID dstOid
, size_t& how_many_bytes
);
159 /// convert an smi oid to its string representation
160 int OidToStr(SmiLPOID srcOid
, SmiUINT32 size
, char *string
, size_t& how_many_bytes
);
163 /// release memory, re-init data members
166 /// initialize object data members
168 void init_value( const SmiLPOID srcOid
, size_t len
);
169 void init_value(const unsigned long *raw_oid
, size_t oid_len
);