Browse Source

added join to PoolStringArray

AlexHolly 8 years ago
parent
commit
9f7ce79ea3
2 changed files with 13 additions and 0 deletions
  1. 11 0
      core/dvector.h
  2. 2 0
      core/variant_call.cpp

+ 11 - 0
core/dvector.h

@@ -34,6 +34,7 @@
 #include "pool_allocator.h"
 #include "pool_allocator.h"
 #include "safe_refcount.h"
 #include "safe_refcount.h"
 #include "os/rw_lock.h"
 #include "os/rw_lock.h"
+#include "ustring.h"
 
 
 struct MemoryPool {
 struct MemoryPool {
 
 
@@ -466,6 +467,16 @@ public:
 		return OK;
 		return OK;
 	}
 	}
 
 
+	String join(String delimiter) {
+		String rs = "";
+		int s = size();
+		Read r = read();
+		for(int i=0;i<s;i++) {
+			rs += r[i] + delimiter;
+		}
+		rs.erase( rs.length()-delimiter.length(), delimiter.length());
+		return rs;
+	}
 
 
 	bool is_locked() const { return alloc && alloc->lock>0; }
 	bool is_locked() const { return alloc && alloc->lock>0; }
 
 

+ 2 - 0
core/variant_call.cpp

@@ -564,6 +564,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
 	VCALL_LOCALMEM1(PoolStringArray,append);
 	VCALL_LOCALMEM1(PoolStringArray,append);
 	VCALL_LOCALMEM1(PoolStringArray,append_array);
 	VCALL_LOCALMEM1(PoolStringArray,append_array);
 	VCALL_LOCALMEM0(PoolStringArray,invert);
 	VCALL_LOCALMEM0(PoolStringArray,invert);
+	VCALL_LOCALMEM1R(PoolStringArray,join);
 
 
 	VCALL_LOCALMEM0R(PoolVector2Array,size);
 	VCALL_LOCALMEM0R(PoolVector2Array,size);
 	VCALL_LOCALMEM2(PoolVector2Array,set);
 	VCALL_LOCALMEM2(PoolVector2Array,set);
@@ -1637,6 +1638,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_scs_create(#m_method),VCA
 	ADDFUNC2(POOL_STRING_ARRAY,INT,PoolStringArray,insert,INT,"idx",STRING,"string",varray());
 	ADDFUNC2(POOL_STRING_ARRAY,INT,PoolStringArray,insert,INT,"idx",STRING,"string",varray());
 	ADDFUNC1(POOL_STRING_ARRAY,NIL,PoolStringArray,resize,INT,"idx",varray());
 	ADDFUNC1(POOL_STRING_ARRAY,NIL,PoolStringArray,resize,INT,"idx",varray());
 	ADDFUNC0(POOL_STRING_ARRAY,NIL,PoolStringArray,invert,varray());
 	ADDFUNC0(POOL_STRING_ARRAY,NIL,PoolStringArray,invert,varray());
+	ADDFUNC1(POOL_STRING_ARRAY,STRING,PoolStringArray,join,STRING,"string",varray());
 
 
 	ADDFUNC0(POOL_VECTOR2_ARRAY,INT,PoolVector2Array,size,varray());
 	ADDFUNC0(POOL_VECTOR2_ARRAY,INT,PoolVector2Array,size,varray());
 	ADDFUNC2(POOL_VECTOR2_ARRAY,NIL,PoolVector2Array,set,INT,"idx",VECTOR2,"vector2",varray());
 	ADDFUNC2(POOL_VECTOR2_ARRAY,NIL,PoolVector2Array,set,INT,"idx",VECTOR2,"vector2",varray());