Changeset 333 for cpp/frams/util/extvalue.h
- Timestamp:
- 03/01/15 01:19:56 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/util/extvalue.h
r326 r333 136 136 static ExtValue invalid() { ExtValue v; v.setInvalid(); return v; } 137 137 static const ExtValue& empty() { static const ExtValue v; return v; } 138 int compare(const ExtValue& src) const; 138 static const ExtValue& zero() { static const ExtValue v(0); return v; } 139 140 enum CompareResult 141 { 142 ResultLower=-1, ResultEqual=0, ResultHigher=1, 143 ResultEqualUnordered, 144 ResultUnequal_RelaxedEqual, 145 ResultUnequal_RelaxedUnequal, 146 ResultMismatch_RelaxedUnequal, 147 ResultMismatch 148 }; 149 // performs all script value comparisons. 150 // relaxed comparison (internal use only, not available in scripts) works like regular == with additional null~=0, notnull!~0 151 // and is used for pseudo-boolean conversion allowing for expressions like "if (null) ..." 152 CompareResult compare(const ExtValue& src) const; 153 154 enum CmpOperator { CmpFIRST,CmpEQ=CmpFIRST,CmpNE,CmpGE,CmpLE,CmpGT,CmpLT,/*relaxed (not)equal*/CmpREQ,CmpRNE }; 155 static const char* cmp_op_names[]; 156 class CmpMessageHandler { public: virtual void cmpMessage(SString& text); }; 157 struct CmpContext { const ExtValue *v1,*v2; CmpMessageHandler *handler; }; 158 static CmpMessageHandler default_cmp_message; 159 static CmpContext default_cmp_context; 160 // interpret compare() result, optional context controls error messages 161 // @return 0=false, 1=true, -1=undefined (null in script) 162 static int interpretCompare(CmpOperator op,CompareResult result,CmpContext *context=&default_cmp_context); 163 139 164 int operator==(const ExtValue& src) const; 140 165 void operator+=(const ExtValue& src); … … 154 179 void setInvalid() { setEmpty(); type = TInvalid; } 155 180 bool makeUnique() { return (type == TObj) && odata().makeUnique(); } //< @return false if nothing has changed 156 ExtPType getType() { return type; }181 ExtPType getType() const { return type; } 157 182 void *getObjectTarget(const char* classname, bool warn = true) const; 158 183 void setInt(paInt v) { if (type != TInt) setri(v); else idata() = v; }
Note: See TracChangeset
for help on using the changeset viewer.