Compiled hazelnupp
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
/*** ../Hazelnupp/Placeholders.h ***/
|
||||
|
||||
#include <string>
|
||||
|
||||
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/StringTools.h ***/
|
||||
|
||||
#include <string>
|
||||
@@ -48,20 +61,7 @@ namespace Hazelnp
|
||||
|
||||
/*** ../Hazelnupp/Version.h ***/
|
||||
|
||||
#define HAZELNUPP_VERSION (1.1)
|
||||
|
||||
/*** ../Hazelnupp/Placeholders.h ***/
|
||||
|
||||
#include <string>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
#define HAZELNUPP_VERSION (1.11)
|
||||
|
||||
/*** ../Hazelnupp/DataType.h ***/
|
||||
|
||||
@@ -104,6 +104,122 @@ namespace Hazelnp
|
||||
}
|
||||
}
|
||||
|
||||
/*** ../Hazelnupp/HazelnuppException.h ***/
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
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 ***/
|
||||
|
||||
#include <string>
|
||||
@@ -506,122 +622,6 @@ namespace Hazelnp
|
||||
};
|
||||
}
|
||||
|
||||
/*** ../Hazelnupp/HazelnuppException.h ***/
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
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/CmdArgsInterface.h ***/
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
Reference in New Issue
Block a user