Skip to content

Commit

Permalink
ENH: Add HumanStringToDataType Method in TypesUtilities.h (BlueQuartz…
Browse files Browse the repository at this point in the history
…Software#754)

* Add HumanStringToDataType method.

Signed-off-by: Joey Kleingers <[email protected]>

* Replace HumanStringToDataType method with IndexToDataType method.

Signed-off-by: Joey Kleingers <[email protected]>

---------

Signed-off-by: Joey Kleingers <[email protected]>
  • Loading branch information
joeykleingers authored and imikejackson committed Oct 26, 2023
1 parent f0db52a commit 8c0c279
Showing 1 changed file with 26 additions and 0 deletions.
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

0 comments on commit 8c0c279

Please sign in to comment.