Audacity  3.0.3
ComponentInterfaceSymbol.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  @file ComponentInterfaceSymbol.h
6 
7  Paul Licameli split from ComponentInterface.h
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_COMPONENT_INTERFACE_SYMBOL__
12 #define __AUDACITY_COMPONENT_INTERFACE_SYMBOL__
13 
14 #include "Identifier.h"
15 #include "Internat.h"
16 
17 /**************************************************************************/
27 {
28 public:
30 
31  // Allows implicit construction from a msgid re-used as an internal string
33  : mInternal{ msgid.MSGID().GET(), }, mMsgid{ msgid }
34  {}
35 
36  // Allows implicit construction from an internal string re-used as a msgid
37  ComponentInterfaceSymbol( const wxString &internal )
38  : mInternal{ internal }, mMsgid{ internal, {} }
39  {}
40 
41  // Allows implicit construction from an internal string re-used as a msgid
42  ComponentInterfaceSymbol( const wxChar *msgid )
43  : mInternal{ msgid }, mMsgid{ msgid, {} }
44  {}
45 
46  // Two-argument version distinguishes internal from translatable string
47  // such as when the first squeezes spaces out
49  const TranslatableString &msgid )
50  : mInternal{ internal.GET() }
51  // Do not permit non-empty msgid with empty internal
52  , mMsgid{ internal.empty() ? TranslatableString{} : msgid }
53  {}
54 
55  const wxString &Internal() const { return mInternal; }
56  const TranslatableString &Msgid() const { return mMsgid; }
57  const TranslatableString Stripped() const { return mMsgid.Stripped(); }
58  const wxString Translation() const { return mMsgid.Translation(); }
59  const wxString StrippedTranslation() const
60  { return Stripped().Translation(); }
61 
62  bool empty() const { return mInternal.empty(); }
63 
65  friend inline bool operator == (
67  { return a.mInternal == b.mInternal; }
68 
69  friend inline bool operator != (
71  { return !( a == b ); }
72 
74  friend inline bool operator < (
76  { return a.mInternal < b.mInternal; }
77 
78 private:
79  wxString mInternal;
81 };
82 
83 // TODO: real type distinctions for these aliases, and move them elsewhere
87 
88 #endif
EnumValueSymbol
ComponentInterfaceSymbol EnumValueSymbol
Definition: ComponentInterfaceSymbol.h:84
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
ComponentInterfaceSymbol::ComponentInterfaceSymbol
ComponentInterfaceSymbol(const wxChar *msgid)
Definition: ComponentInterfaceSymbol.h:42
TranslatableString::empty
bool empty() const
Definition: TranslatableString.h:72
ComponentInterfaceSymbol::ComponentInterfaceSymbol
ComponentInterfaceSymbol(const TranslatableString &msgid)
Definition: ComponentInterfaceSymbol.h:32
ComponentInterfaceSymbol::Translation
const wxString Translation() const
Definition: ComponentInterfaceSymbol.h:58
ComponentInterfaceSymbol::StrippedTranslation
const wxString StrippedTranslation() const
Definition: ComponentInterfaceSymbol.h:59
ComponentInterfaceSymbol::ComponentInterfaceSymbol
ComponentInterfaceSymbol(const Identifier &internal, const TranslatableString &msgid)
Definition: ComponentInterfaceSymbol.h:48
ComponentInterfaceSymbol::operator<
friend bool operator<(const ComponentInterfaceSymbol &a, const ComponentInterfaceSymbol &b)
Comparator for use in ordered containers, using internal name only.
Definition: ComponentInterfaceSymbol.h:74
ComponentInterfaceSymbol::ComponentInterfaceSymbol
ComponentInterfaceSymbol()=default
ComponentInterfaceSymbol::Msgid
const TranslatableString & Msgid() const
Definition: ComponentInterfaceSymbol.h:56
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
ComponentInterfaceSymbol::mInternal
wxString mInternal
Definition: ComponentInterfaceSymbol.h:79
Identifier
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
ComponentInterfaceSymbol::Stripped
const TranslatableString Stripped() const
Definition: ComponentInterfaceSymbol.h:57
ComponentInterfaceSymbol::ComponentInterfaceSymbol
ComponentInterfaceSymbol(const wxString &internal)
Definition: ComponentInterfaceSymbol.h:37
Identifier.h
Identifier::GET
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
Internat.h
ComponentInterfaceSymbol::Internal
const wxString & Internal() const
Definition: ComponentInterfaceSymbol.h:55
ComponentInterfaceSymbol::mMsgid
TranslatableString mMsgid
Definition: ComponentInterfaceSymbol.h:80
TranslatableString::MSGID
Identifier MSGID() const
MSGID is the English lookup key in the catalog, not necessarily for user's eyes if locale is some oth...
Definition: TranslatableString.cpp:17
TranslatableString::Translation
wxString Translation() const
Definition: TranslatableString.h:79
ComponentInterfaceSymbol::empty
bool empty() const
Definition: ComponentInterfaceSymbol.h:62
ComponentInterfaceSymbol::operator==
friend bool operator==(const ComponentInterfaceSymbol &a, const ComponentInterfaceSymbol &b)
Comparator for such as find_if, using internal name only.
Definition: ComponentInterfaceSymbol.h:65
TranslatableString::Stripped
TranslatableString Stripped(unsigned options=MenuCodes) const
non-mutating, constructs another TranslatableString object
Definition: TranslatableString.h:198
ComponentInterfaceSymbol::operator!=
friend bool operator!=(const ComponentInterfaceSymbol &a, const ComponentInterfaceSymbol &b)
Definition: ComponentInterfaceSymbol.h:69