BIND 10 trac2369, updated. 24862b62d9a01d277ea5c5b99666f04b1951de64 [2369] Make InputSource non-copyable
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Nov 6 04:33:48 UTC 2012
The branch, trac2369 has been updated
via 24862b62d9a01d277ea5c5b99666f04b1951de64 (commit)
via 31745f2d5978086e2d0cc40524efc2e5a45b832b (commit)
via ff7cec44f4ee5c59593278558269bdd41a6e5719 (commit)
via 265fb98ba1f1daab43779b8eaeb6d7f8775dd772 (commit)
from 9af419deb6691876904d456faf0da731cb5c96b5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 24862b62d9a01d277ea5c5b99666f04b1951de64
Author: Mukund Sivaraman <muks at isc.org>
Date: Tue Nov 6 10:03:15 2012 +0530
[2369] Make InputSource non-copyable
commit 31745f2d5978086e2d0cc40524efc2e5a45b832b
Author: Mukund Sivaraman <muks at isc.org>
Date: Tue Nov 6 10:00:04 2012 +0530
[2369] Add TODOs to remove saveLine() and compact() later
commit ff7cec44f4ee5c59593278558269bdd41a6e5719
Author: Mukund Sivaraman <muks at isc.org>
Date: Tue Nov 6 09:57:39 2012 +0530
[2369] Describe why the operation failed in OpenError exception
commit 265fb98ba1f1daab43779b8eaeb6d7f8775dd772
Author: Mukund Sivaraman <muks at isc.org>
Date: Tue Nov 6 09:46:34 2012 +0530
[2369] Make constructors explicit
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/master_lexer_inputsource.cc | 13 +++++++++++--
src/lib/dns/master_lexer_inputsource.h | 19 +++++++++++++++----
2 files changed, 26 insertions(+), 6 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/master_lexer_inputsource.cc b/src/lib/dns/master_lexer_inputsource.cc
index 517ffeb..5d8d413 100644
--- a/src/lib/dns/master_lexer_inputsource.cc
+++ b/src/lib/dns/master_lexer_inputsource.cc
@@ -14,6 +14,9 @@
#include <dns/master_lexer_inputsource.h>
+#include <cerrno>
+#include <cstring>
+
namespace isc {
namespace dns {
namespace master_lexer_internal {
@@ -46,10 +49,16 @@ InputSource::InputSource(const char* filename) :
name_(filename),
input_(file_stream_)
{
+ errno = 0;
file_stream_.open(filename);
if (file_stream_.fail()) {
- isc_throw(OpenError,
- "Error opening the input source file: " << filename);
+ std::string error_txt("Error opening the input source file: ");
+ error_txt += filename;
+ if (errno != 0) {
+ error_txt += "; possible cause: ";
+ error_txt += std::strerror(errno);
+ }
+ isc_throw(OpenError, error_txt);
}
}
diff --git a/src/lib/dns/master_lexer_inputsource.h b/src/lib/dns/master_lexer_inputsource.h
index af4c96b..33659d1 100644
--- a/src/lib/dns/master_lexer_inputsource.h
+++ b/src/lib/dns/master_lexer_inputsource.h
@@ -17,6 +17,8 @@
#include <exceptions/exceptions.h>
+#include <boost/noncopyable.hpp>
+
#include <iostream>
#include <fstream>
#include <string>
@@ -34,8 +36,9 @@ namespace master_lexer_internal {
/// can have multiple InputSources if $INCLUDE is used. The source can
/// also be generic input stream (std::istream).
///
-/// This class is not meant for public use.
-class InputSource {
+/// This class is not meant for public use. We also enforce that
+/// instances are non-copyable.
+class InputSource : boost::noncopyable {
public:
/// \brief Returned by getChar() when end of stream is reached.
static const int END_OF_STREAM;
@@ -65,13 +68,13 @@ public:
/// \brief Constructor which takes an input stream. The stream is
/// read-from, but it is not closed.
- InputSource(std::istream& input_stream);
+ explicit InputSource(std::istream& input_stream);
/// \brief Constructor which takes a filename to read from. The
/// associated file stream is managed internally.
///
/// \throws OpenError when opening the input file fails.
- InputSource(const char* filename);
+ explicit InputSource(const char* filename);
/// \brief Destructor
~InputSource();
@@ -95,11 +98,19 @@ public:
/// \brief Saves the current line being read. Later, when
/// \c ungetAll() is called, it skips back to the last-saved line.
+ ///
+ /// TODO: Please make this method private if it is unused after the
+ /// MasterLexer implementation is complete (and only \c mark() is
+ /// used instead).
void saveLine();
/// Removes buffered content before the current location in the
/// \c InputSource. It's not possible to \c ungetChar() after this,
/// unless we read more data using \c getChar().
+ ///
+ /// TODO: Please make this method private if it is unused after the
+ /// MasterLexer implementation is complete (and only \c mark() is
+ /// used instead).
void compact();
/// Calls \c saveLine() and \c compact() in sequence.
More information about the bind10-changes
mailing list