finally returned strings

This commit is contained in:
2022-04-17 00:38:05 +03:00
parent f6b51dbc6e
commit b4f2ca92c7
34 changed files with 247 additions and 276 deletions

View File

@@ -1,24 +1,24 @@
#include "DtsodV24.h"
// returns UniNull if key not found
//returns UniNull if key not found
Unitype DtsodV24_get(Hashtable* dtsod, char* key){
return Hashtable_get(dtsod, key);
}
// adds or sets value
//adds or sets value
void DtsodV24_addOrSet(Hashtable* dtsod, char* key, Unitype value){
Unitype* val=Hashtable_getptr(dtsod, key);
if(val) *val=value;
else Hashtable_add(dtsod, key, value);
}
// checks for dtsod contains value or dont
//checks for dtsod contains value or dont
bool DtsodV24_contains(Hashtable* dtsod, char* key){
Unitype* val=Hashtable_getptr(dtsod, key);
return val!=NULL;
}
// replaces value with UniNull if key exists in dtsod
//replaces value with UniNull if key exists in dtsod
bool DtsodV24_remove(Hashtable* dtsod, char* key){
Unitype* val=Hashtable_getptr(dtsod, key);
if (!val) return false;
@@ -26,7 +26,7 @@ bool DtsodV24_remove(Hashtable* dtsod, char* key){
return true;
}
// frees memory including memory of elements (hashtables, autoarrs, etc.)
//frees memory including memory of elements (hashtables, autoarrs, etc.)
void DtsodV24_free(Hashtable* dtsod){
Hashtable_free(dtsod);
}

View File

@@ -9,22 +9,22 @@ extern "C" {
//parses text to binary values
Maybe DtsodV24_deserialize(char* text);
// creates text representation of dtsod
//creates text representation of dtsod
char* DtsodV24_serialize(Hashtable* dtsod);
// returns value or UniNull if key not found
//returns value or UniNull if key not found
Unitype DtsodV24_get(Hashtable* dtsod, char* key);
// adds or sets value
//adds or sets value
void DtsodV24_addOrSet(Hashtable* dtsod, char* key, Unitype value);
// checks for dtsod contains value or dont
//checks for dtsod contains value or dont
bool DtsodV24_contains(Hashtable* dtsod, char* key);
// replaces value with UniNull if key exists in dtsod
//replaces value with UniNull if key exists in dtsod
bool DtsodV24_remove(Hashtable* dtsod, char* key);
// frees memory including memory of elements (hashtables, autoarrs, etc.)
//frees memory including memory of elements (hashtables, autoarrs, etc.)
void DtsodV24_free(Hashtable* dtsod);
#if __cplusplus

View File

@@ -1,8 +1,8 @@
//
//
// I planned to export functions from DtsodV24.h,
// but C# P/Invoke can't get returned values for some reason.
// Following functions return values by pointer, which looks in C# like out parameter
//
//
#if __cplusplus
extern "C" {
@@ -10,39 +10,39 @@ extern "C" {
#include "DtsodV24.h"
// parses text to binary values
//parses text to binary values
EXPORT void CALL kerep_DtsodV24_deserialize(char* text, Hashtable** output, char** errmsg){
Maybe r=DtsodV24_deserialize(text);
*errmsg= r.errmsg ? r.errmsg : NULL;
*output=r.value.VoidPtr;
}
// creates text representation of dtsod
//creates text representation of dtsod
EXPORT void CALL kerep_DtsodV24_serialize(Hashtable* dtsod, char** output){
*output=DtsodV24_serialize(dtsod);
}
// returns value or UniNull if key not found
//returns value or UniNull if key not found
EXPORT void CALL kerep_DtsodV24_get(Hashtable* dtsod, char* key, Unitype* output){
*output=DtsodV24_get(dtsod, key);
}
// adds or sets the value
//adds or sets the value
EXPORT void CALL kerep_DtsodV24_addOrSet(Hashtable* dtsod, char* key, Unitype value){
DtsodV24_addOrSet(dtsod, key, value);
}
// checks for dtsod contains value or dont
//checks for dtsod contains value or dont
EXPORT void CALL kerep_DtsodV24_contains(Hashtable* dtsod, char* key, bool* output){
*output=DtsodV24_contains(dtsod, key);
}
// replaces value with UniNull if key exists in dtsod
//replaces value with UniNull if key exists in dtsod
EXPORT void CALL kerep_DtsodV24_remove(Hashtable* dtsod, char* key, bool* output){
*output=DtsodV24_remove(dtsod, key);
}
// replaces value with UniNull if key exists in dtsod
//replaces value with UniNull if key exists in dtsod
EXPORT void CALL kerep_DtsodV24_free(Hashtable* dtsod){
DtsodV24_free(dtsod);
}

View File

@@ -1,7 +1,7 @@
#include "DtsodV24.h"
#include "../Autoarr/StringBuilder.h"
// 65536 max length!
//65536 max length!
#define STRB_BC 64
#define STRB_BL 1024
@@ -47,11 +47,6 @@ void __AppendValue(SerializeSharedData* shared, Unitype u){
}
addc('"');
break;
case Char:
addc('\'');
addc(u.Char);
addc('\'');
break;
case Bool:
StringBuilder_append_cptr(b, u.Bool ? "true" : "false");
break;