3 #include "berstream.hpp"
4 #include "bytestream.hpp"
11 namespace dangerous {
namespace snmp {
28 template <
typename EncodingClass>
29 static std::string
encodeToString(
typename EncodingClass::value_type& value ) {
36 bool success = berStream.
write<EncodingClass>( value );
38 throw Exception( std::string(
"Could not encode ") + EncodingClass::NAME );
43 std::string returnValue;
45 byteStream.
copyTo( returnValue );
56 template <
typename EncodingClass>
57 static std::vector<char>
encodeToVector(
typename EncodingClass::value_type& value ) {
64 bool success = berStream.
write<EncodingClass>( value );
66 throw Exception( std::string(
"Could not encode ") + EncodingClass::NAME );
71 std::vector<char> returnValue;
73 byteStream.
copyTo( returnValue );
bool write(const typename EncodingClass::value_type &value)
This performs a full, logical write of a kind of encoded data.
Definition: berstream.hpp:207
A ByteStream is an object that is basically a big wrapper around a character buffer.
Definition: bytestream.hpp:30
This class is a "helper" class that takes some kind of thing and returns a standard string that repre...
Definition: encoder.hpp:20
static std::string encodeToString(typename EncodingClass::value_type &value)
This BER-encodes a value and returns a standard string of the result.
Definition: encoder.hpp:29
A BerStream represents a BER-encoded stream of data.
Definition: berstream.hpp:16
static std::vector< char > encodeToVector(typename EncodingClass::value_type &value)
This BER-encodes a value and returns a standard vector of the result.
Definition: encoder.hpp:57
This defines the base exception class for Dangerous SNMP.
Definition: exception.hpp:10
void copyTo(std::vector< char > &buffer) const
This copies the portion of the ByteStream that's currently available for reading to the specified tar...