Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
36d3b727
Commit
36d3b727
authored
Jun 29, 2012
by
Mukund Sivaraman
Browse files
[2053] Add operator<< to dns::LabelSequence
parent
0bebde9e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/dns/labelsequence.cc
View file @
36d3b727
...
...
@@ -117,5 +117,11 @@ LabelSequence::toText() const {
return
(
name_
.
toText
(
!
isAbsolute
(),
first_label_
,
last_label_
));
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
LabelSequence
&
label_sequence
)
{
os
<<
label_sequence
.
toText
();
return
(
os
);
}
}
// end namespace dns
}
// end namespace isc
src/lib/dns/labelsequence.h
View file @
36d3b727
...
...
@@ -187,6 +187,23 @@ private:
};
///
/// \brief Insert the label sequence as a string into stream.
///
/// This method convert the \c label_sequence into a string and inserts
/// it into the output stream \c os.
///
/// This function overloads the global operator<< to behave as described in
/// ostream::operator<< but applied to \c LabelSequence objects.
///
/// \param os A \c std::ostream object on which the insertion operation is
/// performed.
/// \param name The \c LabelSequence object output by the operation.
/// \return A reference to the same \c std::ostream object referenced by
/// parameter \c os after the insertion operation.
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
LabelSequence
&
label_sequence
);
}
// end namespace dns
}
// end namespace isc
...
...
src/lib/dns/tests/labelsequence_unittest.cc
View file @
36d3b727
...
...
@@ -394,4 +394,10 @@ TEST_F(LabelSequenceTest, getHash) {
hashDistributionCheck
(
ca_servers
);
}
// test operator<<. We simply confirm it appends the result of toText().
TEST_F
(
LabelSequenceTest
,
LeftShiftOperator
)
{
ostringstream
oss
;
oss
<<
ls1
;
EXPECT_EQ
(
ls1
.
toText
(),
oss
.
str
());
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment