diff --git a/src/Context.h b/src/Context.h index 53c8b7896..e072a2826 100644 --- a/src/Context.h +++ b/src/Context.h @@ -16,7 +16,7 @@ */ /** @file - * @brief Enum Version, class Magnum::Context, Magnum::Extension, macro MAGNUM_ASSERT_VERSION_SUPPORTED(), MAGNUM_ASSERT_EXTENSION_SUPPORTED() + * @brief Enum Magnum::Version, class Magnum::Context, Magnum::Extension, macro MAGNUM_ASSERT_VERSION_SUPPORTED(), MAGNUM_ASSERT_EXTENSION_SUPPORTED() */ #include diff --git a/src/IndexedMesh.cpp b/src/IndexedMesh.cpp index 8053cbfcf..099bc3065 100644 --- a/src/IndexedMesh.cpp +++ b/src/IndexedMesh.cpp @@ -87,4 +87,44 @@ void IndexedMesh::bindIndexedImplementationDefault() { void IndexedMesh::bindIndexedImplementationVAO() {} +#ifndef DOXYGEN_GENERATING_OUTPUT +Debug operator<<(Debug debug, IndexedMesh::IndexType value) { + switch(value) { + #define _c(value) case IndexedMesh::IndexType::value: return debug << "IndexedMesh::IndexType::" #value; + _c(UnsignedByte) + _c(UnsignedShort) + _c(UnsignedInt) + #undef _c + } + + return debug << "IndexedMesh::IndexType::(invalid)"; +} +#endif + } + +namespace Corrade { namespace Utility { + +std::string ConfigurationValue::toString(Magnum::IndexedMesh::IndexType value, ConfigurationValueFlags) { + switch(value) { + #define _c(value) case Magnum::IndexedMesh::IndexType::value: return #value; + _c(UnsignedByte) + _c(UnsignedShort) + _c(UnsignedInt) + #undef _c + } + + return ""; +} + +Magnum::IndexedMesh::IndexType ConfigurationValue::fromString(const std::string& stringValue, ConfigurationValueFlags) { + #define _c(value) if(stringValue == #value) return Magnum::IndexedMesh::IndexType::value; + _c(UnsignedByte) + _c(UnsignedShort) + _c(UnsignedInt) + #undef _c + + return Magnum::IndexedMesh::IndexType::UnsignedInt; +} + +}} diff --git a/src/IndexedMesh.h b/src/IndexedMesh.h index 090942179..9d956f99d 100644 --- a/src/IndexedMesh.h +++ b/src/IndexedMesh.h @@ -196,6 +196,32 @@ class MAGNUM_EXPORT IndexedMesh: public Mesh { IndexType _indexType; }; +/** @debugoperator{Magnum::IndexedMesh} */ +Debug MAGNUM_EXPORT operator<<(Debug debug, IndexedMesh::IndexType value); + } +namespace Corrade { namespace Utility { + +/** @configurationvalue{Magnum::IndexedMesh} */ +template<> struct MAGNUM_EXPORT ConfigurationValue { + ConfigurationValue() = delete; + + /** + * @brief Write enum value as string + * + * If the value is invalid, returns empty string. + */ + static std::string toString(Magnum::IndexedMesh::IndexType value, ConfigurationValueFlags); + + /** + * @brief Read enum value as string + * + * If the value is invalid, returns @ref Magnum::IndexedMesh::IndexType "IndexedMesh::IndexType::UnsignedInt". + */ + static Magnum::IndexedMesh::IndexType fromString(const std::string& stringValue, ConfigurationValueFlags); +}; + +}} + #endif diff --git a/src/Test/CMakeLists.txt b/src/Test/CMakeLists.txt index 743268bed..6ae07e8d8 100644 --- a/src/Test/CMakeLists.txt +++ b/src/Test/CMakeLists.txt @@ -1,6 +1,7 @@ corrade_add_test(ArrayTest ArrayTest.cpp) corrade_add_test(ColorTest ColorTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MeshTest MeshTest.cpp LIBRARIES Magnum) +corrade_add_test(IndexedMeshTest IndexedMeshTest.cpp LIBRARIES Magnum) corrade_add_test(ResourceManagerTest ResourceManagerTest.cpp LIBRARIES MagnumTestLib) corrade_add_test(SwizzleTest SwizzleTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(TypeTraitsTest TypeTraitsTest.cpp LIBRARIES Magnum) diff --git a/src/Test/IndexedMeshTest.cpp b/src/Test/IndexedMeshTest.cpp new file mode 100644 index 000000000..6d51e341f --- /dev/null +++ b/src/Test/IndexedMeshTest.cpp @@ -0,0 +1,55 @@ +/* + Copyright © 2010, 2011, 2012 Vladimír Vondruš + + This file is part of Magnum. + + Magnum is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 3 + only, as published by the Free Software Foundation. + + Magnum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License version 3 for more details. +*/ + +#include +#include +#include + +#include "IndexedMesh.h" + +using namespace Corrade::Utility; + +namespace Magnum { namespace Test { + +class IndexedMeshTest: public Corrade::TestSuite::Tester { + public: + IndexedMeshTest(); + + void debug(); + void configuration(); +}; + +IndexedMeshTest::IndexedMeshTest() { + addTests(&IndexedMeshTest::debug, + &IndexedMeshTest::configuration); +} + +void IndexedMeshTest::debug() { + std::ostringstream o; + Debug(&o) << IndexedMesh::IndexType::UnsignedShort; + CORRADE_COMPARE(o.str(), "IndexedMesh::IndexType::UnsignedShort\n"); +} + +void IndexedMeshTest::configuration() { + Configuration c; + + c.setValue("type", IndexedMesh::IndexType::UnsignedByte); + CORRADE_COMPARE(c.value("type"), "UnsignedByte"); + CORRADE_COMPARE(c.value("type"), IndexedMesh::IndexType::UnsignedByte); +} + +}} + +CORRADE_TEST_MAIN(Magnum::Test::IndexedMeshTest)