From fac1bf454ee3d9325893403ea1303d1fb65fcac0 Mon Sep 17 00:00:00 2001
From: whh8b <whh8b@git.zephyr-software.com>
Date: Wed, 11 Nov 2015 03:15:35 +0000
Subject: [PATCH] Go away from anything C++11 related.

---
 include/zipr_options.h | 59 ++++++++++++++++++++++++------------------
 include/zipr_plugin.h  |  2 +-
 2 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/include/zipr_options.h b/include/zipr_options.h
index bcf1c6a..b070aa7 100644
--- a/include/zipr_options.h
+++ b/include/zipr_options.h
@@ -35,6 +35,7 @@
 #include <unistd.h>
 #include <libIRDB-core.hpp>
 #include <iostream>
+#include <sstream>
 
 namespace Zipr_SDK
 {
@@ -50,6 +51,7 @@ enum ZiprOptionType {
 class ZiprOption_t 
 {
 	public:
+	/*
 		ZiprOption_t(ZiprOptionType type)
 			: m_key(""),
 			  m_untyped_value(""),
@@ -59,6 +61,7 @@ class ZiprOption_t
 				m_required(false),
 				m_set(false),
 				m_option_type(type) {};
+	*/
 		ZiprOption_t(ZiprOptionType type, std::string key, std::string value)
 			: m_key(key),
 			  m_untyped_value(value),
@@ -138,7 +141,10 @@ template <typename T>
 class ZiprTypedOption_t : public ZiprOption_t
 {
 	public:
-		using ZiprOption_t::ZiprOption_t;
+		ZiprTypedOption_t(ZiprOptionType type,
+			std::string key,
+			std::string value)
+			: ZiprOption_t(type, key, value) {}
 		void SetValue(const std::string &value) {
 			m_set = true;
 			m_untyped_value = value;
@@ -180,7 +186,10 @@ template <class T>
 class ZiprCompositeOption_t : public ZiprTypedOption_t<T>, public T
 {
 	public:
-		using ZiprTypedOption_t<T>::ZiprTypedOption_t;
+		ZiprCompositeOption_t(ZiprOptionType type,
+			std::string key,
+			std::string value)
+			: ZiprTypedOption_t<T>(type, key, value) {}
 		using ZiprTypedOption_t<T>::ConvertToTyped;
 		void SetValue(const std::string &value) {
 			ZiprTypedOption_t<T>::SetValue(value);
@@ -191,7 +200,6 @@ class ZiprCompositeOption_t : public ZiprTypedOption_t<T>, public T
 class ZiprStringOption_t : public ZiprCompositeOption_t<std::string>
 {
 	public:
-		using ZiprCompositeOption_t<std::string>::ZiprTypedOption_t;
 		ZiprStringOption_t(std::string key, std::string value = "")
 			: ZiprCompositeOption_t(ZiprStringOptionType, key, value) {
 			SetValue(value);
@@ -211,7 +219,6 @@ class ZiprStringOption_t : public ZiprCompositeOption_t<std::string>
 class ZiprBooleanOption_t : public ZiprTypedOption_t<bool>
 {
 	public:
-		using ZiprTypedOption_t<bool>::ZiprTypedOption_t;
 		ZiprBooleanOption_t(std::string key, std::string value = "")
 			: ZiprTypedOption_t(ZiprBooleanOptionType, key, value) {
 			m_key = key;
@@ -219,7 +226,7 @@ class ZiprBooleanOption_t : public ZiprTypedOption_t<bool>
 			m_needs_value = false;
 		}
 		ZiprBooleanOption_t(std::string key, bool value)
-			: ZiprBooleanOption_t(key) {
+			: ZiprTypedOption_t(ZiprBooleanOptionType, key, "") {
 			m_value = value;
 			m_untyped_value = ConvertToUntyped(value);
 		}
@@ -247,13 +254,12 @@ class ZiprBooleanOption_t : public ZiprTypedOption_t<bool>
 class ZiprIntegerOption_t : public ZiprTypedOption_t<int>
 {
 	public:
-		using ZiprTypedOption_t<int>::ZiprTypedOption_t;
 		ZiprIntegerOption_t(std::string key, std::string value = "")
 			: ZiprTypedOption_t(ZiprIntegerOptionType, key, value) {
 			m_value = ConvertToTyped(value);
 		}
 		ZiprIntegerOption_t(std::string key, int value)
-			: ZiprIntegerOption_t(key, "") {
+			: ZiprTypedOption_t(ZiprIntegerOptionType, key, "") {
 			m_value = value;
 			m_untyped_value = ConvertToUntyped(value);
 		}
@@ -263,20 +269,22 @@ class ZiprIntegerOption_t : public ZiprTypedOption_t<int>
 		}
 	private:
 		int ConvertToTyped(std::string value_to_convert) {
-			try {
-				return std::stoi(value_to_convert);
-			} catch (std::exception &e) {
+			int converted = 0;
+			char *endptr = NULL;
+			converted = strtol(value_to_convert.c_str(),
+			                   &endptr, 10);
+			if (*endptr != '\0')
+			{
 				m_set = false;
 				m_untyped_value = "";
 				return 0;
 			}
+			return converted;
 		}
 		std::string ConvertToUntyped(int value_to_convert) {
-			try {
-				return std::to_string(value_to_convert);
-			} catch (std::exception &e) {
-				return std::string("");
-			}
+			std::stringstream ss;
+			ss << value_to_convert;
+			return ss.str();
 		}
 		std::string TypeName() {
 			return "integer";
@@ -286,13 +294,12 @@ class ZiprIntegerOption_t : public ZiprTypedOption_t<int>
 class ZiprDoubleOption_t : public ZiprTypedOption_t<double>
 {
 	public:
-		using ZiprTypedOption_t<double>::ZiprTypedOption_t;
 		ZiprDoubleOption_t(std::string key, std::string value = "")
 			: ZiprTypedOption_t(ZiprDoubleOptionType, key, value) {
 			m_value = ConvertToTyped(value);
 		}
 		ZiprDoubleOption_t(std::string key, double value)
-			: ZiprDoubleOption_t(key, "") {
+			: ZiprTypedOption_t(ZiprDoubleOptionType, key, "") {
 			m_value = value;
 			m_untyped_value = ConvertToUntyped(value);
 		}
@@ -302,20 +309,22 @@ class ZiprDoubleOption_t : public ZiprTypedOption_t<double>
 		}
 	private:
 		double ConvertToTyped(std::string value_to_convert) {
-			try {
-				return (double)std::stof(value_to_convert);
-			} catch (std::exception &e) {
+			double converted = 0.;
+			char *endptr = NULL;
+			converted = strtof(value_to_convert.c_str(),
+			                   &endptr);
+			if (*endptr != '\0')
+			{
 				m_set = false;
 				m_untyped_value = "";
 				return 0;
 			}
+			return converted;
 		}
 		std::string ConvertToUntyped(double value_to_convert) {
-			try {
-				return std::to_string(value_to_convert);
-			} catch (std::exception &e) {
-				return std::string("");
-			}
+			std::stringstream ss;
+			ss << value_to_convert;
+			return ss.str();
 		}
 		std::string TypeName() {
 			return "double";
diff --git a/include/zipr_plugin.h b/include/zipr_plugin.h
index cda3465..cf247d0 100644
--- a/include/zipr_plugin.h
+++ b/include/zipr_plugin.h
@@ -34,7 +34,7 @@ class ZiprPluginInterface_t
 		virtual ZiprPreference PlopAddress(
 			const RangeAddress_t &jump, const Dollop_t &dollop, Range_t &place)
 		{
-			return ZiprPreference::None;
+			return None;
 		}
 
 		virtual bool WillPluginPlop(libIRDB::Instruction_t*)
-- 
GitLab