65 lines
1.6 KiB
C++
65 lines
1.6 KiB
C++
#include "Operand.h"
|
|
#include "Exception.h"
|
|
#include <iostream>
|
|
|
|
namespace jet {
|
|
|
|
Operand::Operand(coreutils::ZString &in) {
|
|
|
|
in.skipWhitespace();
|
|
|
|
if(in.ifNext("SUBSTRING")) {
|
|
if(!in.ifNext("("))
|
|
throw coreutils::Exception("Expecting ( for SUBSTRING parameters.");
|
|
Operand parm1(in);
|
|
if(!in.ifNext(","))
|
|
throw coreutils::Exception("Expecting , in SUBSTRING expression.");
|
|
Operand parm2(in);
|
|
if(in.ifNext(")")) {
|
|
string = parm1.string.substring(parm2.string.asInteger());
|
|
}
|
|
else if(!in.ifNext(","))
|
|
throw coreutils::Exception("Expecting , in SUBSTRING expression.");
|
|
Operand parm3(in);
|
|
if(in.ifNext(")")) {
|
|
string = parm1.string.substring(parm2.string.asInteger(), parm3.string.asInteger());
|
|
}
|
|
else
|
|
throw coreutils::Exception("Expecting ) at end of substring expression.");
|
|
} else if(in.ifNext("LEFT")) {
|
|
|
|
} else if(in.ifNext("RIGHT")) {
|
|
|
|
} else if(in.ifNext("TRIM")) {
|
|
|
|
} else if(in.ifNext("TOUPPER")) {
|
|
|
|
} else if(in.ifNext("TOLOWER")) {
|
|
|
|
} else if(in.ifNext("REVERSE")) {
|
|
|
|
} else if(in.ifNext("CONCAT")) {
|
|
|
|
} else if(in.ifNext("true")) {
|
|
boolean = true;
|
|
string = "true";
|
|
return;
|
|
} else if(in.ifNext("false")) {
|
|
boolean = false;
|
|
string = "false";
|
|
return;
|
|
} else if(in.startsWithDouble()) {
|
|
char *temp = in.getCursor();
|
|
doubleValue = in.asDouble();
|
|
string = coreutils::ZString(temp, in.getCursor() - temp);
|
|
return;
|
|
} else if(in.ifNext("'")) {
|
|
string = in.getTokenExclude("'");
|
|
in.ifNext("'");
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
}
|