From 9ca6fc7ab20de310a7c36056ac7141d6d3c36d54 Mon Sep 17 00:00:00 2001 From: Leonetienne Date: Tue, 8 Feb 2022 09:35:42 +0100 Subject: [PATCH] Compiled new deployment --- INCLUDE/Hazelnupp.cpp | 32 +- INCLUDE/Hazelnupp.h | 830 +++++++++++++++++++++--------------------- 2 files changed, 438 insertions(+), 424 deletions(-) diff --git a/INCLUDE/Hazelnupp.cpp b/INCLUDE/Hazelnupp.cpp index 451eb88..a9d65be 100644 --- a/INCLUDE/Hazelnupp.cpp +++ b/INCLUDE/Hazelnupp.cpp @@ -1,6 +1,6 @@ #include "Hazelnupp.h" -/*** ../Hazelnupp/CmdArgsInterface.cpp ***/ +/*** ./../Hazelnupp/CmdArgsInterface.cpp ***/ #include #include @@ -67,7 +67,7 @@ void CmdArgsInterface::Parse(const int argc, const char* const* argv) { std::cout << GenerateDocumentation() << std::endl << std::endl; std::cerr << "Parameter error: " << exc.What() << std::endl; - quick_exit(-1000); + exit(-1000); } else throw exc; // yeet @@ -78,7 +78,7 @@ void CmdArgsInterface::Parse(const int argc, const char* const* argv) { std::cout << GenerateDocumentation() << std::endl << std::endl; std::cerr << "Parameter error: " << exc.What() << std::endl; - quick_exit(-1001); + exit(-1001); } else throw exc; // yeet @@ -89,7 +89,7 @@ void CmdArgsInterface::Parse(const int argc, const char* const* argv) { std::cout << GenerateDocumentation() << std::endl << std::endl; std::cerr << "Parameter error: " << exc.What() << std::endl; - quick_exit(-1002); + exit(-1002); } else throw exc; // yeet @@ -100,7 +100,7 @@ void CmdArgsInterface::Parse(const int argc, const char* const* argv) { std::cout << GenerateDocumentation() << std::endl << std::endl; std::cerr << "Parameter error: " << exc.What() << std::endl; - quick_exit(-1003); + exit(-1003); } else throw exc; // yeet @@ -111,7 +111,7 @@ void CmdArgsInterface::Parse(const int argc, const char* const* argv) { std::cout << GenerateDocumentation() << std::endl << std::endl; std::cerr << "Parameter error: " << exc.What() << std::endl; - quick_exit(-1004); + exit(-1004); } else throw exc; // yeet @@ -121,7 +121,7 @@ void CmdArgsInterface::Parse(const int argc, const char* const* argv) if ((catchHelp) && (HasParam("--help"))) { std::cout << GenerateDocumentation() << std::endl; - quick_exit(0); + exit(0); } return; @@ -589,7 +589,7 @@ void CmdArgsInterface::ApplyConstraints() // Is ANY parameter present listed as incompatible with our current one? for (const std::string& incompatibility : pc.second.incompatibleParameters) - for (const std::pair& otherParam : parameters) + for (const auto& otherParam : parameters) { if (otherParam.first == incompatibility) throw HazelnuppConstraintIncompatibleParameters(pc.second.key, incompatibility); @@ -685,7 +685,7 @@ const ParamConstraint* CmdArgsInterface::GetConstraintForKey(const std::string& } -/*** ../Hazelnupp/FloatValue.cpp ***/ +/*** ./../Hazelnupp/FloatValue.cpp ***/ #include @@ -762,7 +762,7 @@ const std::vector& FloatValue::GetList() const } -/*** ../Hazelnupp/IntValue.cpp ***/ +/*** ./../Hazelnupp/IntValue.cpp ***/ #include @@ -839,7 +839,7 @@ const std::vector& IntValue::GetList() const } -/*** ../Hazelnupp/ListValue.cpp ***/ +/*** ./../Hazelnupp/ListValue.cpp ***/ #include @@ -938,7 +938,7 @@ const std::vector& ListValue::GetList() const } -/*** ../Hazelnupp/Parameter.cpp ***/ +/*** ./../Hazelnupp/Parameter.cpp ***/ using namespace Hazelnp; @@ -970,7 +970,7 @@ const ::Value* Parameter::GetValue() const } -/*** ../Hazelnupp/StringTools.cpp ***/ +/*** ./../Hazelnupp/StringTools.cpp ***/ using namespace Hazelnp; @@ -1159,7 +1159,7 @@ std::string Internal::StringTools::ToLower(const std::string& str) } -/*** ../Hazelnupp/StringValue.cpp ***/ +/*** ./../Hazelnupp/StringValue.cpp ***/ #include @@ -1228,7 +1228,7 @@ const std::vector& StringValue::GetList() const } -/*** ../Hazelnupp/Value.cpp ***/ +/*** ./../Hazelnupp/Value.cpp ***/ using namespace Hazelnp; @@ -1246,7 +1246,7 @@ DATA_TYPE Value::GetDataType() const } -/*** ../Hazelnupp/VoidValue.cpp ***/ +/*** ./../Hazelnupp/VoidValue.cpp ***/ using namespace Hazelnp; diff --git a/INCLUDE/Hazelnupp.h b/INCLUDE/Hazelnupp.h index 4c6113d..65837df 100644 --- a/INCLUDE/Hazelnupp.h +++ b/INCLUDE/Hazelnupp.h @@ -1,66 +1,13 @@ #pragma once -/*** ../Hazelnupp/StringTools.h ***/ +/*** ./../Hazelnupp/Version.h ***/ -#include -#include -#include -#include - -namespace Hazelnp -{ - namespace Internal - { - /** Internal helper class. Feel free to use it tho. - */ - class StringTools - { - public: - //! Will return wether or not a given char is in a string - static bool Contains(const std::string& str, const char c); - - //! Will replace a part of a string with another string - static std::string Replace(const std::string& str, const char find, const std::string& subst); - - //! Will replace a part of a string with another string - static std::string Replace(const std::string& str, const std::string& find, const std::string& subst); - - //! Will return true if the given string consists only of digits (including signage) - static bool IsNumeric(const std::string& str, const bool allowDecimalPoint = false); - - //! Will convert the number in str to a number. - //! Returns wether or not the operation was successful. - //! Also returns wether the number is an integer, or floating point. If int, cast out_number to int. - static bool ParseNumber(const std::string& str, bool& out_isInt, long double& out_number); - - //! Will split a string by a delimiter char. The delimiter will be excluded! - static std::vector SplitString(const std::string& str, const char delimiter); - - //! Will split a string by a delimiter string. The delimiter will be excluded! - static std::vector SplitString(const std::string& str, const std::string& delimiter); - - //! Will make a string all lower-case - static std::string ToLower(const std::string& str); - }; - } -} - +#pragma once +#define HAZELNUPP_VERSION (1.122) -/*** ../Hazelnupp/Placeholders.h ***/ - -#include - -namespace Hazelnp -{ - namespace Placeholders - { - //! The only purpose of this is to provide the ability to return an empty string as an error for std::string& methods. - static const std::string g_emptyString; - } -} - -/*** ../Hazelnupp/DataType.h ***/ +/*** ./../Hazelnupp/DataType.h ***/ +#pragma once #include namespace Hazelnp @@ -100,124 +47,9 @@ namespace Hazelnp } } -/*** ../Hazelnupp/HazelnuppException.h ***/ - -#include -#include -#include - -namespace Hazelnp -{ - /** Generic hazelnupp exception - */ - class HazelnuppException : public std::exception - { - public: - HazelnuppException() {}; - HazelnuppException(const std::string& msg) : message{ msg } {}; - - //! Will return an error message - const std::string& What() const - { - return message; - } - - protected: - std::string message; - }; - - /** Gets thrown when an non-existent key gets dereferenced - */ - class HazelnuppInvalidKeyException : public HazelnuppException - { - public: - HazelnuppInvalidKeyException() : HazelnuppException() {}; - HazelnuppInvalidKeyException(const std::string& msg) : HazelnuppException(msg) {}; - }; - - /** Gets thrown when an attempt is made to retrieve the wrong data type from a value, when the value not convertible - */ - class HazelnuppValueNotConvertibleException : public HazelnuppException - { - public: - HazelnuppValueNotConvertibleException() : HazelnuppException() {}; - HazelnuppValueNotConvertibleException(const std::string& msg) : HazelnuppException(msg) {}; - }; - - /** Gets thrown something bad happens because of parameter constraints - */ - class HazelnuppConstraintException : public HazelnuppException - { - public: - HazelnuppConstraintException() : HazelnuppException() {}; - HazelnuppConstraintException(const std::string& msg) : HazelnuppException(msg) {}; - }; - - /** Gets thrown when a parameter is of a type that does not match the required type, and is not convertible to it - */ - class HazelnuppConstraintTypeMissmatch : public HazelnuppConstraintException - { - public: - HazelnuppConstraintTypeMissmatch() : HazelnuppConstraintException() {}; - HazelnuppConstraintTypeMissmatch(const std::string& msg) : HazelnuppConstraintException(msg) {}; - - HazelnuppConstraintTypeMissmatch(const std::string& key, const DATA_TYPE requiredType, const DATA_TYPE actualType, const std::string& paramDescription = "") - { - // Generate descriptive error message - std::stringstream ss; - ss << "Cannot convert parameter " << key << " to type " << DataTypeToString(requiredType) - << ". You supplied type: " << DataTypeToString(actualType) << "."; - - // Add the parameter description, if provided - if (paramDescription.length() > 0) - ss << std::endl << key << " => " << paramDescription; - - message = ss.str(); - return; - }; - }; - - /** Gets thrown when a parameter constrained to be required is not provided, and has no default value set - */ - class HazelnuppConstraintMissingValue : public HazelnuppConstraintException - { - public: - HazelnuppConstraintMissingValue() : HazelnuppConstraintException() {}; - HazelnuppConstraintMissingValue(const std::string& key, const std::string& paramDescription = "") - { - // Generate descriptive error message - std::stringstream ss; - ss << "Missing required parameter " << key << "."; - - // Add the parameter description, if provided - if (paramDescription.length() > 0) - ss << std::endl << key << " => " << paramDescription; - - message = ss.str(); - return; - }; - }; - - /** Gets thrown when a parameter constrained to be incompatible with other parameters gets supplied alongside at least one of those incompatible ones - */ - class HazelnuppConstraintIncompatibleParameters : public HazelnuppConstraintException - { - public: - HazelnuppConstraintIncompatibleParameters() : HazelnuppConstraintException() {}; - HazelnuppConstraintIncompatibleParameters(const std::string& key1, const std::string& key2) - { - // Generate descriptive error message - std::stringstream ss; - ss << "Parameter \"" << key1 << "\" is NOT compatible with parameter \"" << key2 << "\"!"; - - message = ss.str(); - return; - }; - }; -} - -/*** ../Hazelnupp/ParamConstraint.h ***/ +/*** ./../Hazelnupp/ParamConstraint.h ***/ +#pragma once #include #include @@ -354,12 +186,9 @@ namespace Hazelnp }; } -/*** ../Hazelnupp/Version.h ***/ - -#define HAZELNUPP_VERSION (1.121) - -/*** ../Hazelnupp/Value.h ***/ +/*** ./../Hazelnupp/Value.h ***/ +#pragma once #include #include @@ -409,234 +238,9 @@ namespace Hazelnp }; } -/*** ../Hazelnupp/ListValue.h ***/ - -#include - -namespace Hazelnp -{ - /** Specializations for list values (uses std::vector) - */ - class ListValue : public Value - { - public: - ListValue(); - ~ListValue() override; - - //! Will return a deeopopy of this object - Value* Deepcopy() const override; - - //! Will return a string suitable for an std::ostream; - std::string GetAsOsString() const override; - - //! Will add this value to the list - void AddValue(const Value* value); - - //! Will return the raw value - const std::vector& GetValue() const; - - operator std::vector() const; - - //! Throws HazelnuppValueNotConvertibleException - long long int GetInt64() const override; - //! Throws HazelnuppValueNotConvertibleException - int GetInt32() const override; - - //! Throws HazelnuppValueNotConvertibleException - long double GetFloat64() const override; - //! Throws HazelnuppValueNotConvertibleException - double GetFloat32() const override; - - //! Throws HazelnuppValueNotConvertibleException - std::string GetString() const override; - - //! Will return this values list - const std::vector& GetList() const override; - - private: - std::vector value; - }; -} - -/*** ../Hazelnupp/FloatValue.h ***/ - -#include - -namespace Hazelnp -{ - /** Specializations for floating point values (uses long double) - */ - class FloatValue : public Value - { - public: - FloatValue(const long double& value); - ~FloatValue() override {}; - - //! Will return a deeopopy of this object - Value* Deepcopy() const override; - - //! Will return a string suitable for an std::ostream; - std::string GetAsOsString() const override; - - //! Will return the raw value - const long double& GetValue() const; - - operator long double() const; - operator double() const; - - //! Will return the data as a long long int - long long int GetInt64() const override; - //! Will return the data as an int - int GetInt32() const override; - - //! Will return the data as a long double - long double GetFloat64() const override; - //! Will return the data as a double - double GetFloat32() const override; - - //! Will return the data as a string - std::string GetString() const override; - - //! Throws HazelnuppValueNotConvertibleException - const std::vector& GetList() const override; - - private: - long double value; - }; -} - -/*** ../Hazelnupp/IntValue.h ***/ - - -namespace Hazelnp -{ - /** Specializations for integer values (uses long long int) - */ - class IntValue : public Value - { - public: - IntValue(const long long int& value); - ~IntValue() override {}; - - //! Will return a deeopopy of this object - Value* Deepcopy() const override; - - //! Will return a string suitable for an std::ostream; - std::string GetAsOsString() const override; - - //! Will return the raw value - const long long int& GetValue() const; - - operator long long int() const; - operator int() const; - - - //! Will return the data as a long long int - long long int GetInt64() const override; - //! Will return the data as an int - int GetInt32() const override; - - //! Will return the data as a long double - long double GetFloat64() const override; - //! Will return the data as a double - double GetFloat32() const override; - - //! Will return the data as a string - std::string GetString() const override; - - //! Throws HazelnuppValueNotConvertibleException - const std::vector& GetList() const override; - - private: - long long int value; - }; -} - -/*** ../Hazelnupp/VoidValue.h ***/ - - -namespace Hazelnp -{ - /** Specializations for void values. These house no value whatsoever, but only communicate information by merely existing. - */ - class VoidValue : public Value - { - public: - VoidValue(); - ~VoidValue() override {}; - - //! Will return a deeopopy of this object - Value* Deepcopy() const override; - - //! Will return a string suitable for an std::ostream; - std::string GetAsOsString() const override; - - //! Throws HazelnuppValueNotConvertibleException - long long int GetInt64() const override; - //! Throws HazelnuppValueNotConvertibleException - int GetInt32() const override; - - //! Throws HazelnuppValueNotConvertibleException - long double GetFloat64() const override; - //! Throws HazelnuppValueNotConvertibleException - double GetFloat32() const override; - - //! Returns an empty string - std::string GetString() const override; - - //! Returns an empty list - const std::vector& GetList() const; - }; -} - -/*** ../Hazelnupp/StringValue.h ***/ - -#include - -namespace Hazelnp -{ - /** Specializations for string values (uses std::string) - */ - class StringValue : public Value - { - public: - StringValue(const std::string& value); - ~StringValue() override {}; - - //! Will return a deeopopy of this object - Value* Deepcopy() const override; - - //! Will return a string suitable for an std::ostream; - std::string GetAsOsString() const override; - - //! Will return the raw value - const std::string& GetValue() const; - - operator std::string() const; - - //! Throws HazelnuppValueNotConvertibleException - long long int GetInt64() const override; - //! Throws HazelnuppValueNotConvertibleException - int GetInt32() const override; - - //! Throws HazelnuppValueNotConvertibleException - long double GetFloat64() const override; - //! Throws HazelnuppValueNotConvertibleException - double GetFloat32() const override; - - //! Will return this value as a string - std::string GetString() const override; - - //! Throws HazelnuppValueNotConvertibleException - const std::vector& GetList() const override; - - private: - std::string value; - }; -} - -/*** ../Hazelnupp/Parameter.h ***/ +/*** ./../Hazelnupp/Parameter.h ***/ +#pragma once #include #include @@ -665,8 +269,9 @@ namespace Hazelnp }; } -/*** ../Hazelnupp/CmdArgsInterface.h ***/ +/*** ./../Hazelnupp/CmdArgsInterface.h ***/ +#pragma once #include #include @@ -811,3 +416,412 @@ namespace Hazelnp bool crashOnFail = true; }; } + +/*** ./../Hazelnupp/StringValue.h ***/ + +#pragma once +#include + +namespace Hazelnp +{ + /** Specializations for string values (uses std::string) + */ + class StringValue : public Value + { + public: + StringValue(const std::string& value); + ~StringValue() override {}; + + //! Will return a deeopopy of this object + Value* Deepcopy() const override; + + //! Will return a string suitable for an std::ostream; + std::string GetAsOsString() const override; + + //! Will return the raw value + const std::string& GetValue() const; + + operator std::string() const; + + //! Throws HazelnuppValueNotConvertibleException + long long int GetInt64() const override; + //! Throws HazelnuppValueNotConvertibleException + int GetInt32() const override; + + //! Throws HazelnuppValueNotConvertibleException + long double GetFloat64() const override; + //! Throws HazelnuppValueNotConvertibleException + double GetFloat32() const override; + + //! Will return this value as a string + std::string GetString() const override; + + //! Throws HazelnuppValueNotConvertibleException + const std::vector& GetList() const override; + + private: + std::string value; + }; +} + +/*** ./../Hazelnupp/VoidValue.h ***/ + +#pragma once + +namespace Hazelnp +{ + /** Specializations for void values. These house no value whatsoever, but only communicate information by merely existing. + */ + class VoidValue : public Value + { + public: + VoidValue(); + ~VoidValue() override {}; + + //! Will return a deeopopy of this object + Value* Deepcopy() const override; + + //! Will return a string suitable for an std::ostream; + std::string GetAsOsString() const override; + + //! Throws HazelnuppValueNotConvertibleException + long long int GetInt64() const override; + //! Throws HazelnuppValueNotConvertibleException + int GetInt32() const override; + + //! Throws HazelnuppValueNotConvertibleException + long double GetFloat64() const override; + //! Throws HazelnuppValueNotConvertibleException + double GetFloat32() const override; + + //! Returns an empty string + std::string GetString() const override; + + //! Returns an empty list + const std::vector& GetList() const override; + }; +} + +/*** ./../Hazelnupp/IntValue.h ***/ + +#pragma once + +namespace Hazelnp +{ + /** Specializations for integer values (uses long long int) + */ + class IntValue : public Value + { + public: + IntValue(const long long int& value); + ~IntValue() override {}; + + //! Will return a deeopopy of this object + Value* Deepcopy() const override; + + //! Will return a string suitable for an std::ostream; + std::string GetAsOsString() const override; + + //! Will return the raw value + const long long int& GetValue() const; + + operator long long int() const; + operator int() const; + + + //! Will return the data as a long long int + long long int GetInt64() const override; + //! Will return the data as an int + int GetInt32() const override; + + //! Will return the data as a long double + long double GetFloat64() const override; + //! Will return the data as a double + double GetFloat32() const override; + + //! Will return the data as a string + std::string GetString() const override; + + //! Throws HazelnuppValueNotConvertibleException + const std::vector& GetList() const override; + + private: + long long int value; + }; +} + +/*** ./../Hazelnupp/FloatValue.h ***/ + +#pragma once +#include + +namespace Hazelnp +{ + /** Specializations for floating point values (uses long double) + */ + class FloatValue : public Value + { + public: + FloatValue(const long double& value); + ~FloatValue() override {}; + + //! Will return a deeopopy of this object + Value* Deepcopy() const override; + + //! Will return a string suitable for an std::ostream; + std::string GetAsOsString() const override; + + //! Will return the raw value + const long double& GetValue() const; + + operator long double() const; + operator double() const; + + //! Will return the data as a long long int + long long int GetInt64() const override; + //! Will return the data as an int + int GetInt32() const override; + + //! Will return the data as a long double + long double GetFloat64() const override; + //! Will return the data as a double + double GetFloat32() const override; + + //! Will return the data as a string + std::string GetString() const override; + + //! Throws HazelnuppValueNotConvertibleException + const std::vector& GetList() const override; + + private: + long double value; + }; +} + +/*** ./../Hazelnupp/ListValue.h ***/ + +#pragma once +#include + +namespace Hazelnp +{ + /** Specializations for list values (uses std::vector) + */ + class ListValue : public Value + { + public: + ListValue(); + ~ListValue() override; + + //! Will return a deeopopy of this object + Value* Deepcopy() const override; + + //! Will return a string suitable for an std::ostream; + std::string GetAsOsString() const override; + + //! Will add this value to the list + void AddValue(const Value* value); + + //! Will return the raw value + const std::vector& GetValue() const; + + operator std::vector() const; + + //! Throws HazelnuppValueNotConvertibleException + long long int GetInt64() const override; + //! Throws HazelnuppValueNotConvertibleException + int GetInt32() const override; + + //! Throws HazelnuppValueNotConvertibleException + long double GetFloat64() const override; + //! Throws HazelnuppValueNotConvertibleException + double GetFloat32() const override; + + //! Throws HazelnuppValueNotConvertibleException + std::string GetString() const override; + + //! Will return this values list + const std::vector& GetList() const override; + + private: + std::vector value; + }; +} + +/*** ./../Hazelnupp/StringTools.h ***/ + +#pragma once +#include +#include +#include +#include + +namespace Hazelnp +{ + namespace Internal + { + /** Internal helper class. Feel free to use it tho. + */ + class StringTools + { + public: + //! Will return wether or not a given char is in a string + static bool Contains(const std::string& str, const char c); + + //! Will replace a part of a string with another string + static std::string Replace(const std::string& str, const char find, const std::string& subst); + + //! Will replace a part of a string with another string + static std::string Replace(const std::string& str, const std::string& find, const std::string& subst); + + //! Will return true if the given string consists only of digits (including signage) + static bool IsNumeric(const std::string& str, const bool allowDecimalPoint = false); + + //! Will convert the number in str to a number. + //! Returns wether or not the operation was successful. + //! Also returns wether the number is an integer, or floating point. If int, cast out_number to int. + static bool ParseNumber(const std::string& str, bool& out_isInt, long double& out_number); + + //! Will split a string by a delimiter char. The delimiter will be excluded! + static std::vector SplitString(const std::string& str, const char delimiter); + + //! Will split a string by a delimiter string. The delimiter will be excluded! + static std::vector SplitString(const std::string& str, const std::string& delimiter); + + //! Will make a string all lower-case + static std::string ToLower(const std::string& str); + }; + } +} + + +/*** ./../Hazelnupp/HazelnuppException.h ***/ + +#pragma once +#include +#include +#include + +namespace Hazelnp +{ + /** Generic hazelnupp exception + */ + class HazelnuppException : public std::exception + { + public: + HazelnuppException() {}; + HazelnuppException(const std::string& msg) : message{ msg } {}; + + //! Will return an error message + const std::string& What() const + { + return message; + } + + protected: + std::string message; + }; + + /** Gets thrown when an non-existent key gets dereferenced + */ + class HazelnuppInvalidKeyException : public HazelnuppException + { + public: + HazelnuppInvalidKeyException() : HazelnuppException() {}; + HazelnuppInvalidKeyException(const std::string& msg) : HazelnuppException(msg) {}; + }; + + /** Gets thrown when an attempt is made to retrieve the wrong data type from a value, when the value not convertible + */ + class HazelnuppValueNotConvertibleException : public HazelnuppException + { + public: + HazelnuppValueNotConvertibleException() : HazelnuppException() {}; + HazelnuppValueNotConvertibleException(const std::string& msg) : HazelnuppException(msg) {}; + }; + + /** Gets thrown something bad happens because of parameter constraints + */ + class HazelnuppConstraintException : public HazelnuppException + { + public: + HazelnuppConstraintException() : HazelnuppException() {}; + HazelnuppConstraintException(const std::string& msg) : HazelnuppException(msg) {}; + }; + + /** Gets thrown when a parameter is of a type that does not match the required type, and is not convertible to it + */ + class HazelnuppConstraintTypeMissmatch : public HazelnuppConstraintException + { + public: + HazelnuppConstraintTypeMissmatch() : HazelnuppConstraintException() {}; + HazelnuppConstraintTypeMissmatch(const std::string& msg) : HazelnuppConstraintException(msg) {}; + + HazelnuppConstraintTypeMissmatch(const std::string& key, const DATA_TYPE requiredType, const DATA_TYPE actualType, const std::string& paramDescription = "") + { + // Generate descriptive error message + std::stringstream ss; + ss << "Cannot convert parameter " << key << " to type " << DataTypeToString(requiredType) + << ". You supplied type: " << DataTypeToString(actualType) << "."; + + // Add the parameter description, if provided + if (paramDescription.length() > 0) + ss << std::endl << key << " => " << paramDescription; + + message = ss.str(); + return; + }; + }; + + /** Gets thrown when a parameter constrained to be required is not provided, and has no default value set + */ + class HazelnuppConstraintMissingValue : public HazelnuppConstraintException + { + public: + HazelnuppConstraintMissingValue() : HazelnuppConstraintException() {}; + HazelnuppConstraintMissingValue(const std::string& key, const std::string& paramDescription = "") + { + // Generate descriptive error message + std::stringstream ss; + ss << "Missing required parameter " << key << "."; + + // Add the parameter description, if provided + if (paramDescription.length() > 0) + ss << std::endl << key << " => " << paramDescription; + + message = ss.str(); + return; + }; + }; + + /** Gets thrown when a parameter constrained to be incompatible with other parameters gets supplied alongside at least one of those incompatible ones + */ + class HazelnuppConstraintIncompatibleParameters : public HazelnuppConstraintException + { + public: + HazelnuppConstraintIncompatibleParameters() : HazelnuppConstraintException() {}; + HazelnuppConstraintIncompatibleParameters(const std::string& key1, const std::string& key2) + { + // Generate descriptive error message + std::stringstream ss; + ss << "Parameter \"" << key1 << "\" is NOT compatible with parameter \"" << key2 << "\"!"; + + message = ss.str(); + return; + }; + }; +} + +/*** ./../Hazelnupp/Placeholders.h ***/ + +#pragma once +#include + +namespace Hazelnp +{ + namespace Placeholders + { + //! The only purpose of this is to provide the ability to return an empty string as an error for std::string& methods. + static const std::string g_emptyString; + } +}