5 #include "numericoid.hpp"
8 namespace dangerous {
namespace snmp {
114 _type = variant._type;
117 v.i32 = variant.v.i32;
119 v.u32 = variant.v.u32;
121 v.u64 = variant.v.u64;
123 new( &v.s ) std::string();
125 }
else if( variant.
is_oid() ) {
127 v.oid = variant.v.oid;
135 _type = variant._type;
138 v.i32 = variant.v.i32;
140 v.u32 = variant.v.u32;
142 v.u64 = variant.v.u64;
144 new( &v.s ) std::string();
146 }
else if( variant.
is_oid() ) {
148 v.oid = variant.v.oid;
242 switch( this->_type ) {
244 v.s.std::string::~string();
271 throw InvalidTypeException(
"Invalid type for int32_t." );
293 throw InvalidTypeException(
"Invalid type for uint32_t." );
313 throw InvalidTypeException(
"Invalid type for uint64_t." );
332 new( &v.s ) std::string();
336 throw InvalidTypeException(
"Invalid type for std::string." );
357 throw InvalidTypeException(
"Invalid type for NumericOid." );
422 throw InvalidTypeException(
"Invalid type for int32_t." );
457 throw InvalidTypeException(
"Invalid type for uint32_t." );
488 throw InvalidTypeException(
"Invalid type for uint64_t." );
523 throw InvalidTypeException(
"Invalid type for std::string." );
554 throw InvalidTypeException(
"Invalid type for NumericOid." );
560 switch( variant.
type() ) {
592 out <<
"noSuchObject";
595 out <<
"noSuchInstance";
598 out <<
"endOfMibView";
Stored as v.oid.
Definition: variant.hpp:91
~Variant()
Destructor; all memory is freed.
Definition: variant.hpp:159
Functionally SIMPLE_NULL.
Definition: variant.hpp:101
std::ostream & operator<<(std::ostream &out, const Variant &variant)
Definition: variant.hpp:559
Functionally SIMPLE_NULL.
Definition: variant.hpp:99
void set_oid(Type type, NumericOid oid=NumericOid())
This sets the value to an OID.
Definition: variant.hpp:349
std::string str() const
This returns a string representing the OID.
A Variant defines an arbitrary value (within the scope of SNMP).
Definition: variant.hpp:78
bool is_string() const
This returns whether or not the Variant represents a string.
Definition: variant.hpp:498
Stored as v.u64.
Definition: variant.hpp:98
Functionally SIMPLE_NULL.
Definition: variant.hpp:100
Stored as v.s.
Definition: variant.hpp:97
bool is_uint32_t() const
This returns whether or not the Variant represents a 32-bit unsigned integer.
Definition: variant.hpp:432
Not stored.
Definition: variant.hpp:92
Stored as v.u32.
Definition: variant.hpp:96
Variant(const Variant &variant)
Copy constructor; the Variant is set to a copy of the given one.
Definition: variant.hpp:113
Stored as v.u32.
Definition: variant.hpp:95
uint32_t get_uint32_t() const
This returns the 32-bit unsigned integer value of the Variant.
Definition: variant.hpp:450
A NumericOid represents an "true" OID; that is, one identified by a series of integers (as opposed to...
Definition: numericoid.hpp:22
Stored as v.i32.
Definition: variant.hpp:89
Variant()
Default constructor; the Variant is set to a null value.
Definition: variant.hpp:108
bool is_uint64_t() const
This returns whether or not the Variant represents a 64-bit unsigned integer.
Definition: variant.hpp:467
void set_null(Type type)
This restores the Variant to its default, null state.
Definition: variant.hpp:228
void set_string(Type type, std::string string=std::string())
This sets the value to a string.
Definition: variant.hpp:326
uint64_t get_uint64_t() const
This returns the 64-bit unsigned integer value of the Variant.
Definition: variant.hpp:483
bool is_int32_t() const
This returns whether or not the Variant represents a 32-bit signed integer.
Definition: variant.hpp:401
bool is_null() const
This returns whether or not the Variant represents a null value.
Definition: variant.hpp:383
void set_uint32_t(Type type, uint32_t u32=0)
This sets the value to an unsigned, 32-bit integer.
Definition: variant.hpp:284
int32_t get_int32_t() const
This returns the 32-bit signed integer value of the Variant.
Definition: variant.hpp:417
Variant & operator=(const Variant &variant)
Assignment operator; the Variant is set to a copy of the given one.
Definition: variant.hpp:134
Type type() const
This returns the type of the Variant.
Definition: variant.hpp:167
void set_uint64_t(Type type, uint64_t u64=0)
This sets the value to an unsigned, 64-bit integer.
Definition: variant.hpp:306
This represents a failed type conversion or use.
Definition: exception.hpp:116
bool is_oid() const
This returns whether or not the Variant represents an OID.
Definition: variant.hpp:533
Type
This enumeration defines the different types of data that can be represented by this Variant...
Definition: variant.hpp:88
const NumericOid & get_oid() const
This returns the OID value of the Variant.
Definition: variant.hpp:549
Stored as v.s.
Definition: variant.hpp:90
void set_int32_t(Type type, int32_t i32=0)
This sets the value to a signed, 32-bit integer.
Definition: variant.hpp:264
Stored as v.s.
Definition: variant.hpp:93
const std::string & get_string() const
This returns the string value of the Variant.
Definition: variant.hpp:516
Stored as v.u32.
Definition: variant.hpp:94