aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/pool
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/pool')
-rw-r--r--externals/grill/pool/help-pool.pd532
-rw-r--r--externals/grill/pool/readme.txt4
-rw-r--r--externals/grill/pool/source/main.cpp3
-rw-r--r--externals/grill/pool/source/pool.cpp190
-rw-r--r--externals/grill/pool/source/pool.h3
5 files changed, 387 insertions, 345 deletions
diff --git a/externals/grill/pool/help-pool.pd b/externals/grill/pool/help-pool.pd
index 15439c1f..47123ef7 100644
--- a/externals/grill/pool/help-pool.pd
+++ b/externals/grill/pool/help-pool.pd
@@ -1,266 +1,266 @@
-#N canvas 132 22 958 714 12;
-#X msg 296 105 set 1 2 3;
-#X obj 238 631 print K;
-#X msg 607 211 getall;
-#X msg 296 134 set A k g;
-#X obj 189 660 print V;
-#X obj 287 605 print D;
-#X msg 296 164 set A l m;
-#X msg 299 193 set 2 34;
-#X msg 429 102 clr A;
-#X msg 429 165 get A;
-#X msg 429 190 get 2;
-#X msg 31 132 echodir \$1;
-#X obj 31 111 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
-;
-#X obj 31 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
-;
-#X msg 31 234 absdir \$1;
-#X text 428 82 clear value;
-#X text 425 143 get value;
-#X obj 336 576 print C;
-#X text 408 576 command;
-#X text 360 605 directory (abs or rel to current);
-#X text 264 661 data value;
-#X text 310 631 data key;
-#X msg 32 314 pool pool1;
-#X msg 33 343 pool;
-#X text 77 343 set to private;
-#X msg 33 405 reset;
-#X text 32 384 clear all pool data;
-#X msg 608 111 clrall;
-#X text 599 89 clear all values in dir;
-#X text 607 190 get all values in dir;
-#X text 175 500 pool name can be given as argument;
-#X text 598 136 clear all values and dirs;
-#X msg 606 158 clrrec;
-#X msg 605 258 getrec;
-#X text 605 236 get all values in dir and subdirs;
-#X text 670 289 bang at EOL;
-#X text 673 208 bang at EOL;
-#X text 670 257 depth may be given;
-#X text 34 291 set pool name;
-#X text 31 89 at each command;
-#X text 31 73 echo current dir;
-#X text 293 80 set values;
-#X text 26 194 (default on);
-#X text 18 178 report absolute dirs;
-#X msg 34 452 help;
-#X text 77 453 get some info;
-#X text 670 274 default=-1 (= infinite);
-#X msg 609 340 cntall;
-#X text 675 338 count all values in dir;
-#X msg 609 366 cntrec;
-#X text 677 364 ... and subdirs;
-#X text 673 378 (depth may be given);
-#X text 295 258 set but don't replace;
-#N canvas 472 45 420 631 dirs 0;
-#X msg 111 40 mkdir fld1;
-#X msg 113 135 chdir;
-#X msg 109 331 updir;
-#X msg 110 468 getsub -1;
-#X text 112 20 make absolute dir;
-#X text 111 64 make relative dir;
-#X msg 112 85 mksub fld2;
-#X text 111 117 change to absolute dir;
-#X msg 112 178 chsub fld2;
-#X text 110 159 change to relative dir;
-#X text 105 312 change to upper dir;
-#X text 106 364 remove absolute dir;
-#X msg 107 383 rmdir fld1;
-#X msg 109 422 rmsub fld2;
-#X text 108 403 remove relative dir;
-#X text 108 450 get subdirs;
-#X text 250 494 -1 ... infinite;
-#X text 166 327 depth may be given;
-#X text 167 343 default=1;
-#X text 208 463 depth may be given;
-#X text 206 479 default=1;
-#X text 107 491 count subdirs;
-#X msg 110 512 cntsub -1;
-#X msg 110 572 getdir;
-#X text 109 552 get current dir;
-#X text 175 572 always absolute;
-#X obj 13 252 s \$0-pool;
-#X msg 111 231 mkchdir fld1;
-#X text 112 211 make and change to absolute dir;
-#X msg 109 276 mkchsub fld2;
-#X text 110 256 make and change to relative dir;
-#X connect 0 0 26 0;
-#X connect 1 0 26 0;
-#X connect 2 0 26 0;
-#X connect 3 0 26 0;
-#X connect 6 0 26 0;
-#X connect 8 0 26 0;
-#X connect 12 0 26 0;
-#X connect 13 0 26 0;
-#X connect 22 0 26 0;
-#X connect 23 0 26 0;
-#X connect 27 0 26 0;
-#X connect 29 0 26 0;
-#X restore 716 496 pd dirs;
-#X text 713 470 directory operations;
-#N canvas 0 22 833 465 file 0;
-#X text 117 207 save dir and subdirs;
-#X text 117 165 save data in current dir;
-#X text 117 253 load data into current dir;
-#X text 115 300 load data into current dir and below;
-#X text 132 340 depth (default -1) and;
-#X text 134 356 mkdir flag (default 1) can be given;
-#X text 117 37 save all;
-#X text 117 81 load all (add to existing data);
-#X text 22 12 file operations;
-#X obj 22 188 s \$0-pool;
-#X text 473 209 save dir and subdirs;
-#X text 473 167 save data in current dir;
-#X text 473 255 load data into current dir;
-#X text 471 302 load data into current dir and below;
-#X text 488 342 depth (default -1) and;
-#X text 490 358 mkdir flag (default 1) can be given;
-#X text 473 39 save all;
-#X text 473 83 load all (add to existing data);
-#X obj 378 190 s \$0-pool;
-#X text 444 12 XML format;
-#X msg 120 54 save pool.dat;
-#X msg 118 100 load pool.dat;
-#X msg 117 184 svdir pool.dat;
-#X msg 117 226 svrec pool.dat;
-#X msg 116 272 lddir pool.dat;
-#X msg 116 319 ldrec pool.dat;
-#X msg 476 56 savex pool.xml;
-#X msg 474 102 loadx pool.xml;
-#X msg 473 186 svxdir pool.xml;
-#X msg 473 228 svxrec pool.xml;
-#X msg 472 274 ldxdir pool.xml;
-#X msg 472 321 ldxrec pool.xml;
-#X text 26 398 If the file name is given without a path specification
-the folder containing the current patcher will be used.;
-#X connect 20 0 9 0;
-#X connect 21 0 9 0;
-#X connect 22 0 9 0;
-#X connect 23 0 9 0;
-#X connect 24 0 9 0;
-#X connect 25 0 9 0;
-#X connect 26 0 18 0;
-#X connect 27 0 18 0;
-#X connect 28 0 18 0;
-#X connect 29 0 18 0;
-#X connect 30 0 18 0;
-#X connect 31 0 18 0;
-#X restore 717 551 pd file;
-#X text 715 528 file operations;
-#X text 715 585 clipboard operations;
-#N canvas 0 22 545 593 clip 0;
-#X text 97 56 copy value associated to key into clipboard;
-#X msg 100 77 copy A;
-#X msg 98 119 cut B;
-#X text 96 101 cut value associated to key into clipboard;
-#X msg 96 401 paste;
-#X msg 98 179 copyall;
-#X text 95 158 copy all values in current dir into clipboard;
-#X msg 97 221 cutall;
-#X text 95 201 cut all values in current dir into clipboard;
-#X text 94 263 copy all values in current dir into clipboard;
-#X text 94 306 cut all values in current dir into clipboard;
-#X msg 97 284 copyrec;
-#X text 194 285 depth may be given (default=-1);
-#X text 193 326 depth may be given (default=-1);
-#X msg 96 326 cutrec 1;
-#X text 194 345 1..only with first level subdirs;
-#X text 96 379 paste clipboard contents into current directory;
-#X text 167 397 depth (default -1) and;
-#X text 169 413 mkdir flag (default 1) can be given;
-#X text 183 448 depth (default -1) and;
-#X text 185 466 mkdir flag (default 1) can be given;
-#X msg 95 453 pasteadd;
-#X text 95 431 paste but don't replace;
-#X msg 94 521 clrclip;
-#X text 171 520 clear clipboard (free memory);
-#X text 22 12 clipboard operations (this is an internal clipboard...)
-;
-#X obj 4 193 s \$0-pool;
-#X connect 1 0 26 0;
-#X connect 2 0 26 0;
-#X connect 4 0 26 0;
-#X connect 5 0 26 0;
-#X connect 7 0 26 0;
-#X connect 11 0 26 0;
-#X connect 14 0 26 0;
-#X connect 21 0 26 0;
-#X connect 23 0 26 0;
-#X restore 716 606 pd clip;
-#X text 715 439 more commands:;
-#X obj 298 389 r \$0-pool;
-#X text 174 517 data is shared among pool objects with the same name
-;
-#X obj 26 10 cnv 15 850 40 empty empty pool 10 22 0 24 -260818 -1 0
-;
-#X text 272 33 http://www.parasitaere-kapazitaeten.net;
-#X obj 386 553 print A;
-#X text 458 552 attributes;
-#X msg 34 490 getattributes;
-#X msg 139 132 getechodir;
-#X msg 130 234 getabsdir;
-#X msg 141 314 getpool;
-#X msg 297 279 add 2 14;
-#X obj 260 478 pool @valcnt 10 @dircnt 5;
-#X text 330 437 expected value and directory counts;
-#X text 330 452 can be given for optimal performance;
-#X msg 429 215 get 3;
-#X msg 300 224 set 3 -1 1;
-#X msg 32 518 getmethods;
-#X text 328 466 (see attributes in properties dialog);
-#X text 715 638 console printout;
-#N canvas 0 22 612 291 print 0;
-#X obj 21 231 s \$0-pool;
-#X msg 109 80 printall;
-#X msg 109 132 printrec;
-#X text 110 60 print all values in dir;
-#X text 109 112 print values in dir and subdirs;
-#X text 190 133 (depth may be given);
-#X text 22 12 print-to-console operations;
-#X text 201 183 (depth may be given);
-#X msg 109 181 printroot;
-#X text 109 161 print values in dir and subdirs (starting from root)
-;
-#X connect 1 0 0 0;
-#X connect 2 0 0 0;
-#X connect 8 0 0 0;
-#X restore 717 659 pd print;
-#X text 272 13 a hierarchical storage object \, (C)2002-2004 Thomas
-Grill;
-#X connect 0 0 71 0;
-#X connect 2 0 71 0;
-#X connect 3 0 71 0;
-#X connect 6 0 71 0;
-#X connect 7 0 71 0;
-#X connect 8 0 71 0;
-#X connect 9 0 71 0;
-#X connect 10 0 71 0;
-#X connect 11 0 71 0;
-#X connect 12 0 11 0;
-#X connect 13 0 14 0;
-#X connect 14 0 71 0;
-#X connect 22 0 71 0;
-#X connect 23 0 71 0;
-#X connect 25 0 71 0;
-#X connect 27 0 71 0;
-#X connect 32 0 71 0;
-#X connect 33 0 71 0;
-#X connect 44 0 71 0;
-#X connect 47 0 71 0;
-#X connect 49 0 71 0;
-#X connect 60 0 71 0;
-#X connect 66 0 71 0;
-#X connect 67 0 71 0;
-#X connect 68 0 71 0;
-#X connect 69 0 71 0;
-#X connect 70 0 71 0;
-#X connect 71 0 4 0;
-#X connect 71 1 1 0;
-#X connect 71 2 5 0;
-#X connect 71 3 17 0;
-#X connect 71 4 64 0;
-#X connect 74 0 71 0;
-#X connect 75 0 71 0;
-#X connect 76 0 71 0;
+#N canvas 4 3 927 697 12;
+#X msg 296 105 set 1 2 3;
+#X obj 238 631 print K;
+#X msg 607 211 getall;
+#X msg 296 134 set A k g;
+#X obj 189 660 print V;
+#X obj 287 605 print D;
+#X msg 296 164 set A l m;
+#X msg 299 193 set 2 34;
+#X msg 429 102 clr A;
+#X msg 429 165 get A;
+#X msg 429 190 get 2;
+#X msg 31 132 echodir \$1;
+#X obj 31 111 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X obj 31 213 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
+#X msg 31 234 absdir \$1;
+#X text 428 82 clear value;
+#X text 425 143 get value;
+#X obj 336 576 print C;
+#X text 408 576 command;
+#X text 360 605 directory (abs or rel to current);
+#X text 264 661 data value;
+#X text 310 631 data key;
+#X msg 32 314 pool pool1;
+#X msg 33 343 pool;
+#X text 77 343 set to private;
+#X msg 33 405 reset;
+#X text 32 384 clear all pool data;
+#X msg 608 111 clrall;
+#X text 599 89 clear all values in dir;
+#X text 607 190 get all values in dir;
+#X text 175 500 pool name can be given as argument;
+#X text 598 136 clear all values and dirs;
+#X msg 606 158 clrrec;
+#X msg 605 258 getrec;
+#X text 605 236 get all values in dir and subdirs;
+#X text 670 289 bang at EOL;
+#X text 673 208 bang at EOL;
+#X text 670 257 depth may be given;
+#X text 34 291 set pool name;
+#X text 31 89 at each command;
+#X text 31 73 echo current dir;
+#X text 293 80 set values;
+#X text 26 194 (default on);
+#X text 18 178 report absolute dirs;
+#X msg 34 452 help;
+#X text 77 453 get some info;
+#X text 670 274 default=-1 (= infinite);
+#X msg 609 340 cntall;
+#X text 675 338 count all values in dir;
+#X msg 609 366 cntrec;
+#X text 677 364 ... and subdirs;
+#X text 673 378 (depth may be given);
+#X text 295 258 set but don't replace;
+#N canvas 472 45 420 631 dirs 0;
+#X msg 111 40 mkdir fld1;
+#X msg 113 135 chdir;
+#X msg 109 331 updir;
+#X msg 110 468 getsub -1;
+#X text 112 20 make absolute dir;
+#X text 111 64 make relative dir;
+#X msg 112 85 mksub fld2;
+#X text 111 117 change to absolute dir;
+#X msg 112 178 chsub fld2;
+#X text 110 159 change to relative dir;
+#X text 105 312 change to upper dir;
+#X text 106 364 remove absolute dir;
+#X msg 107 383 rmdir fld1;
+#X msg 109 422 rmsub fld2;
+#X text 108 403 remove relative dir;
+#X text 108 450 get subdirs;
+#X text 250 494 -1 ... infinite;
+#X text 166 327 depth may be given;
+#X text 167 343 default=1;
+#X text 208 463 depth may be given;
+#X text 206 479 default=1;
+#X text 107 491 count subdirs;
+#X msg 110 512 cntsub -1;
+#X msg 110 572 getdir;
+#X text 109 552 get current dir;
+#X text 175 572 always absolute;
+#X obj 13 252 s \$0-pool;
+#X msg 111 231 mkchdir fld1;
+#X text 112 211 make and change to absolute dir;
+#X msg 109 276 mkchsub fld2;
+#X text 110 256 make and change to relative dir;
+#X connect 0 0 26 0;
+#X connect 1 0 26 0;
+#X connect 2 0 26 0;
+#X connect 3 0 26 0;
+#X connect 6 0 26 0;
+#X connect 8 0 26 0;
+#X connect 12 0 26 0;
+#X connect 13 0 26 0;
+#X connect 22 0 26 0;
+#X connect 23 0 26 0;
+#X connect 27 0 26 0;
+#X connect 29 0 26 0;
+#X restore 716 496 pd dirs;
+#X text 713 470 directory operations;
+#N canvas 0 22 833 465 file 0;
+#X text 117 207 save dir and subdirs;
+#X text 117 165 save data in current dir;
+#X text 117 253 load data into current dir;
+#X text 115 300 load data into current dir and below;
+#X text 132 340 depth (default -1) and;
+#X text 134 356 mkdir flag (default 1) can be given;
+#X text 117 37 save all;
+#X text 117 81 load all (add to existing data);
+#X text 22 12 file operations;
+#X obj 22 188 s \$0-pool;
+#X text 473 209 save dir and subdirs;
+#X text 473 167 save data in current dir;
+#X text 473 255 load data into current dir;
+#X text 471 302 load data into current dir and below;
+#X text 488 342 depth (default -1) and;
+#X text 490 358 mkdir flag (default 1) can be given;
+#X text 473 39 save all;
+#X text 473 83 load all (add to existing data);
+#X obj 378 190 s \$0-pool;
+#X text 444 12 XML format;
+#X msg 120 54 save pool.dat;
+#X msg 118 100 load pool.dat;
+#X msg 117 184 svdir pool.dat;
+#X msg 117 226 svrec pool.dat;
+#X msg 116 272 lddir pool.dat;
+#X msg 116 319 ldrec pool.dat;
+#X msg 476 56 savex pool.xml;
+#X msg 474 102 loadx pool.xml;
+#X msg 473 186 svxdir pool.xml;
+#X msg 473 228 svxrec pool.xml;
+#X msg 472 274 ldxdir pool.xml;
+#X msg 472 321 ldxrec pool.xml;
+#X text 26 398 If the file name is given without a path specification
+the folder containing the current patcher will be used.;
+#X connect 20 0 9 0;
+#X connect 21 0 9 0;
+#X connect 22 0 9 0;
+#X connect 23 0 9 0;
+#X connect 24 0 9 0;
+#X connect 25 0 9 0;
+#X connect 26 0 18 0;
+#X connect 27 0 18 0;
+#X connect 28 0 18 0;
+#X connect 29 0 18 0;
+#X connect 30 0 18 0;
+#X connect 31 0 18 0;
+#X restore 717 551 pd file;
+#X text 715 528 file operations;
+#X text 715 585 clipboard operations;
+#N canvas 0 22 545 593 clip 0;
+#X text 97 56 copy value associated to key into clipboard;
+#X msg 100 77 copy A;
+#X msg 98 119 cut B;
+#X text 96 101 cut value associated to key into clipboard;
+#X msg 96 401 paste;
+#X msg 98 179 copyall;
+#X text 95 158 copy all values in current dir into clipboard;
+#X msg 97 221 cutall;
+#X text 95 201 cut all values in current dir into clipboard;
+#X text 94 263 copy all values in current dir into clipboard;
+#X text 94 306 cut all values in current dir into clipboard;
+#X msg 97 284 copyrec;
+#X text 194 285 depth may be given (default=-1);
+#X text 193 326 depth may be given (default=-1);
+#X msg 96 326 cutrec 1;
+#X text 194 345 1..only with first level subdirs;
+#X text 96 379 paste clipboard contents into current directory;
+#X text 167 397 depth (default -1) and;
+#X text 169 413 mkdir flag (default 1) can be given;
+#X text 183 448 depth (default -1) and;
+#X text 185 466 mkdir flag (default 1) can be given;
+#X msg 95 453 pasteadd;
+#X text 95 431 paste but don't replace;
+#X msg 94 521 clrclip;
+#X text 171 520 clear clipboard (free memory);
+#X text 22 12 clipboard operations (this is an internal clipboard...)
+;
+#X obj 4 193 s \$0-pool;
+#X connect 1 0 26 0;
+#X connect 2 0 26 0;
+#X connect 4 0 26 0;
+#X connect 5 0 26 0;
+#X connect 7 0 26 0;
+#X connect 11 0 26 0;
+#X connect 14 0 26 0;
+#X connect 21 0 26 0;
+#X connect 23 0 26 0;
+#X restore 716 606 pd clip;
+#X text 715 439 more commands:;
+#X obj 298 389 r \$0-pool;
+#X text 174 517 data is shared among pool objects with the same name
+;
+#X obj 26 10 cnv 15 850 40 empty empty pool 10 22 0 24 -260818 -1 0
+;
+#X text 272 33 http://www.parasitaere-kapazitaeten.net;
+#X obj 386 553 print A;
+#X text 458 552 attributes;
+#X msg 34 490 getattributes;
+#X msg 139 132 getechodir;
+#X msg 130 234 getabsdir;
+#X msg 141 314 getpool;
+#X msg 297 279 add 2 14;
+#X obj 260 478 pool @valcnt 10 @dircnt 5;
+#X text 330 437 expected value and directory counts;
+#X text 330 452 can be given for optimal performance;
+#X msg 429 215 get 3;
+#X msg 300 224 set 3 -1 1;
+#X msg 32 518 getmethods;
+#X text 328 466 (see attributes in properties dialog);
+#X text 715 638 console printout;
+#N canvas 0 22 612 291 print 0;
+#X obj 21 231 s \$0-pool;
+#X msg 109 80 printall;
+#X msg 109 132 printrec;
+#X text 110 60 print all values in dir;
+#X text 109 112 print values in dir and subdirs;
+#X text 190 133 (depth may be given);
+#X text 22 12 print-to-console operations;
+#X text 201 183 (depth may be given);
+#X msg 109 181 printroot;
+#X text 109 161 print values in dir and subdirs (starting from root)
+;
+#X connect 1 0 0 0;
+#X connect 2 0 0 0;
+#X connect 8 0 0 0;
+#X restore 717 659 pd print;
+#X text 272 13 a hierarchical storage object \, (C)2002-2004 Thomas
+Grill;
+#X connect 0 0 71 0;
+#X connect 2 0 71 0;
+#X connect 3 0 71 0;
+#X connect 6 0 71 0;
+#X connect 7 0 71 0;
+#X connect 8 0 71 0;
+#X connect 9 0 71 0;
+#X connect 10 0 71 0;
+#X connect 11 0 71 0;
+#X connect 12 0 11 0;
+#X connect 13 0 14 0;
+#X connect 14 0 71 0;
+#X connect 22 0 71 0;
+#X connect 23 0 71 0;
+#X connect 25 0 71 0;
+#X connect 27 0 71 0;
+#X connect 32 0 71 0;
+#X connect 33 0 71 0;
+#X connect 44 0 71 0;
+#X connect 47 0 71 0;
+#X connect 49 0 71 0;
+#X connect 60 0 71 0;
+#X connect 66 0 71 0;
+#X connect 67 0 71 0;
+#X connect 68 0 71 0;
+#X connect 69 0 71 0;
+#X connect 70 0 71 0;
+#X connect 71 0 4 0;
+#X connect 71 1 1 0;
+#X connect 71 2 5 0;
+#X connect 71 3 17 0;
+#X connect 71 4 64 0;
+#X connect 74 0 71 0;
+#X connect 75 0 71 0;
+#X connect 76 0 71 0;
diff --git a/externals/grill/pool/readme.txt b/externals/grill/pool/readme.txt
index 36b47470..33636fec 100644
--- a/externals/grill/pool/readme.txt
+++ b/externals/grill/pool/readme.txt
@@ -86,6 +86,10 @@ o Microsoft Visual C++ 6/7: edit "config-max-msvc.txt" & run "build-max-msvc.bat
Version history:
+0.2.1:
+- fixed "cntsub"... directories in current directory have been forgotten
+- store/create also empty dirs with file I/O
+
0.2.0:
- attributes (pool,private,echodir,absdir)
- added "geti" message for retrieval of a value at an index
diff --git a/externals/grill/pool/source/main.cpp b/externals/grill/pool/source/main.cpp
index 3b7670d2..eb3ae8e6 100644
--- a/externals/grill/pool/source/main.cpp
+++ b/externals/grill/pool/source/main.cpp
@@ -11,7 +11,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "pool.h"
#include <string>
-#define POOL_VERSION "0.2.0"
+#define POOL_VERSION "0.2.1pre"
#define VCNT 64
#define DCNT 16
@@ -703,6 +703,7 @@ I pool::getsub(const S *tag,I level,BL order,get_t how,const AtomList &rdir)
for(I i = 0; i < cnt; ++i) {
AtomList ndir(absdir?gldir:rdir);
ndir.Append(*r[i]);
+ ++ret;
if(how == get_norm) {
ToOutAnything(3,tag,0,NULL);
diff --git a/externals/grill/pool/source/pool.cpp b/externals/grill/pool/source/pool.cpp
index 2dd4d1a0..8773d72c 100644
--- a/externals/grill/pool/source/pool.cpp
+++ b/externals/grill/pool/source/pool.cpp
@@ -367,7 +367,7 @@ I pooldir::GetSub(const A **&lst)
{
const I cnt = CntSub();
lst = new const A *[cnt];
- for(I i = 0,dix = 0; dix < dsize; ++dix) {
+ for(I i = 0,dix = 0; i < cnt; ++dix) {
pooldir *ix = dirs[dix].d;
for(; ix; ix = ix->nxt) lst[i++] = &ix->dir;
}
@@ -539,14 +539,18 @@ BL pooldir::LdDir(istream &is,I depth,BL mkdir)
AtomList d,k,*v = new AtomList;
BL r =
ReadAtoms(is,d,',') &&
- ReadAtoms(is,k,',') && k.Count() == 1 &&
+ ReadAtoms(is,k,',') &&
ReadAtoms(is,*v,'\n');
if(r) {
if(depth < 0 || d.Count() <= depth) {
pooldir *nd = mkdir?AddDir(d):GetDir(d);
if(nd) {
- nd->SetVal(k[0],v); v = NULL;
+ 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
else
@@ -564,6 +568,7 @@ BL pooldir::LdDir(istream &is,I depth,BL mkdir)
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);
@@ -572,9 +577,16 @@ BL pooldir::SvDir(ostream &os,I depth,const AtomList &dir)
os << " , ";
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) {
for(pooldir *ix = dirs[di].d; ix; ix = ix->nxt) {
@@ -703,11 +715,11 @@ static void getvalue(istream &is,string &s)
s = tmp;
}
-BL pooldir::LdDirXML(istream &is,I depth,BL mkdir)
+BL pooldir::LdDirXMLRec(istream &is,I depth,BL mkdir,AtomList &d)
{
- AtomList d,k,v;
- bool inpool = false,inval = false,inkey = false,indata = false;
- const t_symbol *empty = MakeSymbol("");
+ AtomList k,v;
+ bool inval = false,inkey = false,indata = false;
+ int cntval = 0;
while(!is.eof()) {
xmltag tag;
@@ -717,7 +729,7 @@ BL pooldir::LdDirXML(istream &is,I depth,BL mkdir)
string s;
getvalue(is,s);
- if(s.length() && inpool &&
+ if(s.length() &&
(
(!inval && inkey && d.Count()) || /* dir */
(inval && (inkey || indata)) /* value */
@@ -752,86 +764,108 @@ BL pooldir::LdDirXML(istream &is,I depth,BL mkdir)
else
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 == "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 == "value") {
- if(tag.type == xmltag::t_start) {
- inval = true;
- k.Clear(); v.Clear();
+ else if(tag.type == xmltag::t_end) {
+ if(!cntval && mkdir) {
+ // no values have been found in dir -> make empty dir
+ AddDir(d);
}
- 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");
- }
- }
+
+ // 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;
}
+ 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 == "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>");
+ }
+ 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;
- }
+ if(tag.type == xmltag::t_start) {
+ indata = true;
}
-#ifdef FLEXT_DEBUG
- else {
- post("pool - unknown XML tag '%s'",tag.tag.c_str());
+ 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") {
// ignore
diff --git a/externals/grill/pool/source/pool.h b/externals/grill/pool/source/pool.h
index 785ea16f..5b4397c2 100644
--- a/externals/grill/pool/source/pool.h
+++ b/externals/grill/pool/source/pool.h
@@ -111,6 +111,9 @@ protected:
valentry *vals;
direntry *dirs;
+
+private:
+ BL LdDirXMLRec(istream &is,I depth,BL mkdir,AtomList &d);
};
class pooldata: