void toWire(AbstractMessageRenderer& renderer, TSIGContext* tsig_ctx);
};
+/// @brief Pointer to the @ref MessageImpl object.
+typedef boost::shared_ptr<MessageImpl> MessageImplPtr;
+
MessageImpl::MessageImpl(Message::Mode mode) :
mode_(mode),
- rcode_placeholder_(Rcode(0)), // as a placeholder the value doesn't matter
- opcode_placeholder_(Opcode(0)) // ditto
-{
+ rcode_placeholder_(Rcode(0)), // for placeholders the value doesn't matter
+ opcode_placeholder_(Opcode(0)) {
init();
}
struct RenderSection {
RenderSection(AbstractMessageRenderer& renderer, const bool partial_ok) :
counter_(0), renderer_(renderer), partial_ok_(partial_ok),
- truncated_(false)
- {}
+ truncated_(false) {
+ }
+
void operator()(const T& entry) {
// If it's already truncated, ignore the rest of the section.
if (truncated_) {
}
}
}
- unsigned int getTotalCount() { return (counter_); }
+
+ unsigned int getTotalCount() {
+ return (counter_);
+ }
+
unsigned int counter_;
+
AbstractMessageRenderer& renderer_;
+
const bool partial_ok_;
+
bool truncated_;
};
}
}
Message::Message(Mode mode) :
- impl_(new MessageImpl(mode))
-{}
-
-Message::~Message() {
- delete impl_;
+ impl_(new MessageImpl(mode)) {
}
bool
unsigned int
Message::getRRCount(const Section section) const {
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) {
- isc_throw(OutOfRange, "Invalid message section: " << section);
+ isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
}
return (impl_->counts_[section]);
}
"addRRset performed in non-render mode");
}
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) {
- isc_throw(OutOfRange, "Invalid message section: " << section);
+ isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
}
impl_->rrsets_[section].push_back(rrset);
bool
Message::hasRRset(const Section section, const Name& name,
- const RRClass& rrclass, const RRType& rrtype) const
-{
+ const RRClass& rrclass, const RRType& rrtype) const {
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) {
- isc_throw(OutOfRange, "Invalid message section: " << section);
+ isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
}
BOOST_FOREACH(ConstRRsetPtr r, impl_->rrsets_[section]) {
bool
Message::removeRRset(const Section section, RRsetIterator& iterator) {
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) {
- isc_throw(OutOfRange, "Invalid message section: " << section);
+ isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
}
bool removed = false;
"clearSection performed in non-render mode");
}
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) {
- isc_throw(OutOfRange, "Invalid message section: " << section);
+ isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
}
if (section == Message::SECTION_QUESTION) {
impl_->questions_.clear();
namespace {
struct MatchRR {
MatchRR(const Name& name, const RRType& rrtype, const RRClass& rrclass) :
- name_(name), rrtype_(rrtype), rrclass_(rrclass) {}
+ name_(name), rrtype_(rrtype), rrclass_(rrclass) {
+ }
+
bool operator()(const RRsetPtr& rrset) const {
return (rrset->getType() == rrtype_ &&
rrset->getClass() == rrclass_ &&
rrset->getName() == name_);
}
+
const Name& name_;
+
const RRType& rrtype_;
+
const RRClass& rrclass_;
};
}
// is hardcoded here.
int
MessageImpl::parseSection(const Message::Section section,
- InputBuffer& buffer, Message::ParseOptions options)
-{
- assert(static_cast<int>(section) < MessageImpl::NUM_SECTIONS);
+ InputBuffer& buffer, Message::ParseOptions options) {
+ if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) {
+ isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
+ }
unsigned int added = 0;
MessageImpl::addRR(Message::Section section, const Name& name,
const RRClass& rrclass, const RRType& rrtype,
const RRTTL& ttl, ConstRdataPtr rdata,
- Message::ParseOptions options)
-{
+ Message::ParseOptions options) {
if ((options & Message::PRESERVE_ORDER) == 0) {
vector<RRsetPtr>::iterator it =
find_if(rrsets_[section].begin(), rrsets_[section].end(),
void
MessageImpl::addRR(Message::Section section, const Name& name,
const RRClass& rrclass, const RRType& rrtype,
- const RRTTL& ttl, Message::ParseOptions options)
-{
+ const RRTTL& ttl, Message::ParseOptions options) {
if ((options & Message::PRESERVE_ORDER) == 0) {
vector<RRsetPtr>::iterator it =
find_if(rrsets_[section].begin(), rrsets_[section].end(),
void
MessageImpl::addEDNS(Message::Section section, const Name& name,
const RRClass& rrclass, const RRType& rrtype,
- const RRTTL& ttl, const Rdata& rdata)
-{
+ const RRTTL& ttl, const Rdata& rdata) {
if (section != Message::SECTION_ADDITIONAL) {
isc_throw(DNSMessageFORMERR,
"EDNS OPT RR found in an invalid section");
MessageImpl::addTSIG(Message::Section section, unsigned int count,
const InputBuffer& buffer, size_t start_position,
const Name& name, const RRClass& rrclass,
- const RRTTL& ttl, const Rdata& rdata)
-{
+ const RRTTL& ttl, const Rdata& rdata) {
if (section != Message::SECTION_ADDITIONAL) {
isc_throw(DNSMessageFORMERR,
"TSIG RR found in an invalid section");
template <typename T>
struct SectionFormatter {
SectionFormatter(const Message::Section section, string& output) :
- section_(section), output_(output) {}
+ section_(section), output_(output) {
+ }
+
void operator()(const T& entry) {
if (section_ == Message::SECTION_QUESTION) {
output_ += ";";
output_ += entry->toText();
}
}
+
const Message::Section section_;
+
string& output_;
};
}
template <typename T>
struct SectionIteratorImpl {
SectionIteratorImpl(const typename vector<T>::const_iterator& it) :
- it_(it) {}
+ it_(it) {
+ }
+
typename vector<T>::const_iterator it_;
};
template <typename T>
SectionIterator<T>::SectionIterator(const SectionIterator<T>& source) :
- impl_(new SectionIteratorImpl<T>(source.impl_->it_))
-{}
+ impl_(new SectionIteratorImpl<T>(source.impl_->it_)) {
+}
template <typename T>
void
const SectionIterator<RRsetPtr>
Message::endSection(const Section section) const {
if (static_cast<int>(section) >= MessageImpl::NUM_SECTIONS) {
- isc_throw(OutOfRange, "Invalid message section: " << section);
+ isc_throw(OutOfRange, "Invalid message section: " << static_cast<int>(section));
}
if (section == SECTION_QUESTION) {
isc_throw(InvalidMessageSection,