[Gridflow-cvs] [svn] commit: r6050 - /trunk/src/classes2.cxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Thu Aug 12 21:23:18 EDT 2010


Author: matju
Date: Thu Aug 12 21:23:18 2010
New Revision: 6050

Log:
use join() to put format together

Modified:
    trunk/src/classes2.cxx

Modified: trunk/src/classes2.cxx
==============================================================================
--- trunk/src/classes2.cxx (original)
+++ trunk/src/classes2.cxx Thu Aug 12 21:23:18 2010
@@ -53,6 +53,12 @@
 #endif
 
 #define foreach(ITER,COLL) for(typeof(COLL.begin()) ITER = COLL.begin(); ITER != (COLL).end(); ITER++)
+
+string join (int argc, t_atom *argv, string sep=" ", string term="") {
+	std::ostringstream os;
+	for (int i=0; i<argc; i++) os << argv[i] << (i==argc-1 ? term : sep);
+	return os.str();
+}
 
 //****************************************************************
 
@@ -754,12 +760,7 @@
 
 \class GFSprintf : FObject {
 	string format;
-	\constructor (...) {
-		std::ostringstream o;
-		char buf[MAXPDSTRING];
-		for (int i=0; i<argc; i++) {atom_string(&argv[i],buf,MAXPDSTRING); o << buf; if (i!=argc-1) o << ' ';}
-		format = o.str();
-	}
+	\constructor (...) {format = join(argc,argv);}
 	\decl 0 bang   ()          {_0_list(0,0);}
 	\decl 0 float  (t_atom2 a) {_0_list(1,&a);}
 	\decl 0 symbol (t_atom2 a) {_0_list(1,&a);}
@@ -774,13 +775,7 @@
 \class GridSprintf : FObject {
 	string format;
 	\attr NumberTypeE cast;
-	\constructor (...) {
-		std::ostringstream o;
-		char buf[MAXPDSTRING];
-		for (int i=0; i<argc; i++) {atom_string(&argv[i],buf,MAXPDSTRING); o << buf; if (i!=argc-1) o << ' ';}
-		format = o.str();
-		cast = int32_e;
-	}
+	\constructor (...) {format = join(argc,argv); cast = int32_e;}
 	\decl 0 bang   ()          {_0_list(0,0);}
 	\decl 0 float  (t_atom2 a) {_0_list(1,&a);}
 	\decl 0 symbol (t_atom2 a) {_0_list(1,&a);}
@@ -1242,16 +1237,10 @@
 };
 \end class {install("gf/find_file",1,2);}
 
-string join (int argc, t_atom *argv, string sep, string term) {
-	std::ostringstream os;
-	for (int i=0; i<argc; i++) os << argv[i] << (i==argc-1 ? term : sep);
-	return os.str();
-}
-
 \class GFL2S : FObject {
 	t_symbol *sep;
 	\constructor (t_symbol *sep=0) {this->sep=sep?sep:gensym(" ");}
-	\decl 0 list (...) {outlet_symbol(outlets[0],gensym(join(argc,argv,sep->s_name,"").data()));}
+	\decl 0 list (...) {outlet_symbol(outlets[0],gensym(join(argc,argv,sep->s_name).data()));}
 	\decl 1 symbol (t_symbol *sep) {this->sep=sep;}
 };
 \end class {install("gf/l2s",2,1);}



More information about the Gridflow-cvs mailing list