home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 79 / IOPROG_79.ISO / soft / Tools / XMLSPYEnt2004 / XMLSPYEntComplete2004.exe / Data1.cab / _2C96E59562534871849FF1DA33BB2B23 < prev    next >
Encoding:
Text File  |  2003-10-15  |  6.7 KB  |  198 lines

  1. ////////////////////////////////////////////////////////////////////////
  2. //
  3. // Core.h
  4. //
  5. // This file was generated by [=$Host].
  6. //
  7. // YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
  8. // OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
  9. //
  10. // Refer to the [=$HostShort] Documentation for further details.
  11. // [=$HostURL]
  12. //
  13. ////////////////////////////////////////////////////////////////////////
  14.  
  15.  
  16. #ifndef ALTOVAFUNCTIONS_CORE_H_INCLUDED
  17. #define ALTOVAFUNCTIONS_CORE_H_INCLUDED
  18.  
  19. #if _MSC_VER > 1000
  20.     #pragma once
  21. #endif // _MSC_VER > 1000
  22.  
  23. #include <math.h>
  24.  
  25. ////////////////////////////////////////////////////////////////////////
  26. //
  27. //  utilities
  28. //
  29. ////////////////////////////////////////////////////////////////////////
  30.  
  31. // here follows a necessary hack for VS6.0 compiler 
  32. // to be able to use partial template specialisation
  33. namespace AltovaInternal
  34. {
  35.     template <bool>
  36.     struct SelectImpl
  37.     {
  38.         template <class T, class U>
  39.         struct In
  40.         {
  41.             typedef T Result;
  42.         };
  43.     };
  44.  
  45.     template <>
  46.     struct SelectImpl<false>
  47.     {
  48.         template <class T, class U>
  49.         struct In
  50.         {
  51.             typedef U Result;
  52.         };
  53.     };
  54. }
  55.  
  56.  
  57. namespace altova {
  58.  
  59. // utilities to do compile-time return-type selection.
  60. template <bool flag, typename T, typename U>
  61. struct SelectType
  62. {
  63.     typedef typename AltovaInternal::SelectImpl<flag>::template In<T, U>::Result Result;
  64. };
  65.  
  66.  
  67. template <class A, class B>
  68. struct IsTypeGreater
  69. {
  70.     enum { value = A::TYPE > B::TYPE };
  71. };
  72.  
  73.  
  74. ////////////////////////////////////////////////////////////////////////
  75. //
  76. //  Core function library
  77. //
  78. ////////////////////////////////////////////////////////////////////////
  79.  
  80.  
  81. class ALTOVA_DECLSPECIFIER Core
  82. {
  83. public:
  84.     Core() {};
  85.  
  86.     // logical functions
  87.     static CSchemaBoolean    LogicalNot(const CSchemaType& rObj)    
  88.         { return CSchemaBoolean( !rObj.ToBool() ); }
  89.     static CSchemaBoolean    LogicalOr(const CSchemaType& rObj1, const CSchemaType& rObj2)    
  90.         { return CSchemaBoolean( rObj1.ToBool() || rObj2.ToBool() ); }
  91.     static CSchemaBoolean    LogicalAnd(const CSchemaType& rObj1, const CSchemaType& rObj2)
  92.         { return CSchemaBoolean( rObj1.ToBool() && rObj2.ToBool() );    }
  93.  
  94.     // logical functions: comparison
  95.     static CSchemaBoolean    Equal(const CSchemaType& rObj1, const CSchemaType& rObj2)    
  96.         { return CSchemaBoolean( CSchemaType::CompareEqual(rObj1, rObj2) ); }
  97.     static CSchemaBoolean    Greater(const CSchemaType& rObj1, const CSchemaType& rObj2)    
  98.         { return CSchemaBoolean( CSchemaType::CompareGreater(rObj1, rObj2) ); }
  99.     static CSchemaBoolean    Less(const CSchemaType& rObj1, const CSchemaType& rObj2)    
  100.         { return CSchemaBoolean( CSchemaType::CompareLess(rObj1, rObj2) ); }
  101.     static CSchemaBoolean    NotEqual(const CSchemaType& rObj1, const CSchemaType& rObj2)    
  102.         { return CSchemaBoolean( CSchemaType::CompareNotEqual(rObj1, rObj2) ); }
  103.     static CSchemaBoolean    EqualOrGreater(const CSchemaType& rObj1, const CSchemaType& rObj2)    
  104.         { return CSchemaBoolean( CSchemaType::CompareGreaterEqual(rObj1, rObj2) ); }
  105.     static CSchemaBoolean    EqualOrLess(const CSchemaType& rObj1, const CSchemaType& rObj2)    
  106.         { return CSchemaBoolean( CSchemaType::CompareLessEqual(rObj1, rObj2) ); }
  107.  
  108.     // string functions
  109.     static CSchemaString    Concat(const CSchemaString& rObj1, const CSchemaString& rObj2)
  110.         { return CSchemaString( (tstring)rObj1 + (tstring)rObj2 ); }
  111.     static CSchemaString    NormalizeSpace(const CSchemaString& rObj);
  112.     static CSchemaBoolean    StartsWith(const CSchemaString& rString, const CSchemaString& rSubStr)
  113.         { return CSchemaBoolean( ((tstring)rString).find( (tstring)rSubStr )==0 );    }
  114.     static CSchemaInt        StringLength(const CSchemaString& rObj)
  115.         { return CSchemaInt( ((tstring)rObj).length() ); }
  116.     static CSchemaString    Substring(const CSchemaString& rString, const CSchemaTypeNumber& rStart, const CSchemaTypeNumber& rLength);
  117.     static CSchemaString    Substring(const CSchemaString& rString, const CSchemaTypeNumber& rStart);
  118.     static CSchemaString    SubstringAfter(const CSchemaString& rString, const CSchemaString& rSubStr);
  119.     static CSchemaString    SubstringBefore(const CSchemaString& rString, const CSchemaString& rSubStr);
  120.     static CSchemaString    Translate(const CSchemaString& rValue, const CSchemaString& rFrom, const CSchemaString& rTo);
  121.     static CSchemaBoolean    Contains(const CSchemaString& rString, const CSchemaString& rSubStr)
  122.         { return CSchemaBoolean(  (long)(((tstring)rString).find( (tstring)rSubStr ))>=0 ); }
  123.  
  124. ////////////////////////////////////////////////////////////////////////
  125. //
  126. //  Mathematical functions
  127. //
  128. ////////////////////////////////////////////////////////////////////////
  129.  
  130.     // Add
  131.     template <class A, class B>
  132.     static typename SelectType< IsTypeGreater<A,B>::value, A, B>::Result Add(const A& a, const B& b)
  133.     {
  134.         SelectType< IsTypeGreater<A,B>::value, A, B>::Result::calctype result = a.ToCalcValue() + b.ToCalcValue();
  135.         return SelectType< IsTypeGreater<A,B>::value, A, B>::Result(result);
  136.     }
  137.  
  138.     // Subtract
  139.     template <class A, class B>
  140.     static typename SelectType< IsTypeGreater<A,B>::value, A, B>::Result Subtract(const A& a, const B& b)
  141.     {
  142.         SelectType< IsTypeGreater<A,B>::value, A, B>::Result::calctype result = a.ToCalcValue() - b.ToCalcValue();
  143.         return SelectType< IsTypeGreater<A,B>::value, A, B>::Result(result);
  144.     }
  145.  
  146.     // Multiply
  147.     template <class A, class B>
  148.     static typename SelectType< IsTypeGreater<A,B>::value, A, B>::Result Multiply(const A& a, const B& b)
  149.     {
  150.         SelectType< IsTypeGreater<A,B>::value, A, B>::Result::calctype result = a.ToCalcValue() * b.ToCalcValue();
  151.         return SelectType< IsTypeGreater<A,B>::value, A, B>::Result(result);
  152.     }
  153.  
  154.     // Divide
  155.     template <class A, class B>
  156.     static typename SelectType< IsTypeGreater<A,B>::value, A, B>::Result Divide(const A& a, const B& b)
  157.     {
  158.         SelectType< IsTypeGreater<A,B>::value, A, B>::Result::calctype result = a.ToCalcValue() / b.ToCalcValue();
  159.         return SelectType< IsTypeGreater<A,B>::value, A, B>::Result(result);
  160.     }
  161.  
  162.     // Floor
  163.     template <class A>
  164.     static A Floor(const A& a)
  165.     { 
  166.         return floor( a.ToCalcValue() ); 
  167.     }
  168.  
  169.     // Ceiling
  170.     template <class A>
  171.     static A Ceiling(const A& a)
  172.     { 
  173.         return ceil( a.ToCalcValue() );
  174.     }
  175.  
  176.     // Round
  177.     template <class A>
  178.     static A Round(const A& a)
  179.     {
  180.         return round(a.ToCalcValue(),0);
  181.     }
  182.  
  183.     // Modulus
  184.     template <class A, class B>
  185.     static typename SelectType< IsTypeGreater<A,B>::value, A, B>::Result Modulus(const A& a, const B& b)
  186.     {
  187.         SelectType< IsTypeGreater<A,B>::value, A, B>::Result::calctype result = fmod(a.ToCalcValue(), b.ToCalcValue());
  188.         return SelectType< IsTypeGreater<A,B>::value, A, B>::Result(result);
  189.     }
  190.  
  191. protected:
  192.     static double    round(double num, int precision)    { return (double)int(num*pow(10,precision))/pow(10,precision); }
  193. };
  194.  
  195. } // namespace altova
  196.  
  197. #endif // ALTOVAFUNCTIONS_CORE_H_INCLUDED
  198.