summaryrefslogtreecommitdiffstats
path: root/src/lib/dns/messagerenderer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/dns/messagerenderer.h')
-rw-r--r--src/lib/dns/messagerenderer.h38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/lib/dns/messagerenderer.h b/src/lib/dns/messagerenderer.h
index 52d9245211..4673861674 100644
--- a/src/lib/dns/messagerenderer.h
+++ b/src/lib/dns/messagerenderer.h
@@ -102,29 +102,32 @@ protected:
/// This is intentionally defined as \c protected as this base class should
/// never be instantiated (except as part of a derived class).
/// \param buffer The buffer where the data should be rendered into.
+ ///
+ /// We are now doing this:
/// \todo We might want to revisit this API at some point and remove the
/// buffer parameter. In that case it would create it's own buffer and
/// a function to extract the data would be available instead. It seems
/// like a cleaner design, but it's left undone until we would actually
/// benefit from the change.
- AbstractMessageRenderer(isc::util::OutputBuffer& buffer) :
- buffer_(buffer)
- {}
+ AbstractMessageRenderer();
public:
/// \brief The destructor.
virtual ~AbstractMessageRenderer() {}
//@}
protected:
/// \brief Return the output buffer we render into.
- const isc::util::OutputBuffer& getBuffer() const { return (buffer_); }
- isc::util::OutputBuffer& getBuffer() { return (buffer_); }
+ const isc::util::OutputBuffer& getBuffer() const { return (*buffer_); }
+ isc::util::OutputBuffer& getBuffer() { return (*buffer_); }
private:
+ /// \short Local (default) buffer to store data.
+ isc::util::OutputBuffer local_buffer_;
+
/// \short Buffer to store data
///
/// It was decided that there's no need to have this in every subclass,
/// at least not now, and this reduces code size and gives compiler a better
/// chance to optimise.
- isc::util::OutputBuffer& buffer_;
+ isc::util::OutputBuffer* buffer_;
public:
///
/// \name Getter Methods
@@ -136,12 +139,12 @@ public:
/// This method works exactly same as the same method of the \c OutputBuffer
/// class; all notes for \c OutputBuffer apply.
const void* getData() const {
- return (buffer_.getData());
+ return (buffer_->getData());
}
/// \brief Return the length of data written in the internal buffer.
size_t getLength() const {
- return (buffer_.getLength());
+ return (buffer_->getLength());
}
/// \brief Return whether truncation has occurred while rendering.
@@ -209,7 +212,7 @@ public:
///
/// \param len The length of the gap to be inserted in bytes.
void skip(size_t len) {
- buffer_.skip(len);
+ buffer_->skip(len);
}
/// \brief Trim the specified length of data from the end of the internal
@@ -223,7 +226,7 @@ public:
///
/// \param len The length of data that should be trimmed.
void trim(size_t len) {
- buffer_.trim(len);
+ buffer_->trim(len);
}
/// \brief Clear the internal buffer and other internal resources.
@@ -236,7 +239,7 @@ public:
///
/// \param data The 8-bit integer to be written into the internal buffer.
void writeUint8(const uint8_t data) {
- buffer_.writeUint8(data);
+ buffer_->writeUint8(data);
}
/// \brief Write an unsigned 16-bit integer in host byte order into the
@@ -244,7 +247,7 @@ public:
///
/// \param data The 16-bit integer to be written into the buffer.
void writeUint16(uint16_t data) {
- buffer_.writeUint16(data);
+ buffer_->writeUint16(data);
}
/// \brief Write an unsigned 16-bit integer in host byte order at the
@@ -259,7 +262,7 @@ public:
/// \param data The 16-bit integer to be written into the internal buffer.
/// \param pos The beginning position in the buffer to write the data.
void writeUint16At(uint16_t data, size_t pos) {
- buffer_.writeUint16At(data, pos);
+ buffer_->writeUint16At(data, pos);
}
/// \brief Write an unsigned 32-bit integer in host byte order into the
@@ -267,7 +270,7 @@ public:
///
/// \param data The 32-bit integer to be written into the buffer.
void writeUint32(uint32_t data) {
- buffer_.writeUint32(data);
+ buffer_->writeUint32(data);
}
/// \brief Copy an arbitrary length of data into the internal buffer
@@ -278,7 +281,7 @@ public:
/// \param data A pointer to the data to be copied into the internal buffer.
/// \param len The length of the data in bytes.
void writeData(const void *data, size_t len) {
- buffer_.writeData(data, len);
+ buffer_->writeData(data, len);
}
/// \brief Write a \c Name object into the internal buffer in wire format,
@@ -316,10 +319,7 @@ public:
using AbstractMessageRenderer::CASE_SENSITIVE;
/// \brief Constructor from an output buffer.
- ///
- /// \param buffer An \c OutputBuffer object to which wire format data is
- /// written.
- MessageRenderer(isc::util::OutputBuffer& buffer);
+ MessageRenderer();
virtual ~MessageRenderer();
virtual bool isTruncated() const;