/********************************************************************************************************************** CEnumConverter::Register_Enum_Entry_Internal -- registers a string<->integer conversion pair within an enum enum_type_id -- type info of the enum to register a conversion entry for entry_name -- string representation of the enum entry value entry_value -- integer value of the enum entry **********************************************************************************************************************/ void CEnumConverter::Register_Enum_Entry_Internal( const std::type_info &enum_type_id, const std::string &entry_name, uint64 entry_value ) { CConvertibleEnum *enum_object = Find_Enum( enum_type_id ); FATAL_ASSERT( enum_object != nullptr ); enum_object->Register_Entry( entry_name, entry_value ); }
/********************************************************************************************************************** CEnumConverter::Convert_Internal -- converts from an integer to a string for the supplied enum enum_name -- name of the enum this is a conversion operation for value -- integer value to convert from entry_name -- output parameter for the corresponding string value **********************************************************************************************************************/ bool CEnumConverter::Convert_Internal( const std::type_info &enum_type_id, uint64 value, std::string &entry_name ) { CConvertibleEnum *enum_object = Find_Enum( enum_type_id ); if ( enum_object == nullptr ) { return false; } return enum_object->Convert( value, entry_name ); }
bool CEnumConverter::Convert_Internal( const Loki::TypeInfo &enum_type_info, const std::string &entry_name, uint64_t &output_value ) { CConvertibleEnum *enum_object = Find_Enum( enum_type_info ); if ( enum_object == nullptr ) { return false; } return enum_object->Convert( entry_name, output_value ); }
/********************************************************************************************************************** CEnumConverter::Convert -- converts from a string to an integer for the supplied enum enum_name -- name of the enum this is a conversion operation for entry_name -- string value to convert from output_value -- output parameter for the corresponding integer value **********************************************************************************************************************/ bool CEnumConverter::Convert( const std::string &enum_name, const std::wstring &entry_name, uint64 &output_value ) { CConvertibleEnum *enum_object = Find_Enum( enum_name ); if ( enum_object == nullptr ) { return false; } std::string usable_entry_name; NStringUtils::WideString_To_String( entry_name, usable_entry_name ); return enum_object->Convert( usable_entry_name, output_value ); }
/********************************************************************************************************************** CEnumConverter::Convert_Internal -- converts from an integer to a wstring for the supplied enum enum_name -- name of the enum this is a conversion operation for value -- integer value to convert from entry_name -- output parameter for the corresponding string value **********************************************************************************************************************/ bool CEnumConverter::Convert_Internal( const std::type_info &enum_type_id, uint64 value, std::wstring &entry_name ) { CConvertibleEnum *enum_object = Find_Enum( enum_type_id ); if ( enum_object == nullptr ) { return false; } std::string narrow_entry_name; bool success = enum_object->Convert( value, narrow_entry_name ); if ( success ) { NStringUtils::String_To_WideString( narrow_entry_name, entry_name ); } return success; }