[Zrouter-src] ZRouter.org: push to zconf++ zconf++/http_json_handler.cc zconf+...

zrouter-src at zrouter.org zrouter-src at zrouter.org
Tue Jan 24 08:50:02 UTC 2012


details:   /rev/819dbecd1c57
changeset: 56:819dbecd1c57
user:      "Nicolai Petri <nicolai at petri.dk>"
date:      Tue Jan 24 09:49:27 2012 +0100
description:
Use std and zrouter namespace explicit.

diffstat:

 zconf++/http_json_handler.cc |   1 -
 zconf++/model.cc             |   5 +---
 zconf++/utils.cc             |  14 ++++------
 zconf++/zconfig.cc           |  14 ++++------
 zconf++/zrouterhttp.cc       |  58 ++++++++++++++++++++-----------------------
 5 files changed, 40 insertions(+), 52 deletions(-)

diffs (215 lines):

diff -r 4fda6d4d640f -r 819dbecd1c57 zconf++/http_json_handler.cc
--- a/zconf++/http_json_handler.cc	Tue Jan 24 08:52:24 2012 +0100
+++ b/zconf++/http_json_handler.cc	Tue Jan 24 09:49:27 2012 +0100
@@ -37,7 +37,6 @@
 
 	using namespace http;
 	using namespace http::server;
-	using namespace std;
 
 	http_json_handler::http_json_handler(Model::Model &p_model)
 	:model(p_model) {
diff -r 4fda6d4d640f -r 819dbecd1c57 zconf++/model.cc
--- a/zconf++/model.cc	Tue Jan 24 08:52:24 2012 +0100
+++ b/zconf++/model.cc	Tue Jan 24 09:49:27 2012 +0100
@@ -27,9 +27,6 @@
 #include <boost/foreach.hpp>
 #include "model.h"
 
-using namespace std;
-//using namespace boost;
-
 namespace ZRouter
 {
 
@@ -287,7 +284,7 @@
 	}
 
 	std::string ModelWriter::write(Leaf& l, const std::string &indent) {
-		string rv;
+		std::string rv;
 		//	for (int c=0; c < l.numChildren(); c++) {
 		if (l.type() == string_leaf) {
 			//		cout << "  dumping " << " => " << l.get_string() << endl;
diff -r 4fda6d4d640f -r 819dbecd1c57 zconf++/utils.cc
--- a/zconf++/utils.cc	Tue Jan 24 08:52:24 2012 +0100
+++ b/zconf++/utils.cc	Tue Jan 24 09:49:27 2012 +0100
@@ -27,17 +27,15 @@
 #include <deque>
 #include <string>
 
-using namespace std;
-
 namespace ZRouter
 {
 
-	void dump_string_array(string s) {
-		cout << "  " << s << " ";
+	void dump_string_array(std::string s) {
+		std::cout << "  " << s << " ";
 	}
 
-	string chars_to_string(deque<char>::const_iterator is, deque<char>::const_iterator ie) {
-		string ret;
+	std::string chars_to_string(std::deque<char>::const_iterator is, std::deque<char>::const_iterator ie) {
+		std::string ret;
 		while (is != ie) {
 			ret += *is;
 			is++;
@@ -45,8 +43,8 @@
 		return ret;
 	}
 
-	string chars_to_string(deque<unsigned char>::const_iterator is, deque<unsigned char>::const_iterator ie) {
-		string ret;
+	std::string chars_to_string(std::deque<unsigned char>::const_iterator is, std::deque<unsigned char>::const_iterator ie) {
+		std::string ret;
 		while (is != ie) {
 			ret += *is;
 			is++;
diff -r 4fda6d4d640f -r 819dbecd1c57 zconf++/zconfig.cc
--- a/zconf++/zconfig.cc	Tue Jan 24 08:52:24 2012 +0100
+++ b/zconf++/zconfig.cc	Tue Jan 24 09:49:27 2012 +0100
@@ -32,10 +32,7 @@
 #include "zextension.h"
 #include "json_reader.h"
 
-using namespace ZRouter;
-using namespace boost::filesystem;
-using namespace std;
-
+namespace ZRouter { 
 static class Z_Config_Module
 {
 	protected:
@@ -124,15 +121,15 @@
 			LeafRef cfg = model["configuration"];
 			m_running = &cfg["running"];
 			m_configured = &cfg["configured"];
-			if (exists("saved_configuration.json")) {
-				cout << " - loading saved configuration" << endl;
-				ifstream cfgfile("saved_configuration.json");
+			if (boost::filesystem::exists("saved_configuration.json")) {
+				std::cout << " - loading saved configuration" << std::endl;
+				std::ifstream cfgfile("saved_configuration.json");
 				Json::Reader r;
 				LeafRef targetLeaf = *m_running;
 				r.parse(cfgfile, targetLeaf);
 			}
 			else {
-				cout << " - no saved configuration found, building default" << endl;
+				std::cout << " - no saved configuration found, building default" << std::endl;
 				*m_running = build_default_configuration();
 				(*m_running)["config"]["modified"] = Leaf(true);
 			}
@@ -150,3 +147,4 @@
 	//model["system"]["extensions"]["Platform_Posix_Module"]["vendor"]="ZRouter.org";
 	return _module.self_init(io, model);
 }
+}
diff -r 4fda6d4d640f -r 819dbecd1c57 zconf++/zrouterhttp.cc
--- a/zconf++/zrouterhttp.cc	Tue Jan 24 08:52:24 2012 +0100
+++ b/zconf++/zrouterhttp.cc	Tue Jan 24 09:49:27 2012 +0100
@@ -41,29 +41,25 @@
 #include "http_json_handler.h"
 #include "zextension.h"
 
-using namespace std;
+namespace ZRouter {
+	static T_ZExtensionMap extension_map;
 
-using namespace ZRouter;
+	ZExtensionManager::ZExtensionManager() {
+		std::cout << "ZExtensionManager::" << std::endl;
+	}
 
-//static ZRouter::T_ZExtensionMap extension_map;
-static ZRouter::T_ZExtensionMap extension_map;
+	void ZExtensionManager::register_extension(std::string mod_name, int mod_priority, FP_ExtensionInitializer ext_initiator) {
+		TExtensionData d;
+		d.name = mod_name;
+		d.init_priority = mod_priority;
+		d.initializer = ext_initiator;
+		std::cout << "Registering extension " << mod_name << " with init priority " << mod_priority << std::endl;
+		extension_map.insert(std::pair<const int, ZRouter::TExtensionData>(mod_priority, d));
+		//extension_map[mod_name] = d;
+	}
 
-ZExtensionManager::ZExtensionManager() {
-	cout << "ZExtensionManager::" << endl;
 }
 
-
-void ZExtensionManager::register_extension(std::string mod_name, int mod_priority, FP_ExtensionInitializer ext_initiator) {
-	TExtensionData d;
-	d.name = mod_name;
-	d.init_priority = mod_priority;
-	d.initializer = ext_initiator;
-	cout << "Registering extension " << mod_name << " with init priority " << mod_priority << endl;
-	extension_map.insert(std::pair<const int, ZRouter::TExtensionData>(mod_priority, d));
-	//extension_map[mod_name] = d;
-}
-
-
 int main(int argc, char **argv) {
 	// Init random seed stuff
 	srandomdev();
@@ -80,16 +76,16 @@
 		boost::bind(&boost::asio::io_service::stop, &io_service));
 	#endif
 	// Allocate object model
-	Model::Model model;
+	ZRouter::Model::Model model;
 	model["args"].map();
 	for (int ac=1; ac < argc; ac++) {
-		string arg = argv[ac];
-		string::size_type pos = arg.find("=");
-		if (pos != string::npos) {
-			model["args"][argv[ac]] = string(arg, pos + 1);
+		std::string arg = argv[ac];
+		std::string::size_type pos = arg.find("=");
+		if (pos != std::string::npos) {
+			model["args"][argv[ac]] = std::string(arg, pos + 1);
 		}
 		else {
-			model["args"][argv[ac]] = Leaf(true);
+			model["args"][argv[ac]] = ZRouter::Leaf(true);
 		}
 	}
 
@@ -97,7 +93,7 @@
 	model.populate();
 
 	// Create our custom http model interface handler
-	http_json_handler json_handler(model);
+	ZRouter::http_json_handler json_handler(model);
 
 	// Start server
 	http::server::server s(io, "0.0.0.0", "9080", "html");
@@ -105,12 +101,12 @@
 	// Register model interface
 	s.register_handler(&json_handler);
 
-	cout << "Loading extensions" << endl;
+	std::cout << "Loading extensions" << std::endl;
 	// Add all available extensions
-	ZRouter::T_ZExtensionMap::iterator ext_ptr = extension_map.begin();
-	while (ext_ptr != extension_map.end()) {
-		cout << " initializing " << (*ext_ptr).second.name << " using priority " << (*ext_ptr).second.init_priority << endl;
-		Leaf extObj;
+	ZRouter::T_ZExtensionMap::iterator ext_ptr = ZRouter::extension_map.begin();
+	while (ext_ptr != ZRouter::extension_map.end()) {
+		std::cout << " initializing " << (*ext_ptr).second.name << " using priority " << (*ext_ptr).second.init_priority << std::endl;
+		ZRouter::Leaf extObj;
 		extObj["loaded"] = true;
 		extObj["version"] = "unknown";
 		extObj["vendor"] = "unknown";
@@ -119,7 +115,7 @@
 		(*ext_ptr).second.initializer(io, model);
 		ext_ptr++;
 	}
-	cout << "Loading extensions completed" << endl;
+	std::cout << "Loading extensions completed" << std::endl;
 
 	io.run();
 


More information about the Zrouter-src mailing list