@@ -36,6 +36,7 @@ enum class VariantType : int { Int = 0,
3636 ArrayFloat,
3737 ArrayDouble,
3838 ArrayBool,
39+ ArrayString,
3940 Empty,
4041 Unknown };
4142
@@ -66,11 +67,13 @@ DECLARE_VARIANT_TRAIT(int*, ArrayInt);
6667DECLARE_VARIANT_TRAIT (float *, ArrayFloat);
6768DECLARE_VARIANT_TRAIT (double *, ArrayDouble);
6869DECLARE_VARIANT_TRAIT (bool *, ArrayBool);
70+ DECLARE_VARIANT_TRAIT (std::string*, ArrayString);
6971
7072DECLARE_VARIANT_TRAIT (std::vector<int >, ArrayInt);
7173DECLARE_VARIANT_TRAIT (std::vector<float >, ArrayFloat);
7274DECLARE_VARIANT_TRAIT (std::vector<double >, ArrayDouble);
7375DECLARE_VARIANT_TRAIT (std::vector<bool >, ArrayBool);
76+ DECLARE_VARIANT_TRAIT (std::vector<std::string>, ArrayString);
7477
7578template <typename T>
7679struct variant_array_symbol {
@@ -97,6 +100,11 @@ struct variant_array_symbol<bool> {
97100 constexpr static char symbol = ' b' ;
98101};
99102
103+ template <>
104+ struct variant_array_symbol <std::string> {
105+ constexpr static char symbol = ' s' ;
106+ };
107+
100108template <typename T>
101109inline constexpr VariantType variant_trait_v = variant_trait<T>::value;
102110
@@ -121,6 +129,7 @@ DECLARE_VARIANT_TYPE(int*, ArrayInt);
121129DECLARE_VARIANT_TYPE (float *, ArrayFloat);
122130DECLARE_VARIANT_TYPE (double *, ArrayDouble);
123131DECLARE_VARIANT_TYPE (bool *, ArrayBool);
132+ DECLARE_VARIANT_TYPE (std::string*, ArrayString);
124133
125134template <typename S, typename T>
126135struct variant_helper {
@@ -217,6 +226,10 @@ class Variant
217226 mSize = other.mSize ;
218227 variant_helper<storage_t , bool *>::set (&mStore , other.get <bool *>(), mSize );
219228 return ;
229+ case variant_trait_v<std::string*>:
230+ mSize = other.mSize ;
231+ variant_helper<storage_t , std::string*>::set (&mStore , other.get <std::string*>(), mSize );
232+ return ;
220233 default :
221234 mStore = other.mStore ;
222235 mSize = other.mSize ;
@@ -243,6 +256,8 @@ class Variant
243256 case variant_trait_v<bool *>:
244257 *reinterpret_cast <bool **>(&(other.mStore )) = nullptr ;
245258 return ;
259+ case variant_trait_v<std::string*>:
260+ *reinterpret_cast <std::string**>(&(other.mStore )) = nullptr ;
246261 default :
247262 return ;
248263 }
@@ -258,6 +273,7 @@ class Variant
258273 case variant_trait_v<float *>:
259274 case variant_trait_v<double *>:
260275 case variant_trait_v<bool *>:
276+ case variant_trait_v<std::string*>:
261277 if (reinterpret_cast <void **>(&mStore ) != nullptr ) {
262278 free (*reinterpret_cast <void **>(&mStore ));
263279 }
@@ -290,6 +306,10 @@ class Variant
290306 mSize = other.mSize ;
291307 variant_helper<storage_t , bool *>::set (&mStore , other.get <bool *>(), mSize );
292308 return ;
309+ case variant_trait_v<std::string*>:
310+ mSize = other.mSize ;
311+ variant_helper<storage_t , std::string*>::set (&mStore , other.get <std::string*>(), mSize );
312+ return ;
293313 default :
294314 mStore = other.mStore ;
295315 mSize = other.mSize ;
0 commit comments