PageRenderTime 23ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/hphp/runtime/ext/string/ext_string.h

https://gitlab.com/Blueprint-Marketing/hhvm
C Header | 346 lines | 308 code | 14 blank | 24 comment | 0 complexity | 9ddb2be18a998686763719eb73748a60 MD5 | raw file
  1. /*
  2. +----------------------------------------------------------------------+
  3. | HipHop for PHP |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 2010-2014 Facebook, Inc. (http://www.facebook.com) |
  6. | Copyright (c) 1997-2010 The PHP Group |
  7. +----------------------------------------------------------------------+
  8. | This source file is subject to version 3.01 of the PHP license, |
  9. | that is bundled with this package in the file LICENSE, and is |
  10. | available through the world-wide-web at the following url: |
  11. | http://www.php.net/license/3_01.txt |
  12. | If you did not receive a copy of the PHP license and are unable to |
  13. | obtain it through the world-wide-web, please send a note to |
  14. | license@php.net so we can mail you a copy immediately. |
  15. +----------------------------------------------------------------------+
  16. */
  17. #ifndef incl_HPHP_EXT_STRING_H_
  18. #define incl_HPHP_EXT_STRING_H_
  19. #include "hphp/zend/zend-html.h"
  20. #include "hphp/runtime/ext/extension.h"
  21. #include "hphp/runtime/base/zend-string.h"
  22. #include "hphp/runtime/base/zend-printf.h"
  23. #include "hphp/runtime/base/bstring.h"
  24. #include <langinfo.h>
  25. namespace HPHP {
  26. ///////////////////////////////////////////////////////////////////////////////
  27. // transformations and manipulations
  28. extern const HPHP::StaticString k_HPHP_TRIM_CHARLIST;
  29. extern const int64_t k_STR_PAD_RIGHT;
  30. extern const int64_t k_ENT_COMPAT;
  31. String HHVM_FUNCTION(addcslashes,
  32. const String& str,
  33. const String& charlist);
  34. String HHVM_FUNCTION(stripcslashes,
  35. const String& str);
  36. String HHVM_FUNCTION(addslashes,
  37. const String& str);
  38. String HHVM_FUNCTION(stripslashes,
  39. const String& str);
  40. String HHVM_FUNCTION(bin2hex,
  41. const String& str);
  42. Variant HHVM_FUNCTION(hex2bin,
  43. const String& str);
  44. String HHVM_FUNCTION(nl2br,
  45. const String& str,
  46. bool is_xhtml = true);
  47. String HHVM_FUNCTION(quotemeta,
  48. const String& str);
  49. String HHVM_FUNCTION(str_shuffle,
  50. const String& str);
  51. String HHVM_FUNCTION(strrev,
  52. const String& str);
  53. String HHVM_FUNCTION(strtolower,
  54. const String& str);
  55. String HHVM_FUNCTION(strtoupper,
  56. const String& str);
  57. String HHVM_FUNCTION(ucfirst,
  58. const String& str);
  59. String HHVM_FUNCTION(lcfirst,
  60. const String& str);
  61. String HHVM_FUNCTION(ucwords,
  62. const String& str);
  63. String HHVM_FUNCTION(strip_tags,
  64. const String& str,
  65. const Variant& allowable_tags = "");
  66. String HHVM_FUNCTION(trim,
  67. const String& str,
  68. const String& charlist = k_HPHP_TRIM_CHARLIST);
  69. String HHVM_FUNCTION(ltrim,
  70. const String& str,
  71. const String& charlist = k_HPHP_TRIM_CHARLIST);
  72. String HHVM_FUNCTION(rtrim,
  73. const String& str,
  74. const String& charlist = k_HPHP_TRIM_CHARLIST);
  75. String HHVM_FUNCTION(chop,
  76. const String& str,
  77. const String& charlist = k_HPHP_TRIM_CHARLIST);
  78. Variant HHVM_FUNCTION(explode,
  79. const String& delimiter,
  80. const String& str,
  81. int limit = 0x7FFFFFFF);
  82. String HHVM_FUNCTION(implode,
  83. const Variant& arg1,
  84. const Variant& arg2 = null_variant);
  85. String HHVM_FUNCTION(join,
  86. const Variant& arg1,
  87. const Variant& arg2 = null_variant);
  88. Variant HHVM_FUNCTION(str_split,
  89. const String& str,
  90. int64_t split_length = 1);
  91. Variant HHVM_FUNCTION(chunk_split,
  92. const String& body,
  93. int chunklen = 76,
  94. const String& end = "\r\n");
  95. Variant HHVM_FUNCTION(strtok,
  96. const String& str,
  97. const Variant& token = null_variant);
  98. Variant HHVM_FUNCTION(str_replace,
  99. const Variant& search,
  100. const Variant& replace,
  101. const Variant& subject,
  102. VRefParam count = uninit_null());
  103. Variant HHVM_FUNCTION(str_ireplace,
  104. const Variant& search,
  105. const Variant& replace,
  106. const Variant& subject,
  107. VRefParam count = uninit_null());
  108. Variant HHVM_FUNCTION(substr_replace,
  109. const Variant& str,
  110. const Variant& replacement,
  111. const Variant& start,
  112. const Variant& length = 0x7FFFFFFF);
  113. String HHVM_FUNCTION(str_pad,
  114. const String& input,
  115. int pad_length,
  116. const String& pad_string = " ",
  117. int pad_type = k_STR_PAD_RIGHT);
  118. String HHVM_FUNCTION(str_repeat,
  119. const String& input,
  120. int multiplier);
  121. ///////////////////////////////////////////////////////////////////////////////
  122. // encoding/decoding
  123. String HHVM_FUNCTION(html_entity_decode,
  124. const String& str,
  125. int quote_style = k_ENT_COMPAT,
  126. const String& charset = "UTF-8");
  127. String HHVM_FUNCTION(htmlentities,
  128. const String& str,
  129. int quote_style = k_ENT_COMPAT,
  130. const String& charset = "UTF-8",
  131. bool double_encode = true);
  132. String HHVM_FUNCTION(htmlspecialchars_decode,
  133. const String& str,
  134. int quote_style = k_ENT_COMPAT);
  135. String HHVM_FUNCTION(htmlspecialchars,
  136. const String& str,
  137. int quote_style = k_ENT_COMPAT,
  138. const String& charset = "UTF-8",
  139. bool double_encode = true);
  140. String HHVM_FUNCTION(fb_htmlspecialchars,
  141. const String& str,
  142. int quote_style = k_ENT_COMPAT,
  143. const String& charset = "ISO-8859-1",
  144. const Variant& extra = empty_array_ref);
  145. String HHVM_FUNCTION(quoted_printable_encode,
  146. const String& str);
  147. String HHVM_FUNCTION(quoted_printable_decode,
  148. const String& str);
  149. Variant HHVM_FUNCTION(convert_uudecode,
  150. const String& data);
  151. Variant HHVM_FUNCTION(convert_uuencode,
  152. const String& data);
  153. String HHVM_FUNCTION(str_rot13,
  154. const String& str);
  155. int64_t HHVM_FUNCTION(crc32,
  156. const String& str);
  157. String HHVM_FUNCTION(crypt,
  158. const String& str,
  159. const String& salt = "");
  160. String HHVM_FUNCTION(md5,
  161. const String& str,
  162. bool raw_output = false);
  163. String HHVM_FUNCTION(sha1,
  164. const String& str,
  165. bool raw_output = false);
  166. Variant HHVM_FUNCTION(strtr,
  167. const String& str,
  168. const Variant& from,
  169. const Variant& to = null_variant);
  170. String HHVM_FUNCTION(convert_cyr_string,
  171. const String& str,
  172. const String& from,
  173. const String& to);
  174. Array HHVM_FUNCTION(get_html_translation_table,
  175. int table = 0,
  176. int quote_style = k_ENT_COMPAT,
  177. const String& encoding = "UTF-8");
  178. String HHVM_FUNCTION(hebrev,
  179. const String& hebrew_text,
  180. int max_chars_per_line = 0);
  181. String HHVM_FUNCTION(hebrevc,
  182. const String& hebrew_text,
  183. int max_chars_per_line = 0);
  184. Variant HHVM_FUNCTION(setlocale,
  185. int category,
  186. const Variant& locale,
  187. const Array& _argv = null_array);
  188. Array HHVM_FUNCTION(localeconv);
  189. String HHVM_FUNCTION(nl_langinfo,
  190. int item);
  191. ///////////////////////////////////////////////////////////////////////////////
  192. // input/output
  193. Variant f_printf(int _argc,
  194. const String& format,
  195. const Array& _argv = null_array);
  196. Variant f_vprintf(const String& format,
  197. const Array& args);
  198. Variant f_sprintf(int _argc,
  199. const String& format,
  200. const Array& _argv = null_array);
  201. Variant f_vsprintf(const String& format,
  202. const Array& args);
  203. Variant sscanfImpl(const String& str,
  204. const String& format,
  205. const std::vector<Variant*>& args);
  206. TypedValue* HHVM_FN(sscanf)(ActRec* ar);
  207. String HHVM_FUNCTION(chr, const Variant& ascii);
  208. int64_t HHVM_FUNCTION(ord,
  209. const String& str);
  210. Variant HHVM_FUNCTION(money_format,
  211. const String& format,
  212. double number);
  213. String HHVM_FUNCTION(number_format,
  214. double number,
  215. int decimals = 0,
  216. const Variant& dec_point = ".",
  217. const Variant& thousands_sep = ",");
  218. ///////////////////////////////////////////////////////////////////////////////
  219. // analysis
  220. bool str_contains_any_of(const String& haystack, const String& char_list);
  221. int64_t HHVM_FUNCTION(strcmp,
  222. const String& str1,
  223. const String& str2);
  224. Variant HHVM_FUNCTION(strncmp,
  225. const String& str1,
  226. const String& str2,
  227. int len);
  228. int64_t HHVM_FUNCTION(strnatcmp,
  229. const String& str1,
  230. const String& str2);
  231. int64_t HHVM_FUNCTION(strcasecmp,
  232. const String& str1,
  233. const String& str2);
  234. Variant HHVM_FUNCTION(strncasecmp,
  235. const String& str1,
  236. const String& str2,
  237. int len);
  238. int64_t HHVM_FUNCTION(strnatcasecmp,
  239. const String& str1,
  240. const String& str2);
  241. int64_t HHVM_FUNCTION(strcoll,
  242. const String& str1,
  243. const String& str2);
  244. Variant HHVM_FUNCTION(substr_compare,
  245. const String& main_str,
  246. const String& str,
  247. int offset,
  248. int length = INT_MAX,
  249. bool case_insensitivity = false);
  250. Variant HHVM_FUNCTION(strchr,
  251. const String& haystack,
  252. const Variant& needle);
  253. Variant HHVM_FUNCTION(strrchr,
  254. const String& haystack,
  255. const Variant& needle);
  256. Variant HHVM_FUNCTION(strstr,
  257. const String& haystack,
  258. const Variant& needle,
  259. bool before_needle = false);
  260. Variant HHVM_FUNCTION(stristr,
  261. const String& haystack,
  262. const Variant& needle,
  263. bool before_needle = false);
  264. Variant HHVM_FUNCTION(strpbrk,
  265. const String& haystack,
  266. const String& char_list);
  267. Variant HHVM_FUNCTION(strpos,
  268. const String& haystack,
  269. const Variant& needle,
  270. int offset = 0);
  271. Variant HHVM_FUNCTION(stripos,
  272. const String& haystack,
  273. const Variant& needle,
  274. int offset = 0);
  275. Variant HHVM_FUNCTION(strrpos,
  276. const String& haystack,
  277. const Variant& needle,
  278. int offset = 0);
  279. Variant HHVM_FUNCTION(strripos,
  280. const String& haystack,
  281. const Variant& needle,
  282. int offset = 0);
  283. Variant HHVM_FUNCTION(substr_count,
  284. const String& haystack,
  285. const String& needle,
  286. int offset = 0,
  287. int length = 0x7FFFFFFF);
  288. Variant HHVM_FUNCTION(strspn,
  289. const String& str1,
  290. const String& str2,
  291. int start = 0,
  292. int length = 0x7FFFFFFF);
  293. Variant HHVM_FUNCTION(strcspn,
  294. const String& str1,
  295. const String& str2,
  296. int start = 0,
  297. int length = 0x7FFFFFFF);
  298. Variant HHVM_FUNCTION(strlen,
  299. const Variant& vstr);
  300. Array HHVM_FUNCTION(str_getcsv,
  301. const String& str,
  302. const String& delimiter = ",",
  303. const String& enclosure = "\"",
  304. const String& escape = "\\");
  305. Variant HHVM_FUNCTION(count_chars,
  306. const String& str,
  307. int64_t mode = 0);
  308. Variant HHVM_FUNCTION(str_word_count,
  309. const String& str,
  310. int64_t format = 0,
  311. const String& charlist = "");
  312. int64_t HHVM_FUNCTION(levenshtein,
  313. const String& str1,
  314. const String& str2,
  315. int cost_ins = 1,
  316. int cost_rep = 1,
  317. int cost_del = 1);
  318. int64_t HHVM_FUNCTION(similar_text,
  319. const String& first,
  320. const String& second,
  321. VRefParam percent = uninit_null());
  322. Variant HHVM_FUNCTION(soundex,
  323. const String& str);
  324. Variant HHVM_FUNCTION(metaphone,
  325. const String& str,
  326. int phones = 0);
  327. ///////////////////////////////////////////////////////////////////////////////
  328. }
  329. #endif