[Zrouter-src] ZRouter.org: push to zconf++ zconf++/model.h

zrouter-src at zrouter.org zrouter-src at zrouter.org
Wed Jan 18 23:13:01 UTC 2012


details:   /rev/effe7193832e
changeset: 43:effe7193832e
user:      "Nicolai Petri <nicolai at petri.dk>"
date:      Thu Jan 19 00:12:38 2012 +0100
description:
Reserve 2 new leaf types. (set and enum)
Remove tons of unused code.

diffstat:

 zconf++/model.h |  124 +-------------------------------------------------------
 1 files changed, 1 insertions(+), 123 deletions(-)

diffs (194 lines):

diff -r 26eb43f7cb20 -r effe7193832e zconf++/model.h
--- a/zconf++/model.h	Thu Jan 19 00:08:25 2012 +0100
+++ b/zconf++/model.h	Thu Jan 19 00:12:38 2012 +0100
@@ -34,7 +34,7 @@
 
 namespace ZRouter
 {
-	enum LeafType { empty_leaf, object_leaf, array_leaf, numeric_leaf, boolean_leaf, string_leaf, real_leaf, action_leaf, event_leaf };
+	enum LeafType { empty_leaf, object_leaf, array_leaf, numeric_leaf, boolean_leaf, string_leaf, real_leaf, action_leaf, event_leaf, enum_leaf, set_leaf };
 	class ModelWriter;
 	class Leaf;
 	typedef Leaf& LeafRef;
@@ -97,27 +97,7 @@
 				check_type_const(action_leaf);
 				return m_action_handler->describe();
 			}
-			/*Leaf& operator=( const bool p_bool) {
-			 *this = Leaf(p_bool);
-				return *this;
-			}*/
-			/*
-			Leaf& operator=( IModelActionHandler* p_action_hndl) {
-				//std::cout << "Copy2= const " << source.m_value_string << std::endl;
-				check_type(action_leaf);
-				if (is_null()) {
-					std::cout << "copy null as action" << std::endl;
-					//impl = boost::shared_ptr<Leaf_Impl>(new Leaf_Impl());
-				}
-				m_action_handler = p_action_hndl;
-				return *this;
-			}*/
 			const Leaf& operator=(const Leaf& source) {
-				//std::cout << "Copy2= const " << source.m_value_string << std::endl;
-				/*	if (source.is_null()) {
-						//std::cout << "copy null" << std::endl;
-						//impl = boost::shared_ptr<Leaf_Impl>(new Leaf_Impl());
-					}*/
 				m_type = source.m_type;
 				if (m_type == empty_leaf) {
 				}
@@ -166,12 +146,8 @@
 				else if (m_type == action_leaf) {
 					m_action_handler = source.m_action_handler;
 				}
-				//std::cout << "Copy () const " << std::endl;
-				//FIXME:
 			};
-			//			Leaf_Impl(const LeafType);
 			Leaf(const std::string& p_str ) : m_value_string(p_str), m_type(string_leaf) {
-				//std::cout << "Creating string leaf : " << p_str << std::endl;
 			};
 			explicit Leaf( IModelActionHandler* p_action_hndl) : m_action_handler(p_action_hndl), m_type(action_leaf) { ; }
 			Leaf(const int p_int ) : m_value_int(p_int), m_type(numeric_leaf) { };
@@ -180,16 +156,6 @@
 			Leaf(const char* p_str) : m_value_string(p_str), m_type(string_leaf) { };
 			explicit Leaf(const double& p_val) :m_value_real(p_val), m_type(real_leaf) {
 			}
-			/*			std::list<std::string> keys() const {
-							std::list<std::string> kmap;
-
-							for(std::map<std::string, boost::shared_ptr<Leaf_Impl> >::const_iterator it = m_map.begin(); it != m_map.end(); it++)
-							{
-								kmap.push_back(it->first);
-							}
-
-							return kmap;
-						} */
 			Leaf& operator[](const std::string& p_key) {
 				check_type(object_leaf);
 				if (m_map.find(p_key) == m_map.end()) {
@@ -198,13 +164,6 @@
 				}
 				return m_map[p_key];
 			}
-			/*const Leaf& operator[](const std::string& p_key) const  {
-				check_type_const(object_leaf);
-				//if (m_map.find(p_key) == m_map.end())
-				//	return NULL;
-			//		m_map[p_key] = boost::shared_ptr<Leaf_Impl>(new Leaf_Impl());
-				return (m_map.find(p_key)->second);
-			}*/
 			const LeafType type() const
 			{
 				return m_type;
@@ -221,39 +180,20 @@
 			{
 				return *m_parent;
 			}
-			/*			const Leaf& operator[](const int p_idx) const {
-							check_type_const(array_leaf);
-							if (p_idx >= m_array.size())
-								throw std::string("Error!");
-								//m_array.resize(p_idx+1, boost::shared_ptr<Leaf_Impl>((Leaf_Impl*)NULL));
-								//m_array[p_idx] = boost::shared_ptr<Leaf_Impl>(new Leaf_Impl());
-							//if (m_array[p_idx].get() == NULL)
-							//	m_array[p_idx] = boost::shared_ptr<Leaf_Impl>(new Leaf_Impl());
-								//std::cout << "FUCKED" << std::endl;
-							return m_array[p_idx];
-						}*/
 			Leaf& operator[](const int p_idx) {
 				check_type(array_leaf);
-				//			if (m_array.find(p_key) == m_map.end())
-				//				m_map[p_key] = boost::shared_ptr<Leaf_Impl>(new Leaf_Impl());
 				if (p_idx >= m_array.size()) {
 					m_array.resize(p_idx+1, Leaf());
 					m_array[p_idx].m_parent = this;
 				}
-				//m_array[p_idx] = boost::shared_ptr<Leaf_Impl>(new Leaf_Impl());
-				//if (m_array[p_idx].get() == NULL)
-				//	m_array[p_idx] = boost::shared_ptr<Leaf_Impl>(new Leaf_Impl());
-				//std::cout << "FUCKED" << std::endl;
 				return m_array[p_idx];
 			}
 			const std::string get_string() const
 			{
-				//std::cout << "get_string : " << m_type << " " << m_value_string << std::endl;
 				check_type_const(string_leaf);
 				return m_value_string;
 			}
 			const std::string get_string() {
-				//std::cout << "get_string : " << m_type << " " << m_value_string << std::endl;
 				check_type(string_leaf);
 				return m_value_string;
 			}
@@ -302,69 +242,7 @@
 				check_type(string_leaf);
 				return m_value_string == std::string(p_cstr);
 			}
-			/*
-						const Leaf& operator=(const Leaf& source) {
-							//std::cout << "Copy= const " << source.impl->get_string() << std::endl;
-							if (source.is_null()) {
-								std::cout << "copy null" << std::endl;
-							}
-							m_type = source.m_type;
-							m_value_string = source.m_value_string;
-							m_value_int = source.m_value_int;
-							m_map = source.m_map;
-							m_array = source.m_array;
-							return *this;
-						}; */
 	};
-	/*		public:
-				// Constructors
-				Leaf() : impl(new Leaf_Impl() ) { std::cout << "Default const : " << std::endl; };
-				Leaf(const Leaf& source) {
-					std::cout << "Copy (NOT IMPL) const " << source.impl->get_string() << std::endl;
-					//FIXME:
-				};
-				const Leaf& operator=(const Leaf& source) {
-					//std::cout << "Copy= const " << source.impl->get_string() << std::endl;
-					if (source.is_null()) {
-						std::cout << "copy null" << std::endl;
-						impl = boost::shared_ptr<Leaf_Impl>(new Leaf_Impl());
-					}
-					else
-						*impl = *source.impl;
-					return *this;
-				};
-				Leaf(boost::shared_ptr<Leaf_Impl> p_impl) : impl(p_impl ) {
-			//		std::cout << "Const const " << p_impl << std::endl;
-				};
-				// Leaf operator[](const std::string& p_value);
-				LEAF_IMPL_WRAP_WITH_ARG1(Leaf, operator[], const std::string&);
-				LEAF_IMPL_WRAP_CONST_WITH_ARG1(Leaf, operator[], const std::string&);
-				LEAF_IMPL_WRAP_WITH_ARG1(Leaf, operator[], const int);
-				LEAF_IMPL_WRAP_CONST_WITH_ARG1(Leaf, operator[], const int);
-				LEAF_IMPL_CNSTR(const std::string&);
-				LEAF_IMPL_CNSTR(const char*);
-				LEAF_IMPL_CNSTR(const int);
-				//Leaf(const std::string& p_value);
-				LEAF_IMPL_WRAP_CONST(const bool, is_null);
-				LEAF_IMPL_WRAP_CONST(const int, numChildren);
-				LEAF_IMPL_WRAP_CONST(const LeafType, type);
-				LEAF_IMPL_WRAP(const std::string, get_string);
-				LEAF_IMPL_WRAP_CONST(const std::string, get_string);
-				LEAF_IMPL_WRAP_CONST(std::list<std::string>, keys);
-				//std::list<std::string> keys() const {
-				LEAF_IMPL_WRAP(const std::string, to_json);
-				//LEAF_IMPL_WRAP_WITH_ARG1(void, push_back, Leaf);
-				void push_back(const Leaf& p_leaf) {
-						impl->push_back(p_leaf.impl);
-				}
-				operator const char * () {
-					return impl->get_string().c_str();
-				}
-				const bool operator== (const std::string &match) const {
-					return match == impl->get_string();
-				}
-		};
-	*/
 	class Model : public Leaf
 	{
 		public:


More information about the Zrouter-src mailing list