summaryrefslogtreecommitdiffstats
path: root/src/lib/dns/master_lexer.h
diff options
context:
space:
mode:
authorJINMEI Tatuya <jinmei@isc.org>2012-11-13 22:12:20 +0100
committerJINMEI Tatuya <jinmei@isc.org>2012-11-13 22:12:20 +0100
commit9a11ef62ae36d9d891e87ba792fa249ae82f0736 (patch)
tree5add7ee45614d0a9962e5a14e7654245bf6f31dd /src/lib/dns/master_lexer.h
parent[master] Merge branch 'trac2463' (diff)
parent[2372] clarified that INITIAL_WS is recognized only after an EOL. (diff)
downloadkea-9a11ef62ae36d9d891e87ba792fa249ae82f0736.tar.xz
kea-9a11ef62ae36d9d891e87ba792fa249ae82f0736.zip
[master] Merge branch 'trac2372'
Diffstat (limited to 'src/lib/dns/master_lexer.h')
-rw-r--r--src/lib/dns/master_lexer.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/lib/dns/master_lexer.h b/src/lib/dns/master_lexer.h
index da6bb5dee2..854d602e03 100644
--- a/src/lib/dns/master_lexer.h
+++ b/src/lib/dns/master_lexer.h
@@ -24,6 +24,9 @@
namespace isc {
namespace dns {
+namespace master_lexer_internal {
+class State;
+}
/// \brief Tokenizer for parsing DNS master files.
///
@@ -64,9 +67,22 @@ namespace dns {
/// this class does not throw for an error that would be reported as an
/// exception in other classes.
class MasterLexer {
+ friend class master_lexer_internal::State;
public:
class Token; // we define it separately for better readability
+ /// \brief Options for getNextToken.
+ ///
+ /// A compound option, indicating multiple options are set, can be
+ /// specified using the logical OR operator (operator|()).
+ enum Options {
+ NONE = 0, ///< No option
+ INITIAL_WS = 1, ///< recognize begin-of-line spaces after an
+ ///< end-of-line
+ QSTRING = 2, ///< recognize quoted string
+ NUMBER = 4 ///< recognize numeric text as integer
+ };
+
/// \brief The constructor.
///
/// \throw std::bad_alloc Internal resource allocation fails (rare case).
@@ -167,6 +183,16 @@ private:
MasterLexerImpl* impl_;
};
+/// \brief Operator to combine \c MasterLexer options
+///
+/// This is a trivial shortcut so that compound options can be specified
+/// in an intuitive way.
+inline MasterLexer::Options
+operator|(MasterLexer::Options o1, MasterLexer::Options o2) {
+ return (static_cast<MasterLexer::Options>(
+ static_cast<unsigned>(o1) | static_cast<unsigned>(o2)));
+}
+
/// \brief Tokens for \c MasterLexer
///
/// This is a simple value-class encapsulating a type of a lexer token and
@@ -192,7 +218,8 @@ public:
enum Type {
END_OF_LINE, ///< End of line detected (if asked for detecting it)
END_OF_FILE, ///< End of file detected (if asked for detecting it)
- INITIAL_WS, ///< White spaces at the beginning of a line
+ INITIAL_WS, ///< White spaces at the beginning of a line after an
+ ///< end of line
NOVALUE_TYPE_MAX = INITIAL_WS, ///< Max integer corresponding to
/// no-value (type only) types.
/// Mainly for internal use.