just got variables saving from set tag.

This commit is contained in:
Brad Arant 2024-06-13 07:05:36 -07:00
parent 3d98448ec4
commit 9accb60eb9
5 changed files with 24 additions and 16 deletions

View File

@ -1,5 +1,5 @@
#ifndef __Expression_h__ #ifndef __Expression_h__
#define __expression_h__ #define __Expression_h__
#include "MString.h" #include "MString.h"

View File

@ -67,6 +67,7 @@ namespace jet {
else else
if(output) if(output)
copyContainer(container, parent); copyContainer(container, parent);
std::cout << "Destructing " << name << std::endl;
} }
void Tag::parseContainer(coreutils::ZString &in) { void Tag::parseContainer(coreutils::ZString &in) {

View File

@ -6,13 +6,19 @@ namespace jet {
__set::__set(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) { __set::__set(coreutils::ZString &in, coreutils::MString &out, Global &global) : Tag(in, out, global) {
output = false; output = false;
if(variables["scope"] == "local") if(!variableDefined("name"))
variables[variables["name"]] = variables["value"]; throw coreutils::Exception("set tag must have name defined.");
if(variables["scope"] == "global") if(variableDefined("value") && hasContainer)
global.variables[variables["name"]] = container; throw coreutils::Exception("set tag cannot have both value and a container.");
if(!variableDefined("value") && !hasContainer)
global.dump(); 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 {
} }
}
} }

BIN
testjet

Binary file not shown.

View File

@ -6,8 +6,9 @@
int main(int argc, char **argv) { int main(int argc, char **argv) {
coreutils::ZString data("<jet>\n" coreutils::ZString data("<jet>\n"
" <set name=\"varname\" value=\"vardata\" scope=\"local\" />\n" " <set name=\"varname\" value=\"vardata\" scope=\"global\" />\n"
" <set name=\"thename\" scope=\"global\">this is the value</set>\n" " <set name=\"thename\">this is the value</set>\n"
" <set name=\"newname\" scope=\"global\">another container value</set>\n"
" <mysql key=\"uu\">\n" " <mysql key=\"uu\">\n"
" <if value1=\"X\" value2=\"Y\" type=\"eq\">\n" " <if value1=\"X\" value2=\"Y\" type=\"eq\">\n"
" 789\n" " 789\n"
@ -26,6 +27,6 @@ int main(int argc, char **argv) {
coreutils::MString out; coreutils::MString out;
jet::__jet *jet = new jet::__jet(data, out, global); jet::__jet *jet = new jet::__jet(data, out, global);
delete jet; delete jet;
std::cout << ">>-------" << std::endl << out << std::endl << "<<------"; std::cout << ">>-------" << std::endl << out << std::endl << "<<------" << std::endl;
std::cout << ">>" << global.variables["thename"] << "<<" << std::endl; global.dump();
} }