PageRenderTime 41ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/hphp/runtime/ext/ext_string.h

https://github.com/tstarling/hiphop-php
C Header | 191 lines | 137 code | 30 blank | 24 comment | 0 complexity | 0052017321baf7658ff2346f5d363274 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/base/base-includes.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. #include "hphp/runtime/ext/ext_class.h"
  26. namespace HPHP {
  27. ///////////////////////////////////////////////////////////////////////////////
  28. // transformations and manipulations
  29. String f_addcslashes(const String& str, const String& charlist);
  30. String f_stripcslashes(const String& str);
  31. String f_addslashes(const String& str);
  32. String f_stripslashes(const String& str);
  33. String f_bin2hex(const String& str);
  34. Variant f_hex2bin(const String& str);
  35. String f_nl2br(const String& str, bool is_xhtml = true);
  36. String f_quotemeta(const String& str);
  37. String f_str_shuffle(const String& str);
  38. String f_strrev(const String& str);
  39. String f_strtolower(String str);
  40. String f_strtoupper(String str);
  41. String f_ucfirst(String str);
  42. String f_lcfirst(String str);
  43. String f_ucwords(String str);
  44. String f_strip_tags(const String& str, const String& allowable_tags = "");
  45. String f_trim(String str, const String& charlist = k_HPHP_TRIM_CHARLIST);
  46. String f_ltrim(String str, const String& charlist = k_HPHP_TRIM_CHARLIST);
  47. String f_rtrim(String str, const String& charlist = k_HPHP_TRIM_CHARLIST);
  48. String f_chop(String str, const String& charlist = k_HPHP_TRIM_CHARLIST);
  49. Variant f_explode(const String& delimiter, const String& str, int limit = 0x7FFFFFFF);
  50. String f_implode(const Variant& arg1, const Variant& arg2 = null_variant);
  51. String f_join(const Variant& glue, const Variant& pieces = null_variant);
  52. Variant f_str_split(const String& str, int split_length = 1);
  53. Variant f_chunk_split(const String& body, int chunklen = 76,
  54. const String& end = "\r\n");
  55. Variant f_strtok(const String& str, const Variant& token = null_variant);
  56. Variant f_str_replace(const Variant& search, const Variant& replace, const Variant& subject,
  57. VRefParam count = uninit_null());
  58. Variant f_str_ireplace(const Variant& search, const Variant& replace, const Variant& subject,
  59. VRefParam count = uninit_null());
  60. Variant f_substr_replace(const Variant& str, const Variant& replacement, const Variant& start,
  61. const Variant& length = 0x7FFFFFFF);
  62. Variant f_substr(const String& str, int start, int length = 0x7FFFFFFF);
  63. String f_str_pad(const String& input, int pad_length, const String& pad_string = " ",
  64. int pad_type = k_STR_PAD_RIGHT);
  65. String f_str_repeat(const String& input, int multiplier);
  66. ///////////////////////////////////////////////////////////////////////////////
  67. // encoding/decoding
  68. String f_html_entity_decode(const String& str, int quote_style = k_ENT_COMPAT,
  69. const String& charset = "UTF-8");
  70. String f_htmlentities(const String& str, int quote_style = k_ENT_COMPAT,
  71. const String& charset = "UTF-8",
  72. bool double_encode = true);
  73. String f_htmlspecialchars_decode(const String& str,
  74. int quote_style = k_ENT_COMPAT);
  75. String f_htmlspecialchars(const String& str, int quote_style = k_ENT_COMPAT,
  76. const String& charset = "UTF-8",
  77. bool double_encode = true);
  78. String f_fb_htmlspecialchars(const String& str, int quote_style = k_ENT_COMPAT,
  79. const String& charset = "ISO-8859-1",
  80. const Array& extra = empty_array);
  81. String f_quoted_printable_encode(const String& str);
  82. String f_quoted_printable_decode(const String& str);
  83. Variant f_convert_uudecode(const String& data);
  84. Variant f_convert_uuencode(const String& data);
  85. String f_str_rot13(const String& str);
  86. int64_t f_crc32(const String& str);
  87. String f_crypt(const String& str, const String& salt = "");
  88. String f_md5(const String& str, bool raw_output = false);
  89. String f_sha1(const String& str, bool raw_output = false);
  90. Variant f_strtr(const String& str, const Variant& from, const Variant& to = null_variant);
  91. String f_convert_cyr_string(const String& str, const String& from, const String& to);
  92. Array f_get_html_translation_table(int table = 0,
  93. int quote_style = k_ENT_COMPAT,
  94. const String& encoding = "UTF-8");
  95. String f_hebrev(const String& hebrew_text, int max_chars_per_line = 0);
  96. String f_hebrevc(const String& hebrew_text, int max_chars_per_line = 0);
  97. Variant f_setlocale(int _argc, int category, const Variant& locale, const Array& _argv = null_array);
  98. Array f_localeconv();
  99. String f_nl_langinfo(int item);
  100. ///////////////////////////////////////////////////////////////////////////////
  101. // input/output
  102. Variant f_printf(int _argc, const String& format, const Array& _argv = null_array);
  103. Variant f_vprintf(const String& format, const Array& args);
  104. Variant f_sprintf(int _argc, const String& format, const Array& _argv = null_array);
  105. Variant f_vsprintf(const String& format, const Array& args);
  106. Variant f_sscanf(int _argc, const String& str, const String& format, const Array& _argv = null_array);
  107. String f_chr(int64_t ascii);
  108. int64_t f_ord(const String& str);
  109. Variant f_money_format(const String& format, double number);
  110. String f_number_format(double number, int decimals = 0, const Variant& dec_point = ".",
  111. const Variant& thousands_sep = ",");
  112. ///////////////////////////////////////////////////////////////////////////////
  113. // analysis
  114. int64_t f_strcmp(const String& str1, const String& str2);
  115. Variant f_strncmp(const String& str1, const String& str2, int len);
  116. int64_t f_strnatcmp(const String& str1, const String& str2);
  117. int64_t f_strcasecmp(const String& str1, const String& str2);
  118. Variant f_strncasecmp(const String& str1, const String& str2, int len);
  119. int64_t f_strnatcasecmp(const String& str1, const String& str2);
  120. int64_t f_strcoll(const String& str1, const String& str2);
  121. Variant f_substr_compare(const String& main_str, const String& str, int offset,
  122. int length = INT_MAX, bool case_insensitivity = false);
  123. Variant f_strrchr(const String& haystack, const Variant& needle);
  124. Variant f_strstr(const String& haystack, const Variant& needle, bool before_needle = false);
  125. Variant f_stristr(const String& haystack, const Variant& needle);
  126. Variant f_strpbrk(const String& haystack, const String& char_list);
  127. Variant f_strchr(const String& haystack, const Variant& needle);
  128. Variant f_strpos(const String& haystack, const Variant& needle, int offset = 0);
  129. Variant f_stripos(const String& haystack, const Variant& needle, int offset = 0);
  130. Variant f_strrpos(const String& haystack, const Variant& needle, int offset = 0);
  131. Variant f_strripos(const String& haystack, const Variant& needle, int offset = 0);
  132. Variant f_substr_count(const String& haystack, const String& needle, int offset = 0,
  133. int length = 0x7FFFFFFF);
  134. Variant f_strspn(const String& str1, const String& str2, int start = 0,
  135. int length = 0x7FFFFFFF);
  136. Variant f_strcspn(const String& str1, const String& str2, int start = 0,
  137. int length = 0x7FFFFFFF);
  138. Variant f_strlen(const Variant& vstr);
  139. Array f_str_getcsv(const String& str,
  140. const String& delimiter = ",",
  141. const String& enclosure = "\"",
  142. const String& escape = "\\");
  143. Variant f_count_chars(const String& str, int64_t mode = 0);
  144. Variant f_str_word_count(const String& str, int64_t format = 0, const String& charlist = "");
  145. int64_t f_levenshtein(const String& str1, const String& str2, int cost_ins = 1,
  146. int cost_rep = 1, int cost_del = 1);
  147. int64_t f_similar_text(const String& first, const String& second, VRefParam percent = uninit_null());
  148. Variant f_soundex(const String& str);
  149. Variant f_metaphone(const String& str, int phones = 0);
  150. ///////////////////////////////////////////////////////////////////////////////
  151. // special
  152. void f_parse_str(const String& str, VRefParam arr = uninit_null());
  153. ///////////////////////////////////////////////////////////////////////////////
  154. }
  155. #endif