1 /*_############################################################################
6 _## -----------------------------------------------
7 _## Copyright (c) 2001-2010 Jochen Katz, Frank Fock
9 _## This software is based on SNMP++2.6 from Hewlett Packard:
11 _## Copyright (c) 1996
12 _## Hewlett-Packard Company
14 _## ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
15 _## Permission to use, copy, modify, distribute and/or sell this software
16 _## and/or its documentation is hereby granted without fee. User agrees
17 _## to display the above copyright notice and this license notice in all
18 _## copies of the software and any documentation of the software. User
19 _## agrees to assume all liability for the use of the software;
20 _## Hewlett-Packard and Jochen Katz make no representations about the
21 _## suitability of this software for any purpose. It is provided
22 _## "AS-IS" without warranty of any kind, either express or implied. User
23 _## hereby grants a royalty-free license to any and all derivatives based
24 _## upon this software code base.
26 _## Stuttgart, Germany, Thu Sep 2 00:07:47 CEST 2010
28 _##########################################################################*/
29 /*===================================================================
32 Hewlett-Packard Company
34 ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
35 Permission to use, copy, modify, distribute and/or sell this software
36 and/or its documentation is hereby granted without fee. User agrees
37 to display the above copyright notice and this license notice in all
38 copies of the software and any documentation of the software. User
39 agrees to assume all liability for the use of the software; Hewlett-Packard
40 makes no representations about the suitability of this software for any
41 purpose. It is provided "AS-IS without warranty of any kind,either express
42 or implied. User hereby grants a royalty-free license to any and all
43 derivatives based upon this software code base.
46 SNMP++ I N T E G E R. H
48 INTEGER CLASS DEFINITION
50 DESIGN + AUTHOR: Jeff Meyer
53 Class definition for Integer classes.
55 =====================================================================*/
56 // $Id: integer.h 1541 2009-05-29 11:29:22Z katz $
61 #include "snmp_pp/smival.h"
63 #ifdef SNMP_PP_NAMESPACE
67 #define INTOUTBUF 15 // largest ASCII formatted integer
69 //------------[ Integer Classes ]------------------------------------------
72 * 32 bit unsigned integer class.
74 * The integer class allows all the functionality of the various
75 * integers but is contained in a Value object for consistency
76 * among the various types.
77 * class objects may be set or get into Vb objects.
79 class DLLOPT SnmpUInt32 : public SnmpSyntax
84 * Constructor, sets value to zero.
89 * Constructor with value.
91 * @param i - initial value
93 SnmpUInt32(const unsigned long i);
98 * @param c - initial value
100 SnmpUInt32(const SnmpUInt32 &c);
103 * Destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden).
105 virtual ~SnmpUInt32() {};
110 * @return This method always returns sNMP_SYNTAX_UINT32.
112 virtual SmiUINT32 get_syntax() const { return sNMP_SYNTAX_UINT32; };
115 * Overloaded assignment for unsigned longs.
117 * @param i - new value
118 * @return self reference
120 SnmpUInt32& operator=(const unsigned long i);
123 * Overloaded assignment for SnmpUInt32.
125 * @param uli - new value
126 * @return self reference
128 SnmpUInt32& operator=(const SnmpUInt32 &uli);
131 * Map other SnmpSyntax objects to SnmpUInt32.
133 SnmpSyntax& operator=(const SnmpSyntax &val);
136 * Behave like an unsigned long.
138 * @return value as unsigned long
140 operator unsigned long() const { return smival.value.uNumber; };
143 * Get a printable ASCII value.
145 virtual const char *get_printable() const;
150 * @return Pointer to a newly created copy of the object.
152 virtual SnmpSyntax *clone() const
153 { return (SnmpSyntax *)new SnmpUInt32(*this); };
156 * Return validity of the object.
157 * An SnmpUInt32 will only be invalid after a failed asignment
158 * of another SnmpSyntax object.
160 bool valid() const { return valid_flag; };
163 * Return the space needed for serialization.
165 int get_asn1_length() const;
171 { smival.value.uNumber = 0; valid_flag = true; m_changed = true; };
175 SNMP_PP_MUTABLE char output_buffer[INTOUTBUF];
176 SNMP_PP_MUTABLE bool m_changed;
181 * 32 bit signed integer class.
183 class DLLOPT SnmpInt32 : public SnmpSyntax
188 * Constructor, sets value to zero.
193 * Constructor with value.
195 * @param i - initial value
197 SnmpInt32 (const long i);
202 * @param c - initial value
204 SnmpInt32 (const SnmpInt32 &c);
207 * Destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden).
209 virtual ~SnmpInt32() {};
214 * @return This method always returns sNMP_SYNTAX_INT32.
216 virtual SmiUINT32 get_syntax() const { return sNMP_SYNTAX_INT32; };
219 * Overloaded assignment for longs.
221 * @param i - new value
222 * @return self reference
224 SnmpInt32& operator=(const long i);
227 * Overloaded assignment for SnmpInt32.
229 * @param li - new value
230 * @return self reference
232 SnmpInt32& operator=(const SnmpInt32 &li);
235 * Map other SnmpSyntax objects to SnmpInt32.
237 SnmpSyntax& operator=(const SnmpSyntax &val);
240 * Behave like an long.
242 * @return value as long
244 operator long() const { return (long) smival.value.sNumber; };
247 * Get a printable ASCII value.
249 const char *get_printable() const;
254 * @return Pointer to a newly created copy of the object.
256 SnmpSyntax *clone() const { return (SnmpSyntax *)new SnmpInt32(*this); };
259 * Return validity of the object.
260 * An SnmpUInt32 will only be invalid after a failed asignment
261 * of another SnmpSyntax object.
263 bool valid() const { return valid_flag; };
266 * Return the space needed for serialization.
268 int get_asn1_length() const;
274 { smival.value.sNumber = 0; valid_flag = true; m_changed = true; };
278 SNMP_PP_MUTABLE char output_buffer[INTOUTBUF];
279 SNMP_PP_MUTABLE bool m_changed;
282 #ifdef SNMP_PP_NAMESPACE
283 } // end of namespace Snmp_pp