diff options
Diffstat (limited to 'lib/Variables.cc')
-rw-r--r-- | lib/Variables.cc | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/lib/Variables.cc b/lib/Variables.cc index 15de09d..0bb8c01 100644 --- a/lib/Variables.cc +++ b/lib/Variables.cc @@ -4,13 +4,9 @@ #include "String.h" #include "config.h" -Variables::Variables(int nb) : Vars(nb ? new String[nb] : 0), nbvars(nb) { } +Variables::Variables(int nb) : Vars(nb), nbvars(nb) { } -Variables::~Variables() { - if (Vars) { - delete[] Vars; - } -} +Variables::~Variables() { } void Variables::SetTo(int i, const String & s) { Vars[i] = s; @@ -27,7 +23,7 @@ String Variables::operator[](const String & name) { if (i == nbvars) { r = ""; } else { - r = Vars[i].to_charp(Vars[i].strchr('=') + 1); + r = Vars[i].extract(Vars[i].strchr('=') + 1); } return r; @@ -47,9 +43,30 @@ void Variables::Dump(Handle * h) { for (i = 0; i < nbvars; i++) { eqp = Vars[i].strchr('='); - Vn = Vars[i].to_charp(0, eqp - 1); - Vv = Vars[i].to_charp(eqp + 1); + Vn = Vars[i].extract(0, eqp - 1); + Vv = Vars[i].extract(eqp + 1); (*h) << "<INPUT TYPE=\"HIDDEN\" NAME=\"" << Vn << "\" VALUE=\"" << Vv << "\">" << endnl; } } +void Variables::Add(const String & s) { + nbvars++; + Vars.push_back(s); +} + +void Variables::Del(int i) { + nbvars--; + Vars.erase(&Vars[i], &Vars[i]); +} + +void Variables::Del(const String & name) { + int i; + + for (i = 0; i < nbvars; i++) { + if (Vars[i].strstr(name) == 0) break; + } + + if (i != nbvars) { + Del(i); + } +} |