src_other/tuplebase/ZTupleIndex_String.h

00001 /*  @(#) $Id: ZTupleIndex_String.h,v 1.7 2006/11/02 18:08:34 agreen Exp $ */
00002 
00003 /* ------------------------------------------------------------
00004 Copyright (c) 2005 Andrew Green and Learning in Motion, Inc.
00005 http://www.zoolib.org
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a copy
00008 of this software and associated documentation files (the "Software"), to deal
00009 in the Software without restriction, including without limitation the rights
00010 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011 copies of the Software, and to permit persons to whom the Software is
00012 furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020 COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023 ------------------------------------------------------------ */
00024 
00025 #ifndef __ZTupleIndex_String__
00026 #define __ZTupleIndex_String__
00027 #include "zconfig.h"
00028 
00029 #include "ZTupleIndex.h"
00030 #include "ZTextCollator.h"
00031 
00032 // =================================================================================================
00033 #pragma mark -
00034 #pragma mark * ZTupleIndex_String
00035 
00036 class ZTupleIndex_String : public ZTupleIndex
00037         {
00038 public:
00039         ZTupleIndex_String(const ZTuplePropName& iPropName);
00040 
00041         virtual void Add(uint64 iID, const ZTuple* iTuple);
00042 
00043         virtual void Remove(uint64 iID, const ZTuple* iTuple);
00044 
00045         virtual void Find(const std::set<uint64>& iSkipIDs,
00046                 std::vector<const ZTBSpec::Criterion*>& ioCriteria, std::vector<uint64>& oIDs);
00047 
00048         virtual size_t CanHandle(const ZTBSpec::CriterionSect& iCriterionSect);
00049 
00050         virtual void WriteDescription(const ZStrimW& s);
00051 
00052 private:
00053         class Key
00054                 {
00055         public:
00056                 bool operator<(const Key& iOther) const;
00057                 bool operator==(const Key& iOther) const;
00058                 bool operator!=(const Key& iOther) const
00059                         { return !(*this == iOther); }
00060 
00061                 string16 fValue;
00062                 uint64 fID;
00063                 };
00064 
00065         class Compare
00066                 {
00067         public:
00068         typedef Key value_type;
00069 
00070                 Compare();
00071 
00072         bool operator()(const value_type& iLeft, const value_type& iRight) const;
00073 
00074                 ZTextCollator fTextCollator;
00075                 };
00076 
00077         bool pKeyFromTuple(uint64 iID, const ZTuple* iTuple, Key& oKey);
00078 
00079         ZTuplePropName fPropName;
00080         std::set<Key, Compare> fSet;
00081         };
00082 
00083 // =================================================================================================
00084 #pragma mark -
00085 #pragma mark * ZTupleIndexFactory_String
00086 
00087 class ZTupleIndexFactory_String : public ZTupleIndexFactory
00088         {
00089 public:
00090         ZTupleIndexFactory_String(const std::string& iPropName);
00091         virtual ZTupleIndex* Make();
00092 
00093 private:
00094         std::string fPropName;
00095         };
00096 
00097 #endif // __ZTupleIndex_String__

Generated on Thu Jul 26 11:21:59 2007 for ZooLib by  doxygen 1.4.7