diff options
author | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2016-07-02 15:54:37 +0200 |
---|---|---|
committer | Ignacio Etcheverry <ignalfonsore@gmail.com> | 2016-07-02 15:54:37 +0200 |
commit | 38ed5d9c7d5b3ce03e7ac5141ef0115a605e75bf (patch) | |
tree | cfa192e2dcfb18bc2843282ac184aee6a0f99ab7 /core | |
parent | 5b96496a99fccee6fe890810758a88c4ad9d9d6d (diff) |
Prettier str() for arrays
Diffstat (limited to 'core')
-rw-r--r-- | core/variant.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/core/variant.cpp b/core/variant.cpp index 81d10f379a..31321dc0f3 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1559,72 +1559,78 @@ Variant::operator String() const { case VECTOR2_ARRAY: { DVector<Vector2> vec = operator DVector<Vector2>(); - String str; + String str("["); for(int i=0;i<vec.size();i++) { if (i>0) str+=", "; str=str+Variant( vec[i] ); } + str += "]"; return str; } break; case VECTOR3_ARRAY: { DVector<Vector3> vec = operator DVector<Vector3>(); - String str; + String str("["); for(int i=0;i<vec.size();i++) { if (i>0) str+=", "; str=str+Variant( vec[i] ); } + str += "]"; return str; } break; case STRING_ARRAY: { DVector<String> vec = operator DVector<String>(); - String str; + String str("["); for(int i=0;i<vec.size();i++) { if (i>0) str+=", "; str=str+vec[i]; } + str += "]"; return str; } break; case INT_ARRAY: { DVector<int> vec = operator DVector<int>(); - String str; + String str("["); for(int i=0;i<vec.size();i++) { if (i>0) str+=", "; str=str+itos(vec[i]); } + str += "]"; return str; } break; case REAL_ARRAY: { DVector<real_t> vec = operator DVector<real_t>(); - String str; + String str("["); for(int i=0;i<vec.size();i++) { if (i>0) str+=", "; str=str+rtos(vec[i]); } + str += "]"; return str; } break; case ARRAY: { Array arr = operator Array(); - String str; + String str("["); for (int i=0; i<arr.size(); i++) { if (i) str+=", "; str += String(arr[i]); }; + str += "]"; return str; } break; |