Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

integer.h

Go to the documentation of this file.
00001 /*_############################################################################
00002   _## 
00003   _##  integer.h  
00004   _##
00005   _##  SNMP++v3.2.15
00006   _##  -----------------------------------------------
00007   _##  Copyright (c) 2001-2004 Jochen Katz, Frank Fock
00008   _##
00009   _##  This software is based on SNMP++2.6 from Hewlett Packard:
00010   _##  
00011   _##    Copyright (c) 1996
00012   _##    Hewlett-Packard Company
00013   _##  
00014   _##  ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
00015   _##  Permission to use, copy, modify, distribute and/or sell this software 
00016   _##  and/or its documentation is hereby granted without fee. User agrees 
00017   _##  to display the above copyright notice and this license notice in all 
00018   _##  copies of the software and any documentation of the software. User 
00019   _##  agrees to assume all liability for the use of the software; 
00020   _##  Hewlett-Packard and Jochen Katz make no representations about the 
00021   _##  suitability of this software for any purpose. It is provided 
00022   _##  "AS-IS" without warranty of any kind, either express or implied. User 
00023   _##  hereby grants a royalty-free license to any and all derivatives based
00024   _##  upon this software code base. 
00025   _##  
00026   _##  Stuttgart, Germany, Tue Jan  4 21:42:42 CET 2005 
00027   _##  
00028   _##########################################################################*/
00029 /*===================================================================
00030 
00031   Copyright (c) 1999
00032   Hewlett-Packard Company
00033 
00034   ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
00035   Permission to use, copy, modify, distribute and/or sell this software
00036   and/or its documentation is hereby granted without fee. User agrees
00037   to display the above copyright notice and this license notice in all
00038   copies of the software and any documentation of the software. User
00039   agrees to assume all liability for the use of the software; Hewlett-Packard
00040   makes no representations about the suitability of this software for any
00041   purpose. It is provided "AS-IS without warranty of any kind,either express
00042   or implied. User hereby grants a royalty-free license to any and all
00043   derivatives based upon this software code base.
00044 
00045                 
00046   SNMP++ I N T E G E R. H
00047 
00048   INTEGER CLASS DEFINITION
00049 
00050   DESIGN + AUTHOR:
00051   Jeff Meyer
00052 
00053   LANGUAGE:
00054   ANSI C++
00055 
00056   OPERATING SYSTEMS:
00057   MS-Windows Win32
00058   BSD UNIX
00059 
00060   DESCRIPTION:
00061   Class definition for Integer classes.
00062 
00063 =====================================================================*/
00064 // $Id: integer.h,v 1.6 2004/06/20 18:49:21 katz Exp $
00065 
00066 #ifndef _SNMPINTEGER
00067 #define _SNMPINTEGER
00068 
00069 #include "snmp_pp/smival.h"
00070 
00071 #ifdef SNMP_PP_NAMESPACE
00072 namespace Snmp_pp {
00073 #endif
00074 
00075 
00076 #define INTOUTBUF 15  // largest ASCII formatted integer
00077 
00078 //------------[ Integer Classes ]------------------------------------------
00079 
00080 /**
00081  * 32 bit unsigned integer class.
00082  *
00083  * The integer class allows all the functionality of the various
00084  * integers but is contained in a Value object for consistency
00085  * among the various types.
00086  * class objects may be set or get into Vb objects.
00087  */
00088 class DLLOPT SnmpUInt32 : public SnmpSyntax
00089 {
00090  public:
00091 
00092   /**
00093    * Constructor, sets value to zero.
00094    */
00095   SnmpUInt32();
00096 
00097   /**
00098    * Constructor with value.
00099    *
00100    * @param i - initial value
00101    */
00102   SnmpUInt32(const unsigned long i);
00103 
00104   /**
00105    * Copy constructor.
00106    *
00107    * @param c - initial value
00108    */
00109   SnmpUInt32( const SnmpUInt32 &c);
00110 
00111   /**
00112    * Destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden).
00113    */
00114   virtual ~SnmpUInt32() {};
00115 
00116   /**
00117    * Return the syntax.
00118    *
00119    * @return This method always returns sNMP_SYNTAX_UINT32.
00120    */
00121   virtual SmiUINT32 get_syntax() const { return sNMP_SYNTAX_UINT32; };
00122 
00123   /**
00124    * Overloaded assignment for unsigned longs.
00125    *
00126    * @param i - new value
00127    * @return self reference
00128    */
00129   SnmpUInt32& operator=(const unsigned long i);
00130 
00131   /**
00132    * Overloaded assignment for SnmpUInt32.
00133    *
00134    * @param uli - new value
00135    * @return self reference
00136    */
00137   SnmpUInt32& operator=(const SnmpUInt32 &uli);
00138 
00139   /**
00140    * Map other SnmpSyntax objects to SnmpUInt32.
00141    */
00142   SnmpSyntax& operator=(const SnmpSyntax &val);
00143 
00144   /**
00145    * Behave like an unsigned long.
00146    *
00147    * @return value as unsigned long
00148    */
00149   operator unsigned long() const { return smival.value.uNumber; };
00150 
00151   /**
00152    * Get a printable ASCII value.
00153    */
00154   virtual const char *get_printable() const;
00155 
00156   /**
00157    * Clone operator.
00158    *
00159    * @return Pointer to a newly created copy of the object.
00160    */
00161   virtual SnmpSyntax *clone() const
00162     { return (SnmpSyntax *)new SnmpUInt32(*this); };
00163 
00164   /**
00165    * Return validity of the object.
00166    * An SnmpUInt32 will only be invalid after a failed asignment
00167    * of another SnmpSyntax object.
00168    */
00169   bool valid() const { return valid_flag; };
00170 
00171   /**
00172    * Return the space needed for serialization.
00173    */
00174   int get_asn1_length() const;
00175 
00176   /**
00177    * Reset the object.
00178    */
00179   void clear() { smival.value.uNumber = 0; valid_flag = true; };
00180 
00181  protected:
00182   bool valid_flag;
00183   /*mutable*/ char output_buffer[INTOUTBUF];
00184 };
00185 
00186 
00187 /**
00188  * 32 bit signed integer class.
00189  */
00190 class DLLOPT SnmpInt32 : public SnmpSyntax
00191 {
00192  public:
00193 
00194   /**
00195    * Constructor, sets value to zero.
00196    */
00197   SnmpInt32();
00198 
00199   /**
00200    * Constructor with value.
00201    *
00202    * @param i - initial value
00203    */
00204   SnmpInt32 (const long i);
00205 
00206   /**
00207    * Copy constructor.
00208    *
00209    * @param c - initial value
00210    */
00211   SnmpInt32 (const SnmpInt32 &c);
00212 
00213   /**
00214    * Destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden).
00215    */
00216   virtual ~SnmpInt32() {};
00217 
00218   /**
00219    * Return the syntax.
00220    *
00221    * @return This method always returns sNMP_SYNTAX_INT32.
00222    */
00223   virtual SmiUINT32 get_syntax() const { return sNMP_SYNTAX_INT32; };
00224 
00225   /**
00226    * Overloaded assignment for longs.
00227    *
00228    * @param i - new value
00229    * @return self reference
00230    */
00231   SnmpInt32& operator=(const long i);
00232 
00233   /**
00234    * Overloaded assignment for SnmpInt32.
00235    *
00236    * @param li - new value
00237    * @return self reference
00238    */
00239   SnmpInt32& operator=(const SnmpInt32 &li);
00240 
00241   /**
00242    * Map other SnmpSyntax objects to SnmpInt32.
00243    */
00244   SnmpSyntax& operator=(const SnmpSyntax &val);
00245 
00246   /**
00247    * Behave like an long.
00248    *
00249    * @return value as long
00250    */
00251   operator long() const { return (long) smival.value.sNumber; };
00252 
00253   /**
00254    * Get a printable ASCII value.
00255    */
00256   const char *get_printable() const;
00257 
00258   /**
00259    * Clone operator.
00260    *
00261    * @return Pointer to a newly created copy of the object.
00262    */
00263   SnmpSyntax *clone() const { return ( SnmpSyntax *)new SnmpInt32(*this); };
00264 
00265   /**
00266    * Return validity of the object.
00267    * An SnmpUInt32 will only be invalid after a failed asignment
00268    * of another SnmpSyntax object.
00269    */
00270   bool valid() const { return valid_flag; };
00271 
00272   /**
00273    * Return the space needed for serialization.
00274    */
00275   int get_asn1_length() const;
00276 
00277   /**
00278    * Reset the object.
00279    */
00280   void clear() { smival.value.sNumber = 0; valid_flag = true; };
00281 
00282  protected:
00283   bool valid_flag;
00284   /*mutable*/ char output_buffer[INTOUTBUF];
00285 };
00286 
00287 #ifdef SNMP_PP_NAMESPACE
00288 }; // end of namespace Snmp_pp
00289 #endif 
00290 
00291 #endif

Generated on Tue Jan 4 22:42:13 2005 for SNMP++ by doxygen 1.3.2