Changeset 7429


Ignore:
Timestamp:
2004-05-25T13:47:36+12:00 (20 years ago)
Author:
mdewsnip
Message:

(Human Info) Added a couple of addarginfo methods.

Location:
trunk/gsdl/src/recpt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/cgiargs.cpp

    r1285 r7429  
    177177// as the results will be meaningless.
    178178bool cgiargsinfoclass::addarginfo (ostream *logout, const cgiarginfo &info) {
    179   outconvertclass text_t2ascii;
    180179
    181180  cgiarginfo *orginfo = getarginfo (info.shortname);
     
    187186  if (orginfo->longname != info.longname) {
    188187    if (logout != NULL) {
     188      outconvertclass text_t2ascii;
    189189      (*logout) << text_t2ascii << "Error: cgi argument name clash for argument \""
    190190        << info.shortname << "\".\nOne long name was\n  \"" << orginfo->longname
     
    196196  if (orginfo->multiplevalue != info.multiplevalue) {
    197197    if (logout != NULL) {
     198      outconvertclass text_t2ascii;
    198199      (*logout) << text_t2ascii << "Error: cgi argument \"" << info.shortname
    199200        << "\" was given as being a single value option\n"
     
    205206  if (orginfo->multiplechar != info.multiplechar) {
    206207    if (logout != NULL) {
     208      outconvertclass text_t2ascii;
    207209      (*logout) << text_t2ascii << "Error: cgi argument \"" << info.shortname
    208210        << "\" was given as being a single character option\n"
     
    214216  if (!info.multiplechar && info.argdefault.size() > 1) {
    215217    if (logout != NULL) {
     218      outconvertclass text_t2ascii;
    216219      (*logout) << text_t2ascii << "Error: cgi argument \"" << info.shortname
    217220        << "\" was defined as being a single character option\n"
     
    227230       info.savedarginfo==cgiarginfo::mustnot)) {
    228231    if (logout != NULL) {
     232      outconvertclass text_t2ascii;
    229233      (*logout) << text_t2ascii << "Error: it was specified that cgi argument \""
    230234        << info.shortname << "\" should be saved in the state\n"
     
    260264}
    261265
     266bool cgiargsinfoclass::addarginfo (ostream *logout, const text_t& argshortname, const text_tmap& mapinfo)
     267{
     268  cgiarginfo *arginfo = getarginfo (argshortname);
     269  if (arginfo == NULL) {
     270    arginfo = &(argsinfo[argshortname]);
     271    arginfo->shortname = argshortname;
     272    arginfo->defaultstatus = cgiarginfo::config;
     273  }
     274  text_tmap::const_iterator thisInfo = mapinfo.begin();
     275  text_tmap::const_iterator endInfo = mapinfo.end();
     276  while (thisInfo != endInfo) {
     277    if (thisInfo->first == "longname") arginfo->longname = thisInfo->second;
     278    else if (thisInfo->first == "multiplechar") arginfo->multiplechar = (thisInfo->second == "true");
     279    else if (thisInfo->first == "defaultstatus") {
     280      if (thisInfo->second == "none") arginfo->defaultstatus = cgiarginfo::none;
     281      else if (thisInfo->second == "weak") arginfo->defaultstatus = cgiarginfo::weak;
     282      else if (thisInfo->second == "good") arginfo->defaultstatus = cgiarginfo::good;
     283      else if (thisInfo->second == "config") arginfo->defaultstatus = cgiarginfo::config;
     284      else if (thisInfo->second == "imperative") arginfo->defaultstatus = cgiarginfo::imperative;
     285    }
     286    else if (thisInfo->first == "argdefault") {
     287      arginfo->argdefault = thisInfo->second;
     288    }
     289    else if (thisInfo->first == "savedarginfo") {
     290      if (thisInfo->second == "mustnot") arginfo->savedarginfo = cgiarginfo::mustnot;
     291      else if (thisInfo->second == "can") arginfo->savedarginfo = cgiarginfo::can;
     292      else if (thisInfo->second == "must") arginfo->savedarginfo = cgiarginfo::must;
     293    } else if (logout != NULL) {
     294      (*logout) << ("Invalid argument for cgiarg for " + argshortname + " (" + thisInfo->first + ")\n");
     295    }
     296    thisInfo++;
     297  }
     298  return true;
     299}
     300
     301bool cgiargsinfoclass::addarginfo (ostream *logout, const confcgiarg_tmap& info)
     302{
     303  confcgiarg_tmap::const_iterator thisArg = info.begin();
     304  confcgiarg_tmap::const_iterator endArg = info.end();
     305  while (thisArg != endArg) {
     306    if (!addarginfo(logout, thisArg->first, thisArg->second)) return false;
     307    thisArg++;
     308  }
     309  return true;
     310}
     311
    262312cgiarginfo *cgiargsinfoclass::getarginfo (const text_t &key) {
    263313  iterator here = argsinfo.find (key);
  • trunk/gsdl/src/recpt/cgiargs.h

    r1285 r7429  
    5050// response_t is used to define what type of cgi header
    5151// should be produced
    52 enum response_t {location, content};
     52// fullcontent same as content but the action should put content-type as last header.
     53enum response_t {location, content, fullcontent};
    5354
    5455
     
    6869
    6970typedef map<text_t, cgiarg_t, lttext_t> cgiarg_tmap;
     71typedef map<text_t, text_tmap, lttext_t> confcgiarg_tmap;
    7072
    7173// cgiargsclass is used to store a particular set
     
    225227  bool addarginfo (ostream *logout, const cgiargsinfoclass &info);
    226228
     229  // addarginfo will override args info with info loaded from config files
     230  // if the args do not exists will be created
     231  bool addarginfo (ostream *logout, const text_t& argshortname, const text_tmap& mapinfo);
     232  bool addarginfo (ostream *logout, const confcgiarg_tmap& info);
     233
    227234  cgiarginfo *getarginfo (const text_t &key);
    228235  const cgiarginfo *getarginfo (const text_t &key) const;
Note: See TracChangeset for help on using the changeset viewer.