JetCore/testjet.cpp
2024-08-01 16:17:57 -07:00

69 lines
2.1 KiB
C++

#include <iostream>
#include <sstream>
#include "Global.h"
#include "Exception.h"
#include "__jet.h"
int main(int argc, char **argv) {
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"
" <set name=\"ix\" value=\"1\" />\n"
" <set name=\"theexpr\" expr=\"SUBSTRING('abcdefg', 1, 3)\" />\n"
" <set name=\"theexpr2\" expr=\"5+3\" />\n"
" theexpr=($[theexpr])\n"
" theexpr2($[theexpr2])\n"
" <set name=\"varname$[ix]\" value=\"vardata\" scope=\"global\" />\n"
" <set name=\"noeval\" eval=\"no\">this is the value store in #[name].</set>\n"
" <set name=\"thename\" eval=\"yes\">this is the value store in #[name].</set>\n"
" <set name=\"newname\" scope=\"global\">another container value</set>\n"
" >>>$[noeval]<<<\n"
" >>>$[thename]<<<\n"
" local: >>>#[name]<<<\n"
" <mysql key=\"uu\">\n"
" <if value1=\"X\" value2=\"Y\" type=\"ne\">\n"
" 789\n"
" <if expr=\"false\">\n"
" 123\n"
" <else>\n"
" 456\n"
" </if>\n"
" </if>\n"
" </mysql>\n"
" <for name=\"ix\" start=\"1\" end=\"5\" step=\"1\">\n"
" -->#[ix]<--\n"
" </for>\n"
" <call pgm=\"/usr/bin/ls\" arg1=\"-al\" name=\"ls\" />\n"
" $[lsi]\n"
" <read file=\"compile\" name=\"file\" />\n"
" $[filex]\n"
" </html>\n"
"</jet>\n");
coreutils::ZString data2("<jet>\n"
" <if expr=\"false\">\n"
" XXX\n"
" <else>\n"
" YYY\n"
" </if>\n"
"</jet>\n");
// coreutils::ZString data("<jet>ABC<jet>HIJ</jet>XYZ</jet>\n");
std::cout << "---------\n" << data << "----------\n" << std::endl;
try {
jet::Global global;
coreutils::MString out;
jet::__jet *jet = new jet::__jet(data, out, global);
delete jet;
std::cout << ">>-------" << std::endl << out << std::endl << "<<------" << std::endl;
// global.dump();
}
catch(coreutils::Exception e) {
std::cout << "Error caught: " << e.text << std::endl;
}
}