just got variables saving from set tag.
This commit is contained in:
parent
3d98448ec4
commit
9accb60eb9
@ -1,5 +1,5 @@
|
||||
#ifndef __Expression_h__
|
||||
#define __expression_h__
|
||||
#define __Expression_h__
|
||||
|
||||
#include "MString.h"
|
||||
|
||||
|
3
Tag.cpp
3
Tag.cpp
@ -66,7 +66,8 @@ namespace jet {
|
||||
copyContainer(out, parent);
|
||||
else
|
||||
if(output)
|
||||
copyContainer(container, parent);
|
||||
copyContainer(container, parent);
|
||||
std::cout << "Destructing " << name << std::endl;
|
||||
}
|
||||
|
||||
void Tag::parseContainer(coreutils::ZString &in) {
|
||||
|
26
__set.cpp
26
__set.cpp
@ -5,14 +5,20 @@
|
||||
namespace jet {
|
||||
|
||||
__set::__set(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) {
|
||||
output = false;
|
||||
if(variables["scope"] == "local")
|
||||
variables[variables["name"]] = variables["value"];
|
||||
if(variables["scope"] == "global")
|
||||
global.variables[variables["name"]] = container;
|
||||
|
||||
global.dump();
|
||||
|
||||
}
|
||||
|
||||
output = false;
|
||||
if(!variableDefined("name"))
|
||||
throw coreutils::Exception("set tag must have name defined.");
|
||||
if(variableDefined("value") && hasContainer)
|
||||
throw coreutils::Exception("set tag cannot have both value and a container.");
|
||||
if(!variableDefined("value") && !hasContainer)
|
||||
throw coreutils::Exception("set tag must have a value or a container.");
|
||||
if(!variableDefined("scope") || (variables["scope"] == "global")) {
|
||||
if(hasContainer) {
|
||||
global.variables[variables["name"]] = container.parsed();
|
||||
} else
|
||||
global.variables[variables["name"]] = variables["value"];
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,9 @@
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
coreutils::ZString data("<jet>\n"
|
||||
" <set name=\"varname\" value=\"vardata\" scope=\"local\" />\n"
|
||||
" <set name=\"thename\" scope=\"global\">this is the value</set>\n"
|
||||
" <set name=\"varname\" value=\"vardata\" scope=\"global\" />\n"
|
||||
" <set name=\"thename\">this is the value</set>\n"
|
||||
" <set name=\"newname\" scope=\"global\">another container value</set>\n"
|
||||
" <mysql key=\"uu\">\n"
|
||||
" <if value1=\"X\" value2=\"Y\" type=\"eq\">\n"
|
||||
" 789\n"
|
||||
@ -26,6 +27,6 @@ int main(int argc, char **argv) {
|
||||
coreutils::MString out;
|
||||
jet::__jet *jet = new jet::__jet(data, out, global);
|
||||
delete jet;
|
||||
std::cout << ">>-------" << std::endl << out << std::endl << "<<------";
|
||||
std::cout << ">>" << global.variables["thename"] << "<<" << std::endl;
|
||||
std::cout << ">>-------" << std::endl << out << std::endl << "<<------" << std::endl;
|
||||
global.dump();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user