diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-30 23:41:21 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-30 23:41:34 +0000 |
| commit | 422616a43b4f9b7659c96bfffd2f3095461dbea5 (patch) | |
| tree | 33b52ba91695a1e816b6b5a45be485f603032626 /std/string.zc | |
| parent | 51638176265392c70ca2e0014de95867bac4991e (diff) | |
JSON serialization
Diffstat (limited to 'std/string.zc')
| -rw-r--r-- | std/string.zc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/std/string.zc b/std/string.zc index fe5b0ad..0bc9539 100644 --- a/std/string.zc +++ b/std/string.zc @@ -55,6 +55,28 @@ impl String { } } + fn append_c(self, s: char*) { + if (self.vec.len > 0) { + self.vec.len = self.vec.len - 1; + } + let len = strlen(s); + for (let i = 0; i < len; i = i + 1) { + self.vec.push(s[i]); + } + self.vec.push(0); + } + + fn append_c_ptr(ptr: String*, s: char*) { + if (ptr.vec.len > 0) { + ptr.vec.len = ptr.vec.len - 1; + } + let len = strlen(s); + for (let i = 0; i < len; i = i + 1) { + ptr.vec.push(s[i]); + } + ptr.vec.push(0); + } + fn add(self, other: String*) -> String { let new_s = String::from(self.c_str()); new_s.append(other); |
