8b66384b4def433f398d12dfd2e7e802116fe147
1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # This file is free software, which comes along with NIT. This software is
4 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
5 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
7 # is kept unaltered, and a notification of the changes is added.
8 # You are allowed to redistribute it and sell it, alone or is a part of
11 # Native structures for text and bytes
16 # Native strings are simple C char *
17 extern class NativeString `{ char* `}
18 # Creates a new NativeString with a capacity of `length
`
19 new(length: Int) is intern
21 # Returns a char* starting at `index
`.
23 # WARNING: Unsafe for extern code, use only for temporary
24 # pointer manipulation purposes (e.g. write to file or such)
25 fun fast_cstring(index: Int): NativeString is intern
27 # Get char at `index
`.
28 fun [](index: Int): Byte is intern
30 # Set char `item
` at index.
31 fun []=(index: Int, item: Byte) is intern
33 # Copy `self` to `dest
`.
34 fun copy_to(dest: NativeString, length: Int, from: Int, to: Int) is intern
36 # Position of the first nul character.
37 fun cstring_length: Int
40 while self[l] != 0u8 do l += 1
44 # Parse `self` as an Int.
45 fun atoi: Int is intern
47 # Parse `self` as a Float.
48 fun atof: Float `{ return atof(self); `}