queryline.cpp 783 B

1234567891011121314151617181920212223242526272829303132
  1. #include <precomp.h>
  2. #include "queryline.h"
  3. #include <api/api.h>
  4. #include <api/db/metatags.h>
  5. #include <bfc/string/string.h>
  6. #include <bfc/parse/pathparse.h>
  7. QueryLine::QueryLine(const char *query) : autoquery(FALSE), querytext(query), autofield(MT_NAME) {
  8. }
  9. void QueryLine::setQuery(const char *query) {
  10. querytext = query;
  11. String sp = querytext;
  12. if (autoquery && !querytext.isempty()) {
  13. sp = "";
  14. PathParser pp(querytext, " ");
  15. if (pp.getNumStrings() <= 0) return;
  16. for (int i = 0; i < pp.getNumStrings(); i++) {
  17. if (i != 0) sp += " and ";
  18. sp += StringPrintf("(\"%s\" has \"%s\")", autofield.getValue(), pp.enumString(i));
  19. }
  20. }
  21. sqs_setQuery(sp);
  22. }
  23. int QueryLine::setAuto(int bv) {
  24. autoquery = !!bv;
  25. setQuery(querytext);
  26. return 1;
  27. }