Adapt to Ghoul change (use ghoul::to_string instead of std::to_string)

This commit is contained in:
Alexander Bock
2018-07-20 13:56:15 -04:00
parent edc75c562c
commit 74fd38c260
17 changed files with 100 additions and 94 deletions

View File

@@ -27,6 +27,7 @@
#include <ghoul/misc/boolean.h>
#include <ghoul/misc/exception.h>
#include <ghoul/misc/stringconversion.h>
#include <memory>
#include <string>
#include <vector>
@@ -304,15 +305,25 @@ void testSpecificationAndThrow(const Documentation& documentation,
// Make the overload for std::to_string available for the Offense::Reason for easier
// error logging
namespace std {
namespace ghoul {
std::string to_string(openspace::documentation::TestResult testResult);
template <>
std::string to_string(const openspace::documentation::TestResult& testResult);
std::string to_string(openspace::documentation::TestResult::Offense offense);
std::string to_string(openspace::documentation::TestResult::Offense::Reason reason);
std::string to_string(openspace::documentation::TestResult::Warning warning);
std::string to_string(openspace::documentation::TestResult::Warning::Reason reason);
template <>
std::string to_string(const openspace::documentation::TestResult::Offense& offense);
} // namespace std
template <>
std::string to_string(
const openspace::documentation::TestResult::Offense::Reason& reason);
template <>
std::string to_string(const openspace::documentation::TestResult::Warning& warning);
template <>
std::string to_string(
const openspace::documentation::TestResult::Warning::Reason& reason);
} // namespace ghoul
#endif // __OPENSPACE_CORE___DOCUMENTATION___H__

View File

@@ -27,10 +27,6 @@
#include <iterator>
#include <sstream>
namespace std {
std::string to_string(std::string value);
} // namespace std
namespace openspace::documentation {
template <typename T>
@@ -140,32 +136,32 @@ TestResult OperatorVerifier<T, Operator>::operator()(const ghoul::Dictionary& di
template <typename T>
std::string LessVerifier<T>::documentation() const {
return "Less than: " + std::to_string(value);
return "Less than: " + ghoul::to_string(value);
}
template <typename T>
std::string LessEqualVerifier<T>::documentation() const {
return "Less or equal to: " + std::to_string(value);
return "Less or equal to: " + ghoul::to_string(value);
}
template <typename T>
std::string GreaterVerifier<T>::documentation() const {
return "Greater than: " + std::to_string(value);
return "Greater than: " + ghoul::to_string(value);
}
template <typename T>
std::string GreaterEqualVerifier<T>::documentation() const {
return "Greater or equal to: " + std::to_string(value);
return "Greater or equal to: " + ghoul::to_string(value);
}
template <typename T>
std::string EqualVerifier<T>::documentation() const {
return "Equal to: " + std::to_string(value);
return "Equal to: " + ghoul::to_string(value);
}
template <typename T>
std::string UnequalVerifier<T>::documentation() const {
return "Unequal to: " + std::to_string(value);
return "Unequal to: " + ghoul::to_string(value);
}
template <typename T>
@@ -290,8 +286,8 @@ TestResult InRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
template <typename T>
std::string InRangeVerifier<T>::documentation() const {
return "In range: ( " + std::to_string(lower) + "," +
std::to_string(upper) + " )";
return "In range: ( " + ghoul::to_string(lower) + "," +
ghoul::to_string(upper) + " )";
}
template <typename T>
@@ -323,8 +319,8 @@ TestResult NotInRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
template <typename T>
std::string NotInRangeVerifier<T>::documentation() const {
return "Not in range: ( " + std::to_string(lower) + "," +
std::to_string(upper) + " )";
return "Not in range: ( " + ghoul::to_string(lower) + "," +
ghoul::to_string(upper) + " )";
}

View File

@@ -29,7 +29,7 @@
#include <openspace/interaction/joystickinputstate.h>
#include <ghoul/misc/boolean.h>
#include <ghoul/misc/fromstring.h>
#include <ghoul/misc/stringconversion.h>
#include <map>
#include <vector>
@@ -103,14 +103,11 @@ private:
} // namespace openspace::interaction
namespace std {
std::string to_string(const openspace::interaction::JoystickCameraStates::AxisType& type);
} // namespace std
namespace ghoul {
template <>
std::string to_string(const openspace::interaction::JoystickCameraStates::AxisType& type);
template <>
openspace::interaction::JoystickCameraStates::AxisType
from_string(const std::string& string);

View File

@@ -25,7 +25,7 @@
#ifndef __OPENSPACE_CORE___JOYSTICKINPUTSTATE___H__
#define __OPENSPACE_CORE___JOYSTICKINPUTSTATE___H__
#include <ghoul/misc/fromstring.h>
#include <ghoul/misc/stringconversion.h>
#include <array>
#include <memory>
#include <string>
@@ -110,14 +110,11 @@ struct JoystickInputStates : public std::array<JoystickInputState, MaxJoysticks>
} // namespace openspace::interaction
namespace std {
std::string to_string(openspace::interaction::JoystickAction action);
} // namespace std
namespace ghoul {
template <>
std::string to_string(const openspace::interaction::JoystickAction& action);
template <>
openspace::interaction::JoystickAction from_string(const std::string& str);

View File

@@ -57,6 +57,7 @@
// All values that are defined here are compatible with (and are based on) the
// definitions GLFW v3.1
#include <ghoul/misc/stringconversion.h>
#include <map>
#include <string>
@@ -361,12 +362,17 @@ static const std::map<std::string, Key> KeyMapping = {
} // namespace openspace
namespace std {
namespace ghoul {
std::string to_string(openspace::Key key);
std::string to_string(openspace::KeyModifier mod);
std::string to_string(openspace::KeyWithModifier key);
template <>
std::string to_string(const openspace::Key& key);
} // namespace std
template <>
std::string to_string(const openspace::KeyModifier& mod);
template <>
std::string to_string(const openspace::KeyWithModifier& key);
} // namespace ghoul
#endif // __OPENSPACE_CORE___KEYS___H__

View File

@@ -124,17 +124,15 @@ void RenderablePlaneImageLocal::loadTexture() {
std::unique_ptr<ghoul::opengl::Texture> texture =
ghoul::io::TextureReader::ref().loadTexture(absPath(path));
if (texture) {
LDEBUGC(
"RenderablePlaneImageLocal",
fmt::format("Loaded texture from '{}'", absPath(path))
);
texture->uploadTexture();
LDEBUGC(
"RenderablePlaneImageLocal",
fmt::format("Loaded texture from '{}'", absPath(path))
);
texture->uploadTexture();
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
texture->setFilter(ghoul::opengl::Texture::FilterMode::LinearMipMap);
return texture;
}
return texture;
}
);

View File

@@ -34,7 +34,7 @@
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/dictionary.h>
#include <ghoul/misc/fromstring.h>
#include <ghoul/misc/stringconversion.h>
#include <fstream>
#include "cpl_minixml.h"

View File

@@ -60,14 +60,10 @@ struct WarningCompare {
} // namespace
// Unfortunately, the standard library does not contain a no-op for the to_string method
// so we have to include one ourselves
namespace std {
std::string to_string(std::string value) {
return value;
}
namespace ghoul {
std::string to_string(openspace::documentation::TestResult testResult) {
template <>
std::string to_string(const openspace::documentation::TestResult& testResult) {
using namespace openspace::documentation;
if (testResult.success) {
@@ -78,22 +74,25 @@ std::string to_string(openspace::documentation::TestResult testResult) {
stream << "Failure." << '\n';
for (const TestResult::Offense& offense : testResult.offenses) {
stream << " " << std::to_string(offense) << '\n';
stream << " " << ghoul::to_string(offense) << '\n';
}
for (const TestResult::Warning& warning : testResult.warnings) {
stream << " " << std::to_string(warning) << '\n';
stream << " " << ghoul::to_string(warning) << '\n';
}
return stream.str();
}
}
std::string to_string(openspace::documentation::TestResult::Offense offense) {
return offense.offender + ": " + std::to_string(offense.reason);
template <>
std::string to_string(const openspace::documentation::TestResult::Offense& offense) {
return offense.offender + ": " + ghoul::to_string(offense.reason);
}
std::string to_string(openspace::documentation::TestResult::Offense::Reason reason) {
template <>
std::string to_string(const openspace::documentation::TestResult::Offense::Reason& reason)
{
switch (reason) {
case openspace::documentation::TestResult::Offense::Reason::ExtraKey:
return "Extra key";
@@ -110,11 +109,15 @@ std::string to_string(openspace::documentation::TestResult::Offense::Reason reas
}
}
std::string to_string(openspace::documentation::TestResult::Warning warning) {
return warning.offender + ": " + std::to_string(warning.reason);
template <>
std::string to_string(const openspace::documentation::TestResult::Warning& warning) {
return warning.offender + ": " + ghoul::to_string(warning.reason);
}
std::string to_string(openspace::documentation::TestResult::Warning::Reason reason) {
template <>
std::string to_string(
const openspace::documentation::TestResult::Warning::Reason& reason)
{
switch (reason) {
case openspace::documentation::TestResult::Warning::Reason::Deprecated:
return "Deprecated";
@@ -123,7 +126,7 @@ std::string to_string(openspace::documentation::TestResult::Warning::Reason reas
}
}
} // namespace std
} // namespace ghoul
namespace openspace::documentation {

View File

@@ -333,10 +333,10 @@ void OpenSpaceEngine::create(int argc, char** argv,
"Loading of configuration file '{}' failed", configurationFilePath
));
for (const documentation::TestResult::Offense& o : e.result.offenses) {
LERRORC(o.offender, std::to_string(o.reason));
LERRORC(o.offender, ghoul::to_string(o.reason));
}
for (const documentation::TestResult::Warning& w : e.result.warnings) {
LWARNINGC(w.offender, std::to_string(w.reason));
LWARNINGC(w.offender, ghoul::to_string(w.reason));
}
throw;
}
@@ -537,7 +537,7 @@ void OpenSpaceEngine::initialize() {
// Check the required OpenGL versions of the registered modules
ghoul::systemcapabilities::Version version =
_engine->_moduleEngine->requiredOpenGLVersion();
LINFO(fmt::format("Required OpenGL version: {}", std::to_string(version)));
LINFO(fmt::format("Required OpenGL version: {}", ghoul::to_string(version)));
if (OpenGLCap.openGLVersion() < version) {
throw ghoul::RuntimeError(
@@ -913,10 +913,10 @@ void OpenSpaceEngine::configureLogging(bool consoleLog) {
catch (const documentation::SpecificationError& e) {
LERROR("Failed loading of log");
for (const documentation::TestResult::Offense& o : e.result.offenses) {
LERRORC(o.offender, std::to_string(o.reason));
LERRORC(o.offender, ghoul::to_string(o.reason));
}
for (const documentation::TestResult::Warning& w : e.result.warnings) {
LWARNINGC(w.offender, std::to_string(w.reason));
LWARNINGC(w.offender, ghoul::to_string(w.reason));
}
throw;
}
@@ -1017,8 +1017,8 @@ void OpenSpaceEngine::initializeGL() {
auto callback = [](Source source, Type type, Severity severity,
unsigned int id, std::string message) -> void
{
const std::string s = std::to_string(source);
const std::string t = std::to_string(type);
const std::string s = ghoul::to_string(source);
const std::string t = ghoul::to_string(type);
const std::string category =
"OpenGL (" + s + ") [" + t + "] {" + std::to_string(id) + "}";

View File

@@ -223,8 +223,9 @@ std::vector<std::string> JoystickCameraStates::buttonCommand(int button) const {
} // namespace openspace::interaction
namespace std {
namespace ghoul {
template <>
std::string to_string(const openspace::interaction::JoystickCameraStates::AxisType& type)
{
using T = openspace::interaction::JoystickCameraStates::AxisType;
@@ -244,10 +245,6 @@ std::string to_string(const openspace::interaction::JoystickCameraStates::AxisTy
}
}
} // namespace std
namespace ghoul {
template <>
openspace::interaction::JoystickCameraStates::AxisType from_string(
const std::string& string)

View File

@@ -26,6 +26,7 @@
#include <ghoul/glm.h>
#include <ghoul/misc/invariants.h>
#include <ghoul/misc/stringconversion.h>
#include <algorithm>
#include <map>
#include <numeric>
@@ -68,9 +69,10 @@ bool JoystickInputStates::button(int button, JoystickAction action) const {
} // namespace openspace::interaction
namespace std {
namespace ghoul {
std::string to_string(openspace::interaction::JoystickAction action) {
template <>
std::string to_string(const openspace::interaction::JoystickAction& action) {
switch (action) {
case openspace::interaction::JoystickAction::Idle: return "Idle";
case openspace::interaction::JoystickAction::Press: return "Press";
@@ -80,10 +82,6 @@ std::string to_string(openspace::interaction::JoystickAction action) {
}
}
} // namespace std
namespace ghoul {
template <>
openspace::interaction::JoystickAction from_string(const std::string& string) {
static const std::map<std::string, openspace::interaction::JoystickAction> Map = {

View File

@@ -133,7 +133,7 @@ std::string KeyBindingManager::generateJson() const {
}
first = false;
json << "{";
json << "\"key\": \"" << std::to_string(p.first) << "\",";
json << "\"key\": \"" << ghoul::to_string(p.first) << "\",";
json << "\"script\": \"" << escapedJson(p.second.command) << "\",";
json << "\"remoteScripting\": "
<< (p.second.synchronization ? "true," : "false,");

View File

@@ -131,7 +131,7 @@ int joystickAxis(lua_State* L) {
lua_settop(L, 0);
const bool invert = info.invert;
const bool normalize = info.normalize;
ghoul::lua::push(L, std::to_string(info.type), invert, normalize);
ghoul::lua::push(L, ghoul::to_string(info.type), invert, normalize);
ghoul_assert(lua_gettop(L) == 3, "Incorrect number of items left on stack");
return 3;

View File

@@ -440,7 +440,7 @@ int addSceneGraphNode(lua_State* L) {
return ghoul::lua::luaError(
L,
fmt::format("Error loading scene graph node: {}: {}",
e.what(), std::to_string(e.result))
e.what(), ghoul::to_string(e.result))
);
} catch (const ghoul::RuntimeError& e) {
return ghoul::lua::luaError(

View File

@@ -156,7 +156,7 @@ int hasOpenGLVersion(lua_State* L) {
}
int openGLVersion(lua_State* L) {
ghoul::lua::push(L, std::to_string(OpenGLCap.openGLVersion()));
ghoul::lua::push(L, ghoul::to_string(OpenGLCap.openGLVersion()));
return 1;
}

View File

@@ -124,9 +124,10 @@ bool operator==(const KeyWithModifier& lhs, const KeyWithModifier& rhs) {
} // namespace openspace
namespace std {
namespace ghoul {
std::string to_string(openspace::Key key) {
template <>
std::string to_string(const openspace::Key& key) {
for (const std::pair<const std::string, openspace::Key>& p : openspace::KeyMapping) {
if (p.second == key) {
return p.first;
@@ -135,7 +136,8 @@ std::string to_string(openspace::Key key) {
throw ghoul::MissingCaseException();
}
std::string to_string(openspace::KeyModifier mod) {
template <>
std::string to_string(const openspace::KeyModifier& mod) {
using namespace openspace;
if (mod == KeyModifier::NoModifier) {
@@ -155,7 +157,8 @@ std::string to_string(openspace::KeyModifier mod) {
return result.substr(0, result.size() - 1);
}
std::string to_string(openspace::KeyWithModifier key) {
template <>
std::string to_string(const openspace::KeyWithModifier& key) {
if (key.modifier == openspace::KeyModifier::NoModifier) {
return to_string(key.key);
}
@@ -164,4 +167,4 @@ std::string to_string(openspace::KeyWithModifier key) {
}
}
} // namespace std
} // namespace ghoul