#include "__bind.h" #include "__sql.h" #include "Exception.h" #include "SqlBind.h" namespace jet { __bind::__bind(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) { output = false; // Nearest enclosing , through any //etc. in between. __sql *sql = NULL; for(Tag *scope = parent; scope && !sql; scope = scope->parent) sql = dynamic_cast<__sql *>(scope); if(!sql) throw coreutils::Exception("bind must be inside sql."); if(!keywordDefined("value")) throw coreutils::Exception("bind must have a value."); std::string value = resolveKeyword("value").str(); std::string type = keywordDefined("type") ? resolveKeyword("type").str() : ""; std::string nullMode = keywordDefined("null") ? resolveKeyword("null").str() : ""; bool hasAllow = keywordDefined("allow"); std::string allow = hasAllow ? resolveKeyword("allow").str() : ""; sql->addBind(makeBoundValue(value, type, nullMode, hasAllow, allow, (int)sql->bindCount() + 1)); } }