Last active
August 29, 2015 14:02
-
-
Save jan-matejka/92ab03331c9115c8bd8a 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
inline | |
Text Volume::labelTextFmt( bool doing, bool has_label ) const { | |
if (doing && !has_label) | |
return _("Clearing label on %1$s") | |
if (doing && has_label) | |
return _("Setting label on %1$s to %2$s") | |
if (!has_label) | |
return _("Clear label on %1$s") | |
return _("Set label on %1$s to %2$s") | |
} | |
Text Volume::labelText( bool doing ) const { | |
return sformat(labelTextFmt(doing, !label.empty()), dev.c_str(), label.c_str()); | |
} |
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
labelText doing = sformat (labelTextFmt doing $ empty label) [dev, label] | |
where | |
labelTextFmt True False = _("Clearing label on %1$s") | |
labelTextFmt True True = _("Setting label on %1$s to %2$s") | |
labeltextFmt False False = _("Clear label on %1$s") | |
labelTextFmt False True = _("Set label on %1$s to %2$s") |
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
Text Volume::labelText( bool doing ) const { | |
Text txt, fmt; | |
// compiler should be able to optimize this away I *guess* | |
bool has_label = !label.empty() | |
if (doing && !has_label) | |
fmt = _("Clearing label on %1$s") | |
else if(doing && has_label) | |
fmt = _("Setting label on %1$s to %2$s") | |
else if(!doing && !has_label) | |
fmt = _("Clear label on %1$s") | |
else | |
fmt = _("Set label on %1$s to %2$s") | |
return sformat(fmt, dev.c_str(), label.c_str()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
funny, a2.cpp ends up having more negation than if it had
bool has_no_label
.