00001 #ifndef FDO_COMPARE_H_ 00002 #define FDO_COMPARE_H_ 00003 00004 // 00005 // Copyright (C) 2004-2006 Autodesk, Inc. 00006 // 00007 // This library is free software; you can redistribute it and/or 00008 // modify it under the terms of version 2.1 of the GNU Lesser 00009 // General Public License as published by the Free Software Foundation. 00010 // 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public 00017 // License along with this library; if not, write to the Free Software 00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 // 00020 00021 #ifdef _WIN32 00022 #pragma once 00023 #endif 00024 00025 /// \cond DOXYGEN-IGNORE 00026 00027 /// \brief 00028 /// FdoCompareType is an enumeration of different value comparison results when comparing 00029 /// value1 and value2 00030 /// 00031 /// \param FdoCompareType_Undefined 00032 /// The values cannot be compared, usually due to different nullities or incompatible types. 00033 /// \param FdoCompareType_Less 00034 /// Value 1 is less than value2 00035 /// \param FdoCompareType_Greater 00036 /// Value 1 is greater than value2 00037 /// \param FdoCompareType_Equal 00038 /// The values are equal or both null. 00039 /// \param FdoCompareType_PartlyEqual 00040 /// One or both values are partly undefined but the defined parts are equal. 00041 /// For example, a Date value (time undefined) and DateTime value are 00042 /// partly equal if their date parts are equal. A Date value and Time 00043 /// value are always considered partly equal (defined parts do not 00044 /// overlap). 00045 /// 00046 enum FdoCompareType 00047 { 00048 FdoCompareType_Undefined, 00049 FdoCompareType_Less, 00050 FdoCompareType_Greater, 00051 FdoCompareType_Equal, 00052 FdoCompareType_PartlyEqual 00053 }; 00054 /// \endcond 00055 00056 /// \cond DOXYGEN-IGNORE 00057 // General function for comparing values of simple types or types that define the comparison operators. 00058 template< class T> FdoCompareType FdoCompare( T val1, T val2 ) 00059 { 00060 FdoCompareType compare = FdoCompareType_Undefined; 00061 00062 if ( val1 < val2 ) 00063 compare = FdoCompareType_Less; 00064 else if ( val1 > val2 ) 00065 compare = FdoCompareType_Greater; 00066 else 00067 compare = FdoCompareType_Equal; 00068 00069 return compare; 00070 } 00071 /// \endcond 00072 00073 00074 #endif