Commit ee424bbc authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2432] Move common code into a helper method

parent bdf19add
......@@ -55,30 +55,31 @@ RRsetCollection::addRRset(RRsetPtr rrset) {
rrsets_.insert(std::pair<CollectionKey, RRsetPtr>(key, rrset));
}
RRsetCollection::RRsetCollection(const char* filename, const Name& origin,
const RRClass& rrclass)
template<typename T>
void
RRsetCollection::constructHelper(T source, const isc::dns::Name& origin,
const isc::dns::RRClass& rrclass)
{
MasterLoaderCallbacks callbacks
(boost::bind(&RRsetCollection::loaderCallback, this, _1, _2, _3),
boost::bind(&RRsetCollection::loaderCallback, this, _1, _2, _3));
MasterLoader loader(filename, origin, rrclass, callbacks,
MasterLoader loader(source, origin, rrclass, callbacks,
boost::bind(&RRsetCollection::addRRset,
this, _1, _2, _3, _4, _5),
MasterLoader::DEFAULT);
loader.load();
}
RRsetCollection::RRsetCollection(const char* filename, const Name& origin,
const RRClass& rrclass)
{
constructHelper<const char*>(filename, origin, rrclass);
}
RRsetCollection::RRsetCollection(std::istream& input_stream, const Name& origin,
const RRClass& rrclass)
{
MasterLoaderCallbacks callbacks
(boost::bind(&RRsetCollection::loaderCallback, this, _1, _2, _3),
boost::bind(&RRsetCollection::loaderCallback, this, _1, _2, _3));
MasterLoader loader(input_stream, origin, rrclass, callbacks,
boost::bind(&RRsetCollection::addRRset,
this, _1, _2, _3, _4, _5),
MasterLoader::DEFAULT);
loader.load();
constructHelper<std::istream&>(input_stream, origin, rrclass);
}
const AbstractRRset*
......
......@@ -118,6 +118,9 @@ public:
const isc::dns::RRType& rrtype) const;
private:
template<typename T>
void constructHelper(T source, const isc::dns::Name& origin,
const isc::dns::RRClass& rrclass);
void addRRset(const isc::dns::Name& name, const isc::dns::RRClass& rrclass,
const isc::dns::RRType& rrtype, const isc::dns::RRTTL& rrttl,
const isc::dns::rdata::RdataPtr& data);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment