NativeString.hx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package eval;
  2. import haxe.io.Bytes;
  3. @:coreType abstract NativeString {
  4. /** String length */
  5. public var length(get,never):Int;
  6. function get_length():Int;
  7. @:from static public function fromString(s:String):NativeString;
  8. @:from static public function fromBytes(b:Bytes):NativeString;
  9. /**
  10. Returns a character at the specified `index`.
  11. Throws an exception if `index` is outside of the string bounds.
  12. **/
  13. public function char(index:Int):String;
  14. /**
  15. Returns a character code at the specified `index`.
  16. Throws an exception if `index` is outside of the string bounds.
  17. **/
  18. public function code(index:Int):Int;
  19. /**
  20. Returns a fresh string up to `length` characters long, containing the
  21. substring that starts at position `start`.
  22. If `length` is not specified the all characters from `start` to the end
  23. of this string are returned.
  24. Throws an exception if `index` is outside of the string bounds.
  25. **/
  26. public function sub(start:Int, ?length:Int):NativeString;
  27. public function toString():String;
  28. public function toBytes():Bytes;
  29. @:op(A + B)
  30. public function concat(s:NativeString):NativeString;
  31. }