Adding new Commands

Let's say a product has been release and the app loads a keymap like:

XmlElement element( "KEYMAPPINGS" );
if ( gPrefs.GetKeyMappings( element ) )
    commandManager.getKeyMappings()->restoreFromXml( element );

In the next relase of the app you add a couple of short cut commands or a new menu with short cut keys for commands.

How can these new commands be added to the saved key mapping set other than manually checking for each command in the set and manually adding them like this. This could get ugly with a lot of commandds.

Array<KeyPress> kpArray = commandManager.getKeyMappings()->getKeyPressesAssignedToCommand (cmd);
if ( kpArray.size() == 0 )
   commandManager.getKeyMappings()->addKeyPress(cmd, KeyPress('u', ModifierKeys::commandModifier));

Is there a better method?

Well the bit of code you've got there could easily be turned into a nice clean function e.g. "addNewKeyPressesIfUndefined", so it's not like you'd need to have acres of boilerplate code - just a call for each new command you add.

And KeyPress::getTextDescription() to get the string?