mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
VariantConverter: Use FromVar and ToVar as a fallback
This commit is contained in:
parent
56195d1053
commit
d8b71b4eef
2 changed files with 49 additions and 22 deletions
|
|
@ -340,26 +340,4 @@ JUCE_API bool operator== (const var&, const String&);
|
|||
JUCE_API bool operator!= (const var&, const String&);
|
||||
JUCE_API bool operator== (const var&, const char*);
|
||||
JUCE_API bool operator!= (const var&, const char*);
|
||||
|
||||
//==============================================================================
|
||||
/** This template-overloaded class can be used to convert between var and custom types.
|
||||
|
||||
@tags{Core}
|
||||
*/
|
||||
template <typename Type>
|
||||
struct VariantConverter
|
||||
{
|
||||
static Type fromVar (const var& v) { return static_cast<Type> (v); }
|
||||
static var toVar (const Type& t) { return t; }
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN
|
||||
template <>
|
||||
struct VariantConverter<String>
|
||||
{
|
||||
static String fromVar (const var& v) { return v.toString(); }
|
||||
static var toVar (const String& s) { return s; }
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace juce
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue