rtlfield_imp.hpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #ifndef rtlfield_imp_hpp
  14. #define rtlfield_imp_hpp
  15. #include "eclrtl.hpp"
  16. // A base implementation of RtlTypeInfo
  17. struct ECLRTL_API RtlTypeInfoBase : public RtlTypeInfo
  18. {
  19. inline RtlTypeInfoBase(unsigned _fieldType, unsigned _length) : RtlTypeInfo(_fieldType, _length) {}
  20. virtual size32_t size(const byte * self, const byte * selfrow) const;
  21. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  22. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  23. virtual const char * queryLocale() const;
  24. virtual const RtlFieldInfo * const * queryFields() const;
  25. virtual const RtlTypeInfo * queryChildType() const;
  26. };
  27. //-------------------------------------------------------------------------------------------------------------------
  28. struct ECLRTL_API RtlBoolTypeInfo : public RtlTypeInfoBase
  29. {
  30. inline RtlBoolTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  31. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  32. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  33. };
  34. struct ECLRTL_API RtlRealTypeInfo : public RtlTypeInfoBase
  35. {
  36. inline RtlRealTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  37. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  38. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  39. private:
  40. inline double value(const byte * self) const;
  41. };
  42. //MORE: Create specialist versions
  43. struct ECLRTL_API RtlIntTypeInfo : public RtlTypeInfoBase
  44. {
  45. inline RtlIntTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  46. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  47. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  48. };
  49. struct ECLRTL_API RtlSwapIntTypeInfo : public RtlTypeInfoBase
  50. {
  51. inline RtlSwapIntTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  52. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  53. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  54. };
  55. struct ECLRTL_API RtlPackedIntTypeInfo : public RtlTypeInfoBase
  56. {
  57. inline RtlPackedIntTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  58. virtual size32_t size(const byte * self, const byte * selfrow) const;
  59. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  60. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  61. };
  62. struct ECLRTL_API RtlStringTypeInfo : public RtlTypeInfoBase
  63. {
  64. inline RtlStringTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  65. virtual size32_t size(const byte * self, const byte * selfrow) const;
  66. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  67. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  68. };
  69. struct ECLRTL_API RtlDataTypeInfo : public RtlTypeInfoBase
  70. {
  71. inline RtlDataTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  72. virtual size32_t size(const byte * self, const byte * selfrow) const;
  73. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  74. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  75. };
  76. struct ECLRTL_API RtlVarStringTypeInfo : public RtlTypeInfoBase
  77. {
  78. inline RtlVarStringTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  79. virtual size32_t size(const byte * self, const byte * selfrow) const;
  80. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  81. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  82. };
  83. struct ECLRTL_API RtlQStringTypeInfo : public RtlTypeInfoBase
  84. {
  85. inline RtlQStringTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  86. virtual size32_t size(const byte * self, const byte * selfrow) const;
  87. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  88. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  89. };
  90. struct ECLRTL_API RtlDecimalTypeInfo : public RtlTypeInfoBase
  91. {
  92. inline RtlDecimalTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  93. virtual size32_t size(const byte * self, const byte * selfrow) const;
  94. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  95. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  96. size32_t calcSize() const;
  97. };
  98. struct ECLRTL_API RtlCharTypeInfo : public RtlTypeInfoBase
  99. {
  100. inline RtlCharTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  101. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  102. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  103. };
  104. struct ECLRTL_API RtlUnicodeTypeInfo : public RtlTypeInfoBase
  105. {
  106. public:
  107. inline RtlUnicodeTypeInfo(unsigned _fieldType, unsigned _length, const char * _locale) : RtlTypeInfoBase(_fieldType, _length), locale(_locale) {}
  108. virtual size32_t size(const byte * self, const byte * selfrow) const;
  109. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  110. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  111. virtual const char * queryLocale() const { return locale; }
  112. protected:
  113. const char * locale;
  114. };
  115. struct ECLRTL_API RtlVarUnicodeTypeInfo : public RtlTypeInfoBase
  116. {
  117. public:
  118. inline RtlVarUnicodeTypeInfo(unsigned _fieldType, unsigned _length, const char * _locale) : RtlTypeInfoBase(_fieldType, _length), locale(_locale) {}
  119. virtual size32_t size(const byte * self, const byte * selfrow) const;
  120. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  121. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  122. virtual const char * queryLocale() const { return locale; }
  123. protected:
  124. const char * locale;
  125. };
  126. struct ECLRTL_API RtlUtf8TypeInfo : public RtlTypeInfoBase
  127. {
  128. public:
  129. inline RtlUtf8TypeInfo(unsigned _fieldType, unsigned _length, const char * _locale) : RtlTypeInfoBase(_fieldType, _length), locale(_locale) {}
  130. virtual size32_t size(const byte * self, const byte * selfrow) const;
  131. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  132. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  133. virtual const char * queryLocale() const { return locale; }
  134. protected:
  135. const char * locale;
  136. };
  137. struct ECLRTL_API RtlRecordTypeInfo : public RtlTypeInfoBase
  138. {
  139. inline RtlRecordTypeInfo(unsigned _fieldType, unsigned _length, const RtlFieldInfo * const * _fields) : RtlTypeInfoBase(_fieldType, _length), fields(_fields) {}
  140. const RtlFieldInfo * const * fields; // null terminated
  141. virtual size32_t size(const byte * self, const byte * selfrow) const;
  142. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  143. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  144. virtual const RtlFieldInfo * const * queryFields() const { return fields; }
  145. };
  146. struct ECLRTL_API RtlCompoundTypeInfo : public RtlTypeInfoBase
  147. {
  148. inline RtlCompoundTypeInfo(unsigned _fieldType, unsigned _length, const RtlTypeInfo * _child) : RtlTypeInfoBase(_fieldType, _length), child(_child) {}
  149. const RtlTypeInfo * child;
  150. virtual const RtlTypeInfo * queryChildType() const { return child; }
  151. };
  152. struct ECLRTL_API RtlSetTypeInfo : public RtlCompoundTypeInfo
  153. {
  154. inline RtlSetTypeInfo(unsigned _fieldType, unsigned _length, const RtlTypeInfo * _child) : RtlCompoundTypeInfo(_fieldType, _length, _child) {}
  155. virtual size32_t size(const byte * self, const byte * selfrow) const;
  156. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  157. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  158. };
  159. struct ECLRTL_API RtlRowTypeInfo : public RtlCompoundTypeInfo
  160. {
  161. inline RtlRowTypeInfo(unsigned _fieldType, unsigned _length, const RtlTypeInfo * _child) : RtlCompoundTypeInfo(_fieldType, _length, _child) {}
  162. virtual size32_t size(const byte * self, const byte * selfrow) const;
  163. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  164. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  165. };
  166. struct ECLRTL_API RtlDatasetTypeInfo : public RtlCompoundTypeInfo
  167. {
  168. inline RtlDatasetTypeInfo(unsigned _fieldType, unsigned _length, const RtlTypeInfo * _child) : RtlCompoundTypeInfo(_fieldType, _length, _child) {}
  169. virtual size32_t size(const byte * self, const byte * selfrow) const;
  170. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  171. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  172. };
  173. struct ECLRTL_API RtlDictionaryTypeInfo : public RtlCompoundTypeInfo
  174. {
  175. inline RtlDictionaryTypeInfo(unsigned _fieldType, unsigned _length, const RtlTypeInfo * _child) : RtlCompoundTypeInfo(_fieldType, _length, _child) {}
  176. virtual size32_t size(const byte * self, const byte * selfrow) const;
  177. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  178. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  179. };
  180. struct ECLRTL_API RtlIfBlockTypeInfo : public RtlTypeInfoBase
  181. {
  182. inline RtlIfBlockTypeInfo(unsigned _fieldType, unsigned _length, const RtlFieldInfo * const * _fields) : RtlTypeInfoBase(_fieldType, _length), fields(_fields) {}
  183. const RtlFieldInfo * const * fields; // null terminated
  184. virtual bool getCondition(const byte * selfrow) const = 0;
  185. virtual size32_t size(const byte * self, const byte * selfrow) const;
  186. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  187. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  188. virtual const RtlFieldInfo * const * queryFields() const { return fields; }
  189. };
  190. struct ECLRTL_API RtlBitfieldTypeInfo : public RtlTypeInfoBase
  191. {
  192. inline RtlBitfieldTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  193. virtual size32_t size(const byte * self, const byte * selfrow) const;
  194. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  195. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  196. protected:
  197. __int64 signedValue(const byte * self) const;
  198. unsigned __int64 unsignedValue(const byte * self) const;
  199. };
  200. struct ECLRTL_API RtlUnimplementedTypeInfo : public RtlTypeInfoBase
  201. {
  202. inline RtlUnimplementedTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  203. virtual size32_t size(const byte * self, const byte * selfrow) const;
  204. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  205. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  206. };
  207. /*
  208. struct ECLRTL_API RtlAlienTypeInfo : public RtlTypeInfoBase
  209. {
  210. public:
  211. inline RtlAlienTypeInfo(unsigned _fieldType, unsigned _length) : RtlTypeInfoBase(_fieldType, _length) {}
  212. virtual size32_t size(const byte * self, const byte * selfrow) const = 0;
  213. virtual size32_t process(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IFieldProcessor & target) const;
  214. virtual size32_t toXML(const byte * self, const byte * selfrow, const RtlFieldInfo * field, IXmlWriter & target) const;
  215. };
  216. */
  217. //-------------------------------------------------------------------------------------------------------------------
  218. struct ECLRTL_API RtlFieldStrInfo : public RtlFieldInfo
  219. {
  220. RtlFieldStrInfo(const char * _name, const char * _xpath, const RtlTypeInfo * _type);
  221. };
  222. #endif