src_other/tuplebase/ZTSpec.h

00001 /*  @(#) $Id: ZTSpec.h,v 1.1 2007/07/22 04:27:09 agreen Exp $ */
00002 
00003 /* ------------------------------------------------------------
00004 Copyright (c) 2007 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 __ZTSpec__
00026 #define __ZTSpec__ 1
00027 
00028 #include "zconfig.h"
00029 
00030 #include "ZTuple.h"
00031 
00032 typedef ZTuplePropName ZTName;
00033 typedef ZTupleValue ZTValue;
00034 
00035 class ZStreamR;
00036 class ZStreamW;
00037 
00038 // =================================================================================================
00039 #pragma mark -
00040 #pragma mark * ZTName
00041 
00042 // =================================================================================================
00043 #pragma mark -
00044 #pragma mark * ZTValue
00045 
00046 
00047 
00048 // =================================================================================================
00049 #pragma mark -
00050 #pragma mark * ZTSpec
00051 
00052 class ZTSpec
00053         {
00054         ZOOLIB_DEFINE_OPERATOR_BOOL_TYPES(ZTSpec,
00055                 operator_bool_generator_type, operator_bool_type);
00056 public:
00058         enum ERel
00059                 {
00060                 eRel_Invalid,
00061 
00062                 eRel_LT,
00063                 eRel_LE,
00064                 eRel_EQ,
00065                 eRel_GE,
00066                 eRel_GT,
00067 
00068                 eRel_LTProp,
00069                 eRel_LEProp,
00070                 eRel_EQProp,
00071                 eRel_GEProp,
00072                 eRel_GTProp,
00073 
00074                 eRel_Has,
00075                 eRel_HasOfType,
00076                 eRel_Lacks,
00077                 eRel_LacksOfType,
00078 
00079                 eRel_VectorContains,
00080                 eRel_StringContains,
00081                 eRel_Regex
00082                 };
00083         //@{
00086         ZTSpec();
00087 
00088         ZTSpec(const ZTSpec& iOther);
00089 
00090         ZTSpec& operator=(const ZTSpec& iOther);
00091 
00092         ~ZTSpec();
00094 
00095         //@{
00099         explicit ZTSpec(bool iAny);
00100 
00101 //      ZTSpec(const ZTName& iPropName, Comparator iComparator, const ZTValue& iTV);
00102 
00104 
00105         //@{
00108         explicit ZTSpec(const ZTuple& iTuple);
00109 
00110         explicit ZTSpec(const ZStreamR& iStreamR);
00111 
00112         ZTuple AsTuple() const;
00113 
00114         void ToStream(const ZStreamW& iStreamW) const;
00116 
00117         //@{
00120         operator operator_bool_type() const;
00121 
00122         int Compare(const ZTSpec& iOther) const;
00123 
00124         bool operator==(const ZTSpec& iOther) const;
00125         bool operator!=(const ZTSpec& iOther) const;
00126 
00127         bool operator<(const ZTSpec& iOther) const;
00128         bool operator<=(const ZTSpec& iOther) const;
00129         bool operator>(const ZTSpec& iOther) const;
00130         bool operator>=(const ZTSpec& iOther) const;
00132 
00133         //@{
00137         ZTSpec operator&(const ZTSpec& iOther) const;
00138 
00140         ZTSpec& operator&=(const ZTSpec& iOther);
00141 
00143         ZTSpec operator|(const ZTSpec& iOther) const;
00144 
00146         ZTSpec& operator|=(const ZTSpec& iOther);
00148 
00150         bool Matches(const ZTuple& iTuple) const;
00151 
00153         bool IsAny() const;
00154 
00156         bool IsNone() const;
00157 
00158         //@{
00170         static ZTSpec sAny();
00171 
00172         static ZTSpec sNone();
00173 
00174         static ZTSpec sHas(const ZTName& iPropName);
00175 
00176         static ZTSpec sHas(const ZTName& iPropName, ZType iType);
00177 
00178         static ZTSpec sLacks(const ZTName& iPropName);
00179 
00180         static ZTSpec sLacks(const ZTName& iPropName, ZType iType);
00181 
00182         static ZTSpec sEQ(const ZTName& iPropName, const ZTValue& iValue);
00183         static ZTSpec sEQProp(const ZTName& iPropNameL, const ZTName& iPropNameR);
00184 
00185         static ZTSpec sNE(const ZTName& iPropName, const ZTValue& iValue);
00186         static ZTSpec sNEProp(const ZTName& iPropNameL, const ZTName& iPropNameR);
00187 
00188         static ZTSpec sLT(const ZTName& iPropName, const ZTValue& iValue);
00189         static ZTSpec sLTProp(const ZTName& iPropNameL, const ZTName& iPropNameR);
00190 
00191         static ZTSpec sLE(const ZTName& iPropName, const ZTValue& iValue);
00192         static ZTSpec sLEProp(const ZTName& iPropNameL, const ZTName& iPropNameR);
00193 
00194         static ZTSpec sGT(const ZTName& iPropName, const ZTValue& iValue);
00195         static ZTSpec sGTProp(const ZTName& iPropNameL, const ZTName& iPropNameR);
00196 
00197         static ZTSpec sGE(const ZTName& iPropName, const ZTValue& iValue);
00198         static ZTSpec sGEProp(const ZTName& iPropNameL, const ZTName& iPropNameR);
00199 
00200         static ZTSpec sStringContains(
00201                 const ZTName& iPropName, const std::string& iString, int iStrength);
00202 
00203         static ZTSpec sVectorContains(const ZTName& iPropName, const ZTValue& iValue);
00204 
00205         static ZTSpec sRegex(const ZTName& iPropName, const std::string& iRegex, int iStrength);
00207 
00208 private:
00209         };
00210 
00211 namespace ZooLib {
00212 template <>
00213 inline int sCompare_T(const ZTSpec& iL, const ZTSpec& iR)
00214         { return iL.Compare(iR); }
00215 }
00216 
00217 #endif // __ZTSpec__

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