calculator/src/CalcViewModel
Pepe Rivera f6f10444f7 Simplify some of the calc engine string logic (#449)
Description of the changes:
Currently Calculator handles strings by defining integers for each type of function that can be performed, this integer will eventually correspond with an index in s_engineStrings which holds the corresponding display string for each function. Some functions such as Sin can have multiple strings (degrees, rads, grads, inverse). Functions like Sin are mapped to another array called "rgUfne" where a new integer is given depending on the output string which will then be given to s_engineStrings. The new integer returned by the "rgUfne" array runs the risk of overlapping with any new functions that may be added in CCommand.h. Furthermore, it is expected that the strings in s_engineStrings and rgUfne are defined in a particular order (not necessarily sequential), otherwise the logic will break. This makes adding new strings for new functions confusing and difficult, since a lot of the logic is not clearly defined.

This PR attempts to make this a bit simpler by changing the s_engineStrings and rgUfne arrays to be unordered_maps instead of arrays. For s_engineStrings the keys will now be strings, allowing the existing logic for indexing to be used by simply converting the number into a string to access the value. This will also allow us to create keys in the future that are not limited to integers but to strings that hold more meaning.

The rgUfne array will also be updated to be a map that will take in an integer and give you the corresponding string that can be passed to s_engineStrings. The UFNE object in the rgUfne array will also be updated to hold all the possible string keys for a function, instead of indexing them on other numbers that may overlap with existing definitions.

Now to add a new string for a new IDC_FOO function, we would just need to add the "FooString" resource keys to the g_sids array and use the updated rgUfne map to link the IDC_FOO value to the corresponding "FooString" resource key. This way the resource key can be a meaningful string, and not an integer that must be in any particular order.

How changes were validated:
Tested each function manually in standard, scientific, and programmer modes.
2019-04-11 15:20:01 -07:00
..
Common Replace custom types with standard ones (#212) 2019-03-26 14:30:46 -07:00
DataLoaders Updating comments per the C++ core guidelines and removing trailing whitespace (#194) 2019-03-14 23:30:07 -07:00
ApplicationViewModel.cpp ViewModelProperties namespaces converted to static member properties. (#306) 2019-03-20 09:56:59 -07:00
ApplicationViewModel.h ViewModelProperties namespaces converted to static member properties. (#306) 2019-03-20 09:56:59 -07:00
CalcViewModel.vcxproj Build with /W4 (#197) 2019-03-08 23:15:28 -08:00
CalcViewModel.vcxproj.filters Clean up project structure in Visual Studio (#8) 2019-02-04 11:52:28 -08:00
DateCalculatorViewModel.cpp ViewModelProperties namespaces converted to static member properties. (#306) 2019-03-20 09:56:59 -07:00
DateCalculatorViewModel.h Fix issue with Date diff when it includes a Daylight Saving Time (#193) 2019-03-18 11:22:32 -07:00
HistoryItemViewModel.cpp Replace escape sequences with path separators in include paths 2019-03-07 15:51:00 -08:00
HistoryItemViewModel.h Updating comments per the C++ core guidelines and removing trailing whitespace (#194) 2019-03-14 23:30:07 -07:00
HistoryViewModel.cpp Updating comments per the C++ core guidelines and removing trailing whitespace (#194) 2019-03-14 23:30:07 -07:00
HistoryViewModel.h - Avoid referencing project headers from precompiled headers. 2019-02-14 18:20:25 -08:00
MemoryItemViewModel.cpp Hello GitHub 2019-01-28 16:24:37 -08:00
MemoryItemViewModel.h - Avoid referencing project headers from precompiled headers. 2019-02-14 18:20:25 -08:00
packages.config Hello GitHub 2019-01-28 16:24:37 -08:00
pch.cpp Hello GitHub 2019-01-28 16:24:37 -08:00
pch.h Disable use of min/max macros defined by Windows headers. (#363) 2019-03-25 11:28:29 -07:00
StandardCalculatorViewModel.cpp Simplify multiple "or" operators (#341) 2019-03-21 10:43:59 -07:00
StandardCalculatorViewModel.h ViewModelProperties namespaces converted to static member properties. (#306) 2019-03-20 09:56:59 -07:00
targetver.h Hello GitHub 2019-01-28 16:24:37 -08:00
UnitConverterViewModel.cpp Simplify some of the calc engine string logic (#449) 2019-04-11 15:20:01 -07:00
UnitConverterViewModel.h ViewModelProperties namespaces converted to static member properties. (#306) 2019-03-20 09:56:59 -07:00
ViewState.cpp Hello GitHub 2019-01-28 16:24:37 -08:00
ViewState.h Hello GitHub 2019-01-28 16:24:37 -08:00