123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 |
- #ifndef ECRestrictionBuilder_INCLUDED
- #define ECRestrictionBuilder_INCLUDED
- #include <memory>
- #include <utility>
- #include <kopano/zcdefs.h>
- #include <mapidefs.h>
- #include <list>
- namespace KC {
- class ECRestrictionList;
- class _kc_export ECRestriction {
- public:
- enum {
- Full = 0,
- Cheap = 1,
- Shallow = 2
- };
- _kc_hidden virtual ~ECRestriction(void) _kc_impdtor;
-
- HRESULT CreateMAPIRestriction(LPSRestriction *lppRestriction, ULONG ulFlags) const;
-
-
- HRESULT RestrictTable(IMAPITable *, unsigned int flags = TBL_BATCH) const;
-
- _kc_export HRESULT FindRowIn(LPMAPITABLE, BOOKMARK origin, ULONG flags) const;
-
- _kc_hidden virtual HRESULT GetMAPIRestriction(LPVOID base, LPSRestriction, ULONG flags = 0) const = 0;
-
-
- _kc_hidden virtual ECRestriction *Clone(void) const _kc_lvqual = 0;
- #ifdef HAVE_MF_QUAL
- _kc_hidden virtual ECRestriction *Clone(void) && = 0;
- _kc_hidden ECRestrictionList operator+(ECRestriction &&) &&;
- #endif
- _kc_hidden ECRestrictionList operator+(const ECRestriction &) const;
- protected:
- typedef std::shared_ptr<SPropValue> PropPtr;
- typedef std::shared_ptr<ECRestriction> ResPtr;
- typedef std::list<ResPtr> ResList;
- _kc_hidden ECRestriction(void) = default;
- _kc_hidden static HRESULT CopyProp(SPropValue *src, void *base, ULONG flags, SPropValue **dst);
- _kc_hidden static HRESULT CopyPropArray(ULONG nvals, SPropValue *src, void *base, ULONG flags, SPropValue **dst);
- _kc_hidden static void DummyFree(LPVOID);
- };
- class ECRestrictionList _kc_final {
- public:
- ECRestrictionList(const ECRestriction &res1, const ECRestriction &res2) {
- m_list.push_back(ResPtr(res1.Clone()));
- m_list.push_back(ResPtr(res2.Clone()));
- }
- ECRestrictionList(ECRestriction &&o1, ECRestriction &&o2)
- {
- m_list.push_back(ResPtr(std::move(o1).Clone()));
- m_list.push_back(ResPtr(std::move(o2).Clone()));
- }
-
- ECRestrictionList& operator+(const ECRestriction &restriction) {
- m_list.push_back(ResPtr(restriction.Clone()));
- return *this;
- }
- ECRestrictionList &operator+(ECRestriction &&o)
- {
- m_list.push_back(ResPtr(std::move(o).Clone()));
- return *this;
- }
- private:
- typedef std::shared_ptr<ECRestriction> ResPtr;
- typedef std::list<ResPtr> ResList;
- ResList m_list;
- friend class ECAndRestriction;
- friend class ECOrRestriction;
- };
- inline ECRestrictionList ECRestriction::operator+ (const ECRestriction &other) const {
- return ECRestrictionList(*this, other);
- }
- #ifdef HAVE_MF_QUAL
- inline ECRestrictionList ECRestriction::operator+(ECRestriction &&other) &&
- {
- return ECRestrictionList(std::move(*this), std::move(other));
- }
- #endif
- class IRestrictionPush : public ECRestriction {
- public:
- virtual ECRestriction *operator+=(const ECRestriction &) = 0;
- virtual ECRestriction *operator+=(ECRestriction &&) = 0;
- };
- class _kc_export ECAndRestriction _kc_final : public IRestrictionPush {
- public:
- _kc_hidden ECAndRestriction(void) {}
- ECAndRestriction(const ECRestrictionList &list);
- _kc_hidden ECAndRestriction(ECRestrictionList &&o) :
- m_lstRestrictions(std::move(o.m_list))
- {}
- _kc_hidden HRESULT GetMAPIRestriction(LPVOID base, LPSRestriction res, ULONG flags) const _kc_override;
- ECRestriction *Clone(void) const _kc_lvqual _kc_override;
- #ifdef HAVE_MF_QUAL
- _kc_hidden ECRestriction *Clone(void) && _kc_override { return new ECAndRestriction(std::move(*this)); }
- #endif
- ECRestriction *operator+=(const ECRestriction &restriction)
- {
- m_lstRestrictions.push_back(ResPtr(restriction.Clone()));
- return m_lstRestrictions.rbegin()->get();
- }
- ECRestriction *operator+=(ECRestriction &&o)
- {
- m_lstRestrictions.push_back(ResPtr(std::move(o).Clone()));
- return m_lstRestrictions.rbegin()->get();
- }
- void operator+=(const ECRestrictionList &list);
- void operator+=(ECRestrictionList &&);
- private:
- ResList m_lstRestrictions;
- };
- class _kc_export ECOrRestriction _kc_final : public IRestrictionPush {
- public:
- _kc_hidden ECOrRestriction(void) {}
- ECOrRestriction(const ECRestrictionList &list);
- _kc_hidden ECOrRestriction(ECRestrictionList &&o) :
- m_lstRestrictions(std::move(o.m_list))
- {}
- _kc_hidden HRESULT GetMAPIRestriction(LPVOID base, LPSRestriction r, ULONG flags) const _kc_override;
- ECRestriction *Clone(void) const _kc_lvqual _kc_override;
- #ifdef HAVE_MF_QUAL
- ECRestriction *Clone(void) && _kc_override { return new ECOrRestriction(std::move(*this)); }
- #endif
- ECRestriction *operator+=(const ECRestriction &restriction)
- {
- m_lstRestrictions.push_back(ResPtr(restriction.Clone()));
- return m_lstRestrictions.rbegin()->get();
- }
- ECRestriction *operator+=(ECRestriction &&o)
- {
- m_lstRestrictions.push_back(ResPtr(std::move(o).Clone()));
- return m_lstRestrictions.rbegin()->get();
- }
- void operator+=(const ECRestrictionList &list);
- void operator+=(ECRestrictionList &&);
- private:
- ResList m_lstRestrictions;
- };
- class _kc_export ECNotRestriction _kc_final : public IRestrictionPush {
- public:
- _kc_hidden ECNotRestriction(const ECRestriction &restriction)
- : m_ptrRestriction(ResPtr(restriction.Clone()))
- { }
- _kc_hidden ECNotRestriction(ECRestriction &&o) :
- m_ptrRestriction(std::move(o).Clone())
- {}
- ECNotRestriction(std::nullptr_t) {}
- _kc_hidden HRESULT GetMAPIRestriction(LPVOID base, LPSRestriction r, ULONG flags) const _kc_override;
- ECRestriction *Clone(void) const _kc_lvqual _kc_override;
- #ifdef HAVE_MF_QUAL
- ECRestriction *Clone(void) && _kc_override { return new ECNotRestriction(std::move(*this)); }
- #endif
- ECRestriction *operator+=(const ECRestriction &r)
- {
- m_ptrRestriction.reset(r.Clone());
- return m_ptrRestriction.get();
- }
- ECRestriction *operator+=(ECRestriction &&r)
- {
- m_ptrRestriction.reset(std::move(r).Clone());
- return m_ptrRestriction.get();
- }
- private:
- _kc_hidden ECNotRestriction(ResPtr restriction);
- ResPtr m_ptrRestriction;
- };
- class _kc_export ECContentRestriction _kc_final : public ECRestriction {
- public:
- ECContentRestriction(ULONG fuzzy_lvl, ULONG tag, const SPropValue *, ULONG flags);
- _kc_hidden HRESULT GetMAPIRestriction(LPVOID base, LPSRestriction r, ULONG flags) const _kc_override;
- ECRestriction *Clone(void) const _kc_lvqual _kc_override;
- #ifdef HAVE_MF_QUAL
- _kc_hidden ECRestriction *Clone(void) && _kc_override { return new ECContentRestriction(std::move(*this)); }
- #endif
- private:
- _kc_hidden ECContentRestriction(ULONG fuzzy_level, ULONG tag, PropPtr prop);
- private:
- ULONG m_ulFuzzyLevel;
- ULONG m_ulPropTag;
- PropPtr m_ptrProp;
- };
- class _kc_export ECBitMaskRestriction _kc_final : public ECRestriction {
- public:
- _kc_hidden ECBitMaskRestriction(ULONG relBMR, ULONG ulPropTag, ULONG ulMask)
- : m_relBMR(relBMR)
- , m_ulPropTag(ulPropTag)
- , m_ulMask(ulMask)
- { }
- _kc_hidden HRESULT GetMAPIRestriction(LPVOID base, LPSRestriction r, ULONG flags) const _kc_override;
- ECRestriction *Clone(void) const _kc_lvqual _kc_override;
- #ifdef HAVE_MF_QUAL
- _kc_hidden ECRestriction *Clone(void) && _kc_override { return new ECBitMaskRestriction(std::move(*this)); }
- #endif
- private:
- ULONG m_relBMR;
- ULONG m_ulPropTag;
- ULONG m_ulMask;
- };
- class _kc_export ECPropertyRestriction _kc_final : public ECRestriction {
- public:
- ECPropertyRestriction(ULONG relop, ULONG tag, const SPropValue *, ULONG flags);
- _kc_hidden HRESULT GetMAPIRestriction(LPVOID base, LPSRestriction r, ULONG flags) const _kc_override;
- ECRestriction *Clone(void) const _kc_lvqual _kc_override;
- #ifdef HAVE_MF_QUAL
- _kc_hidden ECRestriction *Clone(void) && _kc_override { return new ECPropertyRestriction(std::move(*this)); }
- #endif
- private:
- _kc_hidden ECPropertyRestriction(ULONG relop, ULONG proptag, PropPtr prop);
- ULONG m_relop;
- ULONG m_ulPropTag;
- PropPtr m_ptrProp;
- };
- class _kc_export ECComparePropsRestriction _kc_final : public ECRestriction {
- public:
- _kc_hidden ECComparePropsRestriction(ULONG relop, ULONG ulPropTag1, ULONG ulPropTag2)
- : m_relop(relop)
- , m_ulPropTag1(ulPropTag1)
- , m_ulPropTag2(ulPropTag2)
- { }
- _kc_hidden HRESULT GetMAPIRestriction(LPVOID base, LPSRestriction r, ULONG flags) const _kc_override;
- ECRestriction *Clone(void) const _kc_lvqual _kc_override;
- #ifdef HAVE_MF_QUAL
- _kc_hidden ECRestriction *Clone(void) && _kc_override { return new ECComparePropsRestriction(std::move(*this)); }
- #endif
- private:
- ULONG m_relop;
- ULONG m_ulPropTag1;
- ULONG m_ulPropTag2;
- };
- class _kc_export ECExistRestriction _kc_final : public ECRestriction {
- public:
- _kc_hidden ECExistRestriction(ULONG ulPropTag)
- : m_ulPropTag(ulPropTag)
- { }
- _kc_hidden HRESULT GetMAPIRestriction(LPVOID base, LPSRestriction r, ULONG flags) const _kc_override;
- ECRestriction *Clone(void) const _kc_lvqual _kc_override;
- #ifdef HAVE_MF_QUAL
- _kc_hidden ECRestriction *Clone(void) && _kc_override { return new ECExistRestriction(std::move(*this)); }
- #endif
- private:
- ULONG m_ulPropTag;
- };
- class _kc_export ECRawRestriction _kc_final : public ECRestriction {
- public:
- ECRawRestriction(const SRestriction *, ULONG flags);
- _kc_hidden HRESULT GetMAPIRestriction(LPVOID base, LPSRestriction r, ULONG flags) const _kc_override;
- ECRestriction *Clone(void) const _kc_lvqual _kc_override;
- #ifdef HAVE_MF_QUAL
- _kc_hidden ECRestriction *Clone(void) && _kc_override { return new ECRawRestriction(std::move(*this)); }
- #endif
- private:
- typedef std::shared_ptr<SRestriction> RawResPtr;
- _kc_hidden ECRawRestriction(RawResPtr restriction);
- RawResPtr m_ptrRestriction;
- };
- }
- #endif
|