Update of /cvsroot/pure-data/externals/grill/pool/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1187/source
Modified Files: main.cpp pool.cpp pool.h Log Message: ""
Index: main.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/pool/source/main.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** main.cpp 10 Aug 2004 20:23:28 -0000 1.4 --- main.cpp 17 Aug 2004 04:11:28 -0000 1.5 *************** *** 12,16 **** #include <string>
! #define POOL_VERSION "0.2.0"
#define VCNT 64 --- 12,16 ---- #include <string>
! #define POOL_VERSION "0.2.1pre"
#define VCNT 64 *************** *** 704,707 **** --- 704,708 ---- AtomList ndir(absdir?gldir:rdir); ndir.Append(*r[i]); + ++ret;
if(how == get_norm) {
Index: pool.cpp =================================================================== RCS file: /cvsroot/pure-data/externals/grill/pool/source/pool.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pool.cpp 10 Aug 2004 20:23:28 -0000 1.6 --- pool.cpp 17 Aug 2004 04:11:28 -0000 1.7 *************** *** 368,372 **** const I cnt = CntSub(); lst = new const A *[cnt]; ! for(I i = 0,dix = 0; dix < dsize; ++dix) { pooldir *ix = dirs[dix].d; for(; ix; ix = ix->nxt) lst[i++] = &ix->dir; --- 368,372 ---- 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; *************** *** 540,544 **** BL r = ReadAtoms(is,d,',') && ! ReadAtoms(is,k,',') && k.Count() == 1 && ReadAtoms(is,*v,'\n');
--- 540,544 ---- BL r = ReadAtoms(is,d,',') && ! ReadAtoms(is,k,',') && ReadAtoms(is,*v,'\n');
*************** *** 547,551 **** pooldir *nd = mkdir?AddDir(d):GetDir(d); if(nd) { ! nd->SetVal(k[0],v); v = NULL; } #ifdef FLEXT_DEBUG --- 547,555 ---- pooldir *nd = mkdir?AddDir(d):GetDir(d); if(nd) { ! if(k.Count() == 1) { ! nd->SetVal(k[0],v); v = NULL; ! } ! else if(k.Count() > 1) ! post("pool - file format invalid: key must be a single word"); } #ifdef FLEXT_DEBUG *************** *** 565,568 **** --- 569,573 ---- 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) { *************** *** 573,579 **** --- 578,591 ---- WriteAtoms(os,*ix->data); os << endl; + ++cnt; } } + if(!cnt) { + // no key/value pairs present -> force empty directory + WriteAtoms(os,dir); + os << " , ," << endl; + } if(depth) { + // save sub-directories I nd = depth > 0?depth-1:-1; for(I di = 0; di < dsize; ++di) { *************** *** 704,712 **** }
! BL pooldir::LdDirXML(istream &is,I depth,BL mkdir) { ! AtomList d,k,v; ! bool inpool = false,inval = false,inkey = false,indata = false; ! const t_symbol *empty = MakeSymbol("");
while(!is.eof()) { --- 716,724 ---- }
! BL pooldir::LdDirXMLRec(istream &is,I depth,BL mkdir,AtomList &d) { ! AtomList k,v; ! bool inval = false,inkey = false,indata = false; ! int cntval = 0;
while(!is.eof()) { *************** *** 718,722 **** getvalue(is,s);
! if(s.length() && inpool && ( (!inval && inkey && d.Count()) || /* dir */ --- 730,734 ---- getvalue(is,s);
! if(s.length() && ( (!inval && inkey && d.Count()) || /* dir */ *************** *** 753,836 **** post("pool - error reading XML data"); } ! else if(tag == "pool") { ! if(tag.type == xmltag::t_end) break; ! else inpool = true; ! } ! else if(inpool) { ! if(tag == "dir") { ! if(tag.type == xmltag::t_start) { ! // warn if last directory key was not given ! if(d.Count() && GetSymbol(d[d.Count()-1]) == empty) ! post("pool - XML load: dir key must be given prior to subdirs, ignoring items");
! // initialize dir key as empty ! t_atom at; SetSymbol(at,empty); ! d.Append(at); ! } ! else if(tag.type == xmltag::t_end) { ! if(d.Count()) ! d.Part(0,d.Count()-1); ! else ! post("pool - XML load: superfluous </dir> in XML data"); ! } } ! else if(tag == "value") { ! if(tag.type == xmltag::t_start) { ! inval = true; ! k.Clear(); v.Clear(); } - else if(tag.type == xmltag::t_end) { - if(depth < 0 || d.Count() <= depth) { - // NOW set value
! int fnd; ! for(fnd = d.Count()-1; fnd >= 0; --fnd) ! if(GetSymbol(d[fnd]) == empty) break;
! // look if last dir key has been given ! if(fnd >= 0) { ! if(fnd == d.Count()-1) ! post("pool - XML load: dir key must be given prior to values");
! // else: one directoy level has been left unintialized, ignore items ! } ! else { ! // only use first word of key ! if(k.Count() == 1) { ! pooldir *nd = mkdir?AddDir(d):GetDir(d); ! if(nd) ! nd->SetVal(k[0],new AtomList(v)); ! else ! post("pool - XML load: value key must be exactly one word, value not stored"); ! } ! } } - inval = false; } } ! else if(tag == "key") { ! if(tag.type == xmltag::t_start) { ! inkey = true; ! } ! else if(tag.type == xmltag::t_end) { ! inkey = false; ! } } ! else if(tag == "data") { ! if(!inval) ! post("pool - XML tag <data> not within <value>");
! if(tag.type == xmltag::t_start) { ! indata = true; ! } ! else if(tag.type == xmltag::t_end) { ! indata = false; ! } } ! #ifdef FLEXT_DEBUG ! else { ! post("pool - unknown XML tag '%s'",tag.tag.c_str()); } #endif } else if(tag == "!DOCTYPE") { --- 765,870 ---- post("pool - error reading XML data"); } ! else if(tag == "dir") { ! if(tag.type == xmltag::t_start) { ! // warn if last directory key was not given ! if(d.Count() && GetSymbol(d[d.Count()-1]) == sym__) ! post("pool - XML load: dir key must be given prior to subdirs, ignoring items");
! AtomList dnext(d.Count()+1); ! // copy existing dir ! dnext.Set(d.Count(),d.Atoms(),0,false); ! // initialize current dir key as empty ! SetSymbol(dnext[d.Count()],sym__); ! ! // read next level ! LdDirXMLRec(is,depth,mkdir,dnext); } ! else if(tag.type == xmltag::t_end) { ! if(!cntval && mkdir) { ! // no values have been found in dir -> make empty dir ! AddDir(d); }
! // break tag loop ! break; ! } ! } ! else if(tag == "value") { ! if(tag.type == xmltag::t_start) { ! inval = true; ! ++cntval; ! k.Clear(); v.Clear(); ! } ! else if(tag.type == xmltag::t_end) { ! // set value after tag closing, but only if level <= depth ! if(depth < 0 || d.Count() <= depth) { ! int fnd; ! for(fnd = d.Count()-1; fnd >= 0; --fnd) ! if(GetSymbol(d[fnd]) == sym__) break;
! // look if last dir key has been given ! if(fnd >= 0) { ! if(fnd == d.Count()-1) ! post("pool - XML load: dir key must be given prior to values");
! // else: one directoy level has been left unintialized, ignore items ! } ! else { ! // only use first word of key ! if(k.Count() == 1) { ! pooldir *nd = mkdir?AddDir(d):GetDir(d); ! if(nd) ! nd->SetVal(k[0],new AtomList(v)); ! else ! post("pool - XML load: value key must be exactly one word, value not stored"); ! } } } + inval = false; } ! } ! else if(tag == "key") { ! if(tag.type == xmltag::t_start) { ! inkey = true; } ! else if(tag.type == xmltag::t_end) { ! inkey = false; ! } ! } ! else if(tag == "data") { ! if(!inval) ! post("pool - XML tag <data> not within <value>");
! if(tag.type == xmltag::t_start) { ! indata = true; } ! else if(tag.type == xmltag::t_end) { ! indata = false; } + } + else if(!d.Count() && tag == "pool" && tag.type == xmltag::t_end) { + // break tag loop + break; + } + #ifdef FLEXT_DEBUG + else { + post("pool - unknown XML tag '%s'",tag.tag.c_str()); + } #endif + } + return true; + } + + BL pooldir::LdDirXML(istream &is,I depth,BL mkdir) + { + while(!is.eof()) { + xmltag tag; + if(!gettag(is,tag)) break; + + if(tag == "pool") { + if(tag.type == xmltag::t_start) + LdDirXMLRec(is,depth,mkdir,AtomList()); + else + post("pool - pool not initialized yet"); } else if(tag == "!DOCTYPE") {
Index: pool.h =================================================================== RCS file: /cvsroot/pure-data/externals/grill/pool/source/pool.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pool.h 10 Aug 2004 20:23:28 -0000 1.5 --- pool.h 17 Aug 2004 04:11:28 -0000 1.6 *************** *** 112,115 **** --- 112,118 ---- valentry *vals; direntry *dirs; + + private: + BL LdDirXMLRec(istream &is,I depth,BL mkdir,AtomList &d); };