1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

Define class Identifier and template TaggedIdentifier...

... Identifier holds strings used for internal purposes and not shown to users;
TaggedIdentifier generates subclasses of Identifier for different purposes,
which won't implicitly (that is, inadvertently) interconvert as function
arguments.
This commit is contained in:
Paul Licameli
2019-02-26 14:50:35 -05:00
parent 172c8abe03
commit 3eeb91f23a
4 changed files with 222 additions and 4 deletions

View File

@@ -310,3 +310,25 @@ wxArrayStringEx LocalizedStrings(
std::mem_fn( &EnumValueSymbol::Translation )
);
}
// Find a better place for this?
#include "audacity/Types.h"
Identifier::Identifier(
std::initializer_list<Identifier> components, wxChar separator )
{
if( components.size() < 2 )
{
wxASSERT( false );
return;
}
auto iter = components.begin(), end = components.end();
value = (*iter++).value;
while (iter != end)
value += separator + (*iter++).value;
}
std::vector< Identifier > Identifier::split( wxChar separator ) const
{
auto strings = ::wxSplit( value, separator );
return { strings.begin(), strings.end() };
}