mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-01 16:19:43 +02:00
r & lvalue ref-qualified overloads of TranslatableString functions...
... and moves of TranslatableString arguments where possible
This commit is contained in:
parent
4b3f670bef
commit
8655e2e3b9
@ -380,7 +380,7 @@ public:
|
||||
// Any format arguments that are also of type TranslatableString will be
|
||||
// translated too at substitution time, for non-debug formatting
|
||||
template< typename... Args >
|
||||
TranslatableString &&Format( Args &&...args ) &&
|
||||
TranslatableString &Format( Args &&...args ) &
|
||||
{
|
||||
auto prevFormatter = mFormatter;
|
||||
this->mFormatter = [prevFormatter, args...]
|
||||
@ -399,7 +399,12 @@ public:
|
||||
}
|
||||
}
|
||||
};
|
||||
return std::move( *this );
|
||||
return *this;
|
||||
}
|
||||
template< typename... Args >
|
||||
TranslatableString &&Format( Args &&...args ) &&
|
||||
{
|
||||
return std::move( Format( std::forward<Args>(args)... ) );
|
||||
}
|
||||
|
||||
// Choose a non-default and non-null disambiguating context for lookups
|
||||
@ -407,7 +412,7 @@ public:
|
||||
// This is meant to be the first of chain-call modifications of the
|
||||
// TranslatableString object; it will destroy any previously captured
|
||||
// information
|
||||
TranslatableString &&Context( const wxString &context ) &&
|
||||
TranslatableString &Context( const wxString &context ) &
|
||||
{
|
||||
this->mFormatter = [context]
|
||||
(const wxString &str, Request request) -> wxString {
|
||||
@ -418,17 +423,25 @@ public:
|
||||
return str;
|
||||
}
|
||||
};
|
||||
return std::move( *this );
|
||||
return *this;
|
||||
}
|
||||
TranslatableString &&Context( const wxString &context ) &&
|
||||
{
|
||||
return std::move( Context( context ) );
|
||||
}
|
||||
|
||||
// Append another translatable string; lookup of msgids for
|
||||
// this and for the argument are both delayed until Translate() is invoked
|
||||
// on this, and then the formatter concatenates the translations
|
||||
TranslatableString &Join(
|
||||
TranslatableString arg, const wxString &separator = {} ) &;
|
||||
TranslatableString &&Join(
|
||||
const TranslatableString &arg, const wxString &separator = {} ) &&;
|
||||
TranslatableString &operator +=( const TranslatableString &arg )
|
||||
TranslatableString arg, const wxString &separator = {} ) &&
|
||||
{ return std::move( Join( std::move(arg), separator ) ); }
|
||||
|
||||
TranslatableString &operator +=( TranslatableString arg )
|
||||
{
|
||||
std::move(*this).Join( arg );
|
||||
Join( std::move( arg ) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -507,9 +520,9 @@ private:
|
||||
};
|
||||
|
||||
inline TranslatableString operator +(
|
||||
const TranslatableString &x, const TranslatableString &y )
|
||||
TranslatableString x, TranslatableString y )
|
||||
{
|
||||
return TranslatableString{ x } += y;
|
||||
return std::move(x += std::move(y));
|
||||
}
|
||||
|
||||
using TranslatableStrings = std::vector<TranslatableString>;
|
||||
|
@ -345,12 +345,14 @@ wxString TranslatableString::DoChooseFormat(
|
||||
);
|
||||
}
|
||||
|
||||
TranslatableString &&TranslatableString::Join(
|
||||
const TranslatableString &arg, const wxString &separator ) &&
|
||||
TranslatableString &TranslatableString::Join(
|
||||
const TranslatableString arg, const wxString &separator ) &
|
||||
{
|
||||
auto prevFormatter = mFormatter;
|
||||
mFormatter =
|
||||
[prevFormatter, arg, separator](const wxString &str, Request request)
|
||||
[prevFormatter,
|
||||
arg /* = std::move( arg ) */,
|
||||
separator](const wxString &str, Request request)
|
||||
-> wxString {
|
||||
switch ( request ) {
|
||||
case Request::Context:
|
||||
@ -366,5 +368,5 @@ TranslatableString &&TranslatableString::Join(
|
||||
}
|
||||
}
|
||||
};
|
||||
return std::move( *this );
|
||||
return *this;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user