String.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. function String() {
  2. Object.defineProperties(this, {
  3. 'contents': { enumerable: true, configurable: true, get: String.prototype.__get_contents, set: String.prototype.__set_contents},
  4. 'w_contents': { enumerable: true, configurable: true, get: String.prototype.__get_w_contents, set: String.prototype.__set_w_contents}
  5. })
  6. }
  7. String.prototype.__get_contents = function() {
  8. var retVal = new string()
  9. retVal.__ptr = Polycode.String__get_contents(this.__ptr)
  10. return retVal
  11. }
  12. String.prototype.__set_contents = function(val) {
  13. Polycode.String__set_contents(this.__ptr, val.__ptr)
  14. }
  15. String.prototype.__get_w_contents = function() {
  16. var retVal = new wstring()
  17. retVal.__ptr = Polycode.String__get_w_contents(this.__ptr)
  18. return retVal
  19. }
  20. String.prototype.__set_w_contents = function(val) {
  21. Polycode.String__set_w_contents(this.__ptr, val.__ptr)
  22. }
  23. String.prototype.size = function() {
  24. var retVal = new size_t()
  25. retVal.__ptr = Polycode.String_size(this.__ptr)
  26. return retVal
  27. }
  28. String.prototype.length = function() {
  29. var retVal = new size_t()
  30. retVal.__ptr = Polycode.String_length(this.__ptr)
  31. return retVal
  32. }
  33. String.prototype.substr = function(pos,n) {
  34. return Polycode.String_substr(this.__ptr, pos,n)
  35. }
  36. String.prototype.rfind = function(str,pos) {
  37. var retVal = new size_t()
  38. retVal.__ptr = Polycode.String_rfind(this.__ptr, str,pos)
  39. return retVal
  40. }
  41. String.prototype.find = function(str,pos) {
  42. var retVal = new size_t()
  43. retVal.__ptr = Polycode.String_find(this.__ptr, str,pos)
  44. return retVal
  45. }
  46. String.prototype.find_last_of = function(str,pos) {
  47. var retVal = new size_t()
  48. retVal.__ptr = Polycode.String_find_last_of(this.__ptr, str,pos)
  49. return retVal
  50. }
  51. String.prototype.find_first_of = function(str,pos) {
  52. var retVal = new size_t()
  53. retVal.__ptr = Polycode.String_find_first_of(this.__ptr, str,pos)
  54. return retVal
  55. }
  56. String.prototype.toLowerCase = function() {
  57. return Polycode.String_toLowerCase(this.__ptr)
  58. }
  59. String.prototype.toUpperCase = function() {
  60. return Polycode.String_toUpperCase(this.__ptr)
  61. }
  62. String.prototype.split = function(delim) {
  63. Polycode.String_split(this.__ptr, delim)
  64. }
  65. String.prototype.replace = function(what,withWhat) {
  66. return Polycode.String_replace(this.__ptr, what,withWhat)
  67. }
  68. String.prototype.toNumber = function() {
  69. return Polycode.String_toNumber(this.__ptr)
  70. }
  71. String.prototype.toInteger = function() {
  72. return Polycode.String_toInteger(this.__ptr)
  73. }
  74. String.prototype.c_str = function() {
  75. var retVal = new char()
  76. retVal.__ptr = Polycode.String_c_str(this.__ptr)
  77. return retVal
  78. }
  79. String.prototype.getDataWithEncoding = function(encoding) {
  80. var retVal = new char()
  81. retVal.__ptr = Polycode.String_getDataWithEncoding(this.__ptr, encoding)
  82. return retVal
  83. }
  84. String.prototype.getWDataWithEncoding = function(encoding) {
  85. var retVal = new wchar_t()
  86. retVal.__ptr = Polycode.String_getWDataWithEncoding(this.__ptr, encoding)
  87. return retVal
  88. }
  89. String.prototype.append = function(c) {
  90. Polycode.String_append(this.__ptr, c)
  91. }
  92. String.prototype.getDataSizeWithEncoding = function(encoding) {
  93. var retVal = new size_t()
  94. retVal.__ptr = Polycode.String_getDataSizeWithEncoding(this.__ptr, encoding)
  95. return retVal
  96. }
  97. String.prototype.setDataWithEncoding = function(data,encoding) {
  98. Polycode.String_setDataWithEncoding(this.__ptr, data,encoding)
  99. }
  100. String.prototype.isNumber = function() {
  101. return Polycode.String_isNumber(this.__ptr)
  102. }