Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / ASNMP / asnmp / octet.h
blob3d41450ae85e43960a05d71742975a9b338f8bbc
3 #ifndef OCTET_CLS_
4 #define OCTET_CLS_
5 //=============================================================================
6 /**
7 * @file octet.h
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++.
13 * @author Peter E Mellquist / design/original code Michael R. MacFaden / modified for ACE
15 //=============================================================================
17 /*===================================================================
18 Copyright (c) 1996
19 Hewlett-Packard Company
21 ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
22 Permission to use, copy, modify, distribute and/or sell this software
23 and/or its documentation is hereby granted without fee. User agrees
24 to display the above copyright notice and this license notice in all
25 copies of the software and any documentation of the software. User
26 agrees to assume all liability for the use of the software; Hewlett-Packard
27 makes no representations about the suitability of this software for any
28 purpose. It is provided "AS-IS without warranty of any kind,either express
29 or implied. User hereby grants a royalty-free license to any and all
30 derivatives based upon this software code base.
31 =====================================================================*/
33 //------------------------------------------------------------------------
34 #include "asnmp/smival.h"
36 /**
37 * @class OctetStr
39 * @brief Implement RFC1155 Octet SMI data object
41 class ASNMP_Export OctetStr : public SnmpSyntax
44 public:
45 /// construct octet from byte buffer, assume c style string if size == -1
46 OctetStr( const char *string = "", long size = -1);
48 /// constructor using another octet object
49 OctetStr ( const OctetStr &octet);
51 /// destructor
52 ~OctetStr();
54 /// syntax type
55 SmiUINT32 get_syntax();
57 /// set octet from byte buffer, assume c style string if size == -1
58 void set_data( const SmiBYTE* string, long int size = -1);
60 /// assignment to a string operator overloaded
61 OctetStr& operator=( const char *string);
63 /// assignment to another oid object overloaded
64 OctetStr& operator=( const OctetStr &octet);
66 /// equivlence operator overloaded
67 friend ASNMP_Export bool operator==( const OctetStr &lhs, const OctetStr &rhs);
69 /// not equivlence operator overloaded
70 friend ASNMP_Export bool operator!=( const OctetStr &lhs, const OctetStr &rhs);
72 /// less than < overloaded
73 friend ASNMP_Export bool operator<( const OctetStr &lhs, const OctetStr &rhs);
75 /// less than <= overloaded
76 friend ASNMP_Export bool operator<=( const OctetStr &lhs,const OctetStr &rhs);
78 /// greater than > overloaded
79 friend ASNMP_Export bool operator>( const OctetStr &lhs, const OctetStr &rhs);
81 /// greater than >= overloaded
82 friend ASNMP_Export bool operator>=( const OctetStr &lhs, const OctetStr &rhs);
84 /// equivlence operator overloaded
85 friend ASNMP_Export bool operator==( const OctetStr &lhs,const char *rhs);
87 /// not equivlence operator overloaded
88 friend ASNMP_Export bool operator!=( const OctetStr &lhs,const char *rhs);
90 /// less than < operator overloaded
91 friend ASNMP_Export bool operator<( const OctetStr &lhs,const char *rhs);
93 /// less than <= operator overloaded
94 friend ASNMP_Export bool operator<=( const OctetStr &lhs,char *rhs);
96 /// greater than > operator overloaded
97 friend ASNMP_Export bool operator>( const OctetStr &lhs,const char *rhs);
99 /// greater than >= operator overloaded
100 friend ASNMP_Export bool operator>=( const OctetStr &lhs,const char *rhs);
102 /// append operator, appends a string
103 OctetStr& operator+=( const char *a);
105 /// appends an int
106 OctetStr& operator+=( const char c);
108 /// append one octetStr to another
109 OctetStr& operator+=( const OctetStr& octetstr);
111 /// for non const [], allows reading and writing
112 SmiBYTE& operator[]( int position);
115 * compare the n leftmost bytes (left-to-right)
116 * returns 0, equal
117 * returns -1, <
118 * returns 1 , >
120 int left_comparison( const long n, const OctetStr &o) const;
122 /// return the len of the oid
123 size_t length() const ;
125 /// returns validity
126 int valid() const;
128 /// returns pointer to internal data
129 SmiBYTE *data() const;
131 /// get a printable ASCII value
132 const char *to_string();
134 /// get an ASCII formattted hex dump of the contents
135 const char *to_string_hex();
137 /// create a new instance of this Value
138 SnmpSyntax *clone() const;
140 /// copy an instance of this Value
141 SnmpSyntax& operator=( SnmpSyntax &val);
143 protected:
144 //----[ instance variables ]
145 char *output_buffer; // formatted Octet value
146 int validity; // validity boolean
149 #endif // OCTET_CLS_