Changeset 8485


Ignore:
Timestamp:
2004-11-08T16:58:26+13:00 (19 years ago)
Author:
jrm21
Message:

1) explicitly added 'l=en' to the list of seen macro parameters, otherwise
it will ignore any such macros later.

2) rename 'param' argument to functions since displayclass has a member var
with the same name. (compile with -Wshadow in your CCFLAGS)

3) added a setcollectionmacro() public function - the existing one is
protected, so now it mirrors the setdefaultmacro() arrangement

CVS: ----------------------------------------------------------------------

Location:
trunk/gsdl/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/lib/display.cpp

    r8451 r8485  
    2323 *
    2424 *********************************************************************/
     25#include <ostream>
    2526
    2627#include "display.h"
     
    578579
    579580  logout = NULL;
     581
     582  /* this is a bit of a hack, but if the displayclass has never seen this
     583     parameter before when it does openpage() then macros with this set will
     584     always be ignored. And we set collection-specific macros after doing
     585     openpage() - jrm */
     586  allparams.insert("l=en");
    580587}
    581588
     
    598605//        -4 if no macroname was supplied
    599606int displayclass::setdefaultmacro (text_t package, const text_t &macroname,
    600                    text_t params, const text_t &macrovalue)
    601 {
    602   return setdefaultmacro (package, macroname, params, "memory", macrovalue);
     607                   text_t mparams, const text_t &macrovalue)
     608{
     609  return setdefaultmacro (package, macroname, mparams, "memory", macrovalue);
    603610}
    604611
     
    982989  sort(orderparamlist->begin(), orderparamlist->end());
    983990
    984 //   paramspeclist::iterator pshere = orderparamlist->begin();
    985 //   paramspeclist::iterator psend = orderparamlist->end();
    986 //   while (pshere != psend)
    987 //     {
    988 //       cerr << text_t2ascii << "param=" << (*pshere).param;
    989 //       cerr << " spec=" << (int)((*pshere).spec) << "\n";
    990 //       pshere++;
    991 //     }
     991#if 0 // debugging
     992  outconvertclass text_t2ascii;
     993
     994  paramspeclist::iterator pshere = orderparamlist->begin();
     995  paramspeclist::iterator psend = orderparamlist->end();
     996  while (pshere != psend)
     997    {
     998      cerr << text_t2ascii << "param=" << (*pshere).param;
     999      cerr << " spec=" << (int)((*pshere).spec) << "\n";
     1000      pshere++;
     1001    }
     1002#endif
    9921003}
    9931004
     
    12451256int displayclass::setparammacro (parammacros_t* macrotable,
    12461257                 text_t package, const text_t &macroname,
    1247                  text_t params, const text_t &filename,
     1258                 text_t macroparams, const text_t &filename,
    12481259                 const text_t &macrovalue)
    12491260{
     
    12531264  // put the parameters in a standard form
    12541265  paramhashtype paramhash;
    1255   if (params.empty()) params = "ignore=yes";
    1256   splitparams (params, paramhash);
    1257   joinparams (paramhash, params);
     1266  if (macroparams.empty()) macroparams = "ignore=yes";
     1267  splitparams (macroparams, paramhash);
     1268  joinparams (paramhash, macroparams);
    12581269
    12591270  // make package "Global" if it doesn't point to anything yet
     
    12611272
    12621273  // remember these parameters
    1263   allparams.insert (params);
     1274  allparams.insert (macroparams);
    12641275
    12651276  // remember this filename (this part isn't finished yet -- Rodger).
    12661277
    12671278  // set the macro
    1268   return macrotable->setmacro(package, macroname, params, filename, macrovalue);
     1279  return macrotable->setmacro(package, macroname, macroparams, filename,
     1280                  macrovalue);
    12691281}
    12701282
     
    12761288//        -4 if no macroname was supplied
    12771289int displayclass::setdefaultmacro (text_t package, const text_t &macroname,
    1278                    text_t params, const text_t &filename,
     1290                   text_t macroparams, const text_t &filename,
    12791291                   const text_t &macrovalue)
    12801292{
    1281   return setparammacro(defaultmacros,package,macroname,params,filename,macrovalue);
    1282 }
    1283 
     1293  return setparammacro(defaultmacros,package,macroname,macroparams,
     1294               filename,macrovalue);
     1295}
     1296
     1297// public function
     1298int displayclass::setcollectionmacro(text_t package, const text_t &macroname,
     1299                     text_t mparams, const text_t &macrovalue)
     1300{
     1301  return setcollectionmacro(package, macroname, mparams, "memory", macrovalue);
     1302}
    12841303
    12851304// setcollectionmacro adds an entry to the list of collection specific macros
     
    12901309//        -4 if no macroname was supplied
    12911310int displayclass::setcollectionmacro (text_t package, const text_t &macroname,
    1292                       text_t params, const text_t &filename,
     1311                      text_t mparams, const text_t &filename,
    12931312                      const text_t &macrovalue)
    12941313{
    1295   return setparammacro(collectionmacros,package,macroname,params,filename,macrovalue);
     1314  return setparammacro(collectionmacros,package,macroname,mparams,
     1315               filename,macrovalue);
    12961316}
    12971317
  • trunk/gsdl/lib/display.h

    r7397 r8485  
    195195  int loaddefaultmacros (text_t thisfilename);
    196196
     197
     198  // overrides (or sets) a macro for the current page.
     199  // returns 0 if there was no error,
     200  //        -1 if it redefined a macro
     201  //        -4 if no macroname was supplied
     202  int setcollectionmacro (text_t package, const text_t &macroname,
     203              text_t params, const text_t &macrovalue);
     204
    197205  // loads a collection specific macro file
    198206  // returns 0 if didn't need to load the file (it was already loaded)
Note: See TracChangeset for help on using the changeset viewer.