From fc46f2618332037a8c1b58fbce5d616033bff1c9 Mon Sep 17 00:00:00 2001
From: Dan Klein <danklei@cisco.com>
Date: Wed, 26 Aug 2015 15:05:58 +0300
Subject: Rearranged files and external libraries in two different locations,
 one for cpp (trex-core/external_libs) and one for python
 (trex-core/scripts/external_libs)

---
 external_libs/yaml-cpp/util/parse.cpp | 65 +++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 external_libs/yaml-cpp/util/parse.cpp

(limited to 'external_libs/yaml-cpp/util/parse.cpp')

diff --git a/external_libs/yaml-cpp/util/parse.cpp b/external_libs/yaml-cpp/util/parse.cpp
new file mode 100644
index 00000000..d02a76a7
--- /dev/null
+++ b/external_libs/yaml-cpp/util/parse.cpp
@@ -0,0 +1,65 @@
+#include "yaml-cpp/yaml.h"
+#include "yaml-cpp/eventhandler.h"
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+struct Params {
+	bool hasFile;
+	std::string fileName;
+};
+
+Params ParseArgs(int argc, char **argv) {
+	Params p;
+
+	std::vector<std::string> args(argv + 1, argv + argc);
+	
+	return p;
+}
+
+class NullEventHandler: public YAML::EventHandler
+{
+public:
+	virtual void OnDocumentStart(const YAML::Mark&) {}
+	virtual void OnDocumentEnd() {}
+	
+	virtual void OnNull(const YAML::Mark&, YAML::anchor_t) {}
+	virtual void OnAlias(const YAML::Mark&, YAML::anchor_t) {}
+	virtual void OnScalar(const YAML::Mark&, const std::string&, YAML::anchor_t, const std::string&) {}
+	
+	virtual void OnSequenceStart(const YAML::Mark&, const std::string&, YAML::anchor_t) {}
+	virtual void OnSequenceEnd() {}
+	
+	virtual void OnMapStart(const YAML::Mark&, const std::string&, YAML::anchor_t) {}
+	virtual void OnMapEnd() {}
+};
+
+void parse(std::istream& input)
+{
+	try {
+		YAML::Parser parser(input);
+		YAML::Node doc;
+		while(parser.GetNextDocument(doc)) {
+			YAML::Emitter emitter;
+			emitter << doc;
+			std::cout << emitter.c_str() << "\n";
+		}
+	} catch(const YAML::Exception& e) {
+		std::cerr << e.what() << "\n";
+	}
+}
+
+int main(int argc, char **argv)
+{
+	Params p = ParseArgs(argc, argv);
+
+	if(argc > 1) {
+		std::ifstream fin;
+		fin.open(argv[1]);
+		parse(fin);
+	} else {
+		parse(std::cin);
+	}
+
+	return 0;
+}
-- 
cgit