vtk-m/vtkm/cont/internal/VariantArrayHandleContainer.cxx

71 lines
1.8 KiB
C++
Raw Normal View History

//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
2019-04-15 23:24:21 +00:00
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <sstream>
#include <typeindex>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/internal/VariantArrayHandleContainer.h>
namespace vtkm
{
namespace cont
{
namespace internal
{
VariantArrayHandleContainerBase::VariantArrayHandleContainerBase()
: TypeIndex(typeid(nullptr))
{
}
VariantArrayHandleContainerBase::VariantArrayHandleContainerBase(const std::type_info& typeinfo)
: TypeIndex(typeinfo)
{
}
VariantArrayHandleContainerBase::~VariantArrayHandleContainerBase()
{
}
}
namespace detail
{
VTKM_CONT_EXPORT void ThrowCastAndCallException(
const vtkm::cont::internal::VariantArrayHandleContainerBase& ref,
const std::type_info& type)
{
std::ostringstream out;
out << "Could not find appropriate cast for array in CastAndCall.\n"
"Array: ";
ref.PrintSummary(out);
out << "TypeList: " << type.name() << "\n";
throw vtkm::cont::ErrorBadValue(out.str());
}
VTKM_CONT_EXPORT void ThrowAsMultiplexerException(
const vtkm::cont::internal::VariantArrayHandleContainerBase& ref,
const std::initializer_list<std::string>& arrayTypes)
{
std::ostringstream out;
out << "Could not find appropriate cast for array in AsMultiplexer.\n"
"Array: ";
ref.PrintSummary(out);
out << "Supported arrays:\n";
for (auto&& type : arrayTypes)
{
out << " " << type << "\n";
}
throw vtkm::cont::ErrorBadValue(out.str());
}
}
}
} // namespace vtkm::cont::detail