Fixed some Expression and Operand memory issues.
This commit is contained in:
parent
3db9227adc
commit
5a97da3d1c
@ -15,7 +15,7 @@ namespace jet {
|
||||
double getNumericResult();
|
||||
coreutils::ZString getStringResult();
|
||||
bool boolean;
|
||||
coreutils::ZString string;
|
||||
coreutils::MString string;
|
||||
char *operation;
|
||||
};
|
||||
|
||||
|
@ -90,7 +90,7 @@ namespace jet {
|
||||
|
||||
void Global::outputHeaders() {
|
||||
if(headers.size() > 0) {
|
||||
for(std::map<coreutils::MString, coreutils::MString>::iterator header = headers.begin();
|
||||
for(auto header = headers.begin();
|
||||
header != headers.end();
|
||||
++header) {
|
||||
std::cout << header->first << ": " << header->second << std::endl;
|
||||
|
1
Global.h
1
Global.h
@ -3,7 +3,6 @@
|
||||
|
||||
#include "MString.h"
|
||||
#include <map>
|
||||
//#include <unordered_map>
|
||||
|
||||
namespace jet {
|
||||
|
||||
|
@ -7,7 +7,7 @@ namespace jet {
|
||||
Operand::Operand(coreutils::ZString &in) {
|
||||
|
||||
in.skipWhitespace();
|
||||
|
||||
std::cout << "op: [" << in.unparsed() << "]" << std::endl;
|
||||
if(in.ifNext("SUBSTRING")) {
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for SUBSTRING parameters.");
|
||||
@ -48,10 +48,9 @@ namespace jet {
|
||||
boolean = false;
|
||||
string = "false";
|
||||
return;
|
||||
} else if(in.startsWithDouble()) {
|
||||
char *temp = in.getCursor();
|
||||
} else if(in.startsWithNumber()) {
|
||||
doubleValue = in.asDouble();
|
||||
string = coreutils::ZString(temp, in.getCursor() - temp);
|
||||
string = std::to_string(doubleValue);
|
||||
return;
|
||||
} else if(in.ifNext("'")) {
|
||||
string = in.getTokenExclude("'");
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef __Operand_h__
|
||||
#define __Operand_h__
|
||||
|
||||
#include "ZString.h"
|
||||
#include "MString.h"
|
||||
|
||||
namespace jet {
|
||||
|
||||
@ -19,7 +19,7 @@ namespace jet {
|
||||
///
|
||||
|
||||
bool boolean;
|
||||
coreutils::ZString string;
|
||||
coreutils::MString string;
|
||||
|
||||
private:
|
||||
// dataType enum ={};
|
||||
|
@ -7,7 +7,6 @@ namespace jet {
|
||||
|
||||
__set::__set(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) {
|
||||
output = false;
|
||||
processContainer(container);
|
||||
if(!variableDefined("name"))
|
||||
throw coreutils::Exception("set tag must have name defined.");
|
||||
if(!variableDefined("expr") && variableDefined("value") && hasContainer)
|
||||
@ -24,6 +23,7 @@ namespace jet {
|
||||
throw coreutils::Exception("Cannot use eval with expr.");
|
||||
global.variables[variables["name"]] = Expression(variables["expr"]).string;
|
||||
} else if(hasContainer) {
|
||||
processContainer(container);
|
||||
if(evaluate) {
|
||||
global.variables[variables["name"]] = out;
|
||||
} else {
|
||||
|
@ -16,7 +16,8 @@ int main(int argc, char **argv) {
|
||||
jet::Global global;
|
||||
coreutils::MString out;
|
||||
jet::__jet *jet = new jet::__jet(data, out, global);
|
||||
delete jet;
|
||||
delete jet;
|
||||
global.dump();
|
||||
std::cout << "----------------------" << std::endl;
|
||||
global.outputHeaders();
|
||||
std::cout << out;
|
||||
|
Loading…
x
Reference in New Issue
Block a user