read tag working.

This commit is contained in:
Brad Arant 2024-07-11 15:25:48 -07:00
parent e1be28e53b
commit 15f7b08d68
5 changed files with 12 additions and 6 deletions

View File

@ -3,6 +3,7 @@
#include "KeywordValue.h" #include "KeywordValue.h"
#include "Log.h" #include "Log.h"
#include "__mysql.h" #include "__mysql.h"
#include "__comment.h"
#include "__for.h" #include "__for.h"
#include "__if.h" #include "__if.h"
#include "__read.h" #include "__read.h"
@ -103,6 +104,9 @@ namespace jet {
if(ifTagName(in, "mysql")) { if(ifTagName(in, "mysql")) {
__mysql _mysql(in, out, global); __mysql _mysql(in, out, global);
continue; continue;
} else if(ifTagName(in, "comment")) {
__comment _comment(in, out, global);
continue;
} else if(ifTagName(in, "for")) { } else if(ifTagName(in, "for")) {
__for _for(in, out, global); __for _for(in, out, global);
continue; continue;

2
Tag.h
View File

@ -31,7 +31,7 @@ namespace jet {
bool output = true; bool output = true;
bool evaluate = true; bool evaluate = true;
bool filterBlankLines = false; bool filterBlankLines = false;
bool trim = false; bool trimLines = false;
bool cleanWhitespace = false; bool cleanWhitespace = false;
private: private:

View File

@ -7,15 +7,14 @@
namespace jet { namespace jet {
__read::__read(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) { __read::__read(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) {
if(!variableDefined(coreutils::ZString("file"))) if(!variableDefined("file"))
throw coreutils::Exception("file keyword must be specified."); throw coreutils::Exception("file keyword must be specified.");
if(!variableDefined("name"))
throw coreutils::Exception("name keyword must be specified.");
if(hasContainer) if(hasContainer)
throw coreutils::Exception("read tag does not have a container."); throw coreutils::Exception("read tag does not have a container.");
fd = open(variables["file"].c_str(), O_RDONLY); fd = open(variables["file"].c_str(), O_RDONLY);
while(len = read(fd, &buffer, sizeof(buffer - 1))) { global.variables[variables["name"]].read(fd);
buffer[len] = 0;
out << buffer;
}
close(fd); close(fd);
} }

BIN
testjet

Binary file not shown.

View File

@ -6,6 +6,7 @@
int main(int argc, char **argv) { int main(int argc, char **argv) {
coreutils::ZString data("<jet name=\"localname\" filterblanklines=\"true\">\n" coreutils::ZString data("<jet name=\"localname\" filterblanklines=\"true\">\n"
" <comment>This is a comment and should not show up in the output.</comment>\n"
" <html>\n" " <html>\n"
" <set name=\"ix\" value=\"1\" />\n" " <set name=\"ix\" value=\"1\" />\n"
" <set name=\"theexpr\" expr=\"true\" />\n" " <set name=\"theexpr\" expr=\"true\" />\n"
@ -31,6 +32,8 @@ int main(int argc, char **argv) {
" </for>\n" " </for>\n"
" <call pgm=\"/usr/bin/ls\" arg1=\"-al\" name=\"ls\" />\n" " <call pgm=\"/usr/bin/ls\" arg1=\"-al\" name=\"ls\" />\n"
" $[ls]\n" " $[ls]\n"
" <read file=\"compile\" name=\"file\" />\n"
" $[file]\n"
" </html>\n" " </html>\n"
"</jet>\n"); "</jet>\n");