eclrtl.hpp 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  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 eclrtl_incl
  14. #define eclrtl_incl
  15. #include "jscm.hpp"
  16. // Define CHEAP_UCHAR_DEF and typedef UChar yourself, before including this file, to avoid including ICU's headers
  17. // This is cheaper when only unicode support used is through these interfaces, esp. in generated code
  18. // Will not work if you're including any other ICU libraries in this module!
  19. #ifndef CHEAP_UCHAR_DEF
  20. #ifndef U_OVERRIDE_CXX_ALLOCATION
  21. #define U_OVERRIDE_CXX_ALLOCATION 0 // Enabling this forces all allocation of ICU objects to ICU's heap, but is incompatible with jmemleak
  22. #endif //U_OVERRIDE_CXX_ALLOCATION
  23. #include "unicode/utf.h"
  24. #endif //CHEAP_UCHAR_DEF
  25. #if defined(_WIN32)&&!defined(ECLRTL_LOCAL)
  26. #ifdef ECLRTL_EXPORTS
  27. #define ECLRTL_API __declspec(dllexport)
  28. #else
  29. #define ECLRTL_API __declspec(dllimport)
  30. #endif
  31. #else
  32. #define ECLRTL_API
  33. #endif
  34. #ifdef _MSC_VER
  35. #undef __attribute__ // in case platform.h has been included
  36. #define __attribute__(param) /* do nothing */
  37. #endif
  38. #ifndef I64C
  39. #ifdef _WIN32
  40. #define I64C(n) n##i64
  41. #else
  42. #define I64C(n) n##LL
  43. #endif
  44. #endif
  45. typedef unsigned char byte;
  46. interface IEngineRowAllocator;
  47. interface IOutputMetaData;
  48. interface IOutputRowSerializer;
  49. interface IOutputRowDeserializer;
  50. interface IAtom;
  51. interface IRecordSize;
  52. interface IException;
  53. class StringBuffer;
  54. class MemoryBuffer;
  55. enum DBZaction { DBZnone, DBZzero, DBZnan, DBZfail }; // Different actions on divide by zero
  56. //-----------------------------------------------------------------------------
  57. // RegEx Compiler for ansii strings (uses BOOST)
  58. interface IStrRegExprFindInstance
  59. {
  60. virtual bool found() const = 0;
  61. virtual void getMatchX(size32_t & outlen, char * & out, unsigned n = 0) const = 0;
  62. };
  63. interface ICompiledStrRegExpr
  64. {
  65. virtual void replace(size32_t & outlen, char * & out, size32_t slen, char const * str, size32_t rlen, char const * replace) const = 0;
  66. virtual IStrRegExprFindInstance * find(const char * str, size32_t from, size32_t len, bool needToKeepSearchString) const = 0;
  67. };
  68. // RegEx Compiler for unicode strings
  69. interface IUStrRegExprFindInstance
  70. {
  71. virtual bool found() const = 0;
  72. virtual void getMatchX(size32_t & outlen, UChar * & out, unsigned n = 0) const = 0;
  73. };
  74. interface ICompiledUStrRegExpr
  75. {
  76. virtual void replace(size32_t & outlen, UChar * & out, size32_t slen, UChar const * str, size32_t rlen, UChar const * replace) const = 0;
  77. virtual IUStrRegExprFindInstance * find(const UChar * str, size32_t from, size32_t len) const = 0;
  78. };
  79. //-----------------------------------------------------------------------------
  80. ECLRTL_API void * rtlMalloc(size32_t size);
  81. ECLRTL_API void rtlFree(void * x);
  82. ECLRTL_API void * rtlRealloc(void * _ptr, size32_t size);
  83. ECLRTL_API __int64 rtlRound(double x);
  84. ECLRTL_API double rtlRoundTo(double x, int places);
  85. ECLRTL_API __int64 rtlRoundDown(double x);
  86. ECLRTL_API __int64 rtlRoundUp(double x);
  87. ECLRTL_API void rtlIntFormat(unsigned & len, char * & target, __int64 value, unsigned width, unsigned flags);
  88. ECLRTL_API void rtlRealFormat(unsigned & tlen, char * & target, double value, unsigned width, unsigned places);
  89. ECLRTL_API void holeIntFormat(size32_t maxlen, char * target, __int64 value, unsigned width, unsigned flags);
  90. ECLRTL_API void holeRealFormat(size32_t maxlen, char * target, double value, unsigned width, unsigned places);
  91. ECLRTL_API void rtlUInt4ToStr(size32_t l, char * t, unsigned val);
  92. ECLRTL_API void rtlUInt8ToStr(size32_t l, char * t, unsigned __int64 val);
  93. ECLRTL_API void rtlInt4ToStr(size32_t l, char * t, int val);
  94. ECLRTL_API void rtlInt8ToStr(size32_t l, char * t, __int64 val);
  95. ECLRTL_API void rtlUInt4ToStrX(size32_t & l, char * & t, unsigned val);
  96. ECLRTL_API void rtlUInt8ToStrX(size32_t & l, char * & t, unsigned __int64 val);
  97. ECLRTL_API void rtlInt4ToStrX(size32_t & l, char * & t, int val);
  98. ECLRTL_API void rtlInt8ToStrX(size32_t & l, char * & t, __int64 val);
  99. ECLRTL_API void rtlUInt4ToVStr(size32_t l, char * t, unsigned val);
  100. ECLRTL_API void rtlUInt8ToVStr(size32_t l, char * t, unsigned __int64 val);
  101. ECLRTL_API void rtlInt4ToVStr(size32_t l, char * t, int val);
  102. ECLRTL_API void rtlInt8ToVStr(size32_t l, char * t, __int64 val);
  103. ECLRTL_API char * rtlUInt4ToVStrX(unsigned val);
  104. ECLRTL_API char * rtlUInt8ToVStrX(unsigned __int64 val);
  105. ECLRTL_API char * rtlInt4ToVStrX(int val);
  106. ECLRTL_API char * rtlInt8ToVStrX(__int64 val);
  107. ECLRTL_API double rtlStrToReal(size32_t l, const char * t);
  108. ECLRTL_API double rtlVStrToReal(const char * t);
  109. ECLRTL_API double rtlEStrToReal(size32_t l, const char * t);
  110. ECLRTL_API double rtlUnicodeToReal(size32_t l, UChar const * t);
  111. ECLRTL_API void rtlRealToStr(size32_t l, char * t, double val);
  112. ECLRTL_API void rtlRealToStrX(size32_t & l, char * & t, double val);
  113. ECLRTL_API void rtlRealToVStr(size32_t l, char * t, double val);
  114. ECLRTL_API char * rtlRealToVStrX(double val);
  115. ECLRTL_API void rtlRealToStr(size32_t l, char * t, float val);
  116. ECLRTL_API void rtlRealToStrX(size32_t & l, char * & t, float val);
  117. ECLRTL_API void rtlRealToVStr(size32_t l, char * t, float val);
  118. ECLRTL_API char * rtlRealToVStrX(float val);
  119. ECLRTL_API void rtlStrToStrX(unsigned & tlen, char * & tgt, unsigned slen, const void * src);
  120. ECLRTL_API void rtlStrToDataX(unsigned & tlen, void * & tgt, unsigned slen, const void * src);
  121. ECLRTL_API char * rtlStrToVStrX(unsigned slen, const void * src);
  122. ECLRTL_API char * rtlEStrToVStrX(unsigned slen, const char * src);
  123. ECLRTL_API void rtlEStrToStrX(unsigned & tlen, char * & tgt, unsigned slen, const char * src);
  124. ECLRTL_API void rtlStrToEStrX(unsigned & tlen, char * & tgt, unsigned slen, const char * src);
  125. ECLRTL_API unsigned rtlStrToUInt4(size32_t l, const char * t);
  126. ECLRTL_API unsigned __int64 rtlStrToUInt8(size32_t l, const char * t);
  127. ECLRTL_API int rtlStrToInt4(size32_t l, const char * t);
  128. ECLRTL_API __int64 rtlStrToInt8(size32_t l, const char * t);
  129. ECLRTL_API bool rtlStrToBool(size32_t l, const char * t);
  130. ECLRTL_API __int64 rtlUnicodeToInt8(size32_t l, UChar const * tl);
  131. ECLRTL_API bool rtlUnicodeToBool(size32_t l, UChar const * t);
  132. ECLRTL_API unsigned rtlEStrToUInt4(size32_t l, const char * t);
  133. ECLRTL_API unsigned __int64 rtlEStrToUInt8(size32_t l, const char * t);
  134. ECLRTL_API int rtlEStrToInt4(size32_t l, const char * t);
  135. ECLRTL_API __int64 rtlEStrToInt8(size32_t l, const char * t);
  136. ECLRTL_API unsigned rtlVStrToUInt4(const char * t);
  137. ECLRTL_API unsigned __int64 rtlVStrToUInt8(const char * t);
  138. ECLRTL_API int rtlVStrToInt4(const char * t);
  139. ECLRTL_API __int64 rtlVStrToInt8(const char * t);
  140. ECLRTL_API bool rtlVStrToBool(const char * t);
  141. ECLRTL_API int rtlSearchTableStringN(unsigned count, char * * table, unsigned width, const char * search);
  142. ECLRTL_API int rtlSearchTableVStringN(unsigned count, char * * table, const char * search);
  143. ECLRTL_API int rtlNewSearchDataTable(unsigned count, unsigned elemlen, char * * table, unsigned width, const char * search);
  144. ECLRTL_API int rtlNewSearchEStringTable(unsigned count, unsigned elemlen, char * * table, unsigned width, const char * search);
  145. ECLRTL_API int rtlNewSearchQStringTable(unsigned count, unsigned elemlen, char * * table, unsigned width, const char * search);
  146. ECLRTL_API int rtlNewSearchStringTable(unsigned count, unsigned elemlen, char * * table, unsigned width, const char * search);
  147. ECLRTL_API int rtlNewSearchUnicodeTable(unsigned count, unsigned elemlen, UChar * * table, unsigned width, const UChar * search, const char * locale);
  148. ECLRTL_API int rtlNewSearchVUnicodeTable(unsigned count, UChar * * table, const UChar * search, const char * locale);
  149. ECLRTL_API int rtlNewSearchUtf8Table(unsigned count, unsigned elemlen, char * * table, unsigned width, const char * search, const char * locale);
  150. ECLRTL_API int rtlSearchTableInteger8(unsigned count, __int64 * table, __int64 search);
  151. ECLRTL_API int rtlSearchTableUInteger8(unsigned count, unsigned __int64 * table, unsigned __int64 search);
  152. ECLRTL_API int rtlSearchTableInteger4(unsigned count, int * table, int search);
  153. ECLRTL_API int rtlSearchTableUInteger4(unsigned count, unsigned * table, unsigned search);
  154. ECLRTL_API int searchTableStringN(unsigned count, const char * * table, unsigned width, const char * search);
  155. ECLRTL_API unsigned rtlCrc32(unsigned len, const void * buffer, unsigned crc);
  156. //These functions should have an X in the name
  157. ECLRTL_API void rtlConcat(unsigned & tlen, char * * tgt, ...);
  158. ECLRTL_API void rtlConcatVStr(char * * tgt, ...);
  159. ECLRTL_API void rtlConcatUnicode(unsigned & tlen, UChar * * tgt, ...);
  160. ECLRTL_API void rtlConcatVUnicode(UChar * * tgt, ...);
  161. ECLRTL_API void rtlConcatExtend(unsigned & tlen, char * & tgt, unsigned slen, const char * src);
  162. ECLRTL_API void rtlConcatUnicodeExtend(size32_t & tlen, UChar * & tgt, size32_t slen, const UChar * src);
  163. ECLRTL_API void rtlConcatStrF(unsigned tlen, void * tgt, int fill, ...);
  164. ECLRTL_API void rtlConcatVStrF(unsigned tlen, char * tgt, ...);
  165. ECLRTL_API void rtlConcatUnicodeF(unsigned tlen, UChar * tgt, ...);
  166. ECLRTL_API void rtlConcatVUnicodeF(unsigned tlen, UChar * tgt, ...);
  167. ECLRTL_API char * rtlCreateQuotedString(unsigned _len_tgt,char * tgt);
  168. ECLRTL_API unsigned rtlConcatStrToStr(unsigned tlen, char * tgt, unsigned idx, unsigned slen, const char * src);
  169. ECLRTL_API unsigned rtlConcatVStrToStr(unsigned tlen, char * tgt, unsigned idx, const char * src);
  170. ECLRTL_API void rtlConcatStrToVStr(unsigned tlen, void * _tgt, unsigned slen, const void * src);
  171. ECLRTL_API void rtlConcatVStrToVStr(unsigned tlen, void * _tgt, const char * src);
  172. ECLRTL_API unsigned rtlConcatUnicodeToUnicode(unsigned tlen, UChar * tgt, unsigned idx, unsigned slen, UChar const * src);
  173. ECLRTL_API unsigned rtlConcatVUnicodeToUnicode(unsigned tlen, UChar * tgt, unsigned idx, UChar const * src);
  174. ECLRTL_API void rtlSubDataFX(unsigned & tlen, void * & tgt, unsigned slen, const void * src, unsigned from);
  175. ECLRTL_API void rtlSubDataFT(unsigned tlen, void * tgt, unsigned slen, const void * src, unsigned from, unsigned to);
  176. ECLRTL_API void rtlSubDataFTX(unsigned & tlen, void * & tgt, unsigned slen, const void * src, unsigned from, unsigned to);
  177. ECLRTL_API void rtlSubQStrFX(unsigned & tlen, char * & tgt, unsigned slen, const char * _src, unsigned from);
  178. ECLRTL_API void rtlSubQStrFT(unsigned tlen, char * tgt, unsigned slen, const char * src, unsigned from, unsigned to);
  179. ECLRTL_API void rtlSubQStrFTX(unsigned & tlen, char * & tgt, unsigned slen, const char * _src, unsigned from, unsigned to);
  180. ECLRTL_API void rtlSubStrFTX(unsigned & tlen, char * & tgt, unsigned slen, const char * _src, unsigned from, unsigned to);
  181. ECLRTL_API void rtlSubStrFX(unsigned & tlen, char * & tgt, unsigned slen, const char * _src, unsigned from);
  182. ECLRTL_API void rtlSubStrFT(unsigned tlen, char * tgt, unsigned slen, const char * src, unsigned from, unsigned to);
  183. ECLRTL_API void rtlUnicodeSubStrFTX(unsigned & tlen, UChar * & tgt, unsigned slen, UChar const * src, unsigned from, unsigned to);
  184. ECLRTL_API void rtlUnicodeSubStrFX(unsigned & tlen, UChar * & tgt, unsigned slen, UChar const * src, unsigned from);
  185. ECLRTL_API void rtlESpaceFill(unsigned tlen, char * tgt, unsigned idx);
  186. ECLRTL_API void rtlSpaceFill(unsigned tlen, char * tgt, unsigned idx);
  187. ECLRTL_API void rtlZeroFill(unsigned tlen, char * tgt, unsigned idx);
  188. ECLRTL_API void rtlNullTerminate(unsigned tlen, char * tgt, unsigned idx);
  189. ECLRTL_API void rtlUnicodeSpaceFill(unsigned tlne, UChar * tgt, unsigned idx);
  190. ECLRTL_API void rtlUnicodeNullTerminate(unsigned tlen, UChar * tgt, unsigned idx);
  191. ECLRTL_API void rtlStringToLower(size32_t l, char * t);
  192. ECLRTL_API void rtlStringToUpper(size32_t l, char * t);
  193. ECLRTL_API void rtlUnicodeToLower(size32_t l, UChar * t, char const * locale);
  194. ECLRTL_API void rtlUnicodeToUpper(size32_t l, UChar * t, char const * locale);
  195. ECLRTL_API void rtlUnicodeToLowerX(size32_t & lenout, UChar * & out, size32_t l, const UChar * t, char const * locale);
  196. ECLRTL_API unsigned rtlTrimDataLen(size32_t l, const void * _t); // trims 0 bytes.
  197. ECLRTL_API unsigned rtlTrimStrLen(size32_t l, const char * t);
  198. ECLRTL_API unsigned rtlTrimUnicodeStrLen(size32_t l, UChar const * t);
  199. ECLRTL_API unsigned rtlTrimUtf8StrLen(size32_t l, const char * t);
  200. ECLRTL_API unsigned rtlTrimVStrLen(const char * t);
  201. ECLRTL_API unsigned rtlTrimVUnicodeStrLen(UChar const * t);
  202. ECLRTL_API int rtlCompareStrStr(unsigned l1, const char * p1, unsigned l2, const char * p2);
  203. ECLRTL_API int rtlCompareVStrVStr(const char * p1, const char * p2);
  204. ECLRTL_API int rtlCompareStrBlank(unsigned l1, const char * p1);
  205. ECLRTL_API int rtlCompareDataData(unsigned l1, const void * p1, unsigned l2, const void * p2);
  206. ECLRTL_API int rtlCompareEStrEStr(unsigned l1, const char * p1, unsigned l2, const char * p2);
  207. ECLRTL_API int rtlCompareUnicodeUnicode(unsigned l1, UChar const * p1, unsigned l2, UChar const * p2, char const * locale); // l1,2 in UChars, i.e. bytes/2
  208. ECLRTL_API int rtlCompareUnicodeUnicodeStrength(unsigned l1, UChar const * p1, unsigned l2, UChar const * p2, char const * locale, unsigned strength); // strength should be between 1 (primary) and 5 (identical)
  209. ECLRTL_API int rtlCompareVUnicodeVUnicode(UChar const * p1, UChar const * p2, char const * locale);
  210. ECLRTL_API int rtlCompareVUnicodeVUnicodeStrength(UChar const * p1, UChar const * p2, char const * locale, unsigned strength);
  211. ECLRTL_API void rtlKeyUnicodeX(unsigned & tlen, void * & tgt, unsigned slen, const UChar * src, const char * locale);
  212. ECLRTL_API void rtlKeyUnicodeStrengthX(unsigned & tlen, void * & tgt, unsigned slen, const UChar * src, const char * locale, unsigned strength);
  213. ECLRTL_API bool rtlGetNormalizedUnicodeLocaleName(unsigned len, char const * in, char * out);
  214. ECLRTL_API int rtlPrefixDiffStr(unsigned l1, const char * p1, unsigned l2, const char * p2);
  215. ECLRTL_API int rtlPrefixDiffStrEx(unsigned l1, const char * p1, unsigned l2, const char * p2, unsigned origin);
  216. ECLRTL_API int rtlPrefixDiffUnicode(unsigned l1, const UChar * p1, unsigned l2, const UChar * p2, const char * locale);
  217. ECLRTL_API int rtlPrefixDiffUnicodeEx(unsigned l1, const UChar * p1, unsigned l2, const UChar * p2, const char * locale, unsigned origin);
  218. ECLRTL_API void rtlTrimRight(unsigned &tlen, char * &tgt, unsigned slen, const char * src); // YMA
  219. ECLRTL_API void rtlTrimUnicodeRight(unsigned &tlen, UChar * &tgt, unsigned slen, UChar const * src);
  220. ECLRTL_API void rtlTrimUtf8Right(unsigned &tlen, char * &tgt, unsigned slen, char const * src);
  221. ECLRTL_API void rtlTrimVRight(unsigned &tlen, char * &tgt, const char * src); // YMA
  222. ECLRTL_API void rtlTrimVUnicodeRight(unsigned &tlen, UChar * &tgt, UChar const * src);
  223. ECLRTL_API void rtlTrimLeft(unsigned &tlen, char * &tgt, unsigned slen, const char * src); // YMA
  224. ECLRTL_API void rtlTrimUnicodeLeft(unsigned &tlen, UChar * &tgt, unsigned slen, UChar const * src);
  225. ECLRTL_API void rtlTrimUtf8Left(unsigned &tlen, char * &tgt, unsigned slen, const char * src);
  226. ECLRTL_API void rtlTrimVLeft(unsigned &tlen, char * &tgt, const char * src); // YMA
  227. ECLRTL_API void rtlTrimVUnicodeLeft(unsigned &tlen, UChar * &tgt, UChar const * src);
  228. ECLRTL_API void rtlTrimBoth(unsigned &tlen, char * &tgt, unsigned slen, const char * src); // YMA
  229. ECLRTL_API void rtlTrimUnicodeBoth(unsigned &tlen, UChar * &tgt, unsigned slen, UChar const * src);
  230. ECLRTL_API void rtlTrimUtf8Both(unsigned &tlen, char * &tgt, unsigned slen, const char * src);
  231. ECLRTL_API void rtlTrimVBoth(unsigned &tlen, char * &tgt, const char * src); // YMA
  232. ECLRTL_API void rtlTrimVUnicodeBoth(unsigned &tlen, UChar * &tgt, UChar const * src);
  233. ECLRTL_API void rtlTrimAll(unsigned &tlen, char * &tgt, unsigned slen, const char * src); // YMA
  234. ECLRTL_API void rtlTrimUnicodeAll(unsigned &tlen, UChar * &tgt, unsigned slen, UChar const * src);
  235. ECLRTL_API void rtlTrimUtf8All(unsigned &tlen, char * &tgt, unsigned slen, const char * src);
  236. ECLRTL_API void rtlTrimVAll(unsigned &tlen, char * &tgt, const char * src); // YMA
  237. ECLRTL_API void rtlTrimVUnicodeAll(unsigned &tlen, UChar * &tgt, UChar const * src);
  238. ECLRTL_API unsigned rtlTrimStrLenNonBlank(size32_t l, const char * t);
  239. ECLRTL_API unsigned rtlTrimVStrLenNonBlank(const char * t);
  240. ECLRTL_API void rtlAssignTrimLeftV(size32_t tlen, char * tgt, unsigned slen, const char * src);
  241. ECLRTL_API void rtlAssignTrimVLeftV(size32_t tlen, char * tgt, const char * src);
  242. ECLRTL_API void rtlAssignTrimRightV(size32_t tlen, char * tgt, unsigned slen, const char * src);
  243. ECLRTL_API void rtlAssignTrimVRightV(size32_t tlen, char * tgt, const char * src);
  244. ECLRTL_API void rtlAssignTrimBothV(size32_t tlen, char * tgt, unsigned slen, const char * src);
  245. ECLRTL_API void rtlAssignTrimVBothV(size32_t tlen, char * tgt, const char * src);
  246. ECLRTL_API void rtlAssignTrimAllV(size32_t tlen, char * tgt, unsigned slen, const char * src);
  247. ECLRTL_API void rtlAssignTrimVAllV(size32_t tlen, char * tgt, const char * src);
  248. ECLRTL_API void rtlAssignTrimUnicodeLeftV(size32_t tlen, UChar * tgt, unsigned slen, const UChar * src);
  249. ECLRTL_API void rtlAssignTrimVUnicodeLeftV(size32_t tlen, UChar * tgt, const UChar * src);
  250. ECLRTL_API void rtlAssignTrimUnicodeRightV(size32_t tlen, UChar * tgt, unsigned slen, const UChar * src);
  251. ECLRTL_API void rtlAssignTrimVUnicodeRightV(size32_t tlen, UChar * tgt, const UChar * src);
  252. ECLRTL_API void rtlAssignTrimUnicodeBothV(size32_t tlen, UChar * tgt, unsigned slen, const UChar * src);
  253. ECLRTL_API void rtlAssignTrimVUnicodeBothV(size32_t tlen, UChar * tgt, const UChar * src);
  254. ECLRTL_API void rtlAssignTrimUnicodeAllV(size32_t tlen, UChar * tgt, unsigned slen, const UChar * src);
  255. ECLRTL_API void rtlAssignTrimVUnicodeAllV(size32_t tlen, UChar * tgt, const UChar * src);
  256. ECLRTL_API bool rtlDataToBool(unsigned tlen, const void * tgt);
  257. ECLRTL_API void rtlBoolToData(unsigned tlen, void * tgt, bool src);
  258. ECLRTL_API void rtlBoolToStr(unsigned tlen, void * tgt, bool src);
  259. ECLRTL_API void rtlBoolToVStr(char * tgt, int src);
  260. ECLRTL_API void rtlBoolToStrX(unsigned & tlen, char * & tgt, bool src);
  261. ECLRTL_API char * rtlBoolToVStrX(bool src);
  262. ECLRTL_API void rtlStrToData(unsigned tlen, void * tgt, unsigned slen, const void * src);
  263. ECLRTL_API void rtlStrToStr(unsigned tlen, void * tgt, unsigned slen, const void * src);
  264. ECLRTL_API void rtlDataToData(unsigned tlen, void * tgt, unsigned slen, const void * src);
  265. ECLRTL_API void rtlEStrToEStr(unsigned tlen, void * tgt, unsigned slen, const void * src);
  266. ECLRTL_API void rtlEStrToVStr(unsigned tlen, void * tgt, unsigned slen, const char * src);
  267. ECLRTL_API void rtlStrToVStr(unsigned tlen, void * tgt, unsigned slen, const void * src);
  268. ECLRTL_API void rtlVStrToData(unsigned tlen, void * tgt, const char * src);
  269. ECLRTL_API void rtlVStrToStr(unsigned tlen, void * tgt, const char * src);
  270. ECLRTL_API void rtlVStrToVStr(unsigned tlen, void * tgt, const char * src);
  271. ECLRTL_API void rtlEStrToStr(unsigned outlen, char *out, unsigned inlen, const char *in);
  272. ECLRTL_API void rtlStrToEStr(unsigned outlen, char *out, unsigned inlen, const char *in);
  273. ECLRTL_API void rtlCodepageToUnicode(unsigned outlen, UChar * out, unsigned inlen, char const * in, char const * codepage);
  274. ECLRTL_API void rtlCodepageToVUnicode(unsigned outlen, UChar * out, unsigned inlen, char const * in, char const * codepage);
  275. ECLRTL_API void rtlVCodepageToUnicode(unsigned outlen, UChar * out, char const * in, char const * codepage);
  276. ECLRTL_API void rtlVCodepageToVUnicode(unsigned outlen, UChar * out, char const * in, char const * codepage);
  277. ECLRTL_API void rtlCodepageToUnicodeUnescape(unsigned outlen, UChar * out, unsigned inlen, char const * in, char const * codepage);
  278. ECLRTL_API void rtlUnicodeToCodepage(unsigned outlen, char * out, unsigned inlen, UChar const * in, char const * codepage);
  279. ECLRTL_API void rtlUnicodeToData(unsigned outlen, void * out, unsigned inlen, UChar const * in);
  280. ECLRTL_API void rtlUnicodeToVCodepage(unsigned outlen, char * out, unsigned inlen, UChar const * in, char const * codepage);
  281. ECLRTL_API void rtlVUnicodeToCodepage(unsigned outlen, char * out, UChar const * in, char const * codepage);
  282. ECLRTL_API void rtlVUnicodeToData(unsigned outlen, void * out, UChar const * in);
  283. ECLRTL_API void rtlVUnicodeToVCodepage(unsigned outlen, char * out, UChar const * in, char const * codepage);
  284. ECLRTL_API void rtlCodepageToUnicodeX(unsigned & outlen, UChar * & out, unsigned inlen, char const * in, char const * codepage);
  285. ECLRTL_API UChar * rtlCodepageToVUnicodeX(unsigned inlen, char const * in, char const * codepage);
  286. ECLRTL_API void rtlVCodepageToUnicodeX(unsigned & outlen, UChar * & out, char const * in, char const * codepage);
  287. ECLRTL_API UChar * rtlVCodepageToVUnicodeX(char const * in, char const * codepage);
  288. ECLRTL_API void rtlCodepageToUnicodeXUnescape(unsigned & outlen, UChar * & out, unsigned inlen, char const * in, char const * codepage);
  289. ECLRTL_API void rtlUnicodeToCodepageX(unsigned & outlen, char * & out, unsigned inlen, UChar const * in, char const * codepage);
  290. ECLRTL_API void rtlUnicodeToDataX(unsigned & outlen, void * & out, unsigned inlen, UChar const * in);
  291. ECLRTL_API char * rtlUnicodeToVCodepageX(unsigned inlen, UChar const * in, char const * codepage);
  292. ECLRTL_API void rtlVUnicodeToCodepageX(unsigned & outlen, char * & out, UChar const * in, char const * codepage);
  293. ECLRTL_API char * rtlVUnicodeToVCodepageX(UChar const * in, char const * codepage);
  294. ECLRTL_API void rtlStrToUnicode(unsigned outlen, UChar * out, unsigned inlen, char const * in);
  295. ECLRTL_API void rtlUnicodeToStr(unsigned outlen, char * out, unsigned inlen, UChar const * in);
  296. ECLRTL_API void rtlStrToUnicodeX(unsigned & outlen, UChar * & out, unsigned inlen, char const * in);
  297. ECLRTL_API void rtlUnicodeToStrX(unsigned & outlen, char * & out, unsigned inlen, UChar const * in);
  298. ECLRTL_API void rtlUnicodeToEscapedStrX(unsigned & outlen, char * & out, unsigned inlen, UChar const * in);
  299. ECLRTL_API bool rtlCodepageToCodepage(unsigned outlen, char * out, unsigned inlen, char const * in, char const * outcodepage, char const * incodepage); //returns success, false probably means illegal input or overflow
  300. ECLRTL_API int rtlSingleUtf8ToCodepage(char * out, unsigned inlen, char const * in, char const * outcodepage); //returns number of trailbytes on character in UTF8 if valid, -1 error (illegal input or overflow (this routine assumes output is single character, which can break if outcodepage uses multibyte sequences, so don't do that))
  301. ECLRTL_API void rtlCreateOrder(void * tgt, const void * src, unsigned num, unsigned width, const void * compare);
  302. ECLRTL_API unsigned rtlRankFromOrder(unsigned index, unsigned num, const void * order);
  303. ECLRTL_API unsigned rtlRankedFromOrder(unsigned index, unsigned num, const void * order) ;
  304. ECLRTL_API void rtlEcho(unsigned len, const char * src); // useful for testing.
  305. const unsigned int HASH32_INIT = 0x811C9DC5;
  306. const unsigned __int64 HASH64_INIT = I64C(0xcbf29ce484222325);
  307. ECLRTL_API unsigned rtlHashData( unsigned length, const void *_k, unsigned initval);
  308. ECLRTL_API unsigned rtlHashString( unsigned length, const char *_k, unsigned initval);
  309. ECLRTL_API unsigned rtlHashUnicode(unsigned length, UChar const * k, unsigned initval);
  310. ECLRTL_API unsigned rtlHashUtf8(unsigned length, const char * k, unsigned initval);
  311. ECLRTL_API unsigned rtlHashVStr(const char * k, unsigned initval);
  312. ECLRTL_API unsigned rtlHashVUnicode(UChar const * k, unsigned initval);
  313. ECLRTL_API unsigned rtlHashDataNC( unsigned length, const void * _k, unsigned initval);
  314. ECLRTL_API unsigned rtlHashVStrNC(const char * k, unsigned initval);
  315. ECLRTL_API hash64_t rtlHash64Data(size32_t len, const void *buf, hash64_t hval);
  316. ECLRTL_API hash64_t rtlHash64VStr(const char *str, hash64_t hval);
  317. ECLRTL_API hash64_t rtlHash64Unicode(unsigned length, UChar const * k, hash64_t initval);
  318. ECLRTL_API hash64_t rtlHash64Utf8(unsigned length, const char * k, hash64_t initval);
  319. ECLRTL_API hash64_t rtlHash64VUnicode(UChar const * k, hash64_t initval);
  320. ECLRTL_API unsigned rtlHash32Data(size32_t len, const void *buf, unsigned hval);
  321. ECLRTL_API unsigned rtlHash32VStr(const char *str, unsigned hval);
  322. ECLRTL_API unsigned rtlHash32Unicode(unsigned length, UChar const * k, unsigned initval);
  323. ECLRTL_API unsigned rtlHash32Utf8(unsigned length, const char * k, unsigned initval);
  324. ECLRTL_API unsigned rtlHash32VUnicode(UChar const * k, unsigned initval);
  325. ECLRTL_API unsigned rtlCrcData( unsigned length, const void *_k, unsigned initval);
  326. ECLRTL_API unsigned rtlCrcUnicode(unsigned length, UChar const * k, unsigned initval);
  327. ECLRTL_API unsigned rtlCrcUtf8(unsigned length, const char * k, unsigned initval);
  328. ECLRTL_API unsigned rtlCrcVStr( const char * k, unsigned initval);
  329. ECLRTL_API unsigned rtlCrcVUnicode(UChar const * k, unsigned initval);
  330. ECLRTL_API unsigned rtlRandom();
  331. ECLRTL_API void rtlSeedRandom(unsigned value);
  332. ECLRTL_API void rtlFail(int code, const char *msg) __attribute__((noreturn));
  333. ECLRTL_API void rtlSysFail(int code, const char *msg) __attribute__((noreturn));
  334. ECLRTL_API void rtlFailUnexpected() __attribute__((noreturn));
  335. ECLRTL_API void rtlFailOnAssert() __attribute__((noreturn));
  336. ECLRTL_API void rtlFailDivideByZero() __attribute__((noreturn));
  337. ECLRTL_API void rtlThrowOutOfMemory(int code, const char *msg) __attribute__((noreturn));
  338. ECLRTL_API void rtlReportFieldOverflow(unsigned size, unsigned max, const char * name);
  339. ECLRTL_API void rtlReportRowOverflow(unsigned size, unsigned max);
  340. ECLRTL_API void rtlCheckFieldOverflow(unsigned size, unsigned max, const char * name);
  341. ECLRTL_API void rtlCheckRowOverflow(unsigned size, unsigned max);
  342. inline int rtlReadInt1(const void * data) { return *(signed char *)data; }
  343. inline int rtlReadInt2(const void * data) { return *(signed short *)data; }
  344. ECLRTL_API int rtlReadInt3(const void * data);
  345. inline int rtlReadInt4(const void * data) { return *(signed int *)data; }
  346. ECLRTL_API __int64 rtlReadInt5(const void * data);
  347. ECLRTL_API __int64 rtlReadInt6(const void * data);
  348. ECLRTL_API __int64 rtlReadInt7(const void * data);
  349. inline __int64 rtlReadInt8(const void * data) { return *(signed __int64 *)data; }
  350. ECLRTL_API __int64 rtlReadInt(const void * data, unsigned length);
  351. inline unsigned int rtlReadUInt1(const void * data) { return *(unsigned char *)data; }
  352. inline unsigned int rtlReadUInt2(const void * data) { return *(unsigned short *)data; }
  353. ECLRTL_API unsigned rtlReadUInt3(const void * data);
  354. inline unsigned int rtlReadUInt4(const void * data) { return *(unsigned int *)data; }
  355. ECLRTL_API unsigned __int64 rtlReadUInt5(const void * data);
  356. ECLRTL_API unsigned __int64 rtlReadUInt6(const void * data);
  357. ECLRTL_API unsigned __int64 rtlReadUInt7(const void * data);
  358. inline unsigned __int64 rtlReadUInt8(const void * data) { return *(unsigned __int64 *)data; }
  359. ECLRTL_API unsigned __int64 rtlReadUInt(const void * data, unsigned length);
  360. //MORE: Change if reverse endian, or if alignment issues.
  361. inline size32_t rtlReadSize32t(void * data) { return *(const size32_t *)data; }
  362. inline void rtlWriteInt1(void * data, unsigned value) { *(unsigned char *)data = value; }
  363. inline void rtlWriteInt2(void * data, unsigned value) { *(unsigned short *)data = value; }
  364. ECLRTL_API void rtlWriteInt3(void * data, unsigned value);
  365. inline void rtlWriteInt4(void * data, unsigned value) { *(unsigned *)data = value; }
  366. ECLRTL_API void rtlWriteInt5(void * data, unsigned __int64 value);
  367. ECLRTL_API void rtlWriteInt6(void * data, unsigned __int64 value);
  368. ECLRTL_API void rtlWriteInt7(void * data, unsigned __int64 value);
  369. inline void rtlWriteInt8(void * data, unsigned value) { *(unsigned __int64 *)data = value; }
  370. inline void rtlWriteSize32t(void * data, unsigned value) { *(size32_t *)data = value; }
  371. ECLRTL_API void rtlWriteInt(void * self, __int64 val, unsigned length);
  372. inline int rtlReadSwapInt1(const void * data) { return *(signed char *)data; }
  373. ECLRTL_API int rtlReadSwapInt2(const void * data);
  374. ECLRTL_API int rtlReadSwapInt3(const void * data);
  375. ECLRTL_API int rtlReadSwapInt4(const void * data);
  376. ECLRTL_API __int64 rtlReadSwapInt5(const void * data);
  377. ECLRTL_API __int64 rtlReadSwapInt6(const void * data);
  378. ECLRTL_API __int64 rtlReadSwapInt7(const void * data);
  379. ECLRTL_API __int64 rtlReadSwapInt8(const void * data);
  380. ECLRTL_API __int64 rtlReadSwapInt(const void * data, unsigned length);
  381. inline unsigned int rtlReadSwapUInt1(const void * data) { return *(unsigned char *)data; }
  382. ECLRTL_API unsigned rtlReadSwapUInt2(const void * data);
  383. ECLRTL_API unsigned rtlReadSwapUInt3(const void * data);
  384. ECLRTL_API unsigned rtlReadSwapUInt4(const void * data);
  385. ECLRTL_API unsigned __int64 rtlReadSwapUInt5(const void * data);
  386. ECLRTL_API unsigned __int64 rtlReadSwapUInt6(const void * data);
  387. ECLRTL_API unsigned __int64 rtlReadSwapUInt7(const void * data);
  388. ECLRTL_API unsigned __int64 rtlReadSwapUInt8(const void * data);
  389. ECLRTL_API unsigned __int64 rtlReadSwapUInt(const void * data, unsigned length);
  390. ECLRTL_API void rtlWriteSwapInt3(void * data, unsigned value);
  391. ECLRTL_API void rtlWriteSwapInt5(void * data, unsigned __int64 value);
  392. ECLRTL_API void rtlWriteSwapInt6(void * data, unsigned __int64 value);
  393. ECLRTL_API void rtlWriteSwapInt7(void * data, unsigned __int64 value);
  394. ECLRTL_API short rtlRevInt2(const void * data);
  395. ECLRTL_API int rtlRevInt3(const void * data);
  396. ECLRTL_API int rtlRevInt4(const void * data);
  397. ECLRTL_API __int64 rtlRevInt5(const void * data);
  398. ECLRTL_API __int64 rtlRevInt6(const void * data);
  399. ECLRTL_API __int64 rtlRevInt7(const void * data);
  400. ECLRTL_API __int64 rtlRevInt8(const void * data);
  401. ECLRTL_API unsigned short rtlRevUInt2(const void * data);
  402. ECLRTL_API unsigned rtlRevUInt3(const void * data);
  403. ECLRTL_API unsigned rtlRevUInt4(const void * data);
  404. ECLRTL_API unsigned __int64 rtlRevUInt5(const void * data);
  405. ECLRTL_API unsigned __int64 rtlRevUInt6(const void * data);
  406. ECLRTL_API unsigned __int64 rtlRevUInt7(const void * data);
  407. ECLRTL_API unsigned __int64 rtlRevUInt8(const void * data);
  408. ECLRTL_API unsigned rtlCastUInt3(unsigned value);
  409. ECLRTL_API unsigned __int64 rtlCastUInt5(unsigned __int64 value);
  410. ECLRTL_API unsigned __int64 rtlCastUInt6(unsigned __int64 value);
  411. ECLRTL_API unsigned __int64 rtlCastUInt7(unsigned __int64 value);
  412. ECLRTL_API signed rtlCastInt3(signed value);
  413. ECLRTL_API __int64 rtlCastInt5(__int64 value);
  414. ECLRTL_API __int64 rtlCastInt6(__int64 value);
  415. ECLRTL_API __int64 rtlCastInt7(__int64 value);
  416. inline unsigned rtliCastUInt3(unsigned value) { return (value & 0xffffff); }
  417. inline unsigned __int64 rtliCastUInt5(unsigned __int64 value) { return (value & I64C(0xffffffffff)); }
  418. inline unsigned __int64 rtliCastUInt6(unsigned __int64 value) { return (value & I64C(0xffffffffffff)); }
  419. inline unsigned __int64 rtliCastUInt7(unsigned __int64 value) { return (value & I64C(0xffffffffffffff)); }
  420. inline signed rtliCastInt3(signed value) { return (value << 8) >> 8; }
  421. inline __int64 rtliCastInt5(__int64 value) { return (value << 24) >> 24; }
  422. inline __int64 rtliCastInt6(__int64 value) { return (value << 16) >> 16; }
  423. inline __int64 rtliCastInt7(__int64 value) { return (value << 8) >> 8; }
  424. ECLRTL_API unsigned __int64 rtlGetPackedUnsigned(const void * _ptr);
  425. ECLRTL_API void rtlSetPackedUnsigned(void * _ptr, unsigned __int64 value);
  426. ECLRTL_API size32_t rtlGetPackedSize(const void * _ptr);
  427. ECLRTL_API __int64 rtlGetPackedSigned(const void * ptr);
  428. ECLRTL_API void rtlSetPackedSigned(void * ptr, __int64 value);
  429. ECLRTL_API size32_t rtlGetPackedSizeFromFirst(byte first);
  430. ECLRTL_API void rtlReleaseRow(const void * row);
  431. ECLRTL_API void * rtlLinkRow(const void * row);
  432. ECLRTL_API void rtlReleaseRowset(unsigned count, byte * * rowset);
  433. ECLRTL_API byte * * rtlLinkRowset(byte * * rowset);
  434. ECLRTL_API void ensureRtlLoaded(); // call this to create a static link to the rtl...
  435. ECLRTL_API void outputXmlString(unsigned len, const char *field, const char *fieldname, StringBuffer &out);
  436. ECLRTL_API void outputXmlBool(bool field, const char *fieldname, StringBuffer &out);
  437. ECLRTL_API void outputXmlData(unsigned len, const void *field, const char *fieldname, StringBuffer &out);
  438. ECLRTL_API void outputXmlInt(__int64 field, const char *fieldname, StringBuffer &out);
  439. ECLRTL_API void outputXmlUInt(unsigned __int64 field, const char *fieldname, StringBuffer &out);
  440. ECLRTL_API void outputXmlReal(double field, const char *fieldname, StringBuffer &out);
  441. ECLRTL_API void outputXmlDecimal(const void *field, unsigned digits, unsigned precision, const char *fieldname, StringBuffer &out);
  442. ECLRTL_API void outputXmlUDecimal(const void *field, unsigned digits, unsigned precision, const char *fieldname, StringBuffer &out);
  443. ECLRTL_API void outputXmlUnicode(unsigned len, const UChar *field, const char *fieldname, StringBuffer &out);
  444. ECLRTL_API void outputXmlUtf8(unsigned len, const char *field, const char *fieldname, StringBuffer &out);
  445. ECLRTL_API void outputXmlBeginNested(const char *fieldname, StringBuffer &out);
  446. ECLRTL_API void outputXmlEndNested(const char *fieldname, StringBuffer &out);
  447. ECLRTL_API void outputXmlSetAll(StringBuffer &out);
  448. ECLRTL_API void outputXmlAttrString(unsigned len, const char *field, const char *fieldname, StringBuffer &out);
  449. ECLRTL_API void outputXmlAttrData(unsigned len, const void *field, const char *fieldname, StringBuffer &out);
  450. ECLRTL_API void outputXmlAttrBool(bool field, const char *fieldname, StringBuffer &out);
  451. ECLRTL_API void outputXmlAttrInt(__int64 field, const char *fieldname, StringBuffer &out);
  452. ECLRTL_API void outputXmlAttrUInt(unsigned __int64 field, const char *fieldname, StringBuffer &out);
  453. ECLRTL_API void outputXmlAttrReal(double field, const char *fieldname, StringBuffer &out);
  454. ECLRTL_API void outputXmlAttrDecimal(const void *field, unsigned size, unsigned precision, const char *fieldname, StringBuffer &out);
  455. ECLRTL_API void outputXmlAttrUDecimal(const void *field, unsigned size, unsigned precision, const char *fieldname, StringBuffer &out);
  456. ECLRTL_API void outputXmlAttrUnicode(unsigned len, const UChar *field, const char *fieldname, StringBuffer &out);
  457. ECLRTL_API void outputXmlAttrUtf8(unsigned len, const char *field, const char *fieldname, StringBuffer &out);
  458. ECLRTL_API void outputJsonDecimal(const void *field, unsigned digits, unsigned precision, const char *fieldname, StringBuffer &out);
  459. ECLRTL_API void outputJsonUDecimal(const void *field, unsigned digits, unsigned precision, const char *fieldname, StringBuffer &out);
  460. ECLRTL_API void outputJsonUnicode(unsigned len, const UChar *field, const char *fieldname, StringBuffer &out);
  461. ECLRTL_API void deserializeRaw(unsigned size, void *record, MemoryBuffer & in);
  462. ECLRTL_API void deserializeDataX(size32_t & len, void * & data, MemoryBuffer &in);
  463. ECLRTL_API void deserializeStringX(size32_t & len, char * & data, MemoryBuffer &in);
  464. ECLRTL_API char * deserializeCStringX(MemoryBuffer &in);
  465. ECLRTL_API void deserializeSet(bool & isAll, size32_t & len, void * & data, MemoryBuffer &in);
  466. ECLRTL_API void deserializeUnicodeX(size32_t & len, UChar * & data, MemoryBuffer &in);
  467. ECLRTL_API void deserializeUtf8X(size32_t & len, char * & data, MemoryBuffer &in);
  468. ECLRTL_API UChar * deserializeVUnicodeX(MemoryBuffer &in);
  469. ECLRTL_API void deserializeQStrX(size32_t & len, char * & data, MemoryBuffer &out);
  470. ECLRTL_API void deserializeRowsetX(size32_t & count, byte * * & data, IEngineRowAllocator * _rowAllocator, IOutputRowDeserializer * deserializer, MemoryBuffer &in);
  471. ECLRTL_API void deserializeGroupedRowsetX(size32_t & count, byte * * & data, IEngineRowAllocator * _rowAllocator, IOutputRowDeserializer * deserializer, MemoryBuffer &in);
  472. ECLRTL_API void deserializeDictionaryX(size32_t & count, byte * * & rowset, IEngineRowAllocator * _rowAllocator, IOutputRowDeserializer * deserializer, MemoryBuffer &in);
  473. ECLRTL_API byte * rtlDeserializeRow(IEngineRowAllocator * rowAllocator, IOutputRowDeserializer * deserializer, const void * src);
  474. ECLRTL_API byte * rtlDeserializeBufferRow(IEngineRowAllocator * rowAllocator, IOutputRowDeserializer * deserializer, MemoryBuffer & buffer);
  475. ECLRTL_API void serializeRaw(unsigned size, const void *record, MemoryBuffer &out);
  476. ECLRTL_API void serializeDataX(size32_t len, const void * data, MemoryBuffer &out);
  477. ECLRTL_API void serializeStringX(size32_t len, const char * data, MemoryBuffer &out);
  478. ECLRTL_API void serializeCStringX(const char * data, MemoryBuffer &out);
  479. ECLRTL_API void serializeSet(bool isAll, size32_t len, const void * data, MemoryBuffer &in);
  480. ECLRTL_API void serializeUnicodeX(size32_t len, const UChar * data, MemoryBuffer &out);
  481. ECLRTL_API void serializeUtf8X(size32_t len, const char * data, MemoryBuffer &out);
  482. ECLRTL_API void serializeQStrX(size32_t len, const char * data, MemoryBuffer &out);
  483. ECLRTL_API void serializeRowsetX(size32_t count, byte * * data, IOutputRowSerializer * serializer, MemoryBuffer &out);
  484. ECLRTL_API void serializeGroupedRowsetX(size32_t count, byte * * data, IOutputRowSerializer * serializer, MemoryBuffer &out);
  485. ECLRTL_API void serializeRow(const void * row, IOutputRowSerializer * serializer, MemoryBuffer & out);
  486. ECLRTL_API void serializeDictionaryX(size32_t count, byte * * rows, IOutputRowSerializer * serializer, MemoryBuffer & buffer);
  487. ECLRTL_API void serializeFixedString(unsigned len, const char *field, MemoryBuffer &out);
  488. ECLRTL_API void serializeLPString(unsigned len, const char *field, MemoryBuffer &out);
  489. ECLRTL_API void serializeVarString(const char *field, MemoryBuffer &out);
  490. ECLRTL_API void serializeBool(bool field, MemoryBuffer &out);
  491. ECLRTL_API void serializeFixedData(unsigned len, const void *field, MemoryBuffer &out);
  492. ECLRTL_API void serializeLPData(unsigned len, const void *field, MemoryBuffer &out);
  493. ECLRTL_API void serializeInt1(signed char field, MemoryBuffer &out);
  494. ECLRTL_API void serializeInt2(signed short field, MemoryBuffer &out);
  495. ECLRTL_API void serializeInt3(signed int field, MemoryBuffer &out);
  496. ECLRTL_API void serializeInt4(signed int field, MemoryBuffer &out);
  497. ECLRTL_API void serializeInt5(signed __int64 field, MemoryBuffer &out);
  498. ECLRTL_API void serializeInt6(signed __int64 field, MemoryBuffer &out);
  499. ECLRTL_API void serializeInt7(signed __int64 field, MemoryBuffer &out);
  500. ECLRTL_API void serializeInt8(signed __int64 field, MemoryBuffer &out);
  501. ECLRTL_API void serializeUInt1(unsigned char field, MemoryBuffer &out);
  502. ECLRTL_API void serializeUInt2(unsigned short field, MemoryBuffer &out);
  503. ECLRTL_API void serializeUInt3(unsigned int field, MemoryBuffer &out);
  504. ECLRTL_API void serializeUInt4(unsigned int field, MemoryBuffer &out);
  505. ECLRTL_API void serializeUInt5(unsigned __int64 field, MemoryBuffer &out);
  506. ECLRTL_API void serializeUInt6(unsigned __int64 field, MemoryBuffer &out);
  507. ECLRTL_API void serializeUInt7(unsigned __int64 field, MemoryBuffer &out);
  508. ECLRTL_API void serializeUInt8(unsigned __int64 field, MemoryBuffer &out);
  509. ECLRTL_API void serializeReal4(float field, MemoryBuffer &out);
  510. ECLRTL_API void serializeReal8(double field, MemoryBuffer &out);
  511. //These maths functions can all have out of range arguments....
  512. ECLRTL_API double rtlLog(double x);
  513. ECLRTL_API double rtlLog10(double x);
  514. ECLRTL_API double rtlSqrt(double x);
  515. ECLRTL_API double rtlACos(double x);
  516. ECLRTL_API double rtlASin(double x);
  517. ECLRTL_API bool rtlIsValidReal(unsigned size, const void * data);
  518. ECLRTL_API double rtlCreateRealNull();
  519. ECLRTL_API unsigned rtlQStrLength(unsigned size);
  520. ECLRTL_API unsigned rtlQStrSize(unsigned length);
  521. ECLRTL_API void rtlStrToQStr(size32_t outlen, char * out, size32_t inlen, const void *in);
  522. ECLRTL_API void rtlStrToQStrX(size32_t & outlen, char * & out, size32_t inlen, const void *in);
  523. ECLRTL_API void rtlQStrToData(size32_t outlen, void * out, size32_t inlen, const char *in);
  524. ECLRTL_API void rtlQStrToDataX(size32_t & outlen, void * & out, size32_t inlen, const char *in);
  525. ECLRTL_API void rtlQStrToStr(size32_t outlen, char * out, size32_t inlen, const char *in);
  526. ECLRTL_API void rtlQStrToQStr(size32_t outlen, char * out, size32_t inlen, const char *in);
  527. ECLRTL_API void rtlQStrToStrX(size32_t & outlen, char * & out, size32_t inlen, const char *in);
  528. ECLRTL_API void rtlQStrToQStrX(size32_t & outlen, char * & out, size32_t inlen, const char *in);
  529. ECLRTL_API void rtlQStrToVStr(size32_t outlen, char * out, size32_t inlen, const char *in);
  530. ECLRTL_API void rtlStrToQStrNX(size32_t & outlen, char * & out, size32_t inlen, const void *in, size32_t logicalLength);
  531. ECLRTL_API int rtlCompareQStrQStr(size32_t llen, const void * left, size32_t rlen, const void * right);
  532. ECLRTL_API void rtlDecPushQStr(size32_t len, const void * data);
  533. ECLRTL_API bool rtlQStrToBool(size32_t inlen, const char * in);
  534. ECLRTL_API void rtlUnicodeToUnicode(size32_t outlen, UChar * out, size32_t inlen, UChar const *in);
  535. ECLRTL_API void rtlUnicodeToVUnicode(size32_t outlen, UChar * out, size32_t inlen, UChar const *in);
  536. ECLRTL_API void rtlVUnicodeToUnicode(size32_t outlen, UChar * out, UChar const *in);
  537. ECLRTL_API void rtlVUnicodeToVUnicode(size32_t outlen, UChar * out, UChar const *in);
  538. ECLRTL_API void rtlUnicodeToUnicodeX(unsigned & tlen, UChar * & tgt, unsigned slen, UChar const * src);
  539. ECLRTL_API UChar * rtlUnicodeToVUnicodeX(unsigned slen, UChar const * src);
  540. ECLRTL_API void rtlVUnicodeToUnicodeX(unsigned & tlen, UChar * & tgt, UChar const * src);
  541. ECLRTL_API UChar * rtlVUnicodeToVUnicodeX(UChar const * src);
  542. ECLRTL_API void rtlDecPushUnicode(size32_t len, UChar const * data);
  543. ECLRTL_API unsigned rtlUnicodeStrlen(UChar const * str);
  544. ECLRTL_API void rtlUnicodeStrcpy(UChar * tgt, UChar const * src);
  545. ECLRTL_API void rtlStrToVUnicode(unsigned outlen, UChar * out, unsigned inlen, char const * in);
  546. ECLRTL_API unsigned rtlUtf8Size(const void * data);
  547. ECLRTL_API unsigned rtlUtf8Size(unsigned len, const void * data);
  548. ECLRTL_API unsigned rtlUtf8Length(unsigned size, const void * data);
  549. ECLRTL_API unsigned rtlUtf8Char(const void * data);
  550. ECLRTL_API void rtlUtf8ToData(size32_t outlen, void * out, size32_t inlen, const char *in);
  551. ECLRTL_API void rtlUtf8ToDataX(size32_t & outlen, void * & out, size32_t inlen, const char *in);
  552. ECLRTL_API void rtlUtf8ToStr(size32_t outlen, char * out, size32_t inlen, const char *in);
  553. ECLRTL_API void rtlUtf8ToStrX(size32_t & outlen, char * & out, size32_t inlen, const char *in);
  554. ECLRTL_API char * rtlUtf8ToVStr(size32_t inlen, const char *in);
  555. ECLRTL_API void rtlDataToUtf8(size32_t outlen, char * out, size32_t inlen, const void *in);
  556. ECLRTL_API void rtlDataToUtf8X(size32_t & outlen, char * & out, size32_t inlen, const void *in);
  557. ECLRTL_API void rtlStrToUtf8(size32_t outlen, char * out, size32_t inlen, const char *in);
  558. ECLRTL_API void rtlStrToUtf8X(size32_t & outlen, char * & out, size32_t inlen, const char *in);
  559. ECLRTL_API void rtlUtf8ToUtf8(size32_t outlen, char * out, size32_t inlen, const char *in);
  560. ECLRTL_API void rtlUtf8ToUtf8X(size32_t & outlen, char * & out, size32_t inlen, const char *in);
  561. ECLRTL_API int rtlCompareUtf8Utf8(size32_t llen, const char * left, size32_t rlen, const char * right, const char * locale);
  562. ECLRTL_API int rtlCompareUtf8Utf8Strength(size32_t llen, const char * left, size32_t rlen, const char * right, const char * locale, unsigned strength);
  563. ECLRTL_API void rtlDecPushUtf8(size32_t len, const void * data);
  564. ECLRTL_API bool rtlUtf8ToBool(size32_t inlen, const char * in);
  565. ECLRTL_API __int64 rtlUtf8ToInt(size32_t inlen, const char * in);
  566. ECLRTL_API double rtlUtf8ToReal(size32_t inlen, const char * in);
  567. ECLRTL_API void rtlCodepageToUtf8(unsigned outlen, char * out, unsigned inlen, char const * in, char const * codepage);
  568. ECLRTL_API void rtlCodepageToUtf8X(unsigned & outlen, char * & out, unsigned inlen, char const * in, char const * codepage);
  569. ECLRTL_API void rtlUtf8ToCodepage(unsigned outlen, char * out, unsigned inlen, char const * in, char const * codepage);
  570. ECLRTL_API void rtlUtf8ToCodepageX(unsigned & outlen, char * & out, unsigned inlen, char const * in, char const * codepage);
  571. ECLRTL_API void rtlUnicodeToUtf8X(unsigned & outlen, char * & out, unsigned inlen, const UChar * in);
  572. ECLRTL_API void rtlUnicodeToUtf8(unsigned outlen, char * out, unsigned inlen, const UChar * in);
  573. ECLRTL_API void rtlUtf8ToUnicodeX(unsigned & outlen, UChar * & out, unsigned inlen, char const * in);
  574. ECLRTL_API void rtlUtf8ToUnicode(unsigned outlen, UChar * out, unsigned inlen, char const * in);
  575. ECLRTL_API void rtlUtf8SubStrFTX(unsigned & tlen, char * & tgt, unsigned slen, char const * src, unsigned from, unsigned to);
  576. ECLRTL_API void rtlUtf8SubStrFX(unsigned & tlen, char * & tgt, unsigned slen, char const * src, unsigned from);
  577. ECLRTL_API void rtlUtf8SubStrFT(unsigned tlen, char * tgt, unsigned slen, char const * src, unsigned from, unsigned to);
  578. ECLRTL_API void rtlUtf8ToLower(size32_t l, char * t, char const * locale);
  579. ECLRTL_API void rtlConcatUtf8(unsigned & tlen, char * * tgt, ...);
  580. ECLRTL_API unsigned rtlConcatUtf8ToUtf8(unsigned tlen, char * tgt, unsigned idx, unsigned slen, const char * src);
  581. ECLRTL_API void rtlUtf8SpaceFill(unsigned tlne, char * tgt, unsigned idx);
  582. ECLRTL_API ICompiledStrRegExpr * rtlCreateCompiledStrRegExpr(const char * regExpr, bool isCaseSensitive);
  583. ECLRTL_API void rtlDestroyCompiledStrRegExpr(ICompiledStrRegExpr * compiled);
  584. ECLRTL_API void rtlDestroyStrRegExprFindInstance(IStrRegExprFindInstance * compiled);
  585. ECLRTL_API ICompiledUStrRegExpr * rtlCreateCompiledUStrRegExpr(const UChar * regExpr, bool isCaseSensitive);
  586. ECLRTL_API void rtlDestroyCompiledUStrRegExpr(ICompiledUStrRegExpr * compiled);
  587. ECLRTL_API void rtlDestroyUStrRegExprFindInstance(IUStrRegExprFindInstance * compiled);
  588. ECLRTL_API void rtlCreateRange(size32_t & outlen, char * & out, unsigned fieldLen, unsigned compareLen, size32_t len, const char * str, byte fill, byte pad);
  589. ECLRTL_API void rtlCreateRangeLow(size32_t & outlen, char * & out, unsigned fieldLen, unsigned compareLen, size32_t len, const char * str);
  590. ECLRTL_API void rtlCreateRangeHigh(size32_t & outlen, char * & out, unsigned fieldLen, unsigned compareLen, size32_t len, const char * str);
  591. ECLRTL_API void rtlCreateDataRangeLow(size32_t & outlen, void * & out, unsigned fieldLen, unsigned compareLen, size32_t len, const void * str);
  592. ECLRTL_API void rtlCreateDataRangeHigh(size32_t & outlen, void * & out, unsigned fieldLen, unsigned compareLen, size32_t len, const void * str);
  593. ECLRTL_API void rtlCreateStrRangeLow(size32_t & outlen, char * & out, unsigned fieldLen, unsigned compareLen, size32_t len, const char * str);
  594. ECLRTL_API void rtlCreateStrRangeHigh(size32_t & outlen, char * & out, unsigned fieldLen, unsigned compareLen, size32_t len, const char * str);
  595. ECLRTL_API void rtlCreateQStrRangeLow(size32_t & outlen, char * & out, unsigned fieldLen, unsigned compareLen, size32_t len, const char * str);
  596. ECLRTL_API void rtlCreateQStrRangeHigh(size32_t & outlen, char * & out, unsigned fieldLen, unsigned compareLen, size32_t len, const char * str);
  597. ECLRTL_API void rtlCreateUnicodeRangeLow(size32_t & outlen, UChar * & out, unsigned fieldLen, unsigned compareLen, size32_t len, const UChar * str);
  598. ECLRTL_API void rtlCreateUnicodeRangeHigh(size32_t & outlen, UChar * & out, unsigned fieldLen, unsigned compareLen, size32_t len, const UChar * str);
  599. ECLRTL_API unsigned rtlCountRows(size32_t len, const void * data, IRecordSize * rs);
  600. ECLRTL_API unsigned rtlCountToSize(unsigned count, const void * data, IRecordSize * rs);
  601. ECLRTL_API void rtlSetToSetX(bool & outIsAll, size32_t & outLen, void * & outData, bool inIsAll, size32_t inLen, void * inData);
  602. ECLRTL_API void rtlAppendSetX(bool & outIsAll, size32_t & outLen, void * & outData, bool leftIsAll, size32_t leftLen, void * leftData, bool rightIsAll, size32_t rightLen, void * rightData);
  603. // rtlCodepageConvert uses a target buffer provided by the user (and returns the length actually used)
  604. // rtlCodepageConvertX allocates the target buffer itself (user must free)
  605. // If you can guess an upper bound on the target length, the rtlCodepageConvert will be more efficient.
  606. // I believe, for example, that when converting from UTF-8 to any single byte encoding, the target cannot be longer than the source.
  607. // If you can't guess an upper bound, rtlCodepageConvertX comes in two forms, with and without preflighting.
  608. // Switching preflighting on optimizes for memory, the returned buffer is exactly the required size.
  609. // Switching preflighting off optimizes for speed, the returned buffer is the maximum possible size (unicode size * max bytes per char).
  610. // For acceptible names of codepages, see system/icu/include/codepages.txt
  611. ECLRTL_API void * rtlOpenCodepageConverter(char const * sourceName, char const * targetName, bool & failed);
  612. ECLRTL_API void rtlCloseCodepageConverter(void * converter);
  613. ECLRTL_API unsigned rtlCodepageConvert(void * converter, unsigned targetLength, char * target, unsigned sourceLength, char const * source, bool & failed);
  614. ECLRTL_API void rtlCodepageConvertX(void * converter, unsigned & targetLength, char * & target, unsigned sourceLength, char const * source, bool & failed, bool preflight);
  615. ECLRTL_API void xmlDecodeStrX(size32_t & outLen, char * & out, size32_t inLen, const char * in);
  616. ECLRTL_API void xmlDecodeUStrX(size32_t & outLen, UChar * & out, size32_t inLen, const UChar * in);
  617. ECLRTL_API void xmlEncodeStrX(size32_t & outLen, char * & out, size32_t inLen, const char * in, unsigned flags);
  618. ECLRTL_API void xmlEncodeUStrX(size32_t & outLen, UChar * & out, size32_t inLen, const UChar * in, unsigned flags);
  619. ECLRTL_API bool rtlCsvStrToBool(size32_t l, const char * t);
  620. ECLRTL_API void rtlHashMd5Init(size32_t sizestate, void * _state);
  621. ECLRTL_API void rtlHashMd5Data(size32_t len, const void *buf, size32_t sizestate, void * _state);
  622. ECLRTL_API void rtlHashMd5Finish(void * out, size32_t sizestate, void * _state);
  623. ECLRTL_API void rtlExtractTag(size32_t & outLen, char * & out, const char * text, const char * tag, const char * rootTag);
  624. ECLRTL_API void rtlExceptionExtract(size32_t & outLen, char * & out, const char * text, const char * tag);
  625. ECLRTL_API void rtlExceptionExtract(size32_t & outLen, char * & out, IException * e, const char * tag);
  626. ECLRTL_API void rtlAddExceptionTag(StringBuffer & errorText, const char * tag, const char * value);
  627. ECLRTL_API int rtlQueryLocalFailCode(IException * e);
  628. ECLRTL_API void rtlGetLocalFailMessage(size32_t & len, char * & text, IException * e, const char * tag);
  629. ECLRTL_API void rtlFreeException(IException * e);
  630. ECLRTL_API IAtom * rtlCreateFieldNameAtom(const char * name);
  631. /**
  632. * Wrapper function to encode input binary data with base 64 code.
  633. *
  634. * @param tlen Encoded string length
  635. * @param tgt Pointer to encoded string
  636. * @param slen Input binary data length
  637. * @param src Pointer to input binary data
  638. * @see void JBASE64_Encode(const void *data, long length, StringBuffer &out, bool addLineBreaks=true)
  639. * function in jutil library
  640. */
  641. ECLRTL_API void rtlBase64Encode(size32_t & tlen, char * & tgt, size32_t slen, const void * src);
  642. /**
  643. * Wrapper function to decode base 64 encoded string.
  644. * It handles when the decoder fails to decode string.
  645. *
  646. * @param tlen Decoded data length
  647. * @param tgt Pointer to decoded data
  648. * @param slen Input string length
  649. * @param src Pointer to input string
  650. * @see bool JBASE64_Decode(const char *in, long length, StringBuffer &out) function
  651. * in jutil library.
  652. */
  653. ECLRTL_API void rtlBase64Decode(size32_t & tlen, void * & tgt, size32_t slen, const char * src);
  654. //Test functions:
  655. ECLRTL_API void rtlTestGetPrimes(size32_t & len, void * & data);
  656. ECLRTL_API void rtlTestFibList(bool & outAll, size32_t & outSize, void * & outData, bool inAll, size32_t inSize, const void * inData);
  657. ECLRTL_API unsigned rtlTick();
  658. ECLRTL_API unsigned rtlDelayReturn(unsigned value, unsigned sleepTime);
  659. ECLRTL_API bool rtlGPF();
  660. //-----------------------------------------------------------------------------
  661. interface IEmbedFunctionContext : extends IInterface
  662. {
  663. virtual void bindBooleanParam(const char *name, bool val) = 0;
  664. virtual void bindDataParam(const char *name, size32_t len, const void *val) = 0;
  665. virtual void bindRealParam(const char *name, double val) = 0;
  666. virtual void bindSignedParam(const char *name, __int64 val) = 0;
  667. virtual void bindUnsignedParam(const char *name, unsigned __int64 val) = 0;
  668. virtual void bindStringParam(const char *name, size32_t len, const char *val) = 0;
  669. virtual void bindVStringParam(const char *name, const char *val) = 0;
  670. virtual void bindUTF8Param(const char *name, size32_t chars, const char *val) = 0;
  671. virtual void bindUnicodeParam(const char *name, size32_t chars, const UChar *val) = 0;
  672. virtual void bindSetParam(const char *name, int elemType, size32_t elemSize, bool isAll, size32_t totalBytes, void *setData) = 0;
  673. virtual bool getBooleanResult() = 0;
  674. virtual void getDataResult(size32_t &len, void * &result) = 0;
  675. virtual double getRealResult() = 0;
  676. virtual __int64 getSignedResult() = 0;
  677. virtual unsigned __int64 getUnsignedResult() = 0;
  678. virtual void getStringResult(size32_t &len, char * &result) = 0;
  679. virtual void getUTF8Result(size32_t &chars, char * &result) = 0;
  680. virtual void getUnicodeResult(size32_t &chars, UChar * &result) = 0;
  681. virtual void getSetResult(bool & __isAllResult, size32_t & __resultBytes, void * & __result, int elemType, size32_t elemSize) = 0;
  682. virtual void importFunction(size32_t len, const char *function) = 0;
  683. virtual void compileEmbeddedScript(size32_t len, const char *script) = 0;
  684. virtual void callFunction() = 0;
  685. };
  686. interface IEmbedContext : extends IInterface
  687. {
  688. virtual IEmbedFunctionContext *createFunctionContext(bool isImport, const char *options) = 0;
  689. // MORE - add syntax checked here!
  690. };
  691. #endif