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