Last active
April 7, 2019 07:45
-
-
Save TurtleShip/22041177fd36f6d57b01feb10e2e8925 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void UnitConverter::RestoreUserPreferences(const wstring& userPreferences) | |
{ | |
if (userPreferences.empty()) | |
{ | |
return; | |
} | |
vector<wstring> outerTokens = StringToVector(userPreferences, L"|"); | |
if (outerTokens.size() == 3) | |
{ | |
auto fromType = StringToUnit(outerTokens[0]); | |
auto toType = StringToUnit(outerTokens[1]); | |
m_currentCategory = StringToCategory(outerTokens[2]); | |
// Only restore from the saved units if they are valid in the current available units. | |
auto itr = m_categoryToUnits.find(m_currentCategory); | |
if (itr != m_categoryToUnits.end()) | |
{ | |
auto curUnits = itr->second; | |
if (find(curUnits.begin(), curUnits.end(), fromType) != curUnits.end()) | |
{ | |
m_fromType = fromType; | |
} | |
if (find(curUnits.begin(), curUnits.end(), fromType) != curUnits.end()) | |
{ | |
m_toType = toType; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NIT:
if (outerTokens.size() != 3)
{
return;
}