Changeset 7386
- Timestamp:
- 2004-05-24T16:39:27+12:00 (20 years ago)
- Location:
- trunk/gsdl/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/lib/display.cpp
r6021 r7386 43 43 44 44 45 // macro value structure46 struct mvalue47 {48 text_t filename;49 text_t value;50 };51 45 52 46 inline bool operator==(const mvalue &x, const mvalue &y) { … … 62 56 63 57 ///////////////////////////////////// 64 // stuff for defaultmacros_t58 // stuff for parammacros_t 65 59 ///////////////////////////////////// 66 60 … … 69 63 typedef map<text_t, defmacromap, lttext_t> defpackagemap; 70 64 71 // all methods in defaultmacros_t assume the parameters65 // all methods in parammacros_t assume the parameters 72 66 // and packages in a standard form and not empty 73 class defaultmacros_t67 class parammacros_t 74 68 { 75 69 protected: … … 118 112 // -3 if it redefined a macro and hid a Global macro 119 113 // -4 if either a package, macroname, or params were not supplied 120 int defaultmacros_t::setmacro(const text_t &package,114 int parammacros_t::setmacro(const text_t &package, 121 115 const text_t ¯oname, 122 116 const text_t ¶ms, … … 158 152 } 159 153 160 void defaultmacros_t::delmacro(const text_t &package,154 void parammacros_t::delmacro(const text_t &package, 161 155 const text_t ¯oname, 162 156 const text_t ¶ms) … … 177 171 } 178 172 179 defmacromap * defaultmacros_t::package_find (const text_t &packagename)173 defmacromap *parammacros_t::package_find (const text_t &packagename) 180 174 { 181 175 if (packagename.empty()) return NULL; … … 187 181 } 188 182 189 defparammap * defaultmacros_t::macro_find (const text_t &packagename,183 defparammap *parammacros_t::macro_find (const text_t &packagename, 190 184 const text_t ¯oname) 191 185 { … … 199 193 } 200 194 201 mvalue * defaultmacros_t::parameter_find (const text_t &packagename,195 mvalue *parammacros_t::parameter_find (const text_t &packagename, 202 196 const text_t ¯oname, 203 197 const text_t ¶metername) … … 574 568 displayclass::displayclass () 575 569 { 576 defaultmacros = new defaultmacros_t; 577 defaultfiles = new fileinfomap; 570 defaultmacros = new parammacros_t; 571 collectionmacros = new parammacros_t; 572 defaultfiles = new fileinfomap; 578 573 579 574 orderparamlist = new paramspeclist; … … 589 584 { 590 585 delete defaultmacros; 586 delete collectionmacros; 591 587 delete defaultfiles; 592 588 … … 602 598 // -4 if no macroname was supplied 603 599 int displayclass::setdefaultmacro (text_t package, const text_t ¯oname, 604 text_t params, const text_t ¯ovalue) 605 { 600 text_t params, const text_t ¯ovalue) 601 { 602 // **** Looks to me like the last two parameters are the wrong way around!!! 606 603 return setdefaultmacro (macroname, package, params, macrovalue, "memory"); 607 604 } … … 686 683 687 684 688 // loads a default macro file (if it isn't already loaded)685 // loads a macro file into the specified macrotable datastructure 689 686 // returns 0 if didn't need to load the file (it was already loaded) 690 687 // 1 if was (re)loaded 691 688 // -1 an error occurred while trying to load the file 692 int displayclass::load defaultmacros (text_t thisfilename) {689 int displayclass::loadparammacros (parammacros_t* macrotable, text_t thisfilename) { 693 690 // convert the filename to a C string 694 691 char *filenamestr = thisfilename.getcstr(); … … 835 832 836 833 // define the macro 837 err = setdefaultmacro (macropackage, macroname, macroparameters, 838 thisfilename, macrovalue); 834 835 err = setparammacro (macrotable, macropackage, macroname, macroparameters, 836 thisfilename, macrovalue); 839 837 if ((err == -1 || err == -3) && logout != NULL) { 840 838 (*logout) << text_t2ascii << "Warning: redefinition of _" << … … 906 904 } 907 905 906 907 // loads a default macro file (if it isn't already loaded) 908 // returns 0 if didn't need to load the file (it was already loaded) 909 // 1 if was (re)loaded 910 // -1 an error occurred while trying to load the file 911 int displayclass::loaddefaultmacros (text_t thisfilename) 912 { 913 return loadparammacros(defaultmacros,thisfilename); 914 } 915 916 // loads a collection specific macro file 917 // returns 0 if didn't need to load the file (it was already loaded) 918 // 1 if was (re)loaded 919 // -1 an error occurred while trying to load the file 920 int displayclass::loadcollectionmacros (text_t thisfilename) 921 { 922 return loadparammacros(collectionmacros,thisfilename); 923 } 924 925 908 926 void displayclass::unloaddefaultmacros () { 909 927 defaultmacros->clear(); 928 } 929 930 void displayclass::unloadcollectionmacros () { 931 collectionmacros->clear(); 910 932 } 911 933 … … 977 999 // -4 if no macroname was supplied 978 1000 int displayclass::setmacro (const text_t ¯oname, 979 980 1001 text_t package, 1002 const text_t ¯ovalue) 981 1003 { 982 1004 // make sure a macroname was supplied … … 1216 1238 1217 1239 1240 // setparammacro adds an entry to the list of default macros 1241 // returns 0 if there was no error, 1242 // -1 if it redefined a macro 1243 // -2 if it hid a Global macro 1244 // -3 if it redefined a macro and hid a Global macro 1245 // -4 if no macroname was supplied 1246 int displayclass::setparammacro (parammacros_t* macrotable, 1247 text_t package, const text_t ¯oname, 1248 text_t params, const text_t &filename, 1249 const text_t ¯ovalue) 1250 { 1251 // make sure a macroname was supplied 1252 if (macroname.empty()) return -4; 1253 1254 // put the parameters in a standard form 1255 paramhashtype paramhash; 1256 if (params.empty()) params = "ignore=yes"; 1257 splitparams (params, paramhash); 1258 joinparams (paramhash, params); 1259 1260 // make package "Global" if it doesn't point to anything yet 1261 if (package.empty()) package = "Global"; 1262 1263 // remember these parameters 1264 allparams.insert (params); 1265 1266 // remember this filename (this part isn't finished yet -- Rodger). 1267 1268 // set the macro 1269 return macrotable->setmacro(package, macroname, params, filename, macrovalue); 1270 } 1271 1218 1272 // setdefaultmacro adds an entry to the list of default macros 1219 1273 // returns 0 if there was no error, … … 1223 1277 // -4 if no macroname was supplied 1224 1278 int displayclass::setdefaultmacro (text_t package, const text_t ¯oname, 1225 text_t params, const text_t &filename, 1226 const text_t ¯ovalue) 1227 { 1228 // make sure a macroname was supplied 1229 if (macroname.empty()) return -4; 1230 1231 // put the parameters in a standard form 1232 paramhashtype paramhash; 1233 if (params.empty()) params = "ignore=yes"; 1234 splitparams (params, paramhash); 1235 joinparams (paramhash, params); 1236 1237 // make package "Global" if it doesn't point to anything yet 1238 if (package.empty()) package = "Global"; 1239 1240 // remember these parameters 1241 allparams.insert (params); 1242 1243 // remember this filename (this part isn't finished yet -- Rodger). 1244 1245 // set the macro 1246 return defaultmacros->setmacro(package, macroname, params, filename, macrovalue); 1279 text_t params, const text_t &filename, 1280 const text_t ¯ovalue) 1281 { 1282 return setparammacro(defaultmacros,package,macroname,params,filename,macrovalue); 1283 } 1284 1285 1286 // setcollectionmacro adds an entry to the list of collection specific macros 1287 // returns 0 if there was no error, 1288 // -1 if it redefined a macro 1289 // -2 if it hid a Global macro 1290 // -3 if it redefined a macro and hid a Global macro 1291 // -4 if no macroname was supplied 1292 int displayclass::setcollectionmacro (text_t package, const text_t ¯oname, 1293 text_t params, const text_t &filename, 1294 const text_t ¯ovalue) 1295 { 1296 return setparammacro(collectionmacros,package,macroname,params,filename,macrovalue); 1247 1297 } 1248 1298 … … 1326 1376 1327 1377 return result; 1378 } 1379 1380 1381 mvalue* displayclass::macro_find (parammacros_t* macrotable, text_t packagename, 1382 const text_t ¯oname) 1383 { 1384 mvalue *macrovalue = NULL; 1385 1386 // next look in the named parammacros for the named package 1387 if (macrotable->macro_find (packagename, macroname) != NULL) 1388 { 1389 paramspeclist::iterator paramhere, paramend; 1390 1391 paramhere = orderparamlist->begin(); paramend = orderparamlist->end(); 1392 while ((macrovalue == NULL) && (paramhere != paramend)) 1393 { 1394 macrovalue = macrotable->parameter_find(packagename, macroname, 1395 (*paramhere).param); 1396 paramhere++; 1397 } 1398 } 1399 1400 return macrovalue; 1328 1401 } 1329 1402 … … 1462 1535 packagelist.push_back ("Global"); 1463 1536 1464 paramspeclist::iterator paramhere, paramend;1465 1537 text_tlist::iterator packagehere = packagelist.begin(); 1466 1538 text_tlist::iterator packageend = packagelist.end(); … … 1473 1545 macrovalue = currentmacros->macro_find("Style", macroname); 1474 1546 1547 // look in the collection specific macros 1548 if (macrovalue == NULL) { 1549 macrovalue = macro_find(collectionmacros,*packagehere,macroname); 1550 } 1551 1552 // and again in the collection specific package "Style" 1553 if (macrovalue == NULL) { 1554 macrovalue = macro_find(collectionmacros,(char*)"Style",macroname); 1555 } 1556 1475 1557 // look in the default macros 1476 if (macrovalue == NULL) 1477 { 1478 // next look in the defaultmacros 1479 if (defaultmacros->macro_find (*packagehere, macroname) != NULL) 1480 { 1481 paramhere = orderparamlist->begin(); paramend = orderparamlist->end(); 1482 while ((macrovalue == NULL) && (paramhere != paramend)) 1483 { 1484 // cerr << text_t2ascii << "\npackage: " << *packagehere << "\n"; 1485 // cerr << text_t2ascii << "macroname: " << macroname << "\n"; 1486 // cerr << text_t2ascii << "param: " << (*paramhere).param << "\n"; 1487 // cerr << "spec: " << (int)((*paramhere).spec) << "\n"; 1488 macrovalue = defaultmacros->parameter_find(*packagehere, macroname, 1489 (*paramhere).param); 1490 paramhere++; 1491 } 1492 } 1493 } 1558 if (macrovalue == NULL) { 1559 macrovalue = macro_find(defaultmacros,*packagehere,macroname); 1560 } 1494 1561 1495 1562 // and again in the package "Style" 1496 if (macrovalue == NULL) 1497 { 1498 // next look in the defaultmacros 1499 if (defaultmacros->macro_find ("Style", macroname) != NULL) 1500 { 1501 paramhere = orderparamlist->begin(); paramend = orderparamlist->end(); 1502 while ((macrovalue == NULL) && (paramhere != paramend)) 1503 { 1504 macrovalue = defaultmacros->parameter_find("Style", macroname, 1505 (*paramhere).param); 1506 paramhere++; 1507 } 1508 } 1509 } 1563 if (macrovalue == NULL) { 1564 macrovalue = macro_find(defaultmacros,(char*)"Style",macroname); 1565 } 1566 1510 1567 if (macrovalue == NULL) packagehere++; 1511 1568 } -
trunk/gsdl/lib/display.h
r6021 r7386 87 87 88 88 // class prototypes 89 class defaultmacros_t;89 class parammacros_t; 90 90 class currentmacros_t; 91 91 … … 96 96 { 97 97 int otherinfo; 98 }; 99 100 // macro value structure 101 struct mvalue 102 { 103 text_t filename; 104 text_t value; 98 105 }; 99 106 … … 186 193 int loaddefaultmacros (text_t thisfilename); 187 194 195 // loads a collection specific macro file 196 // returns 0 if didn't need to load the file (it was already loaded) 197 // 1 if was (re)loaded 198 // -1 an error occurred while trying to load the file 199 int loadcollectionmacros (text_t thisfilename); 200 188 201 // unloads all default macros 189 202 void unloaddefaultmacros (); 203 204 // unloads all collection specific macros 205 void unloadcollectionmacros (); 190 206 191 207 // prepares to create a page: deletes all macros set with … … 230 246 231 247 // general variables 232 text_tset allparams; // possible parameter combinations 233 defaultmacros_t *defaultmacros; 234 fileinfomap *defaultfiles; 248 text_tset allparams; // possible parameter combinations 249 parammacros_t *defaultmacros; 250 parammacros_t *collectionmacros; 251 fileinfomap *defaultfiles; 235 252 236 253 // variables to do with a page expansion … … 248 265 int checkdefaultmacrofiles (); 249 266 267 int loadparammacros (parammacros_t* macrotable, text_t thisfilename); 268 269 int setparammacro (parammacros_t* macrotable, 270 text_t package, const text_t ¯oname, 271 text_t params, const text_t &filename, 272 const text_t ¯ovalue); 273 250 274 int setdefaultmacro (text_t package, const text_t ¯oname, 251 275 text_t params, const text_t &filename, 252 276 const text_t ¯ovalue); 253 277 278 int setcollectionmacro (text_t package, const text_t ¯oname, 279 text_t params, const text_t &filename, 280 const text_t ¯ovalue); 281 254 282 // evaluates a boolean expression 255 283 bool boolexpr (text_t package, const text_t &expr, int recursiondepth); 284 285 mvalue* macro_find (parammacros_t* macrotable, text_t packagename, 286 const text_t ¯oname); 256 287 257 288 // (recursively) expand out a macro
Note:
See TracChangeset
for help on using the changeset viewer.