Update of /cvsroot/pure-data/externals/grill/pool/source
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30698/source
Modified Files:
data.cpp main.cpp pool.cpp pool.h
Log Message:
better symbol handling
added seti, clri
name changes for svn repository
more inlined functions
Index: data.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/pool/source/data.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** data.cpp 10 Aug 2004 20:23:27 -0000 1.3
--- data.cpp 30 Oct 2004 03:58:58 -0000 1.4
***************
*** 33,37 ****
const A pooldata::nullatom = { A_NULL };
!
V pooldata::Reset()
{
--- 33,37 ----
const A pooldata::nullatom = { A_NULL };
! /*
V pooldata::Reset()
{
***************
*** 45,48 ****
--- 45,49 ----
}
+
BL pooldata::ChkDir(const AtomList &d)
{
***************
*** 71,74 ****
--- 72,83 ----
}
+ V pooldata::Clri(const AtomList &d,I ix)
+ {
+ pooldir *pd = root.GetDir(d);
+ if(!pd) return false;
+ pd->ClrVali(ix);
+ return true;
+ }
+
BL pooldata::ClrAll(const AtomList &d,BL rec,BL dironly)
{
***************
*** 108,111 ****
--- 117,121 ----
return pd?pd->CntAll():0;
}
+ */
I pooldata::GetAll(const AtomList &d,A *&keys,AtomList *&lst)
***************
*** 129,132 ****
--- 139,143 ----
}
+ /*
I pooldata::CntSub(const AtomList &d)
{
***************
*** 134,137 ****
--- 145,149 ----
return pd?pd->CntSub():0;
}
+ */
I pooldata::GetSub(const AtomList &d,const t_atom **&dirs)
***************
*** 150,157 ****
{
pooldir *pd = root.GetDir(d);
! if(pd)
! return pd->Paste(clip,depth,repl,mkdir);
! else
! return false;
}
--- 162,166 ----
{
pooldir *pd = root.GetDir(d);
! return pd && pd->Paste(clip,depth,repl,mkdir);
}
***************
*** 291,294 ****
return false;
}
-
-
--- 300,301 ----
Index: main.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/pool/source/main.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** main.cpp 17 Aug 2004 04:11:28 -0000 1.5
--- main.cpp 30 Oct 2004 03:58:59 -0000 1.6
***************
*** 17,20 ****
--- 17,22 ----
#define DCNT 16
+ const t_symbol *sym_echo = flext::MakeSymbol("echo");
+
class pool:
public flext_base
***************
*** 24,28 ****
public:
pool(I argc,const A *argv);
! ~pool();
static V setup(t_classid);
--- 26,30 ----
public:
pool(I argc,const A *argv);
! virtual ~pool();
static V setup(t_classid);
***************
*** 56,62 ****
// handle data
! V m_set(I argc,const A *argv) { set(MakeSymbol("set"),argc,argv,true); }
! V m_add(I argc,const A *argv) { set(MakeSymbol("add"),argc,argv,false); }
V m_clr(I argc,const A *argv);
V m_clrall(); // only values
V m_clrrec(); // also subdirectories
--- 58,66 ----
// handle data
! V m_set(I argc,const A *argv) { set(argc,argv,true); }
! V m_seti(I argc,const A *argv); // set value at index
! V m_add(I argc,const A *argv) { set(argc,argv,false); }
V m_clr(I argc,const A *argv);
+ V m_clri(I ix); // clear value at index
V m_clrall(); // only values
V m_clrrec(); // also subdirectories
***************
*** 80,92 ****
// cut/copy/paste
! V m_paste(I argc,const A *argv) { paste(MakeSymbol("paste"),argc,argv,true); } // paste contents of clipboard
! V m_pasteadd(I argc,const A *argv) { paste(MakeSymbol("pasteadd"),argc,argv,false); } // paste but don't replace
V m_clrclip(); // clear clipboard
! V m_cut(I argc,const A *argv) { copy(MakeSymbol("cut"),argc,argv,true); } // cut value into clipboard
! V m_copy(I argc,const A *argv) { copy(MakeSymbol("copy"),argc,argv,false); } // copy value into clipboard
! V m_cutall() { copyall(MakeSymbol("cutall"),true,0); } // cut all values in current directory into clipboard
! V m_copyall() { copyall(MakeSymbol("copyall"),false,0); } // copy all values in current directory into clipboard
! V m_cutrec(I argc,const A *argv) { copyrec(MakeSymbol("cutrec"),argc,argv,true); } // cut directory (and subdirs) into clipboard
! V m_copyrec(I argc,const A *argv) { copyrec(MakeSymbol("copyrec"),argc,argv,false); } // cut directory (and subdirs) into clipboard
// load/save from/to file
--- 84,96 ----
// cut/copy/paste
! V m_paste(I argc,const A *argv) { paste(thisTag(),argc,argv,true); } // paste contents of clipboard
! V m_pasteadd(I argc,const A *argv) { paste(thisTag(),argc,argv,false); } // paste but don't replace
V m_clrclip(); // clear clipboard
! V m_cut(I argc,const A *argv) { copy(thisTag(),argc,argv,true); } // cut value into clipboard
! V m_copy(I argc,const A *argv) { copy(thisTag(),argc,argv,false); } // copy value into clipboard
! V m_cutall() { copyall(thisTag(),true,0); } // cut all values in current directory into clipboard
! V m_copyall() { copyall(thisTag(),false,0); } // copy all values in current directory into clipboard
! V m_cutrec(I argc,const A *argv) { copyrec(thisTag(),argc,argv,true); } // cut directory (and subdirs) into clipboard
! V m_copyrec(I argc,const A *argv) { copyrec(thisTag(),argc,argv,false); } // cut directory (and subdirs) into clipboard
// load/save from/to file
***************
*** 116,120 ****
enum get_t { get_norm,get_cnt,get_print };
! V set(const S *tag,I argc,const A *argv,BL over);
V getdir(const S *tag);
I getrec(const S *tag,I level,BL order,get_t how = get_norm,const AtomList &rdir = AtomList());
--- 120,124 ----
enum get_t { get_norm,get_cnt,get_print };
! V set(I argc,const A *argv,BL over);
V getdir(const S *tag);
I getrec(const S *tag,I level,BL order,get_t how = get_norm,const AtomList &rdir = AtomList());
***************
*** 133,137 ****
V svrec(I argc,const A *argv,BL xml); // save values recursively
! V echodir() { if(echo) getdir(MakeSymbol("echo")); }
BL priv,absdir,echo;
--- 137,141 ----
V svrec(I argc,const A *argv,BL xml); // save values recursively
! V echodir() { if(echo) getdir(sym_echo); }
BL priv,absdir,echo;
***************
*** 174,179 ****
--- 178,185 ----
FLEXT_CALLBACK_V(m_set)
+ FLEXT_CALLBACK_V(m_seti)
FLEXT_CALLBACK_V(m_add)
FLEXT_CALLBACK_V(m_clr)
+ FLEXT_CALLBACK_I(m_clri)
FLEXT_CALLBACK(m_clrall)
FLEXT_CALLBACK(m_clrrec)
***************
*** 240,245 ****
FLEXT_CADDMETHOD_(c,0,"reset",m_reset);
- FLEXT_CADDMETHOD_(c,0,"set",m_set);
- FLEXT_CADDMETHOD_(c,0,"add",m_add);
FLEXT_CADDMETHOD_(c,0,"getdir",m_getdir);
FLEXT_CADDMETHOD_(c,0,"mkdir",m_mkdir);
--- 246,249 ----
***************
*** 254,258 ****
--- 258,265 ----
FLEXT_CADDMETHOD_(c,0,"set",m_set);
+ FLEXT_CADDMETHOD_(c,0,"seti",m_seti);
+ FLEXT_CADDMETHOD_(c,0,"add",m_add);
FLEXT_CADDMETHOD_(c,0,"clr",m_clr);
+ FLEXT_CADDMETHOD_(c,0,"clri",m_clri);
FLEXT_CADDMETHOD_(c,0,"clrall",m_clrall);
FLEXT_CADDMETHOD_(c,0,"clrrec",m_clrrec);
***************
*** 393,403 ****
}
! V pool::m_getdir() { getdir(MakeSymbol("getdir")); }
V pool::m_mkdir(I argc,const A *argv,BL abs,BL chg)
{
! const char *nm = chg?"mkchdir":"mkdir";
if(!ValChk(argc,argv))
! post("%s - %s: invalid directory name",thisName(),nm);
else {
AtomList ndir;
--- 400,410 ----
}
! V pool::m_getdir() { getdir(thisTag()); }
V pool::m_mkdir(I argc,const A *argv,BL abs,BL chg)
{
! // const char *nm = chg?"mkchdir":"mkdir";
if(!ValChk(argc,argv))
! post("%s - %s: invalid directory name",thisName(),GetString(thisTag()));
else {
AtomList ndir;
***************
*** 405,409 ****
else (ndir = curdir).Append(argc,argv);
if(!pl->MkDir(ndir,vcnt,dcnt)) {
! post("%s - %s: directory couldn't be created",thisName(),nm);
}
else if(chg)
--- 412,416 ----
else (ndir = curdir).Append(argc,argv);
if(!pl->MkDir(ndir,vcnt,dcnt)) {
! post("%s - %s: directory couldn't be created",thisName(),GetString(thisTag()));
}
else if(chg)
***************
*** 418,422 ****
{
if(!ValChk(argc,argv))
! post("%s - chdir: invalid directory name",thisName());
else {
AtomList prv(curdir);
--- 425,429 ----
{
if(!ValChk(argc,argv))
! post("%s - %s: invalid directory name",thisName(),GetString(thisTag()));
else {
AtomList prv(curdir);
***************
*** 424,428 ****
else curdir.Append(argc,argv);
if(!pl->ChkDir(curdir)) {
! post("%s - chdir: directory couldn't be changed",thisName());
curdir = prv;
}
--- 431,435 ----
else curdir.Append(argc,argv);
if(!pl->ChkDir(curdir)) {
! post("%s - %s: directory couldn't be changed",thisName(),GetString(thisTag()));
curdir = prv;
}
***************
*** 438,448 ****
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - updir: superfluous arguments ignored",thisName());
lvls = GetAInt(argv[0]);
if(lvls < 0)
! post("%s - updir: invalid level specification - set to 1",thisName());
}
else
! post("%s - updir: invalid level specification - set to 1",thisName());
}
--- 445,455 ----
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
if(lvls < 0)
! post("%s - %s: invalid level specification - set to 1",thisName(),GetString(thisTag()));
}
else
! post("%s - %s: invalid level specification - set to 1",thisName(),GetString(thisTag()));
}
***************
*** 450,454 ****
if(lvls > curdir.Count()) {
! post("%s - updir: level exceeds directory depth - corrected",thisName());
curdir();
}
--- 457,461 ----
if(lvls > curdir.Count()) {
! post("%s - %s: level exceeds directory depth - corrected",thisName(),GetString(thisTag()));
curdir();
}
***************
*** 457,461 ****
if(!pl->ChkDir(curdir)) {
! post("%s - updir: directory couldn't be changed",thisName());
curdir = prv;
}
--- 464,468 ----
if(!pl->ChkDir(curdir)) {
! post("%s - %s: directory couldn't be changed",thisName(),GetString(thisTag()));
curdir = prv;
}
***************
*** 470,474 ****
if(!pl->RmDir(curdir))
! post("%s - rmdir: directory couldn't be removed",thisName());
curdir();
--- 477,481 ----
if(!pl->RmDir(curdir))
! post("%s - %s: directory couldn't be removed",thisName(),GetString(thisTag()));
curdir();
***************
*** 476,489 ****
}
! V pool::set(const S *tag,I argc,const A *argv,BL over)
{
if(!argc || !KeyChk(argv[0]))
! post("%s - %s: invalid key",thisName(),GetString(tag));
else if(!ValChk(argc-1,argv+1)) {
! post("%s - %s: invalid data values",thisName(),GetString(tag));
}
else
if(!pl->Set(curdir,argv[0],new AtomList(argc-1,argv+1),over))
! post("%s - %s: value couldn't be set",thisName(),GetString(tag));
echodir();
--- 483,510 ----
}
! V pool::set(I argc,const A *argv,BL over)
{
if(!argc || !KeyChk(argv[0]))
! post("%s - %s: invalid key",thisName(),GetString(thisTag()));
else if(!ValChk(argc-1,argv+1)) {
! post("%s - %s: invalid data values",thisName(),GetString(thisTag()));
}
else
if(!pl->Set(curdir,argv[0],new AtomList(argc-1,argv+1),over))
! post("%s - %s: value couldn't be set",thisName(),GetString(thisTag()));
!
! echodir();
! }
!
! V pool::m_seti(I argc,const A *argv)
! {
! if(!argc || !CanbeInt(argv[0]))
! post("%s - %s: invalid index",thisName(),GetString(thisTag()));
! else if(!ValChk(argc-1,argv+1)) {
! post("%s - %s: invalid data values",thisName(),GetString(thisTag()));
! }
! else
! if(!pl->Seti(curdir,GetAInt(argv[0]),new AtomList(argc-1,argv+1)))
! post("%s - %s: value couldn't be set",thisName(),GetString(thisTag()));
echodir();
***************
*** 493,503 ****
{
if(!argc || !KeyChk(argv[0]))
! post("%s - clr: invalid key",thisName());
else {
if(argc > 1)
! post("%s - clr: superfluous arguments ignored",thisName());
if(!pl->Clr(curdir,argv[0]))
! post("%s - clr: value couldn't be cleared",thisName());
}
--- 514,536 ----
{
if(!argc || !KeyChk(argv[0]))
! post("%s - %s: invalid key",thisName(),GetString(thisTag()));
else {
if(argc > 1)
! post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
if(!pl->Clr(curdir,argv[0]))
! post("%s - %s: value couldn't be cleared",thisName(),GetString(thisTag()));
! }
!
! echodir();
! }
!
! V pool::m_clri(I ix)
! {
! if(ix < 0)
! post("%s - %s: invalid index",thisName(),GetString(thisTag()));
! else {
! if(!pl->Clri(curdir,ix))
! post("%s - %s: value couldn't be cleared",thisName(),GetString(thisTag()));
}
***************
*** 508,512 ****
{
if(!pl->ClrAll(curdir,false))
! post("%s - clrall: values couldn't be cleared",thisName());
echodir();
--- 541,545 ----
{
if(!pl->ClrAll(curdir,false))
! post("%s - %s: values couldn't be cleared",thisName(),GetString(thisTag()));
echodir();
***************
*** 516,520 ****
{
if(!pl->ClrAll(curdir,true))
! post("%s - clrrec: values couldn't be cleared",thisName());
echodir();
--- 549,553 ----
{
if(!pl->ClrAll(curdir,true))
! post("%s - %s: values couldn't be cleared",thisName(),GetString(thisTag()));
echodir();
***************
*** 524,528 ****
{
if(!pl->ClrAll(curdir,true,true))
! post("%s - clrsub: directories couldn't be cleared",thisName());
echodir();
--- 557,561 ----
{
if(!pl->ClrAll(curdir,true,true))
! post("%s - %s: directories couldn't be cleared",thisName(),GetString(thisTag()));
echodir();
***************
*** 532,543 ****
{
if(!argc || !KeyChk(argv[0]))
! post("%s - get: invalid key",thisName());
else {
if(argc > 1)
! post("%s - get: superfluous arguments ignored",thisName());
poolval *r = pl->Ref(curdir,argv[0]);
! ToOutAnything(3,MakeSymbol("get"),0,NULL);
if(absdir)
ToOutList(2,curdir);
--- 565,576 ----
{
if(!argc || !KeyChk(argv[0]))
! post("%s - %s: invalid key",thisName(),GetString(thisTag()));
else {
if(argc > 1)
! post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
poolval *r = pl->Ref(curdir,argv[0]);
! ToOutAnything(3,thisTag(),0,NULL);
if(absdir)
ToOutList(2,curdir);
***************
*** 560,568 ****
{
if(ix < 0)
! post("%s - geti: invalid index",thisName());
else {
poolval *r = pl->Refi(curdir,ix);
! ToOutAnything(3,MakeSymbol("geti"),0,NULL);
if(absdir)
ToOutList(2,curdir);
--- 593,601 ----
{
if(ix < 0)
! post("%s - %s: invalid index",thisName(),GetString(thisTag()));
else {
poolval *r = pl->Refi(curdir,ix);
! ToOutAnything(3,thisTag(),0,NULL);
if(absdir)
ToOutList(2,curdir);
***************
*** 582,586 ****
}
! I pool::getrec(const S *tag,I level,BL order,get_t how,const AtomList &rdir)
{
AtomList gldir(curdir);
--- 615,619 ----
}
! I pool::getrec(const t_symbol *tag,I level,BL order,get_t how,const AtomList &rdir)
{
AtomList gldir(curdir);
***************
*** 635,639 ****
V pool::m_getall()
{
! getrec(MakeSymbol("getall"),0,false);
ToOutBang(3);
--- 668,672 ----
V pool::m_getall()
{
! getrec(thisTag(),0,false);
ToOutBang(3);
***************
*** 643,647 ****
V pool::m_ogetall()
{
! getrec(MakeSymbol("ogetall"),0,true);
ToOutBang(3);
--- 676,680 ----
V pool::m_ogetall()
{
! getrec(thisTag(),0,true);
ToOutBang(3);
***************
*** 655,665 ****
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - getrec: superfluous arguments ignored",thisName());
lvls = GetAInt(argv[0]);
}
else
! post("%s - getrec: invalid level specification - set to infinite",thisName());
}
! getrec(MakeSymbol("getrec"),lvls,false);
ToOutBang(3);
--- 688,698 ----
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
}
else
! post("%s - %s: invalid level specification - set to infinite",thisName(),GetString(thisTag()));
}
! getrec(thisTag(),lvls,false);
ToOutBang(3);
***************
*** 674,684 ****
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - ogetrec: superfluous arguments ignored",thisName());
lvls = GetAInt(argv[0]);
}
else
! post("%s - ogetrec: invalid level specification - set to infinite",thisName());
}
! getrec(MakeSymbol("ogetrec"),lvls,true);
ToOutBang(3);
--- 707,717 ----
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
}
else
! post("%s - %s: invalid level specification - set to infinite",thisName(),GetString(thisTag()));
}
! getrec(thisTag(),lvls,true);
ToOutBang(3);
***************
*** 728,739 ****
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - getsub: superfluous arguments ignored",thisName());
lvls = GetAInt(argv[0]);
}
else
! post("%s - getsub: invalid level specification - set to 0",thisName());
}
! getsub(MakeSymbol("getsub"),lvls,false);
ToOutBang(3);
--- 761,772 ----
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
}
else
! post("%s - %s: invalid level specification - set to 0",thisName(),GetString(thisTag()));
}
! getsub(thisTag(),lvls,false);
ToOutBang(3);
***************
*** 748,759 ****
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - ogetsub: superfluous arguments ignored",thisName());
lvls = GetAInt(argv[0]);
}
else
! post("%s - ogetsub: invalid level specification - set to 0",thisName());
}
! getsub(MakeSymbol("ogetsub"),lvls,true);
ToOutBang(3);
--- 781,792 ----
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
}
else
! post("%s - %s: invalid level specification - set to 0",thisName(),GetString(thisTag()));
}
! getsub(thisTag(),lvls,true);
ToOutBang(3);
***************
*** 764,770 ****
V pool::m_cntall()
{
! const S *tag = MakeSymbol("cntall");
! I cnt = getrec(tag,0,false,get_cnt);
! ToOutSymbol(3,tag);
ToOutBang(2);
ToOutBang(1);
--- 797,802 ----
V pool::m_cntall()
{
! I cnt = getrec(thisTag(),0,false,get_cnt);
! ToOutSymbol(3,thisTag());
ToOutBang(2);
ToOutBang(1);
***************
*** 776,794 ****
V pool::m_cntrec(I argc,const A *argv)
{
- const S *tag = MakeSymbol("cntrec");
-
I lvls = -1;
if(argc > 0) {
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - %s: superfluous arguments ignored",thisName(),GetString(tag));
lvls = GetAInt(argv[0]);
}
else
! post("%s - %s: invalid level specification - set to infinite",thisName(),GetString(tag));
}
! I cnt = getrec(tag,lvls,false,get_cnt);
! ToOutSymbol(3,tag);
ToOutBang(2);
ToOutBang(1);
--- 808,824 ----
V pool::m_cntrec(I argc,const A *argv)
{
I lvls = -1;
if(argc > 0) {
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
}
else
! post("%s - %s: invalid level specification - set to infinite",thisName(),GetString(thisTag()));
}
! I cnt = getrec(thisTag(),lvls,false,get_cnt);
! ToOutSymbol(3,thisTag());
ToOutBang(2);
ToOutBang(1);
***************
*** 801,819 ****
V pool::m_cntsub(I argc,const A *argv)
{
- const S *tag = MakeSymbol("cntsub");
-
I lvls = 0;
if(argc > 0) {
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - %s: superfluous arguments ignored",thisName(),GetString(tag));
lvls = GetAInt(argv[0]);
}
else
! post("%s - %s: invalid level specification - set to 0",thisName(),GetString(tag));
}
! I cnt = getsub(tag,lvls,false,get_cnt);
! ToOutSymbol(3,tag);
ToOutBang(2);
ToOutBang(1);
--- 831,847 ----
V pool::m_cntsub(I argc,const A *argv)
{
I lvls = 0;
if(argc > 0) {
if(CanbeInt(argv[0])) {
if(argc > 1)
! post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
lvls = GetAInt(argv[0]);
}
else
! post("%s - %s: invalid level specification - set to 0",thisName(),GetString(thisTag()));
}
! I cnt = getsub(thisTag(),lvls,false,get_cnt);
! ToOutSymbol(3,thisTag());
ToOutBang(2);
ToOutBang(1);
***************
*** 825,830 ****
V pool::m_printall()
{
! const S *tag = MakeSymbol("printall");
! I cnt = getrec(tag,0,false,get_print);
post("");
}
--- 853,857 ----
V pool::m_printall()
{
! I cnt = getrec(thisTag(),0,false,get_print);
post("");
}
***************
*** 939,955 ****
V pool::load(I argc,const A *argv,BL xml)
{
- const C *sym = xml?"loadx":"load";
const C *flnm = NULL;
if(argc > 0) {
! if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
! post("%s - %s: no filename given",thisName(),sym);
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->LoadXML(fl.c_str()):pl->Load(fl.c_str())))
! post("%s - %s: error loading data",thisName(),sym);
}
--- 966,981 ----
V pool::load(I argc,const A *argv,BL xml)
{
const C *flnm = NULL;
if(argc > 0) {
! if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
! post("%s - %s: no filename given",thisName(),GetString(thisTag()));
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->LoadXML(fl.c_str()):pl->Load(fl.c_str())))
! post("%s - %s: error loading data",thisName(),GetString(thisTag()));
}
***************
*** 959,975 ****
V pool::save(I argc,const A *argv,BL xml)
{
- const C *sym = xml?"savex":"save";
const C *flnm = NULL;
if(argc > 0) {
! if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
! post("%s - %s: no filename given",thisName(),sym);
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->SaveXML(fl.c_str()):pl->Save(fl.c_str())))
! post("%s - %s: error saving data",thisName(),sym);
}
--- 985,1000 ----
V pool::save(I argc,const A *argv,BL xml)
{
const C *flnm = NULL;
if(argc > 0) {
! if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
! post("%s - %s: no filename given",thisName(),GetString(thisTag()));
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->SaveXML(fl.c_str()):pl->Save(fl.c_str())))
! post("%s - %s: error saving data",thisName(),GetString(thisTag()));
}
***************
*** 979,995 ****
V pool::lddir(I argc,const A *argv,BL xml)
{
- const C *sym = xml?"ldxdir":"lddir";
const C *flnm = NULL;
if(argc > 0) {
! if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
! post("%s - %s: invalid filename",thisName(),sym);
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->LdDirXML(curdir,fl.c_str(),0):pl->LdDir(curdir,fl.c_str(),0)))
! post("%s - %s: directory couldn't be loaded",thisName(),sym);
}
--- 1004,1019 ----
V pool::lddir(I argc,const A *argv,BL xml)
{
const C *flnm = NULL;
if(argc > 0) {
! if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
! post("%s - %s: invalid filename",thisName(),GetString(thisTag()));
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->LdDirXML(curdir,fl.c_str(),0):pl->LdDir(curdir,fl.c_str(),0)))
! post("%s - %s: directory couldn't be loaded",thisName(),GetString(thisTag()));
}
***************
*** 999,1003 ****
V pool::ldrec(I argc,const A *argv,BL xml)
{
- const C *sym = xml?"ldxrec":"ldrec";
const C *flnm = NULL;
I depth = -1;
--- 1023,1026 ----
***************
*** 1009,1020 ****
if(CanbeInt(argv[1])) depth = GetAInt(argv[1]);
else
! post("%s - %s: invalid depth argument - set to -1",thisName(),sym);
if(argc >= 3) {
if(CanbeBool(argv[2])) mkdir = GetABool(argv[2]);
else
! post("%s - %s: invalid mkdir argument - set to true",thisName(),sym);
! if(argc > 3) post("%s - %s: superfluous arguments ignored",thisName(),sym);
}
}
--- 1032,1043 ----
if(CanbeInt(argv[1])) depth = GetAInt(argv[1]);
else
! post("%s - %s: invalid depth argument - set to -1",thisName(),GetString(thisTag()));
if(argc >= 3) {
if(CanbeBool(argv[2])) mkdir = GetABool(argv[2]);
else
! post("%s - %s: invalid mkdir argument - set to true",thisName(),GetString(thisTag()));
! if(argc > 3) post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
}
}
***************
*** 1022,1030 ****
if(!flnm)
! post("%s - %s: invalid filename",thisName(),sym);
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->LdDirXML(curdir,fl.c_str(),depth,mkdir):pl->LdDir(curdir,fl.c_str(),depth,mkdir)))
! post("%s - %s: directory couldn't be saved",thisName(),sym);
}
--- 1045,1053 ----
if(!flnm)
! post("%s - %s: invalid filename",thisName(),GetString(thisTag()));
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->LdDirXML(curdir,fl.c_str(),depth,mkdir):pl->LdDir(curdir,fl.c_str(),depth,mkdir)))
! post("%s - %s: directory couldn't be saved",thisName(),GetString(thisTag()));
}
***************
*** 1034,1050 ****
V pool::svdir(I argc,const A *argv,BL xml)
{
- const C *sym = xml?"svxdir":"svdir";
const C *flnm = NULL;
if(argc > 0) {
! if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
! post("%s - %s: invalid filename",thisName(),sym);
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->SvDirXML(curdir,fl.c_str(),0,absdir):pl->SvDir(curdir,fl.c_str(),0,absdir)))
! post("%s - %s: directory couldn't be saved",thisName(),sym);
}
--- 1057,1072 ----
V pool::svdir(I argc,const A *argv,BL xml)
{
const C *flnm = NULL;
if(argc > 0) {
! if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
! post("%s - %s: invalid filename",thisName(),GetString(thisTag()));
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->SvDirXML(curdir,fl.c_str(),0,absdir):pl->SvDir(curdir,fl.c_str(),0,absdir)))
! post("%s - %s: directory couldn't be saved",thisName(),GetString(thisTag()));
}
***************
*** 1054,1070 ****
V pool::svrec(I argc,const A *argv,BL xml)
{
- const C *sym = xml?"svxrec":"svrec";
const C *flnm = NULL;
if(argc > 0) {
! if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
! post("%s - %s: invalid filename",thisName(),sym);
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->SvDirXML(curdir,fl.c_str(),-1,absdir):pl->SvDir(curdir,fl.c_str(),-1,absdir)))
! post("%s - %s: directory couldn't be saved",thisName(),sym);
}
--- 1076,1091 ----
V pool::svrec(I argc,const A *argv,BL xml)
{
const C *flnm = NULL;
if(argc > 0) {
! if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),GetString(thisTag()));
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
! post("%s - %s: invalid filename",thisName(),GetString(thisTag()));
else {
string fl(MakeFilename(flnm));
if(!(xml?pl->SvDirXML(curdir,fl.c_str(),-1,absdir):pl->SvDir(curdir,fl.c_str(),-1,absdir)))
! post("%s - %s: directory couldn't be saved",thisName(),GetString(thisTag()));
}
***************
*** 1097,1101 ****
ToOutInt(ix,GetInt(a));
else
! post("%s - output atom: type not supported!",thisName());
}
--- 1118,1122 ----
ToOutInt(ix,GetInt(a));
else
! post("%s - %s type not supported!",thisName(),GetString(thisTag()));
}
Index: pool.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/pool/source/pool.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** pool.cpp 21 Aug 2004 04:13:01 -0000 1.8
--- pool.cpp 30 Oct 2004 03:59:00 -0000 1.9
***************
*** 192,196 ****
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) {
--- 192,196 ----
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) {
***************
*** 229,232 ****
--- 229,264 ----
}
+ BL pooldir::SetVali(I rix,AtomList *data)
+ {
+ poolval *prv = NULL,*ix = NULL;
+ for(I vix = 0; vix < vsize; ++vix)
+ if(rix > vals[vix].cnt) rix -= vals[vix].cnt;
+ else {
+ ix = vals[vix].v;
+ for(; ix && rix; prv = ix,ix = ix->nxt) --rix;
+ if(ix && !rix) break;
+ }
+
+ if(ix) {
+ // data exists... overwrite it
+
+ if(data)
+ ix->Set(data);
+ else {
+ // delete key
+
+ poolval *nv = ix->nxt;
+ if(prv) prv->nxt = nv;
+ else vals[vix].v = nv;
+ vals[vix].cnt--;
+ ix->nxt = NULL;
+ delete ix;
+ }
+ return true;
+ }
+ else
+ return false;
+ }
+
poolval *pooldir::RefVal(const A &key)
{
***************
*** 241,245 ****
}
-
poolval *pooldir::RefVali(I rix)
{
--- 273,276 ----
Index: pool.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/pool/source/pool.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pool.h 17 Aug 2004 04:11:28 -0000 1.6
--- pool.h 30 Oct 2004 03:59:01 -0000 1.7
***************
*** 70,74 ****
--- 70,76 ----
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);
***************
*** 117,120 ****
--- 119,123 ----
};
+
class pooldata:
public flext
***************
*** 127,146 ****
BL Pop() { return --refs > 0; }
! V Reset();
! BL MkDir(const AtomList &d,I vcnt = 0,I dcnt = 0);
! BL ChkDir(const AtomList &d);
! BL RmDir(const AtomList &d);
- BL Set(const AtomList &d,const A &key,AtomList *data,BL over = true);
- BL Clr(const AtomList &d,const A &key);
- BL ClrAll(const AtomList &d,BL rec,BL dironly = false);
- AtomList *Peek(const AtomList &d,const A &key);
- AtomList *Get(const AtomList &d,const A &key);
- poolval *Ref(const AtomList &d,const A &key);
- poolval *Refi(const AtomList &d,I ix);
- I CntAll(const AtomList &d);
I PrintAll(const AtomList &d);
I GetAll(const AtomList &d,A *&keys,AtomList *&lst);
! I CntSub(const AtomList &d);
I GetSub(const AtomList &d,const t_atom **&dirs);
--- 130,230 ----
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);
! return true;
! }
!
! 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);
! if(!pd) return false;
! pd->SetVal(key,data,over);
! return true;
! }
!
! BL Seti(const AtomList &d,I ix,AtomList *data)
! {
! pooldir *pd = root.GetDir(d);
! if(!pd) return false;
! pd->SetVali(ix,data);
! return true;
! }
!
! BL Clr(const AtomList &d,const A &key)
! {
! pooldir *pd = root.GetDir(d);
! if(!pd) return false;
! pd->ClrVal(key);
! return true;
! }
!
! BL Clri(const AtomList &d,I ix)
! {
! pooldir *pd = root.GetDir(d);
! if(!pd) return false;
! pd->ClrVali(ix);
! return true;
! }
!
! BL ClrAll(const AtomList &d,BL rec,BL dironly = false)
! {
! pooldir *pd = root.GetDir(d);
! if(!pd) return false;
! pd->Clear(rec,dironly);
! return true;
! }
!
! AtomList *Peek(const AtomList &d,const A &key)
! {
! pooldir *pd = root.GetDir(d);
! return pd?pd->PeekVal(key):NULL;
! }
!
! AtomList *Get(const AtomList &d,const A &key)
! {
! pooldir *pd = root.GetDir(d);
! return pd?pd->GetVal(key):NULL;
! }
!
! poolval *Ref(const AtomList &d,const A &key)
! {
! pooldir *pd = root.GetDir(d);
! return pd?pd->RefVal(key):NULL;
! }
!
! poolval *Refi(const AtomList &d,I ix)
! {
! pooldir *pd = root.GetDir(d);
! return pd?pd->RefVali(ix):NULL;
! }
!
! I CntAll(const AtomList &d)
! {
! pooldir *pd = root.GetDir(d);
! return pd?pd->CntAll():0;
! }
I PrintAll(const AtomList &d);
I GetAll(const AtomList &d,A *&keys,AtomList *&lst);
!
! I CntSub(const AtomList &d)
! {
! pooldir *pd = root.GetDir(d);
! return pd?pd->CntSub():0;
! }
!
I GetSub(const AtomList &d,const t_atom **&dirs);