ECSubRestriction.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #ifndef ECSUBRESTRICTION_H
  18. #define ECSUBRESTRICTION_H
  19. #include <set>
  20. #include <vector>
  21. #include <kopano/ECKeyTable.h>
  22. #include "ECDatabase.h"
  23. #include "soapH.h"
  24. #include <kopano/ustringutil.h>
  25. namespace KC {
  26. class ECSession;
  27. // These are some helper function to help running subqueries.
  28. /*
  29. * How we run subqueries assumes the following:
  30. * - SubSubRestrictions are invalid
  31. * - The most efficient way to run a search with a subquery is to first evaluate the subquery and THEN the
  32. * main query
  33. *
  34. * We number subqueries in a query in a depth-first order. The numbering can be used because we don't have
  35. * nested subqueries (see above). Each subquery can therefore be pre-calculated for each item in the main
  36. * query target. The results of the subqueries is then passed to the main query solver, which only needs
  37. * to check the outcome of a subquery.
  38. */
  39. // A set containing all the objects that match a subquery. The row id here is for the parent object, not for
  40. // the actual object that matched the restriction (ie the message id is in here, not the recipient id or
  41. // attachment id)
  42. typedef std::set<unsigned int> SUBRESTRICTIONRESULT;
  43. // A list of sets of subquery matches
  44. typedef std::vector<SUBRESTRICTIONRESULT *> SUBRESTRICTIONRESULTS;
  45. ECRESULT GetSubRestrictionCount(struct restrictTable *lpRestrict, unsigned int *lpulCount);
  46. ECRESULT GetSubRestriction(struct restrictTable *lpBase, unsigned int ulCount, struct restrictSub **lppSubRestrict);
  47. // Get results for all subqueries for a set of objects
  48. ECRESULT RunSubRestrictions(ECSession *lpSession, void *lpECODStore, struct restrictTable *lpRestrict, ECObjectTableList *lpObjects, const ECLocale &locale, SUBRESTRICTIONRESULTS **lppResults);
  49. ECRESULT RunSubRestriction(ECSession *lpSession, void *lpECODStore, struct restrictSub *lpSubRestrict, ECObjectTableList *lpObjects, const ECLocale &locale, SUBRESTRICTIONRESULT **lppResult);
  50. ECRESULT FreeSubRestrictionResults(SUBRESTRICTIONRESULTS *lpResults);
  51. #define SUBRESTRICTION_MAXDEPTH 64
  52. } /* namespace */
  53. #endif