more work on variables.
This commit is contained in:
1 parent
7453db9bd9
commit
0379974d5e
4 files changed
+37
-15
No files matched your search
+26
@@ -30,5 +30,31 @@ namespace jet {
|
||||
void Global::removeSession(coreutils::MString sessionId) {
|
||||
sessions.erase(sessionId);
|
||||
}
|
||||
|
||||
coreutils::ZString Global::getVariable(coreutils::ZString &variable) {
|
||||
if(variable.ifNext("$[")) {
|
||||
if(variable.ifNext("!")) {
|
||||
return variables[renderVariableName(variable)];
|
||||
} if(variable.ifNext(":")) {
|
||||
// TODO: should only allow CGI variable name. Allow variable substitution.
|
||||
} if(variable.ifNext("@")) {
|
||||
// TODO: should only allow environment variables. Allow substitution.
|
||||
} else {
|
||||
return variables[renderVariableName(variable)];
|
||||
}
|
||||
throw coreutils::Exception("expected variable name or type designator.");
|
||||
} if(variable.ifNext("#[")) {
|
||||
// TODO: this local variable type has no special naming conventions. We
|
||||
// just need to do nested variable substitution for the entry.
|
||||
|
||||
}
|
||||
throw coreutils::Exception("Expecting a variable initializer ('$[' or '#[').");
|
||||
}
|
||||
|
||||
coreutils::MString Global::renderVariableName(coreutils::ZString &variable) {
|
||||
coreutils::MString name = variable.getTokenInclude("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-");
|
||||
if(variable.ifNext("]"))
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user