serialize()

This commit is contained in:
2022-03-04 14:32:09 +03:00
parent 8c9431460e
commit 6cc3acea1d
19 changed files with 295 additions and 45 deletions

View File

@@ -66,3 +66,11 @@ bool string_compare(string str0, string str1){
return false;
return true;
}
//creates new string which is reversed variant of <s>
string string_reverse(string s){
string r={malloc(s.length), s.length};
for(uint32 i; i<s.length; i++)
r.ptr[i]=s.ptr[s.length-i-1];
return r;
}

View File

@@ -31,3 +31,6 @@ string string_cpFromCharPtr(char* cptr);
//compares two strings, NullPtr-friendly
bool string_compare(string str0, string str1);
//creates new string which is reversed variant of <s>
string string_reverse(string s);

View File

@@ -114,3 +114,16 @@ void Unitype_free(Unitype u){
default: throw(ERR_WRONGTYPE);
}
}
void printuni(Unitype v){
switch (v.type) {
case Null: printf("{Null}");break;
case Double: printf("{%s:%lf}",typename(v.type),v.Double);break;
case Char: printf("{%s:%c}",typename(v.type),v.Char);break;
case Bool:
case UInt64: printf("{%s:%lu}",typename(v.type),v.UInt64);break;
case Int64: printf("{%s:%ld}",typename(v.type),v.Int64);break;
default: printf("{%s:%p}",typename(v.type),v.VoidPtr);break;
}
}

View File

@@ -49,3 +49,4 @@ static const Unitype UniFalse={Bool,.Bool=false};
//frees VoidPtr value or does nothing if type isn't pointer
void Unitype_free(Unitype u);
void printuni(Unitype v);