~zorba-coders/zorba/bugs-912586-912593-912722

« back to all changes in this revision

Viewing changes to src/types/casting.h

  • Committer: Cezar Andrei
  • Date: 2012-03-28 15:42:12 UTC
  • mfrom: (10606.1.129 zorba)
  • Revision ID: cezar.lp@cezarandrei.com-20120328154212-jh2heq49xcqjppce
Merge from trunck and resolve ChangeLog conflict.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include "common/shared_types.h"
21
21
#include "types/root_typemanager.h"
22
22
 
 
23
#include "store/api/xs_type_codes.h"
 
24
 
 
25
 
23
26
namespace zorba
24
27
{
25
28
        
37
40
                            zstring& strval,
38
41
                            store::ItemFactory*, 
39
42
                            namespace_context *nsCtx,
40
 
                            const ErrorInfo& aErrorInfo
41
 
                        );
 
43
                            const ErrorInfo& aErrorInfo);
 
44
 
42
45
  typedef bool (*DownCastFunc)(
43
46
                            store::Item_t&,
44
47
                            const store::Item*, 
45
 
                            RootTypeManager& aTS,
46
 
                            TypeConstants::atomic_type_code_t aTargetAtomicType,
 
48
                            store::SchemaTypeCode aTargetAtomicType,
47
49
                            store::ItemFactory*,
48
 
                            const ErrorInfo& aErrorInfo
49
 
                        ); 
 
50
                            const ErrorInfo& aErrorInfo);
 
51
 
50
52
private:
51
 
  static const int          theMapping[TypeConstants::ATOMIC_TYPE_CODE_LIST_SIZE];
52
 
  static const CastFunc     theCastMatrix[23][23];
53
 
  static const DownCastFunc theDownCastMatrix[23];
 
53
  static const int          theMapping[store::XS_LAST];
 
54
  static const CastFunc     theCastMatrix[24][24];
 
55
  static const DownCastFunc theDownCastMatrix[24];
54
56
 
55
57
  GenericCast() {}
56
58
    
63
65
  
64
66
  /**
65
67
   * Promotes the passed item to the passed target type.
66
 
   * @param aItem
67
 
   * @param aTargetType
 
68
   * @param item
 
69
   * @param targetType
68
70
   * @return 0 if promotion is not possible else promoted item
69
71
   *         if the item type is a subtype of the target type, then
70
72
   *         the passed item is returned
71
73
   */
72
74
  static bool promote(
73
75
        store::Item_t& result,
74
 
        store::Item_t& aItem,
75
 
        const XQType* aTargetType,
 
76
        store::Item_t& item,
 
77
        const XQType* targetType,
 
78
        const TypeManager* tm,
 
79
        const QueryLoc& loc);
 
80
 
 
81
  static bool promote(
 
82
        store::Item_t& result,
 
83
        store::Item_t& item,
 
84
        store::SchemaTypeCode targetType,
76
85
        const TypeManager* tm,
77
86
        const QueryLoc& loc);
78
87
 
94
103
   */
95
104
  static bool castToAtomic(
96
105
        store::Item_t& result,
97
 
        store::Item_t& aItem, 
98
 
        const XQType* aTargetType,
99
 
        const TypeManager* tm, 
100
 
        namespace_context* aNCtx,
 
106
        store::Item_t& item, 
 
107
        const XQType* targetType,
 
108
        const TypeManager* tm, 
 
109
        namespace_context* nameCtx,
 
110
        const QueryLoc& loc);
 
111
 
 
112
  /**
 
113
   * Executes the casting of the passed item. If the passed item has the same
 
114
   * type or a subtype of the passed targetType, the passed item is directly
 
115
   * returned.
 
116
   */
 
117
  static bool castToAtomic(
 
118
        store::Item_t& result,
 
119
        store::Item_t& item, 
 
120
        store::SchemaTypeCode targetType,
 
121
        const TypeManager* tm, 
 
122
        namespace_context* nameCtx,
101
123
        const QueryLoc& loc);
102
124
 
103
125
  static bool castToSimple(