From ec29c539742bade40d572945cb25507dbec11fa3 Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Mon, 14 Mar 2022 12:01:17 +0300 Subject: [PATCH] new functions for dtsod --- DtsodC/DtsodParser/DtsodV24.c | 27 +++++++++++++++++++++++++++ DtsodC/DtsodParser/DtsodV24.h | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 DtsodC/DtsodParser/DtsodV24.c diff --git a/DtsodC/DtsodParser/DtsodV24.c b/DtsodC/DtsodParser/DtsodV24.c new file mode 100644 index 0000000..bf8cbf2 --- /dev/null +++ b/DtsodC/DtsodParser/DtsodV24.c @@ -0,0 +1,27 @@ +#include "DtsodV24.h" + +//returns UniNull if key not found +Unitype DtsodV24_get(Hashtable* dtsod, char* key){ + return Hashtable_get(dtsod, key); +} + +//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 +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 +bool DtsodV24_remove(Hashtable* dtsod, char* key){ + Unitype* val=Hashtable_getptr(dtsod, key); + if (!val) return false; + *val=UniNull; + return true; +} diff --git a/DtsodC/DtsodParser/DtsodV24.h b/DtsodC/DtsodParser/DtsodV24.h index 465e13f..2b15f1a 100644 --- a/DtsodC/DtsodParser/DtsodV24.h +++ b/DtsodC/DtsodParser/DtsodV24.h @@ -1,6 +1,24 @@ +#if __cplusplus +extern "c" { +#endif + #pragma once #include "../base/base.h" #include "../Hashtable/Hashtable.h" +//parses text to binary values Hashtable* DtsodV24_deserialize(char* text); +//creates text representation of dtsod char* DtsodV24_serialize(Hashtable* dtsod); +//returns value or UniNull if key not found +Unitype DtsodV24_get(Hashtable* dtsod, char* key); +//adds or sets value +void DtsodV24_addOrSet(Hashtable* dtsod, char* key, Unitype value); +//checks for dtsod contains value or dont +bool DtsodV24_contains(Hashtable* dtsod, char* key); +//replaces value with UniNull if key exists in dtsod +bool DtsodV24_remove(Hashtable* dtsod, char* key); + +#if __cplusplus +} +#endif \ No newline at end of file