summaryrefslogtreecommitdiff
path: root/src/third_party/yaml-cpp-0.5.1/src/scantag.cpp
diff options
context:
space:
mode:
authorShaun Verch <shaun.verch@10gen.com>2013-11-09 15:38:08 -0500
committerShaun Verch <shaun.verch@10gen.com>2013-11-13 16:46:49 -0500
commitc9168762e4870e2305143aeb3aee462f7a3bbc5d (patch)
treebce59d385849346dc5e4c3bce64302af0722789d /src/third_party/yaml-cpp-0.5.1/src/scantag.cpp
parent0a1c8c986f31f49c4d878c3819fe10608f4b2b06 (diff)
downloadmongo-c9168762e4870e2305143aeb3aee462f7a3bbc5d.tar.gz
SERVER-11575 Added support for YAML Config File
Diffstat (limited to 'src/third_party/yaml-cpp-0.5.1/src/scantag.cpp')
-rw-r--r--src/third_party/yaml-cpp-0.5.1/src/scantag.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/third_party/yaml-cpp-0.5.1/src/scantag.cpp b/src/third_party/yaml-cpp-0.5.1/src/scantag.cpp
new file mode 100644
index 00000000000..b71cbcc49f4
--- /dev/null
+++ b/src/third_party/yaml-cpp-0.5.1/src/scantag.cpp
@@ -0,0 +1,84 @@
+#include "scanner.h"
+#include "regex.h"
+#include "exp.h"
+#include "yaml-cpp/exceptions.h"
+
+namespace YAML
+{
+ const std::string ScanVerbatimTag(Stream& INPUT)
+ {
+ std::string tag;
+
+ // eat the start character
+ INPUT.get();
+
+ while(INPUT) {
+ if(INPUT.peek() == Keys::VerbatimTagEnd) {
+ // eat the end character
+ INPUT.get();
+ return tag;
+ }
+
+ int n = Exp::URI().Match(INPUT);
+ if(n <= 0)
+ break;
+
+ tag += INPUT.get(n);
+ }
+
+ throw ParserException(INPUT.mark(), ErrorMsg::END_OF_VERBATIM_TAG);
+ }
+
+ const std::string ScanTagHandle(Stream& INPUT, bool& canBeHandle)
+ {
+ std::string tag;
+ canBeHandle = true;
+ Mark firstNonWordChar;
+
+ while(INPUT) {
+ if(INPUT.peek() == Keys::Tag) {
+ if(!canBeHandle)
+ throw ParserException(firstNonWordChar, ErrorMsg::CHAR_IN_TAG_HANDLE);
+ break;
+ }
+
+ int n = 0;
+ if(canBeHandle) {
+ n = Exp::Word().Match(INPUT);
+ if(n <= 0) {
+ canBeHandle = false;
+ firstNonWordChar = INPUT.mark();
+ }
+ }
+
+ if(!canBeHandle)
+ n = Exp::Tag().Match(INPUT);
+
+ if(n <= 0)
+ break;
+
+ tag += INPUT.get(n);
+ }
+
+ return tag;
+ }
+
+ const std::string ScanTagSuffix(Stream& INPUT)
+ {
+ std::string tag;
+
+ while(INPUT) {
+ int n = Exp::Tag().Match(INPUT);
+ if(n <= 0)
+ break;
+
+ tag += INPUT.get(n);
+ }
+
+ if(tag.empty())
+ throw ParserException(INPUT.mark(), ErrorMsg::TAG_WITH_NO_SUFFIX);
+
+ return tag;
+ }
+}
+