mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Using std string in verifiers
This commit is contained in:
@@ -22,12 +22,15 @@
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <ghoul/format.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/misc/stringconversion.h>
|
||||
#include <iterator>
|
||||
#include <numeric>
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace openspace::documentation {
|
||||
|
||||
@@ -72,7 +75,7 @@ TestResult TemplateVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
|
||||
template <typename T>
|
||||
std::string TemplateVerifier<T>::documentation() const {
|
||||
return "Value of type '" + type() + "'";
|
||||
return std::format("Value of type '{}'", type());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -84,7 +87,7 @@ std::string Vector2Verifier<T>::type() const {
|
||||
return "Vector2<double>";
|
||||
}
|
||||
else {
|
||||
return std::string("Vector2<") + typeid(T).name() + ">";
|
||||
return std::format("Vector2<{}>", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +100,7 @@ std::string Vector3Verifier<T>::type() const {
|
||||
return "Vector3<double>";
|
||||
}
|
||||
else {
|
||||
return std::string("Vector3<") + typeid(T).name() + ">";
|
||||
return std::format("Vector3<{}>", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +113,7 @@ std::string Vector4Verifier<T>::type() const {
|
||||
return "Vector4<double>";
|
||||
}
|
||||
else {
|
||||
return std::string("Vector4<") + typeid(T).name() + ">";
|
||||
return std::format("Vector4<{}>", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +126,7 @@ std::string Matrix2x2Verifier<T>::type() const {
|
||||
return "Matrix2x2<double>";
|
||||
}
|
||||
else {
|
||||
return std::string("Matrix2x2<") + typeid(T).name() + ">";
|
||||
return std::format("Matrix2x2<{}>", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +139,7 @@ std::string Matrix2x3Verifier<T>::type() const {
|
||||
return "Matrix2x3<double>";
|
||||
}
|
||||
else {
|
||||
return std::string("Matrix2x3<") + typeid(T).name() + ">";
|
||||
return std::format("Matrix2x3<{}>", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +152,7 @@ std::string Matrix2x4Verifier<T>::type() const {
|
||||
return "Matrix2x4<double>";
|
||||
}
|
||||
else {
|
||||
return std::string("Matrix2x4<") + typeid(T).name() + ">";
|
||||
return std::format("Matrix2x4<{}>", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +165,7 @@ std::string Matrix3x2Verifier<T>::type() const {
|
||||
return "Matrix3x2<double>";
|
||||
}
|
||||
else {
|
||||
return std::string("Matrix3x2<") + typeid(T).name() + ">";
|
||||
return std::format("Matrix3x2<{}>", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +178,7 @@ std::string Matrix3x3Verifier<T>::type() const {
|
||||
return "Matrix3x3<double>";
|
||||
}
|
||||
else {
|
||||
return std::string("Matrix3x3<") + typeid(T).name() + ">";
|
||||
return std::format("Matrix3x3<{}>", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +191,7 @@ std::string Matrix3x4Verifier<T>::type() const {
|
||||
return "Matrix3x4<double>";
|
||||
}
|
||||
else {
|
||||
return std::string("Matrix3x4<") + typeid(T).name() + ">";
|
||||
return std::format("Matrix3x4<{}>", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +204,7 @@ std::string Matrix4x2Verifier<T>::type() const {
|
||||
return "Matrix4x2<double>";
|
||||
}
|
||||
else {
|
||||
return std::string("Matrix4x2<") + typeid(T).name() + ">";
|
||||
return std::format("Matrix4x2<{}>", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +217,7 @@ std::string Matrix4x3Verifier<T>::type() const {
|
||||
return "Matrix4x3<double>";
|
||||
}
|
||||
else {
|
||||
return std::string("Matrix4x3<") + typeid(T).name() + ">";
|
||||
return std::format("Matrix4x3<{}>", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +230,7 @@ std::string Matrix4x4Verifier<T>::type() const {
|
||||
return "Matrix4x4<double>";
|
||||
}
|
||||
else {
|
||||
return std::string("Matrix4x4<") + typeid(T).name() + ">";
|
||||
return std::format("Matrix4x4<{}>", typeid(T).name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,32 +296,32 @@ TestResult OperatorVerifier<T, Operator>::operator()(const ghoul::Dictionary& di
|
||||
|
||||
template <typename T>
|
||||
std::string LessVerifier<T>::documentation() const {
|
||||
return "Less than: " + ghoul::to_string(value);
|
||||
return std::format("Less than: {}", ghoul::to_string(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string LessEqualVerifier<T>::documentation() const {
|
||||
return "Less or equal to: " + ghoul::to_string(value);
|
||||
return std::format("Less or equal to: {}", ghoul::to_string(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string GreaterVerifier<T>::documentation() const {
|
||||
return "Greater than: " + ghoul::to_string(value);
|
||||
return std::format("Greater than: {}", ghoul::to_string(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string GreaterEqualVerifier<T>::documentation() const {
|
||||
return "Greater or equal to: " + ghoul::to_string(value);
|
||||
return std::format("Greater or equal to: {}", ghoul::to_string(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string EqualVerifier<T>::documentation() const {
|
||||
return "Equal to: " + ghoul::to_string(value);
|
||||
return std::format("Equal to: {}", ghoul::to_string(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string UnequalVerifier<T>::documentation() const {
|
||||
return "Unequal to: " + ghoul::to_string(value);
|
||||
return std::format("Unequal to: {}", ghoul::to_string(value));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -544,7 +547,7 @@ TestResult InRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
else if constexpr (std::is_same_v<typename T::Type, int>) {
|
||||
const double d = dict.value<double>(key);
|
||||
double intPart;
|
||||
bool isInt = modf(d, &intPart) == 0.0;
|
||||
const bool isInt = std::modf(d, &intPart) == 0.0;
|
||||
if (isInt) {
|
||||
val = static_cast<int>(d);
|
||||
}
|
||||
@@ -584,8 +587,9 @@ TestResult InRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
|
||||
template <typename T>
|
||||
std::string InRangeVerifier<T>::documentation() const {
|
||||
return "In range: ( " + ghoul::to_string(lower) + "," +
|
||||
ghoul::to_string(upper) + " )";
|
||||
return std::format(
|
||||
"In range: ( {}, {})", ghoul::to_string(lower), ghoul::to_string(upper)
|
||||
);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -637,7 +641,7 @@ TestResult NotInRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
|
||||
else if constexpr (std::is_same_v<typename T::Type, int>) {
|
||||
const double d = dict.value<double>(key);
|
||||
double intPart;
|
||||
bool isInt = modf(d, &intPart) == 0.0;
|
||||
const bool isInt = std::modf(d, &intPart) == 0.0;
|
||||
if (isInt) {
|
||||
val = static_cast<int>(d);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user