JetCore/testjet.cpp
2024-09-24 20:20:29 -07:00

66 lines
2.3 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 name1=\"localname\" filterblanklines=\"true\" trimlines=\"true\">\n"
" <comment>This is a comment and should not show up in the output.</comment>\n"
" <html>\n"
" $[nonexistant]\n"
" <mysql host=\"localhost\" database=\"barant\" user=\"barant\" password=\"uversa\" sessionid=\"1\">\n"
" <sql sessionid=\"1\">select * from testdata</sql>\n"
" $[1.text]\n"
" $[1.value]\n"
" </mysql>\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"
" <set name=\"iz\" value=\"data\" />\n"
" <set name=\"ix1\" value=\"1\" />\n"
" <set name=\"test$[ix$[ix1]]$[iz]\" value=\"0123456789\" />\n"
" $[test$[ix$[ix1]]$[iz]]\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"
" <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");
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;
// global.dump();
}
catch(coreutils::Exception e) {
std::cout << "Error caught: " << e.text << std::endl;
}
}