[PD-cvs] externals/grill/pool/source data.cpp, 1.8, 1.9 main.cpp, 1.17, 1.18 pool.cpp, 1.24, 1.25 pool.h, 1.12, 1.13
Thomas Grill
xovo at users.sourceforge.net
Thu Jan 3 17:06:09 CET 2008
- Previous message: [PD-cvs] externals/iem/iemmatrix/src iemmatrix_sources.c, 1.9, 1.10 iemmatrix_sources.h, 1.9, 1.10 matrix.c, 1.1, 1.2
- Next message: [PD-cvs] externals/grill/pool pool-help.pd, 1.5, 1.6 pool.vcproj, 1.21, 1.22 readme.txt, 1.33, 1.34
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/pure-data/externals/grill/pool/source
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10064/source
Modified Files:
data.cpp main.cpp pool.cpp pool.h
Log Message:
clarify usage of absdir flag for file operations
fixed buffer overrun problems
some assertions
added success/error reporting for file operations
got rid of type abbreviations
changed obviously buggy pool name registering
Index: data.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/pool/source/data.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** data.cpp 20 Jan 2007 14:27:39 -0000 1.8
--- data.cpp 3 Jan 2008 16:06:07 -0000 1.9
***************
*** 1,14 ****
/*
-
pool - hierarchical storage object for PD and Max/MSP
! Copyright (c) 2002-2006 Thomas Grill (gr at grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
#include "pool.h"
-
#include <string.h>
#include <ctype.h>
--- 1,15 ----
/*
pool - hierarchical storage object for PD and Max/MSP
! Copyright (c) 2002-2008 Thomas Grill (gr at grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
+ $LastChangedRevision: 26 $
+ $LastChangedDate: 2008-01-03 16:14:29 +0100 (Thu, 03 Jan 2008) $
+ $LastChangedBy: thomas $
*/
#include "pool.h"
#include <string.h>
#include <ctype.h>
***************
*** 18,22 ****
using namespace std;
! pooldata::pooldata(const S *s,I vcnt,I dcnt):
sym(s),nxt(NULL),refs(0),
root(nullatom,NULL,vcnt,dcnt)
--- 19,23 ----
using namespace std;
! pooldata::pooldata(const t_symbol *s,int vcnt,int dcnt):
sym(s),nxt(NULL),refs(0),
root(nullatom,NULL,vcnt,dcnt)
***************
*** 31,37 ****
! const A pooldata::nullatom = { A_NULL };
! I pooldata::GetAll(const AtomList &d,A *&keys,Atoms *&lst)
{
pooldir *pd = root.GetDir(d);
--- 32,38 ----
! const t_atom pooldata::nullatom = { A_NULL };
! int pooldata::GetAll(const AtomList &d,t_atom *&keys,Atoms *&lst)
{
pooldir *pd = root.GetDir(d);
***************
*** 44,48 ****
}
! I pooldata::PrintAll(const AtomList &d)
{
char tmp[1024];
--- 45,49 ----
}
! int pooldata::PrintAll(const AtomList &d)
{
char tmp[1024];
***************
*** 55,59 ****
}
! I pooldata::GetSub(const AtomList &d,const t_atom **&dirs)
{
pooldir *pd = root.GetDir(d);
--- 56,60 ----
}
! int pooldata::GetSub(const AtomList &d,const t_atom **&dirs)
{
pooldir *pd = root.GetDir(d);
***************
*** 67,71 ****
! BL pooldata::Paste(const AtomList &d,const pooldir *clip,I depth,BL repl,BL mkdir)
{
pooldir *pd = root.GetDir(d);
--- 68,72 ----
! bool pooldata::Paste(const AtomList &d,const pooldir *clip,int depth,bool repl,bool mkdir)
{
pooldir *pd = root.GetDir(d);
***************
*** 73,77 ****
}
! pooldir *pooldata::Copy(const AtomList &d,const A &key,BL cut)
{
pooldir *pd = root.GetDir(d);
--- 74,78 ----
}
! pooldir *pooldata::Copy(const AtomList &d,const t_atom &key,bool cut)
{
pooldir *pd = root.GetDir(d);
***************
*** 90,94 ****
}
! pooldir *pooldata::CopyAll(const AtomList &d,I depth,BL cut)
{
pooldir *pd = root.GetDir(d);
--- 91,95 ----
}
! pooldir *pooldata::CopyAll(const AtomList &d,int depth,bool cut)
{
pooldir *pd = root.GetDir(d);
***************
*** 126,130 ****
pooldir *pd = root.GetDir(d);
if(pd) {
! char tmp[1024];
const char *t = CnvFlnm(tmp,flnm,sizeof tmp);
if(t) {
--- 127,131 ----
pooldir *pd = root.GetDir(d);
if(pd) {
! char tmp[1024]; // CnvFlnm checks for size of string buffer
const char *t = CnvFlnm(tmp,flnm,sizeof tmp);
if(t) {
***************
*** 138,147 ****
}
! BL pooldata::SvDir(const AtomList &d,const C *flnm,I depth,BL absdir)
{
pooldir *pd = root.GetDir(d);
if(pd) {
! C tmp[1024];
! const C *t = CnvFlnm(tmp,flnm,sizeof tmp);
if(t) {
ofstream file(t);
--- 139,148 ----
}
! bool pooldata::SvDir(const AtomList &d,const char *flnm,int depth,bool absdir)
{
pooldir *pd = root.GetDir(d);
if(pd) {
! char tmp[1024]; // CnvFlnm checks for size of string buffer
! const char *t = CnvFlnm(tmp,flnm,sizeof tmp);
if(t) {
ofstream file(t);
***************
*** 156,168 ****
}
! BL pooldata::LdDirXML(const AtomList &d,const C *flnm,I depth,BL mkdir)
{
pooldir *pd = root.GetDir(d);
if(pd) {
! C tmp[1024];
! const C *t = CnvFlnm(tmp,flnm,sizeof tmp);
if(t) {
ifstream file(t);
! BL ret = file.good() != 0;
if(ret) {
file.getline(tmp,sizeof tmp);
--- 157,169 ----
}
! bool pooldata::LdDirXML(const AtomList &d,const char *flnm,int depth,bool mkdir)
{
pooldir *pd = root.GetDir(d);
if(pd) {
! char tmp[1024]; // CnvFlnm checks for size of string buffer
! const char *t = CnvFlnm(tmp,flnm,sizeof tmp);
if(t) {
ifstream file(t);
! bool ret = file.good() != 0;
if(ret) {
file.getline(tmp,sizeof tmp);
***************
*** 185,194 ****
}
! BL pooldata::SvDirXML(const AtomList &d,const C *flnm,I depth,BL absdir)
{
pooldir *pd = root.GetDir(d);
if(pd) {
! C tmp[1024];
! const C *t = CnvFlnm(tmp,flnm,sizeof tmp);
if(t) {
ofstream file(t);
--- 186,195 ----
}
! bool pooldata::SvDirXML(const AtomList &d,const char *flnm,int depth,bool absdir)
{
pooldir *pd = root.GetDir(d);
if(pd) {
! char tmp[1024]; // CnvFlnm checks for size of string buffer
! const char *t = CnvFlnm(tmp,flnm,sizeof tmp);
if(t) {
ofstream file(t);
***************
*** 199,203 ****
file << "<!DOCTYPE pool SYSTEM \"http://grrrr.org/ext/pool/pool-0.2.dtd\">" << endl;
file << "<pool>" << endl;
! BL ret = pd->SvDirXML(file,depth,tmp);
file << "</pool>" << endl;
return ret;
--- 200,204 ----
file << "<!DOCTYPE pool SYSTEM \"http://grrrr.org/ext/pool/pool-0.2.dtd\">" << endl;
file << "<pool>" << endl;
! bool ret = pd->SvDirXML(file,depth,tmp);
file << "</pool>" << endl;
return ret;
Index: main.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/pool/source/main.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** main.cpp 20 Jan 2007 14:27:39 -0000 1.17
--- main.cpp 3 Jan 2008 16:06:07 -0000 1.18
***************
*** 1,10 ****
/*
-
pool - hierarchical storage object for PD and Max/MSP
! Copyright (c) 2002-2006 Thomas Grill (gr at grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
[...1137 lines suppressed...]
#if FLEXT_SYS == FLEXT_SYS_PD
// / and \ must not be mixed!
// (char *) type casts for BorlandC++
! char *sl = strchr((char *)fn,'/');
! if(!sl) sl = strchr((char *)fn,'\\');
if(!sl || (sl != fn
#if FLEXT_OS == FLEXT_OS_WIN
***************
*** 1382,1386 ****
)) {
// prepend absolute canvas path if filename has no absolute path
! const C *p = GetString(canvas_getdir(thisCanvas()));
return string(p)+'/'+fn;
}
--- 1384,1388 ----
)) {
// prepend absolute canvas path if filename has no absolute path
! const char *p = GetString(canvas_getdir(thisCanvas()));
return string(p)+'/'+fn;
}
Index: pool.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/pool/source/pool.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** pool.cpp 20 Jan 2007 14:27:39 -0000 1.24
--- pool.cpp 3 Jan 2008 16:06:07 -0000 1.25
***************
*** 1,18 ****
/*
-
pool - hierarchical storage object for PD and Max/MSP
! Copyright (c) 2002-2006 Thomas Grill (gr at grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
#include "pool.h"
-
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <fstream>
#if FLEXT_OS == FLEXT_OS_WIN
--- 1,20 ----
/*
pool - hierarchical storage object for PD and Max/MSP
! Copyright (c) 2002-2008 Thomas Grill (gr at grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
+ $LastChangedRevision: 26 $
+ $LastChangedDate: 2008-01-03 16:14:29 +0100 (Thu, 03 Jan 2008) $
+ $LastChangedBy: thomas $
*/
#include "pool.h"
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <fstream>
+ #include <vector>
#if FLEXT_OS == FLEXT_OS_WIN
***************
*** 115,122 ****
! inline I compare(I a,I b) { return a == b?0:(a < b?-1:1); }
! inline I compare(F a,F b) { return a == b?0:(a < b?-1:1); }
! static I compare(const S *a,const S *b)
{
if(a == b)
--- 117,124 ----
! inline int compare(int a,int b) { return a == b?0:(a < b?-1:1); }
! inline int compare(float a,float b) { return a == b?0:(a < b?-1:1); }
! static int compare(const t_symbol *a,const t_symbol *b)
{
if(a == b)
***************
*** 126,130 ****
}
! static I compare(const A &a,const A &b)
{
if(flext::GetType(a) == flext::GetType(b)) {
--- 128,132 ----
}
! static int compare(const t_atom &a,const t_atom &b)
{
if(flext::GetType(a) == flext::GetType(b)) {
***************
*** 152,156 ****
! poolval::poolval(const A &k,AtomList *d):
data(d),nxt(NULL)
{
--- 154,158 ----
! poolval::poolval(const t_atom &k,AtomList *d):
data(d),nxt(NULL)
{
***************
*** 178,182 ****
! pooldir::pooldir(const A &d,pooldir *p,I vcnt,I dcnt):
parent(p),nxt(NULL),vals(NULL),dirs(NULL),
vbits(Int2Bits(vcnt)),dbits(Int2Bits(dcnt)),
--- 180,184 ----
! pooldir::pooldir(const t_atom &d,pooldir *p,int vcnt,int dcnt):
parent(p),nxt(NULL),vals(NULL),dirs(NULL),
vbits(Int2Bits(vcnt)),dbits(Int2Bits(dcnt)),
***************
*** 194,201 ****
}
! V pooldir::Clear(BL rec,BL dironly)
{
if(rec && dirs) {
! for(I i = 0; i < dsize; ++i) {
pooldir *d = dirs[i].d,*d1;
if(d) {
--- 196,203 ----
}
! void pooldir::Clear(bool rec,bool dironly)
{
if(rec && dirs) {
! for(int i = 0; i < dsize; ++i) {
pooldir *d = dirs[i].d,*d1;
if(d) {
***************
*** 211,215 ****
}
if(!dironly && vals) {
! for(I i = 0; i < vsize; ++i) {
poolval *v = vals[i].v,*v1;
if(v) {
--- 213,217 ----
}
if(!dironly && vals) {
! for(int i = 0; i < vsize; ++i) {
poolval *v = vals[i].v,*v1;
if(v) {
***************
*** 226,230 ****
}
! V pooldir::Reset(BL realloc)
{
Clear(true,false);
--- 228,232 ----
}
! void pooldir::Reset(bool realloc)
{
Clear(true,false);
***************
*** 243,251 ****
}
! pooldir *pooldir::AddDir(I argc,const A *argv,I vcnt,I dcnt)
{
if(!argc) return this;
! I c = 1,dix = DIdx(argv[0]);
pooldir *prv = NULL,*ix = dirs[dix].d;
for(; ix; prv = ix,ix = ix->nxt) {
--- 245,253 ----
}
! pooldir *pooldir::AddDir(int argc,const t_atom *argv,int vcnt,int dcnt)
{
if(!argc) return this;
! int c = 1,dix = DIdx(argv[0]);
pooldir *prv = NULL,*ix = dirs[dix].d;
for(; ix; prv = ix,ix = ix->nxt) {
***************
*** 267,275 ****
}
! pooldir *pooldir::GetDir(I argc,const A *argv,BL rmv)
{
if(!argc) return this;
! I c = 1,dix = DIdx(argv[0]);
pooldir *prv = NULL,*ix = dirs[dix].d;
for(; ix; prv = ix,ix = ix->nxt) {
--- 269,277 ----
}
! pooldir *pooldir::GetDir(int argc,const t_atom *argv,bool rmv)
{
if(!argc) return this;
! int c = 1,dix = DIdx(argv[0]);
pooldir *prv = NULL,*ix = dirs[dix].d;
for(; ix; prv = ix,ix = ix->nxt) {
***************
*** 296,300 ****
}
! BL pooldir::DelDir(I argc,const A *argv)
{
pooldir *pd = GetDir(argc,argv,true);
--- 298,302 ----
}
! bool pooldir::DelDir(int argc,const t_atom *argv)
{
pooldir *pd = GetDir(argc,argv,true);
***************
*** 307,313 ****
}
! V pooldir::SetVal(const A &key,AtomList *data,BL over)
{
! I c = 1,vix = VIdx(key);
poolval *prv = NULL,*ix = vals[vix].v;
for(; ix; prv = ix,ix = ix->nxt) {
--- 309,315 ----
}
! void pooldir::SetVal(const t_atom &key,AtomList *data,bool over)
{
! int c = 1,vix = VIdx(key);
poolval *prv = NULL,*ix = vals[vix].v;
for(; ix; prv = ix,ix = ix->nxt) {
***************
*** 346,350 ****
}
! BL pooldir::SetVali(I rix,AtomList *data)
{
poolval *prv = NULL,*ix = NULL;
--- 348,352 ----
}
! bool pooldir::SetVali(int rix,AtomList *data)
{
poolval *prv = NULL,*ix = NULL;
***************
*** 379,385 ****
}
! poolval *pooldir::RefVal(const A &key)
{
! I c = 1,vix = VIdx(key);
poolval *ix = vals[vix].v;
for(; ix; ix = ix->nxt) {
--- 381,387 ----
}
! poolval *pooldir::RefVal(const t_atom &key)
{
! int c = 1,vix = VIdx(key);
poolval *ix = vals[vix].v;
for(; ix; ix = ix->nxt) {
***************
*** 391,397 ****
}
! poolval *pooldir::RefVali(I rix)
{
! for(I vix = 0; vix < vsize; ++vix)
if(rix > vals[vix].cnt) rix -= vals[vix].cnt;
else {
--- 393,399 ----
}
! poolval *pooldir::RefVali(int rix)
{
! for(int vix = 0; vix < vsize; ++vix)
if(rix > vals[vix].cnt) rix -= vals[vix].cnt;
else {
***************
*** 403,407 ****
}
! flext::AtomList *pooldir::PeekVal(const A &key)
{
poolval *ix = RefVal(key);
--- 405,409 ----
}
! flext::AtomList *pooldir::PeekVal(const t_atom &key)
{
poolval *ix = RefVal(key);
***************
*** 409,415 ****
}
! flext::AtomList *pooldir::GetVal(const A &key,BL cut)
{
! I c = 1,vix = VIdx(key);
poolval *prv = NULL,*ix = vals[vix].v;
for(; ix; prv = ix,ix = ix->nxt) {
--- 411,417 ----
}
! flext::AtomList *pooldir::GetVal(const t_atom &key,bool cut)
{
! int c = 1,vix = VIdx(key);
poolval *prv = NULL,*ix = vals[vix].v;
for(; ix; prv = ix,ix = ix->nxt) {
***************
*** 437,455 ****
}
! I pooldir::CntAll() const
{
! I cnt = 0;
! for(I vix = 0; vix < vsize; ++vix) cnt += vals[vix].cnt;
return cnt;
}
! I pooldir::PrintAll(char *buf,int len) const
{
int offs = strlen(buf);
! I cnt = 0;
! for(I vix = 0; vix < vsize; ++vix) {
poolval *ix = vals[vix].v;
! for(I i = 0; ix; ++i,ix = ix->nxt) {
PrintAtom(ix->key,buf+offs,len-offs);
strcat(buf+offs," , ");
--- 439,457 ----
}
! int pooldir::CntAll() const
{
! int cnt = 0;
! for(int vix = 0; vix < vsize; ++vix) cnt += vals[vix].cnt;
return cnt;
}
! int pooldir::PrintAll(char *buf,int len) const
{
int offs = strlen(buf);
! int cnt = 0;
! for(int vix = 0; vix < vsize; ++vix) {
poolval *ix = vals[vix].v;
! for(int i = 0; ix; ++i,ix = ix->nxt) {
PrintAtom(ix->key,buf+offs,len-offs);
strcat(buf+offs," , ");
***************
*** 466,477 ****
}
! I pooldir::GetKeys(AtomList &keys)
{
! I cnt = CntAll();
keys(cnt);
! for(I vix = 0; vix < vsize; ++vix) {
poolval *ix = vals[vix].v;
! for(I i = 0; ix; ++i,ix = ix->nxt)
SetAtom(keys[i],ix->key);
}
--- 468,479 ----
}
! int pooldir::GetKeys(AtomList &keys)
{
! int cnt = CntAll();
keys(cnt);
! for(int vix = 0; vix < vsize; ++vix) {
poolval *ix = vals[vix].v;
! for(int i = 0; ix; ++i,ix = ix->nxt)
SetAtom(keys[i],ix->key);
}
***************
*** 479,489 ****
}
! I pooldir::GetAll(A *&keys,Atoms *&lst,BL cut)
{
! I cnt = CntAll();
! keys = new A[cnt];
lst = new Atoms[cnt];
! for(I i = 0,vix = 0; vix < vsize; ++vix) {
poolval *ix = vals[vix].v;
for(; ix; ++i) {
--- 481,491 ----
}
! int pooldir::GetAll(t_atom *&keys,Atoms *&lst,bool cut)
{
! int cnt = CntAll();
! keys = new t_atom[cnt];
lst = new Atoms[cnt];
! for(int i = 0,vix = 0; vix < vsize; ++vix) {
poolval *ix = vals[vix].v;
for(; ix; ++i) {
***************
*** 505,521 ****
! I pooldir::CntSub() const
{
! I cnt = 0;
! for(I dix = 0; dix < dsize; ++dix) cnt += dirs[dix].cnt;
return cnt;
}
! I pooldir::GetSub(const A **&lst)
{
! const I cnt = CntSub();
! lst = new const A *[cnt];
! for(I i = 0,dix = 0; i < cnt; ++dix) {
pooldir *ix = dirs[dix].d;
for(; ix; ix = ix->nxt) lst[i++] = &ix->dir;
--- 507,523 ----
! int pooldir::CntSub() const
{
! int cnt = 0;
! for(int dix = 0; dix < dsize; ++dix) cnt += dirs[dix].cnt;
return cnt;
}
! int pooldir::GetSub(const t_atom **&lst)
{
! const int cnt = CntSub();
! lst = new const t_atom *[cnt];
! for(int i = 0,dix = 0; i < cnt; ++dix) {
pooldir *ix = dirs[dix].d;
for(; ix; ix = ix->nxt) lst[i++] = &ix->dir;
***************
*** 525,533 ****
! BL pooldir::Paste(const pooldir *p,I depth,BL repl,BL mkdir)
{
! BL ok = true;
! for(I vi = 0; vi < p->vsize; ++vi) {
for(poolval *ix = p->vals[vi].v; ix; ix = ix->nxt) {
SetVal(ix->key,new Atoms(*ix->data),repl);
--- 527,535 ----
! bool pooldir::Paste(const pooldir *p,int depth,bool repl,bool mkdir)
{
! bool ok = true;
! for(int vi = 0; vi < p->vsize; ++vi) {
for(poolval *ix = p->vals[vi].v; ix; ix = ix->nxt) {
SetVal(ix->key,new Atoms(*ix->data),repl);
***************
*** 536,540 ****
if(ok && depth) {
! for(I di = 0; di < p->dsize; ++di) {
for(pooldir *dix = p->dirs[di].d; ok && dix; dix = dix->nxt) {
pooldir *ndir = mkdir?AddDir(1,&dix->dir):GetDir(1,&dix->dir);
--- 538,542 ----
if(ok && depth) {
! for(int di = 0; di < p->dsize; ++di) {
for(pooldir *dix = p->dirs[di].d; ok && dix; dix = dix->nxt) {
pooldir *ndir = mkdir?AddDir(1,&dix->dir):GetDir(1,&dix->dir);
***************
*** 549,558 ****
}
! BL pooldir::Copy(pooldir *p,I depth,BL cut)
{
! BL ok = true;
if(cut) {
! for(I vi = 0; vi < vsize; ++vi) {
for(poolval *ix = vals[vi].v; ix; ix = ix->nxt)
p->SetVal(ix->key,ix->data);
--- 551,560 ----
}
! bool pooldir::Copy(pooldir *p,int depth,bool cut)
{
! bool ok = true;
if(cut) {
! for(int vi = 0; vi < vsize; ++vi) {
for(poolval *ix = vals[vi].v; ix; ix = ix->nxt)
p->SetVal(ix->key,ix->data);
***************
*** 562,566 ****
}
else {
! for(I vi = 0; vi < vsize; ++vi) {
for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) {
p->SetVal(ix->key,new Atoms(*ix->data));
--- 564,568 ----
}
else {
! for(int vi = 0; vi < vsize; ++vi) {
for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) {
p->SetVal(ix->key,new Atoms(*ix->data));
***************
*** 570,574 ****
if(ok && depth) {
! for(I di = 0; di < dsize; ++di) {
for(pooldir *dix = dirs[di].d; ok && dix; dix = dix->nxt) {
pooldir *ndir = p->AddDir(1,&dix->dir);
--- 572,576 ----
if(ok && depth) {
! for(int di = 0; di < dsize; ++di) {
for(pooldir *dix = dirs[di].d; ok && dix; dix = dix->nxt) {
pooldir *ndir = p->AddDir(1,&dix->dir);
***************
*** 586,590 ****
static bool _isspace(char c) { return c > 0 && isspace(c); }
! static const char *ReadAtom(const char *c,A &a,bool utf8)
{
// skip leading whitespace (NON-ASCII character are < 0)
--- 588,592 ----
static bool _isspace(char c) { return c > 0 && isspace(c); }
! static const char *ReadAtom(const char *c,t_atom &a,bool utf8)
{
// skip leading whitespace (NON-ASCII character are < 0)
***************
*** 654,660 ****
wchar_t wtmp[1024];
int err = MultiByteToWideChar(CP_UTF8,0,tmp,strlen(tmp),wtmp,1024);
! if(!err) return false;
err = WideCharToMultiByte(CP_ACP,0,wtmp,err,tmp,1024,NULL,FALSE);
! if(!err) return false;
tmp[err] = 0;
c = tmp;
--- 656,662 ----
wchar_t wtmp[1024];
int err = MultiByteToWideChar(CP_UTF8,0,tmp,strlen(tmp),wtmp,1024);
! if(!err) return NULL;
err = WideCharToMultiByte(CP_ACP,0,wtmp,err,tmp,1024,NULL,FALSE);
! if(!err) return NULL;
tmp[err] = 0;
c = tmp;
***************
*** 668,672 ****
TECObjectRef converter;
OSStatus status = TECCreateConverter(&converter,inconv,outconv);
! if(status) return false;
ByteCount inlen,outlen;
--- 670,674 ----
TECObjectRef converter;
OSStatus status = TECCreateConverter(&converter,inconv,outconv);
! if(status) return NULL;
ByteCount inlen,outlen;
***************
*** 680,689 ****
TECDisposeConverter(converter);
c = ctmp;
! if(status) return false;
#else
wchar_t wtmp[1024];
size_t len = mbstowcs(wtmp,tmp,1024);
if(len < 0) return false;
! if(!WCStoUTF8(tmp,wtmp,sizeof(tmp))) return false;
c = tmp;
#endif
--- 682,691 ----
TECDisposeConverter(converter);
c = ctmp;
! if(status) return NULL;
#else
wchar_t wtmp[1024];
size_t len = mbstowcs(wtmp,tmp,1024);
if(len < 0) return false;
! if(!WCStoUTF8(tmp,wtmp,sizeof(tmp))) return NULL;
c = tmp;
#endif
***************
*** 697,729 ****
}
! static BL ParseAtoms(C *tmp,flext::AtomList &l,bool utf8)
{
! const int MAXATOMS = 1024;
! int cnt = 0;
! t_atom atoms[MAXATOMS];
! for(const char *t = tmp; *t && cnt < MAXATOMS; ++cnt) {
! t = ReadAtom(t,atoms[cnt],utf8);
! if(!t) break;
}
! l(cnt,atoms);
! return true;
}
! static BL ParseAtoms(string &s,flext::AtomList &l,bool utf8)
{
! return ParseAtoms((C *)s.c_str(),l,utf8);
}
! static bool ReadAtoms(istream &is,flext::AtomList &l,C del,bool utf8)
{
! char tmp[1024];
! is.getline(tmp,sizeof tmp,del);
! if(is.eof() || !is.good())
! return false;
! else
! return ParseAtoms(tmp,l,utf8);
}
! static bool WriteAtom(ostream &os,const A &a,bool utf8)
{
if(flext::IsFloat(a))
--- 699,735 ----
}
! static bool ParseAtoms(const char *tmp,flext::AtomList &l,bool utf8)
{
! FLEXT_ASSERT(tmp);
! vector<t_atom> atoms;
! while(*tmp) {
! t_atom at;
! tmp = ReadAtom(tmp,at,utf8);
! if(!tmp) break;
! atoms.push_back(at);
}
! l(atoms.size(),&atoms[0]);
! return true;
}
! static bool ParseAtoms(string &s,flext::AtomList &l,bool utf8)
{
! return ParseAtoms((char *)s.c_str(),l,utf8);
}
! static bool ReadAtoms(istream &is,flext::AtomList &l,char del,bool utf8)
{
! vector<char> tmp;
! for(;;) {
! char c = is.get();
! if(is.eof() || c == del) break;
! tmp.push_back(c);
! }
! tmp.push_back(0); // end-of-string marker
!
! return is.good() && ParseAtoms(&tmp[0],l,utf8);
}
! static bool WriteAtom(ostream &os,const t_atom &a,bool utf8)
{
if(flext::IsFloat(a))
***************
*** 792,796 ****
static void WriteAtoms(ostream &os,const flext::AtomList &l,bool utf8)
{
! for(I i = 0; i < l.Count(); ++i) {
WriteAtom(os,l[i],utf8);
if(i < l.Count()-1) os << ' ';
--- 798,802 ----
static void WriteAtoms(ostream &os,const flext::AtomList &l,bool utf8)
{
! for(int i = 0; i < l.Count(); ++i) {
WriteAtom(os,l[i],utf8);
if(i < l.Count()-1) os << ' ';
***************
*** 798,806 ****
}
! BL pooldir::LdDir(istream &is,I depth,BL mkdir)
{
! for(I i = 1; !is.eof(); ++i) {
Atoms d,k,*v = new Atoms;
! BL r =
ReadAtoms(is,d,',',false) &&
ReadAtoms(is,k,',',false) &&
--- 804,812 ----
}
! bool pooldir::LdDir(istream &is,int depth,bool mkdir)
{
! for(int i = 1; !is.eof(); ++i) {
Atoms d,k,*v = new Atoms;
! bool r =
ReadAtoms(is,d,',',false) &&
ReadAtoms(is,k,',',false) &&
***************
*** 831,838 ****
}
! BL pooldir::SvDir(ostream &os,I depth,const AtomList &dir)
{
! I cnt = 0;
! for(I vi = 0; vi < vsize; ++vi) {
for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) {
WriteAtoms(os,dir,false);
--- 837,844 ----
}
! bool pooldir::SvDir(ostream &os,int depth,const AtomList &dir)
{
! int cnt = 0;
! for(int vi = 0; vi < vsize; ++vi) {
for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) {
WriteAtoms(os,dir,false);
***************
*** 852,857 ****
if(depth) {
// save sub-directories
! I nd = depth > 0?depth-1:-1;
! for(I di = 0; di < dsize; ++di) {
for(pooldir *ix = dirs[di].d; ix; ix = ix->nxt) {
ix->SvDir(os,nd,Atoms(dir).Append(ix->dir));
--- 858,863 ----
if(depth) {
// save sub-directories
! int nd = depth > 0?depth-1:-1;
! for(int di = 0; di < dsize; ++di) {
for(pooldir *ix = dirs[di].d; ix; ix = ix->nxt) {
ix->SvDir(os,nd,Atoms(dir).Append(ix->dir));
***************
*** 866,870 ****
string tag,attr;
bool Ok() const { return tag.length() > 0; }
! bool operator ==(const C *t) const { return !tag.compare(t); }
void Clear()
--- 872,876 ----
string tag,attr;
bool Ok() const { return tag.length() > 0; }
! bool operator ==(const char *t) const { return !tag.compare(t); }
void Clear()
***************
*** 980,984 ****
}
! BL pooldir::LdDirXMLRec(istream &is,I depth,BL mkdir,AtomList &d)
{
Atoms k,v;
--- 986,990 ----
}
! bool pooldir::LdDirXMLRec(istream &is,int depth,bool mkdir,AtomList &d)
{
Atoms k,v;
***************
*** 1000,1004 ****
)
) {
! BL ret = true;
if(indata) {
if(v.Count())
--- 1006,1010 ----
)
) {
! bool ret = true;
if(indata) {
if(v.Count())
***************
*** 1122,1126 ****
}
! BL pooldir::LdDirXML(istream &is,I depth,BL mkdir)
{
while(!is.eof()) {
--- 1128,1132 ----
}
! bool pooldir::LdDirXML(istream &is,int depth,bool mkdir)
{
while(!is.eof()) {
***************
*** 1148,1157 ****
}
! static void indent(ostream &s,I cnt)
{
! for(I i = 0; i < cnt; ++i) s << '\t';
}
! BL pooldir::SvDirXML(ostream &os,I depth,const AtomList &dir,I ind)
{
int i,lvls = ind?(dir.Count()?1:0):dir.Count();
--- 1154,1163 ----
}
! static void indent(ostream &s,int cnt)
{
! for(int i = 0; i < cnt; ++i) s << '\t';
}
! bool pooldir::SvDirXML(ostream &os,int depth,const AtomList &dir,int ind)
{
int i,lvls = ind?(dir.Count()?1:0):dir.Count();
***************
*** 1166,1170 ****
}
! for(I vi = 0; vi < vsize; ++vi) {
for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) {
indent(os,ind+lvls);
--- 1172,1176 ----
}
! for(int vi = 0; vi < vsize; ++vi) {
for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) {
indent(os,ind+lvls);
***************
*** 1178,1183 ****
if(depth) {
! I nd = depth > 0?depth-1:-1;
! for(I di = 0; di < dsize; ++di) {
for(pooldir *ix = dirs[di].d; ix; ix = ix->nxt) {
ix->SvDirXML(os,nd,Atoms(dir).Append(ix->dir),ind+lvls);
--- 1184,1189 ----
if(depth) {
! int nd = depth > 0?depth-1:-1;
! for(int di = 0; di < dsize; ++di) {
for(pooldir *ix = dirs[di].d; ix; ix = ix->nxt) {
ix->SvDirXML(os,nd,Atoms(dir).Append(ix->dir),ind+lvls);
Index: pool.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/pool/source/pool.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** pool.h 30 Sep 2006 19:23:16 -0000 1.12
--- pool.h 3 Jan 2008 16:06:07 -0000 1.13
***************
*** 1,10 ****
/*
-
pool - hierarchical storage object for PD and Max/MSP
! Copyright (c) 2002-2006 Thomas Grill (gr at grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
--- 1,12 ----
/*
pool - hierarchical storage object for PD and Max/MSP
! Copyright (c) 2002-2008 Thomas Grill (gr at grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
+ $LastChangedRevision: 26 $
+ $LastChangedDate: 2008-01-03 16:14:29 +0100 (Thu, 03 Jan 2008) $
+ $LastChangedBy: thomas $
*/
***************
*** 24,43 ****
using namespace std;
- typedef void V;
- typedef int I;
- typedef unsigned long UL;
- typedef float F;
- typedef char C;
- typedef bool BL;
- typedef t_atom A;
- typedef t_symbol S;
typedef flext::AtomListStatic<8> Atoms;
class poolval:
public flext
{
public:
! poolval(const A &key,AtomList *data);
~poolval();
--- 26,38 ----
using namespace std;
typedef flext::AtomListStatic<8> Atoms;
+
class poolval:
public flext
{
public:
! poolval(const t_atom &key,AtomList *data);
~poolval();
***************
*** 45,49 ****
poolval *Dup() const;
! A key;
AtomList *data;
poolval *nxt;
--- 40,44 ----
poolval *Dup() const;
! t_atom key;
AtomList *data;
poolval *nxt;
***************
*** 54,97 ****
{
public:
! pooldir(const A &dir,pooldir *parent,I vcnt,I dcnt);
~pooldir();
! V Clear(BL rec,BL dironly = false);
! V Reset(BL realloc = true);
! BL Empty() const { return !dirs && !vals; }
! BL HasDirs() const { return dirs != NULL; }
! BL HasVals() const { return vals != NULL; }
! pooldir *GetDir(I argc,const A *argv,BL cut = false);
! pooldir *GetDir(const AtomList &d,BL cut = false) { return GetDir(d.Count(),d.Atoms(),cut); }
! BL DelDir(I argc,const A *argv);
! BL DelDir(const AtomList &d) { return DelDir(d.Count(),d.Atoms()); }
! pooldir *AddDir(I argc,const A *argv,I vcnt = 0,I dcnt = 0);
! pooldir *AddDir(const AtomList &d,I vcnt = 0,I dcnt = 0) { return AddDir(d.Count(),d.Atoms(),vcnt,dcnt); }
! V SetVal(const A &key,AtomList *data,BL over = true);
! BL SetVali(I ix,AtomList *data);
! V ClrVal(const A &key) { SetVal(key,NULL); }
! BL ClrVali(I ix) { return SetVali(ix,NULL); }
! AtomList *PeekVal(const A &key);
! AtomList *GetVal(const A &key,BL cut = false);
! I CntAll() const;
! I GetAll(A *&keys,Atoms *&lst,BL cut = false);
! I PrintAll(char *buf,int len) const;
! I GetKeys(AtomList &keys);
! I CntSub() const;
! I GetSub(const A **&dirs);
! poolval *RefVal(const A &key);
! poolval *RefVali(I ix);
! BL Paste(const pooldir *p,I depth,BL repl,BL mkdir);
! BL Copy(pooldir *p,I depth,BL cur);
! BL LdDir(istream &is,I depth,BL mkdir);
! BL LdDirXML(istream &is,I depth,BL mkdir);
! BL SvDir(ostream &os,I depth,const AtomList &dir = AtomList());
! BL SvDirXML(ostream &os,I depth,const AtomList &dir = AtomList(),I ind = 0);
int VSize() const { return vsize; }
--- 49,92 ----
{
public:
! pooldir(const t_atom &dir,pooldir *parent,int vcnt,int dcnt);
~pooldir();
! void Clear(bool rec,bool dironly = false);
! void Reset(bool realloc = true);
! bool Empty() const { return !dirs && !vals; }
! bool HasDirs() const { return dirs != NULL; }
! bool HasVals() const { return vals != NULL; }
! pooldir *GetDir(int argc,const t_atom *argv,bool cut = false);
! pooldir *GetDir(const AtomList &d,bool cut = false) { return GetDir(d.Count(),d.Atoms(),cut); }
! bool DelDir(int argc,const t_atom *argv);
! bool DelDir(const AtomList &d) { return DelDir(d.Count(),d.Atoms()); }
! pooldir *AddDir(int argc,const t_atom *argv,int vcnt = 0,int dcnt = 0);
! pooldir *AddDir(const AtomList &d,int vcnt = 0,int dcnt = 0) { return AddDir(d.Count(),d.Atoms(),vcnt,dcnt); }
! void SetVal(const t_atom &key,AtomList *data,bool over = true);
! bool SetVali(int ix,AtomList *data);
! void ClrVal(const t_atom &key) { SetVal(key,NULL); }
! bool ClrVali(int ix) { return SetVali(ix,NULL); }
! AtomList *PeekVal(const t_atom &key);
! AtomList *GetVal(const t_atom &key,bool cut = false);
! int CntAll() const;
! int GetAll(t_atom *&keys,Atoms *&lst,bool cut = false);
! int PrintAll(char *buf,int len) const;
! int GetKeys(AtomList &keys);
! int CntSub() const;
! int GetSub(const t_atom **&dirs);
! poolval *RefVal(const t_atom &key);
! poolval *RefVali(int ix);
! bool Paste(const pooldir *p,int depth,bool repl,bool mkdir);
! bool Copy(pooldir *p,int depth,bool cur);
! bool LdDir(istream &is,int depth,bool mkdir);
! bool LdDirXML(istream &is,int depth,bool mkdir);
! bool SvDir(ostream &os,int depth,const AtomList &dir = AtomList());
! bool SvDirXML(ostream &os,int depth,const AtomList &dir = AtomList(),int ind = 0);
int VSize() const { return vsize; }
***************
*** 99,110 ****
protected:
! int VIdx(const A &v) const { return FoldBits(AtomHash(v),vbits); }
! int DIdx(const A &d) const { return FoldBits(AtomHash(d),dbits); }
! A dir;
pooldir *nxt;
pooldir *parent;
! const I vbits,dbits,vsize,dsize;
static unsigned int FoldBits(unsigned long h,int bits);
--- 94,105 ----
protected:
! int VIdx(const t_atom &v) const { return FoldBits(AtomHash(v),vbits); }
! int DIdx(const t_atom &d) const { return FoldBits(AtomHash(d),dbits); }
! t_atom dir;
pooldir *nxt;
pooldir *parent;
! const int vbits,dbits,vsize,dsize;
static unsigned int FoldBits(unsigned long h,int bits);
***************
*** 118,122 ****
private:
! BL LdDirXMLRec(istream &is,I depth,BL mkdir,AtomList &d);
};
--- 113,117 ----
private:
! bool LdDirXMLRec(istream &is,int depth,bool mkdir,AtomList &d);
};
***************
*** 126,140 ****
{
public:
! pooldata(const S *s = NULL,I vcnt = 0,I dcnt = 0);
~pooldata();
bool Private() const { return sym == NULL; }
! V Push() { ++refs; }
! BL Pop() { return --refs > 0; }
! V Reset() { root.Reset(); }
! BL MkDir(const AtomList &d,I vcnt = 0,I dcnt = 0)
{
root.AddDir(d,vcnt,dcnt);
--- 121,135 ----
{
public:
! pooldata(const t_symbol *s = NULL,int vcnt = 0,int dcnt = 0);
~pooldata();
bool Private() const { return sym == NULL; }
! void Push() { ++refs; }
! bool Pop() { return --refs > 0; }
! void Reset() { root.Reset(); }
! bool MkDir(const AtomList &d,int vcnt = 0,int dcnt = 0)
{
root.AddDir(d,vcnt,dcnt);
***************
*** 142,156 ****
}
! BL ChkDir(const AtomList &d)
{
return root.GetDir(d) != NULL;
}
! BL RmDir(const AtomList &d)
{
return root.DelDir(d);
}
! BL Set(const AtomList &d,const A &key,AtomList *data,BL over = true)
{
pooldir *pd = root.GetDir(d);
--- 137,151 ----
}
! bool ChkDir(const AtomList &d)
{
return root.GetDir(d) != NULL;
}
! bool RmDir(const AtomList &d)
{
return root.DelDir(d);
}
! bool Set(const AtomList &d,const t_atom &key,AtomList *data,bool over = true)
{
pooldir *pd = root.GetDir(d);
***************
*** 160,164 ****
}
! BL Seti(const AtomList &d,I ix,AtomList *data)
{
pooldir *pd = root.GetDir(d);
--- 155,159 ----
}
! bool Seti(const AtomList &d,int ix,AtomList *data)
{
pooldir *pd = root.GetDir(d);
***************
*** 168,172 ****
}
! BL Clr(const AtomList &d,const A &key)
{
pooldir *pd = root.GetDir(d);
--- 163,167 ----
}
! bool Clr(const AtomList &d,const t_atom &key)
{
pooldir *pd = root.GetDir(d);
***************
*** 176,180 ****
}
! BL Clri(const AtomList &d,I ix)
{
pooldir *pd = root.GetDir(d);
--- 171,175 ----
}
! bool Clri(const AtomList &d,int ix)
{
pooldir *pd = root.GetDir(d);
***************
*** 184,188 ****
}
! BL ClrAll(const AtomList &d,BL rec,BL dironly = false)
{
pooldir *pd = root.GetDir(d);
--- 179,183 ----
}
! bool ClrAll(const AtomList &d,bool rec,bool dironly = false)
{
pooldir *pd = root.GetDir(d);
***************
*** 192,196 ****
}
! AtomList *Peek(const AtomList &d,const A &key)
{
pooldir *pd = root.GetDir(d);
--- 187,191 ----
}
! AtomList *Peek(const AtomList &d,const t_atom &key)
{
pooldir *pd = root.GetDir(d);
***************
*** 198,202 ****
}
! AtomList *Get(const AtomList &d,const A &key)
{
pooldir *pd = root.GetDir(d);
--- 193,197 ----
}
! AtomList *Get(const AtomList &d,const t_atom &key)
{
pooldir *pd = root.GetDir(d);
***************
*** 204,208 ****
}
! poolval *Ref(const AtomList &d,const A &key)
{
pooldir *pd = root.GetDir(d);
--- 199,203 ----
}
! poolval *Ref(const AtomList &d,const t_atom &key)
{
pooldir *pd = root.GetDir(d);
***************
*** 210,214 ****
}
! poolval *Refi(const AtomList &d,I ix)
{
pooldir *pd = root.GetDir(d);
--- 205,209 ----
}
! poolval *Refi(const AtomList &d,int ix)
{
pooldir *pd = root.GetDir(d);
***************
*** 216,220 ****
}
! I CntAll(const AtomList &d)
{
pooldir *pd = root.GetDir(d);
--- 211,215 ----
}
! int CntAll(const AtomList &d)
{
pooldir *pd = root.GetDir(d);
***************
*** 222,229 ****
}
! I PrintAll(const AtomList &d);
! I GetAll(const AtomList &d,A *&keys,Atoms *&lst);
! I CntSub(const AtomList &d)
{
pooldir *pd = root.GetDir(d);
--- 217,224 ----
}
! int PrintAll(const AtomList &d);
! int GetAll(const AtomList &d,t_atom *&keys,Atoms *&lst);
! int CntSub(const AtomList &d)
{
pooldir *pd = root.GetDir(d);
***************
*** 231,251 ****
}
! I GetSub(const AtomList &d,const t_atom **&dirs);
! BL Paste(const AtomList &d,const pooldir *clip,I depth = -1,BL repl = true,BL mkdir = true);
! pooldir *Copy(const AtomList &d,const A &key,BL cut);
! pooldir *CopyAll(const AtomList &d,I depth,BL cut);
! BL LdDir(const AtomList &d,const C *flnm,I depth,BL mkdir = true);
! BL SvDir(const AtomList &d,const C *flnm,I depth,BL absdir);
! BL Load(const C *flnm) { AtomList l; return LdDir(l,flnm,-1); }
! BL Save(const C *flnm) { AtomList l; return SvDir(l,flnm,-1,true); }
! BL LdDirXML(const AtomList &d,const C *flnm,I depth,BL mkdir = true);
! BL SvDirXML(const AtomList &d,const C *flnm,I depth,BL absdir);
! BL LoadXML(const C *flnm) { AtomList l; return LdDirXML(l,flnm,-1); }
! BL SaveXML(const C *flnm) { AtomList l; return SvDirXML(l,flnm,-1,true); }
! I refs;
! const S *sym;
pooldata *nxt;
--- 226,246 ----
}
! int GetSub(const AtomList &d,const t_atom **&dirs);
! bool Paste(const AtomList &d,const pooldir *clip,int depth = -1,bool repl = true,bool mkdir = true);
! pooldir *Copy(const AtomList &d,const t_atom &key,bool cut);
! pooldir *CopyAll(const AtomList &d,int depth,bool cut);
! bool LdDir(const AtomList &d,const char *flnm,int depth,bool mkdir = true);
! bool SvDir(const AtomList &d,const char *flnm,int depth,bool absdir);
! bool Load(const char *flnm) { AtomList l; return LdDir(l,flnm,-1); }
! bool Save(const char *flnm) { AtomList l; return SvDir(l,flnm,-1,true); }
! bool LdDirXML(const AtomList &d,const char *flnm,int depth,bool mkdir = true);
! bool SvDirXML(const AtomList &d,const char *flnm,int depth,bool absdir);
! bool LoadXML(const char *flnm) { AtomList l; return LdDirXML(l,flnm,-1); }
! bool SaveXML(const char *flnm) { AtomList l; return SvDirXML(l,flnm,-1,true); }
! int refs;
! const t_symbol *sym;
pooldata *nxt;
***************
*** 253,257 ****
private:
! static const A nullatom;
};
--- 248,252 ----
private:
! static const t_atom nullatom;
};
- Previous message: [PD-cvs] externals/iem/iemmatrix/src iemmatrix_sources.c, 1.9, 1.10 iemmatrix_sources.h, 1.9, 1.10 matrix.c, 1.1, 1.2
- Next message: [PD-cvs] externals/grill/pool pool-help.pd, 1.5, 1.6 pool.vcproj, 1.21, 1.22 readme.txt, 1.33, 1.34
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Pd-cvs
mailing list