rtlembed.hpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2014 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 rtlembed_hpp
  14. #define rtlembed_hpp
  15. // NOTE - not included from generated code (see rtlfield.hpp)
  16. #include "eclrtl.hpp"
  17. #include "nbcd.hpp"
  18. class NullFieldProcessor : public CInterfaceOf<IFieldProcessor>
  19. {
  20. public:
  21. NullFieldProcessor(const RtlFieldInfo * field)
  22. : intResult(0), uintResult(0), boolResult(false), doubleResult(0),
  23. stringResult(NULL), unicodeResult(NULL), resultChars(0), fieldExpected(field)
  24. {
  25. if (field && field->initializer && !isVirtualInitializer(field->initializer))
  26. {
  27. field->process((const byte *) field->initializer, (const byte *) field->initializer, *this);
  28. assertex(fieldExpected==NULL);
  29. }
  30. }
  31. virtual void processString(unsigned len, const char *value, const RtlFieldInfo * field)
  32. {
  33. checkExpected(field);
  34. stringResult = value;
  35. resultChars = len;
  36. }
  37. virtual void processBool(bool value, const RtlFieldInfo * field)
  38. {
  39. checkExpected(field);
  40. boolResult = value;
  41. }
  42. virtual void processData(unsigned len, const void *value, const RtlFieldInfo * field)
  43. {
  44. checkExpected(field);
  45. stringResult = (const char *) value;
  46. resultChars = len;
  47. }
  48. virtual void processInt(__int64 value, const RtlFieldInfo * field)
  49. {
  50. checkExpected(field);
  51. intResult = value;
  52. }
  53. virtual void processUInt(unsigned __int64 value, const RtlFieldInfo * field)
  54. {
  55. checkExpected(field);
  56. uintResult = value;
  57. }
  58. virtual void processReal(double value, const RtlFieldInfo * field)
  59. {
  60. checkExpected(field);
  61. doubleResult = value;
  62. }
  63. virtual void processDecimal(const void *value, unsigned digits, unsigned precision, const RtlFieldInfo * field)
  64. {
  65. checkExpected(field);
  66. decimalResult.setDecimal(digits, precision, value);
  67. }
  68. virtual void processUDecimal(const void *value, unsigned digits, unsigned precision, const RtlFieldInfo * field)
  69. {
  70. checkExpected(field);
  71. decimalResult.setDecimal(digits, precision, value);
  72. }
  73. virtual void processUnicode(unsigned chars, const UChar *value, const RtlFieldInfo * field)
  74. {
  75. checkExpected(field);
  76. unicodeResult = value;
  77. resultChars = chars;
  78. }
  79. virtual void processQString(unsigned len, const char *value, const RtlFieldInfo * field)
  80. {
  81. checkExpected(field);
  82. stringResult = value;
  83. resultChars = len;
  84. }
  85. virtual void processUtf8(unsigned chars, const char *value, const RtlFieldInfo * field)
  86. {
  87. checkExpected(field);
  88. stringResult = value;
  89. resultChars = chars;
  90. }
  91. virtual bool processBeginSet(const RtlFieldInfo * field, unsigned numElements, bool isAll, const byte *data)
  92. {
  93. UNIMPLEMENTED;
  94. }
  95. virtual bool processBeginDataset(const RtlFieldInfo * field, unsigned numRows)
  96. {
  97. throwUnexpected();
  98. }
  99. virtual bool processBeginRow(const RtlFieldInfo * field)
  100. {
  101. throwUnexpected();
  102. }
  103. virtual void processEndSet(const RtlFieldInfo * field)
  104. {
  105. throwUnexpected();
  106. }
  107. virtual void processEndDataset(const RtlFieldInfo * field)
  108. {
  109. throwUnexpected();
  110. }
  111. virtual void processEndRow(const RtlFieldInfo * field)
  112. {
  113. }
  114. __int64 intResult;
  115. __uint64 uintResult;
  116. bool boolResult;
  117. double doubleResult;
  118. Decimal decimalResult;
  119. const char *stringResult;
  120. const UChar *unicodeResult;
  121. unsigned resultChars;
  122. protected:
  123. const RtlFieldInfo * fieldExpected;
  124. void checkExpected(const RtlFieldInfo * field)
  125. {
  126. assertex(field==fieldExpected);
  127. fieldExpected = NULL;
  128. }
  129. };
  130. #endif