Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add IndexToDataType Method #754

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/complex/Common/TypesUtility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,32 @@ inline constexpr DataType StringToDataType(std::string_view dataTypeString)
}
}

/**
* @brief Returns a DataType for the passed in index
* @param index
* @return
*/
inline std::optional<DataType> IndexToDataType(usize index)
{
switch(index)
{
case static_cast<int>(DataType::int8):
case static_cast<int>(DataType::uint8):
case static_cast<int>(DataType::int16):
case static_cast<int>(DataType::uint16):
case static_cast<int>(DataType::int32):
case static_cast<int>(DataType::uint32):
case static_cast<int>(DataType::int64):
case static_cast<int>(DataType::uint64):
case static_cast<int>(DataType::float32):
case static_cast<int>(DataType::float64):
case static_cast<int>(DataType::boolean):
return static_cast<DataType>(index);
default:
return {};
}
}

/**
* @brief Converts DataType to NumericType. Fails on DataType::bool and DataType::error.
* @param dataType
Expand Down