libsheepy

C lib for handling text files, strings and json like data structure with an object oriented system
git clone https://spartatek.se/git/libsheepy.git
Log | Files | Refs | README | LICENSE

libsheepyCSmallJson.c (795251B)


      1 // MIT License
      2 //
      3 // Copyright (c) 2026 Remy Noulin
      4 //
      5 // Permission is hereby granted, free of charge, to any person obtaining a copy
      6 // of this software and associated documentation files (the "Software"), to deal
      7 // in the Software without restriction, including without limitation the rights
      8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      9 // copies of the Software, and to permit persons to whom the Software is
     10 // furnished to do so, subject to the following conditions:
     11 //
     12 // The above copyright notice and this permission notice shall be included in all
     13 // copies or substantial portions of the Software.
     14 //
     15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     21 // SOFTWARE.
     22 
     23 #include "../libsheepyObject.h"
     24 #include "libsheepyCSmallJson.h"
     25 #include "libsheepyCSmallJsonInternal.h"
     26 #include "../../release/libsheepy.h"
     27 #include "laxjson.h"
     28 #include "yaml.h"
     29 // isdigit
     30 #include <ctype.h>
     31 
     32 #define internal static
     33 
     34 #include <ctype.h>
     35 #include <stdio.h>
     36 #include <stdarg.h>
     37 #include <stdbool.h>
     38 #include <string.h>
     39 #include <stdlib.h>
     40 #include <stdint.h>
     41 
     42 void initiateSmallJson(smallJsont *self);
     43 void registerMethodsSmallJson(smallJsonFunctionst *f);
     44 void initiateAllocateSmallJson(smallJsont **self);
     45 smallJsont* createSJF(const char *paramType, ...);
     46 void finalizeRecycleSmallJson(void *arg UNUSED);
     47 void finalizeSmallJson(void);
     48 smallJsont* allocSmallJson(void);
     49 void cleanUpSmallJsonTerminateG(smallJsont **val);
     50 void cleanUpSmallJsonFreeLocalG(smallJsont *val);
     51 void cleanUpSmallJsonFreeG(smallJsont **val);
     52 void cleanUpSmallJsonFinishG(smallJsont **val);
     53 void cleanUpSmallJsonDisposeG(smallJsont *val);
     54 void cleanUpSmallJsonSmashG(smallJsont **val);
     55 internal void freeSmallJson(smallJsont *self);
     56 internal void terminateSmallJson(smallJsont **self);
     57 internal char* toStringSmallJson(smallJsont *self);
     58 internal smallJsont* duplicateSmallJson(smallJsont *self);
     59 internal char* escapeSmallJson(smallJsont *self);
     60 internal void disposeSmallJson(smallJsont *self);
     61 internal void smashSmallJson(smallJsont **self);
     62 #if (NFreeStackCheck)
     63 internal void finishSmallJson(smallJsont **self);
     64 #else
     65 internal void finishSmallJson(smallJsont **self);
     66 #endif
     67 internal const char* helpSmallJson(smallJsont UNUSED *self);
     68 internal void resetSmallJson(smallJsont *self);
     69 internal smallt* getsoSmallJson(smallJsont *self);
     70 internal void setsoSmallJson(smallJsont *self, smallt *so);
     71 internal smallJsont* mirrorSmallJson(smallJsont *self);
     72 internal const char* getTopTypeSmallJson(smallJsont *self);
     73 internal smallJsont* setTypeUndefinedSmallJson(smallJsont *self);
     74 internal smallJsont* setTypeBoolSmallJson(smallJsont *self);
     75 internal smallJsont* setTypeDoubleSmallJson(smallJsont *self);
     76 internal smallJsont* setTypeIntSmallJson(smallJsont *self);
     77 internal smallJsont* setTypeStringSmallJson(smallJsont *self);
     78 internal smallJsont* setTypeDictSmallJson(smallJsont *self);
     79 internal smallJsont* setTypeArraySmallJson(smallJsont *self);
     80 internal smallJsont* setTopSmallJson(smallJsont *self, baset *value);
     81 internal smallJsont* setTopBoolSmallJson(smallJsont *self, bool value);
     82 internal smallJsont* setTopDoubleSmallJson(smallJsont *self, double value);
     83 internal smallJsont* setTopIntSmallJson(smallJsont *self, int64_t value);
     84 internal smallJsont* setTopStringSmallJson(smallJsont *self, const char *value);
     85 internal smallJsont* setTopCharSmallJson(smallJsont *self, char c);
     86 internal smallJsont* setTopDictSmallJson(smallJsont *self, smallDictt *value);
     87 internal smallJsont* setTopArraySmallJson(smallJsont *self, smallArrayt *value);
     88 internal smallJsont* setTopArraycSmallJson(smallJsont *self, char **value);
     89 internal smallJsont* setTopCArraycSmallJson(smallJsont *self, const char **value);
     90 internal smallJsont* setTopSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
     91 internal smallJsont* setTopSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
     92 internal smallJsont* setTopSmallIntSmallJson(smallJsont *self, smallIntt *value);
     93 internal smallJsont* setTopSmallJsonSmallJson(smallJsont *self, smallJsont *value);
     94 internal smallJsont* setTopSmallStringSmallJson(smallJsont *self, smallStringt *value);
     95 internal smallJsont* setTopNFreeSmallJson(smallJsont *self, baset *value);
     96 internal smallJsont* setTopNFreeBoolSmallJson(smallJsont *self, bool value);
     97 internal smallJsont* setTopNFreeDoubleSmallJson(smallJsont *self, double value);
     98 internal smallJsont* setTopNFreeIntSmallJson(smallJsont *self, int64_t value);
     99 internal smallJsont* setTopNFreeStringSmallJson(smallJsont *self, char *value);
    100 internal smallJsont* setTopNFreeDictSmallJson(smallJsont *self, smallDictt *value);
    101 internal smallJsont* setTopNFreeArraySmallJson(smallJsont *self, smallArrayt *value);
    102 internal smallJsont* setTopNFreeArraycSmallJson(smallJsont *self, char **value);
    103 internal smallJsont* setTopNFreeSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
    104 internal smallJsont* setTopNFreeSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
    105 internal smallJsont* setTopNFreeSmallIntSmallJson(smallJsont *self, smallIntt *value);
    106 internal smallJsont* setTopNFreeSmallJsonSmallJson(smallJsont *self, smallJsont *value);
    107 internal smallJsont* setTopNFreeSmallStringSmallJson(smallJsont *self, smallStringt *value);
    108 internal smallJsont* fromArraySmallJson(smallJsont *self, char **array, size_t size);
    109 internal smallJsont* fromCArraySmallJson(smallJsont *self, const char **array, size_t size);
    110 internal smallJsont* fromArrayNFreeSmallJson(smallJsont *self, char **array, size_t size);
    111 internal smallJsont* fromArrayDictSmallJson(smallJsont *self, smallArrayt *items);
    112 internal smallArrayt* toArrayDictSmallJson(smallJsont *self);
    113 internal baset* getTopSmallJson(smallJsont *self);
    114 internal undefinedt*   getTopUndefinedSmallJson(smallJsont *self);
    115 internal bool          getTopBoolSmallJson(smallJsont *self);
    116 internal bool*         getTopBoolPSmallJson(smallJsont *self);
    117 internal double        getTopDoubleSmallJson(smallJsont *self);
    118 internal double*       getTopDoublePSmallJson(smallJsont *self);
    119 internal int64_t       getTopIntSmallJson(smallJsont *self);
    120 internal int64_t*      getTopIntPSmallJson(smallJsont *self);
    121 internal int32_t       getTopInt32SmallJson(smallJsont *self);
    122 internal int32_t*      getTopInt32PSmallJson(smallJsont *self);
    123 internal uint64_t      getTopUintSmallJson(smallJsont *self);
    124 internal uint64_t*     getTopUintPSmallJson(smallJsont *self);
    125 internal uint32_t      getTopUint32SmallJson(smallJsont *self);
    126 internal uint32_t*     getTopUint32PSmallJson(smallJsont *self);
    127 internal char*         getTopSSmallJson(smallJsont *self);
    128 internal smallDictt*   getTopDictSmallJson(smallJsont *self);
    129 internal smallArrayt*  getTopArraySmallJson(smallJsont *self);
    130 internal smallBoolt*   getTopSmallBoolSmallJson(smallJsont *self);
    131 internal smallDoublet* getTopSmallDoubleSmallJson(smallJsont *self);
    132 internal smallIntt* getTopSmallIntSmallJson(smallJsont *self);
    133 internal smallStringt* getTopSmallStringSmallJson(smallJsont *self);
    134 internal bool isPythonIndex(const char *start, size_t len);
    135 internal jsonPathRest keyIsSmallJson(smallJsont *self UNUSED, const char *key);
    136 internal const char* keyIsSSmallJson(smallJsont *self UNUSED, const char *key);
    137 internal char*  makeKeySmallJson(smallJsont *self UNUSED, const char *key);
    138 internal char*  iMakeKeySmallJson(smallJsont *self UNUSED, char **key);
    139 internal char*  bMakeKeySmallJson(smallJsont *self UNUSED, char *dest, const char *key);
    140 internal char*  bLMakeKeySmallJson(smallJsont *self UNUSED, char *dest, size_t size, const char *key);
    141 internal size_t makeKeyLenSmallJson(smallJsont *self UNUSED, const char *key);
    142 internal void unescapeKey(char *dest, char *key, size_t length);
    143 internal smallJsont* setSmallJson(smallJsont *self, const char *key, baset *value);
    144 internal smallJsont* setUndefinedSmallJson(smallJsont *self, const char *key);
    145 internal smallJsont* setBoolSmallJson(smallJsont *self, const char *key, bool value);
    146 internal smallJsont* setDoubleSmallJson(smallJsont *self, const char *key, double value);
    147 internal smallJsont* setIntSmallJson(smallJsont *self, const char *key, int64_t value);
    148 internal smallJsont* setSSmallJson(smallJsont *self, const char *key, const char *string);
    149 internal smallJsont* setCharSmallJson(smallJsont *self, const char *key, char c);
    150 internal smallJsont* setDictSmallJson(smallJsont *self, const char *key, smallDictt *dict);
    151 internal smallJsont* setArraySmallJson(smallJsont *self, const char *key, smallArrayt *array);
    152 internal smallJsont* setArraycSmallJson(smallJsont *self, const char *key, char **array);
    153 internal smallJsont* setCArraycSmallJson(smallJsont *self, const char *key, const char **array);
    154 internal smallJsont* setSmallBoolSmallJson(smallJsont *self, const char *key, smallBoolt *value);
    155 internal smallJsont* setSmallBytesSmallJson(smallJsont *self, const char *key, smallBytest *value);
    156 internal smallJsont* setSmallDoubleSmallJson(smallJsont *self, const char *key, smallDoublet *value);
    157 internal smallJsont* setSmallIntSmallJson(smallJsont *self, const char *key, smallIntt *value);
    158 internal smallJsont* setSmallJsonSmallJson(smallJsont *self, const char *key, smallJsont *value);
    159 internal smallJsont* setSmallStringSmallJson(smallJsont *self, const char *key, smallStringt *string);
    160 internal smallJsont* setSmallContainerSmallJson(smallJsont *self, const char *key, smallContainert *container);
    161 internal smallJsont* setNFreeSmallJson(smallJsont *self, const char *key, baset *value);
    162 internal smallJsont* setNFreeUndefinedSmallJson(smallJsont *self, const char *key, undefinedt *u);
    163 internal smallJsont* setNFreeSSmallJson(smallJsont *self, const char *key, char *string);
    164 internal smallJsont* setNFreeDictSmallJson(smallJsont *self, const char *key, smallDictt *dict);
    165 internal smallJsont* setNFreeArraySmallJson(smallJsont *self, const char *key, smallArrayt *array);
    166 internal smallJsont* setNFreeArraycSmallJson(smallJsont *self, const char *key, char **array);
    167 internal smallJsont* setNFreeSmallBoolSmallJson(smallJsont *self, const char *key, smallBoolt *value);
    168 internal smallJsont* setNFreeSmallBytesSmallJson(smallJsont *self, const char *key, smallBytest *value);
    169 internal smallJsont* setNFreeSmallDoubleSmallJson(smallJsont *self, const char *key, smallDoublet *value);
    170 internal smallJsont* setNFreeSmallIntSmallJson(smallJsont *self, const char *key, smallIntt *value);
    171 internal smallJsont* setNFreeSmallJsonSmallJson(smallJsont *self, const char *key, smallJsont *value);
    172 internal smallJsont* setNFreeSmallStringSmallJson(smallJsont *self, const char *key, smallStringt *string);
    173 internal smallJsont* setNFreeSmallContainerSmallJson(smallJsont *self, const char *key, smallContainert *container);
    174 internal smallJsont* setPDictSmallJson(smallJsont *self, const char *key, smallDictt *dict);
    175 internal smallJsont* setPArraySmallJson(smallJsont *self, const char *key, smallArrayt *array);
    176 internal smallJsont* setPSmallJsonSmallJson(smallJsont *self, const char *key, smallJsont *value);
    177 internal smallJsont* setPSmallStringSmallJson(smallJsont *self, const char *key, smallStringt *string);
    178 internal smallJsont* setNFreePDictSmallJson(smallJsont *self, const char *key, smallDictt *dict);
    179 internal smallJsont* setNFreePArraySmallJson(smallJsont *self, const char *key, smallArrayt *array);
    180 internal smallJsont* setNFreePSmallJsonSmallJson(smallJsont *self, const char *key, smallJsont *value);
    181 internal smallJsont* setNFreePSmallStringSmallJson(smallJsont *self, const char *key, smallStringt *string);
    182 internal smallJsont* setAtSmallJson(smallJsont *self, int64_t index, baset *value);
    183 internal smallJsont* setAtUndefinedSmallJson(smallJsont *self, int64_t index);
    184 internal smallJsont* setAtBoolSmallJson(smallJsont *self, int64_t index, bool value);
    185 internal smallJsont* setAtDoubleSmallJson(smallJsont *self, int64_t index, double value);
    186 internal smallJsont* setAtIntSmallJson(smallJsont *self, int64_t index, int64_t value);
    187 internal smallJsont* setAtSSmallJson(smallJsont *self, int64_t index, const char *string);
    188 internal smallJsont* setAtCharSmallJson(smallJsont *self, int64_t index, char c);
    189 internal smallJsont* setAtDictSmallJson(smallJsont *self, int64_t index, smallDictt *dict);
    190 internal smallJsont* setAtArraySmallJson(smallJsont *self, int64_t index, smallArrayt *array);
    191 internal smallJsont* setAtArraycSmallJson(smallJsont *self, int64_t index, char **array);
    192 internal smallJsont* setAtCArraycSmallJson(smallJsont *self, int64_t index, const char **array);
    193 internal smallJsont* setAtSmallBoolSmallJson(smallJsont *self, int64_t index, smallBoolt *value);
    194 internal smallJsont* setAtSmallBytesSmallJson(smallJsont *self, int64_t index, smallBytest *value);
    195 internal smallJsont* setAtSmallDoubleSmallJson(smallJsont *self, int64_t index, smallDoublet *value);
    196 internal smallJsont* setAtSmallIntSmallJson(smallJsont *self, int64_t index, smallIntt *value);
    197 internal smallJsont* setAtSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *value);
    198 internal smallJsont* setAtSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *string);
    199 internal smallJsont* setAtSmallContainerSmallJson(smallJsont *self, int64_t index, smallContainert *container);
    200 internal smallJsont* setAtNFreeSmallJson(smallJsont *self, int64_t index, baset *value);
    201 internal smallJsont* setAtNFreeUndefinedSmallJson(smallJsont *self, int64_t index, undefinedt *u);
    202 internal smallJsont* setAtNFreeSSmallJson(smallJsont *self, int64_t index, char *string);
    203 internal smallJsont* setAtNFreeDictSmallJson(smallJsont *self, int64_t index, smallDictt *dict);
    204 internal smallJsont* setAtNFreeArraySmallJson(smallJsont *self, int64_t index, smallArrayt *array);
    205 internal smallJsont* setAtNFreeArraycSmallJson(smallJsont *self, int64_t index, char **array);
    206 internal smallJsont* setAtNFreeSmallBoolSmallJson(smallJsont *self, int64_t index, smallBoolt *value);
    207 internal smallJsont* setAtNFreeSmallBytesSmallJson(smallJsont *self, int64_t index, smallBytest *value);
    208 internal smallJsont* setAtNFreeSmallDoubleSmallJson(smallJsont *self, int64_t index, smallDoublet *value);
    209 internal smallJsont* setAtNFreeSmallIntSmallJson(smallJsont *self, int64_t index, smallIntt *value);
    210 internal smallJsont* setAtNFreeSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *value);
    211 internal smallJsont* setAtNFreeSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *string);
    212 internal smallJsont* setAtNFreeSmallContainerSmallJson(smallJsont *self, int64_t index, smallContainert *container);
    213 internal smallJsont* setPAtDictSmallJson(smallJsont *self, int64_t index, smallDictt *dict);
    214 internal smallJsont* setPAtArraySmallJson(smallJsont *self, int64_t index, smallArrayt *array);
    215 internal smallJsont* setPAtSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *value);
    216 internal smallJsont* setPAtSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *string);
    217 internal smallJsont* setPAtNFreeDictSmallJson(smallJsont *self, int64_t index, smallDictt *dict);
    218 internal smallJsont* setPAtNFreeArraySmallJson(smallJsont *self, int64_t index, smallArrayt *array);
    219 internal smallJsont* setPAtNFreeSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *value);
    220 internal smallJsont* setPAtNFreeSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *string);
    221 internal smallJsont* pushSmallJson(smallJsont *self, baset *value);
    222 internal smallJsont* pushUndefinedSmallJson(smallJsont *self);
    223 internal smallJsont* pushBoolSmallJson(smallJsont *self, bool value);
    224 internal smallJsont* pushDoubleSmallJson(smallJsont *self, double value);
    225 internal smallJsont* pushIntSmallJson(smallJsont *self, int64_t value);
    226 internal smallJsont* pushSSmallJson(smallJsont *self, const char *string);
    227 internal smallJsont* pushCharSmallJson(smallJsont *self, char c);
    228 internal smallJsont* pushDictSmallJson(smallJsont *self, smallDictt *dict);
    229 internal smallJsont* pushArraySmallJson(smallJsont *self, smallArrayt *array);
    230 internal smallJsont* pushArraycSmallJson(smallJsont *self, char **array);
    231 internal smallJsont* pushCArraycSmallJson(smallJsont *self, const char **array);
    232 internal smallJsont* pushSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
    233 internal smallJsont* pushSmallBytesSmallJson(smallJsont *self, smallBytest *value);
    234 internal smallJsont* pushSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
    235 internal smallJsont* pushSmallIntSmallJson(smallJsont *self, smallIntt *value);
    236 internal smallJsont* pushSmallJsonSmallJson(smallJsont *self, smallJsont *value);
    237 internal smallJsont* pushSmallStringSmallJson(smallJsont *self, smallStringt *string);
    238 internal smallJsont* pushSmallContainerSmallJson(smallJsont *self, smallContainert *container);
    239 internal smallJsont* pushNFreeSmallJson(smallJsont *self, baset *value);
    240 internal smallJsont* pushNFreeUndefinedSmallJson(smallJsont *self, undefinedt *u);
    241 internal smallJsont* pushNFreeSSmallJson(smallJsont *self, char *string);
    242 internal smallJsont* pushNFreeDictSmallJson(smallJsont *self, smallDictt *dict);
    243 internal smallJsont* pushNFreeArraySmallJson(smallJsont *self, smallArrayt *array);
    244 internal smallJsont* pushNFreeArraycSmallJson(smallJsont *self, char **array);
    245 internal smallJsont* pushNFreeSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
    246 internal smallJsont* pushNFreeSmallBytesSmallJson(smallJsont *self, smallBytest *value);
    247 internal smallJsont* pushNFreeSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
    248 internal smallJsont* pushNFreeSmallIntSmallJson(smallJsont *self, smallIntt *value);
    249 internal smallJsont* pushNFreeSmallJsonSmallJson(smallJsont *self, smallJsont *value);
    250 internal smallJsont* pushNFreeSmallStringSmallJson(smallJsont *self, smallStringt *string);
    251 internal smallJsont* pushNFreeSmallContainerSmallJson(smallJsont *self, smallContainert *container);
    252 internal smallJsont* pushManySmallJson(smallJsont *self, ...);
    253 internal smallJsont* pushManySSmallJson(smallJsont *self, ...);
    254 internal smallJsont* pushNFreeManySmallJson(smallJsont *self, ...);
    255 internal smallJsont* pushNFreeManySSmallJson(smallJsont *self, ...);
    256 internal baset* popSmallJson(smallJsont *self);
    257 internal undefinedt* popUndefinedSmallJson(smallJsont *self);
    258 internal bool popBoolSmallJson(smallJsont *self);
    259 internal double popDoubleSmallJson(smallJsont *self);
    260 internal int64_t popIntSmallJson(smallJsont *self);
    261 internal int32_t popInt32SmallJson(smallJsont *self);
    262 internal uint64_t popUintSmallJson(smallJsont *self);
    263 internal uint32_t popUint32SmallJson(smallJsont *self);
    264 internal char* popSSmallJson(smallJsont *self);
    265 internal smallDictt* popDictSmallJson(smallJsont *self);
    266 internal smallArrayt* popArraySmallJson(smallJsont *self);
    267 internal smallBoolt* popSmallBoolSmallJson(smallJsont *self);
    268 internal smallBytest* popSmallBytesSmallJson(smallJsont *self);
    269 internal smallDoublet* popSmallDoubleSmallJson(smallJsont *self);
    270 internal smallIntt* popSmallIntSmallJson(smallJsont *self);
    271 internal smallJsont* popSmallJsonSmallJson(smallJsont *self);
    272 internal smallStringt* popSmallStringSmallJson(smallJsont *self);
    273 internal void* popVoidSmallJson(smallJsont *self);
    274 internal smallContainert* popSmallContainerSmallJson(smallJsont *self);
    275 internal double popNumSmallJson(smallJsont *self);
    276 internal smallJsont* prependSmallJson(smallJsont *self, baset *value);
    277 internal smallJsont* prependUndefinedSmallJson(smallJsont *self);
    278 internal smallJsont* prependBoolSmallJson(smallJsont *self, bool value);
    279 internal smallJsont* prependDoubleSmallJson(smallJsont *self, double value);
    280 internal smallJsont* prependIntSmallJson(smallJsont *self, int64_t value);
    281 internal smallJsont* prependSSmallJson(smallJsont *self, const char *string);
    282 internal smallJsont* prependCharSmallJson(smallJsont *self, char c);
    283 internal smallJsont* prependDictSmallJson(smallJsont *self, smallDictt *dict);
    284 internal smallJsont* prependArraySmallJson(smallJsont *self, smallArrayt *array);
    285 internal smallJsont* prependArraycSmallJson(smallJsont *self, char **array);
    286 internal smallJsont* prependCArraycSmallJson(smallJsont *self, const char **array);
    287 internal smallJsont* prependSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
    288 internal smallJsont* prependSmallBytesSmallJson(smallJsont *self, smallBytest *value);
    289 internal smallJsont* prependSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
    290 internal smallJsont* prependSmallIntSmallJson(smallJsont *self, smallIntt *value);
    291 internal smallJsont* prependSmallJsonSmallJson(smallJsont *self, smallJsont *value);
    292 internal smallJsont* prependSmallStringSmallJson(smallJsont *self, smallStringt *string);
    293 internal smallJsont* prependSmallContainerSmallJson(smallJsont *self, smallContainert *container);
    294 internal smallJsont* prependNFreeSmallJson(smallJsont *self, baset *value);
    295 internal smallJsont* prependNFreeUndefinedSmallJson(smallJsont *self, undefinedt *u);
    296 internal smallJsont* prependNFreeSSmallJson(smallJsont *self, char *string);
    297 internal smallJsont* prependNFreeDictSmallJson(smallJsont *self, smallDictt *dict);
    298 internal smallJsont* prependNFreeArraySmallJson(smallJsont *self, smallArrayt *array);
    299 internal smallJsont* prependNFreeArraycSmallJson(smallJsont *self, char **array);
    300 internal smallJsont* prependNFreeSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
    301 internal smallJsont* prependNFreeSmallBytesSmallJson(smallJsont *self, smallBytest *value);
    302 internal smallJsont* prependNFreeSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
    303 internal smallJsont* prependNFreeSmallIntSmallJson(smallJsont *self, smallIntt *value);
    304 internal smallJsont* prependNFreeSmallJsonSmallJson(smallJsont *self, smallJsont *value);
    305 internal smallJsont* prependNFreeSmallStringSmallJson(smallJsont *self, smallStringt *string);
    306 internal smallJsont* prependNFreeSmallContainerSmallJson(smallJsont *self, smallContainert *container);
    307 internal baset* dequeueSmallJson(smallJsont *self);
    308 internal undefinedt* dequeueUndefinedSmallJson(smallJsont *self);
    309 internal bool dequeueBoolSmallJson(smallJsont *self);
    310 internal double dequeueDoubleSmallJson(smallJsont *self);
    311 internal int64_t dequeueIntSmallJson(smallJsont *self);
    312 internal int32_t dequeueInt32SmallJson(smallJsont *self);
    313 internal uint64_t dequeueUintSmallJson(smallJsont *self);
    314 internal uint32_t dequeueUint32SmallJson(smallJsont *self);
    315 internal char* dequeueSSmallJson(smallJsont *self);
    316 internal smallDictt* dequeueDictSmallJson(smallJsont *self);
    317 internal smallArrayt* dequeueArraySmallJson(smallJsont *self);
    318 internal smallBoolt* dequeueSmallBoolSmallJson(smallJsont *self);
    319 internal smallBytest* dequeueSmallBytesSmallJson(smallJsont *self);
    320 internal smallDoublet* dequeueSmallDoubleSmallJson(smallJsont *self);
    321 internal smallIntt* dequeueSmallIntSmallJson(smallJsont *self);
    322 internal smallJsont* dequeueSmallJsonSmallJson(smallJsont *self);
    323 internal smallStringt* dequeueSmallStringSmallJson(smallJsont *self);
    324 internal void* dequeueVoidSmallJson(smallJsont *self);
    325 internal smallContainert* dequeueSmallContainerSmallJson(smallJsont *self);
    326 internal double dequeueNumSmallJson(smallJsont *self);
    327 internal smallJsont* reverseSmallJson(smallJsont *self);
    328 internal smallJsont* catSmallJson(smallJsont *self, ...);
    329 internal smallJsont* mergeDictSmallJson(smallJsont *self, smallDictt *smallDict);
    330 internal smallJsont* mergeDictNSmashSmallJson(smallJsont *self, smallDictt *smallDict);
    331 internal smallJsont* mergeSmallJson(smallJsont *self, smallJsont *smallJson);
    332 internal smallJsont* mergeNSmashSmallJson(smallJsont *self, smallJsont *smallJson);
    333 internal smallJsont* appendSmallJson(smallJsont *self, smallArrayt *array);
    334 internal smallJsont* appendNSmashSmallJson(smallJsont *self, smallArrayt *array);
    335 internal smallJsont* appendArraySmallJson(smallJsont *self, char **array);
    336 internal smallJsont* appendCArraySmallJson(smallJsont *self, const char **array);
    337 internal smallJsont* appendNSmashArraySmallJson(smallJsont *self, char **array);
    338 internal smallJsont* shiftSmallJson(smallJsont *self, smallArrayt *array);
    339 internal smallJsont* shiftNSmashSmallJson(smallJsont *self, smallArrayt *array);
    340 internal smallJsont* shiftSmallJsonSmallJson(smallJsont *self, smallJsont *array);
    341 internal smallJsont* shiftNSmashSmallJsonSmallJson(smallJsont *self, smallJsont *array);
    342 internal smallJsont* addSmallJson(smallJsont *self, smallArrayt *array);
    343 internal smallJsont* addJsonSmallJson(smallJsont *self, smallJsont *array);
    344 internal smallJsont* sliceSmallJson(smallJsont *self, int64_t start, int64_t end);
    345 internal smallJsont* cropSmallJson(smallJsont *self, int64_t start, int64_t end);
    346 internal char* cropSSmallJson(smallJsont *self, int64_t start, int64_t end);
    347 internal smallStringt* cropSmallStringSmallJson(smallJsont *self, int64_t start, int64_t end);
    348 internal baset* cropElemAtSmallJson(smallJsont *self, int64_t index);
    349 internal undefinedt* cropElemAtUndefinedSmallJson(smallJsont *self, int64_t index);
    350 internal bool cropElemAtBoolSmallJson(smallJsont *self, int64_t index);
    351 internal double cropElemAtDoubleSmallJson(smallJsont *self, int64_t index);
    352 internal int64_t cropElemAtIntSmallJson(smallJsont *self, int64_t index);
    353 internal int32_t cropElemAtInt32SmallJson(smallJsont *self, int64_t index);
    354 internal uint64_t cropElemAtUintSmallJson(smallJsont *self, int64_t index);
    355 internal uint32_t cropElemAtUint32SmallJson(smallJsont *self, int64_t index);
    356 internal char* cropElemAtSSmallJson(smallJsont *self, int64_t index);
    357 internal char cropElemAtCharSmallJson(smallJsont *self, int64_t index);
    358 internal smallDictt* cropElemAtDictSmallJson(smallJsont *self, int64_t index);
    359 internal smallArrayt* cropElemAtArraySmallJson(smallJsont *self, int64_t index);
    360 internal smallBoolt* cropElemAtSmallBoolSmallJson(smallJsont *self, int64_t index);
    361 internal smallBytest* cropElemAtSmallBytesSmallJson(smallJsont *self, int64_t index);
    362 internal smallDoublet* cropElemAtSmallDoubleSmallJson(smallJsont *self, int64_t index);
    363 internal smallIntt* cropElemAtSmallIntSmallJson(smallJsont *self, int64_t index);
    364 internal smallJsont* cropElemAtSmallJsonSmallJson(smallJsont *self, int64_t index);
    365 internal smallStringt* cropElemAtSmallStringSmallJson(smallJsont *self, int64_t index);
    366 internal void* cropElemAtVoidSmallJson(smallJsont *self, int64_t index);
    367 internal smallContainert* cropElemAtSmallContainerSmallJson(smallJsont *self, int64_t index);
    368 internal baset* cropElemKeySmallJson(smallJsont *self, const char* key);
    369 internal undefinedt* cropElemKeyUndefinedSmallJson(smallJsont *self, const char* key);
    370 internal bool cropElemKeyBoolSmallJson(smallJsont *self, const char* key);
    371 internal double cropElemKeyDoubleSmallJson(smallJsont *self, const char* key);
    372 internal int64_t cropElemKeyIntSmallJson(smallJsont *self, const char* key);
    373 internal int32_t cropElemKeyInt32SmallJson(smallJsont *self, const char* key);
    374 internal uint64_t cropElemKeyUintSmallJson(smallJsont *self, const char* key);
    375 internal uint32_t cropElemKeyUint32SmallJson(smallJsont *self, const char* key);
    376 internal char* cropElemKeySSmallJson(smallJsont *self, const char* key);
    377 internal smallDictt* cropElemKeyDictSmallJson(smallJsont *self, const char* key);
    378 internal smallArrayt* cropElemKeyArraySmallJson(smallJsont *self, const char* key);
    379 internal smallBoolt* cropElemKeySmallBoolSmallJson(smallJsont *self, const char* key);
    380 internal smallBytest* cropElemKeySmallBytesSmallJson(smallJsont *self, const char* key);
    381 internal smallDoublet* cropElemKeySmallDoubleSmallJson(smallJsont *self, const char* key);
    382 internal smallIntt* cropElemKeySmallIntSmallJson(smallJsont *self, const char* key);
    383 internal smallJsont* cropElemKeySmallJsonSmallJson(smallJsont *self, const char* key);
    384 internal smallStringt* cropElemKeySmallStringSmallJson(smallJsont *self, const char* key);
    385 internal void* cropElemKeyVoidSmallJson(smallJsont *self, const char* key);
    386 internal smallContainert* cropElemKeySmallContainerSmallJson(smallJsont *self, const char* key);
    387 internal smallJsont* copySmallJson(smallJsont *self, int64_t start, int64_t end);
    388 internal smallJsont* insertSmallJson(smallJsont *self, int64_t index, smallArrayt *toInsert);
    389 internal smallJsont* insertNSmashSmallJson(smallJsont *self, int64_t index, smallArrayt *toInsert);
    390 internal smallJsont* insertSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *toInsert);
    391 internal smallJsont* insertNSmashSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *toInsert);
    392 internal smallJsont* insertStringSmallJson(smallJsont *self, int64_t index, smallStringt *toInsert);
    393 internal smallJsont* insertSSmallJson(smallJsont *self, int64_t index, const char *toInsert);
    394 internal smallJsont* insertNFreeStringSmallJson(smallJsont *self, int64_t index, smallStringt *toInsert);
    395 internal smallJsont* insertSNFreeSmallJson(smallJsont *self, int64_t index, char *toInsert);
    396 internal smallJsont* injectSmallJson(smallJsont *self, int64_t index, baset *toInject);
    397 internal smallJsont* injectUndefinedSmallJson(smallJsont *self, int64_t index);
    398 internal smallJsont* injectBoolSmallJson(smallJsont *self, int64_t index, bool toInject);
    399 internal smallJsont* injectDoubleSmallJson(smallJsont *self, int64_t index, double toInject);
    400 internal smallJsont* injectIntSmallJson(smallJsont *self, int64_t index, int64_t toInject);
    401 internal smallJsont* injectSSmallJson(smallJsont *self, int64_t index, const char *toInject);
    402 internal smallJsont* injectCharSmallJson(smallJsont *self, int64_t index, char c);
    403 internal smallJsont* injectDictSmallJson(smallJsont *self, int64_t index, smallDictt *toInject);
    404 internal smallJsont* injectArraySmallJson(smallJsont *self, int64_t index, smallArrayt *toInject);
    405 internal smallJsont* injectArraycSmallJson(smallJsont *self, int64_t index, char **toInject);
    406 internal smallJsont* injectCArraycSmallJson(smallJsont *self, int64_t index, const char **toInject);
    407 internal smallJsont* injectSmallBoolSmallJson(smallJsont *self, int64_t index, smallBoolt *toInject);
    408 internal smallJsont* injectSmallBytesSmallJson(smallJsont *self, int64_t index, smallBytest *toInject);
    409 internal smallJsont* injectSmallDoubleSmallJson(smallJsont *self, int64_t index, smallDoublet *toInject);
    410 internal smallJsont* injectSmallIntSmallJson(smallJsont *self, int64_t index, smallIntt *toInject);
    411 internal smallJsont* injectSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *toInject);
    412 internal smallJsont* injectSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *toInject);
    413 internal smallJsont* injectSmallContainerSmallJson(smallJsont *self, int64_t index, smallContainert *toInject);
    414 internal smallJsont* injectNFreeSmallJson(smallJsont *self, int64_t index, baset *toInject);
    415 internal smallJsont* injectNFreeUndefinedSmallJson(smallJsont *self, int64_t index, undefinedt *u);
    416 internal smallJsont* injectNFreeSSmallJson(smallJsont *self, int64_t index, char *toInject);
    417 internal smallJsont* injectNFreeDictSmallJson(smallJsont *self, int64_t index, smallDictt *toInject);
    418 internal smallJsont* injectNFreeArraySmallJson(smallJsont *self, int64_t index, smallArrayt *toInject);
    419 internal smallJsont* injectNFreeArraycSmallJson(smallJsont *self, int64_t index, char **toInject);
    420 internal smallJsont* injectNFreeSmallBoolSmallJson(smallJsont *self, int64_t index, smallBoolt *toInject);
    421 internal smallJsont* injectNFreeSmallBytesSmallJson(smallJsont *self, int64_t index, smallBytest *toInject);
    422 internal smallJsont* injectNFreeSmallDoubleSmallJson(smallJsont *self, int64_t index, smallDoublet *toInject);
    423 internal smallJsont* injectNFreeSmallIntSmallJson(smallJsont *self, int64_t index, smallIntt *toInject);
    424 internal smallJsont* injectNFreeSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *toInject);
    425 internal smallJsont* injectNFreeSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *toInject);
    426 internal smallJsont* injectNFreeSmallContainerSmallJson(smallJsont *self, int64_t index, smallContainert *toInject);
    427 internal smallJsont* uniqSmallJson(smallJsont *self);
    428 internal int sortSCmp(const void * a, const void * b);
    429 internal smallJsont* sortSmallJson(smallJsont *self);
    430 #if (__APPLE__ || __FreeBSD__ || __DragonFly__)
    431 internal int sortFCmp(void *func, const void *a, const void *b);
    432 #else
    433 internal int sortFCmp(const void *a, const void *b, void *func);
    434 #endif
    435 internal int icSortSCmp(const void * a, const void * b);
    436 internal smallJsont* icSortSmallJson(smallJsont *self);
    437 #if (__APPLE__ || __FreeBSD__ || __DragonFly__)
    438 internal smallJsont* sortFSmallJson(smallJsont *self, shCmpt compareFunction);
    439 #else
    440 internal smallJsont* sortFSmallJson(smallJsont *self, shCmpt compareFunction);
    441 #endif
    442 internal smallJsont* icUniqSmallJson(smallJsont *self);
    443 internal smallJsont* uniqCharSmallJson(smallJsont *self, char c);
    444 internal smallJsont* icUniqCharSmallJson(smallJsont *self, char c);
    445 internal bool hasSmallJson(smallJsont *self, baset *value);
    446 internal bool hasUndefinedSmallJson(smallJsont *self, undefinedt *u);
    447 internal bool hasBoolSmallJson(smallJsont *self, bool value);
    448 internal bool hasDoubleSmallJson(smallJsont *self, double value);
    449 internal bool hasIntSmallJson(smallJsont *self, int64_t value);
    450 internal bool hasSSmallJson(smallJsont *self, const char *string);
    451 internal bool hasCharSmallJson(smallJsont *self, char c);
    452 internal bool hasDictSmallJson(smallJsont *self, smallDictt *dict);
    453 internal bool hasArraySmallJson(smallJsont *self, smallArrayt *array);
    454 internal bool hasArraycSmallJson(smallJsont *self, char **array);
    455 internal bool hasCArraycSmallJson(smallJsont *self, const char **array);
    456 internal bool hasSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
    457 internal bool hasSmallBytesSmallJson(smallJsont *self, smallBytest *value);
    458 internal bool hasSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
    459 internal bool hasSmallIntSmallJson(smallJsont *self, smallIntt *value);
    460 internal bool hasSmallJsonSmallJson(smallJsont *self, smallJsont *value);
    461 internal bool hasSmallStringSmallJson(smallJsont *self, smallStringt *string);
    462 internal bool hasSmallContainerSmallJson(smallJsont *self, smallContainert *container);
    463 internal smallJsont* findSmallJson(smallJsont *self, const char *needle);
    464 internal smallJsont* findCharSmallJson(smallJsont *self, char c);
    465 internal smallJsont* findSmallStringSmallJson(smallJsont *self, smallStringt *needle);
    466 internal smallJsont* findJsonSmallJson(smallJsont *self, smallJsont *needle);
    467 internal ssize_t indexOfSmallJson(smallJsont *self, baset *value);
    468 internal ssize_t indexOfUndefinedSmallJson(smallJsont *self, undefinedt *u);
    469 internal ssize_t indexOfBoolSmallJson(smallJsont *self, bool value);
    470 internal ssize_t indexOfDoubleSmallJson(smallJsont *self, double value);
    471 internal ssize_t indexOfIntSmallJson(smallJsont *self, int64_t value);
    472 internal ssize_t indexOfSSmallJson(smallJsont *self, const char *string);
    473 internal ssize_t indexOfCharSmallJson(smallJsont *self, char c);
    474 internal ssize_t indexOfDictSmallJson(smallJsont *self, smallDictt *dict);
    475 internal ssize_t indexOfArraySmallJson(smallJsont *self, smallArrayt *array);
    476 internal ssize_t indexOfArraycSmallJson(smallJsont *self, char **array);
    477 internal ssize_t indexOfCArraycSmallJson(smallJsont *self, const char **array);
    478 internal ssize_t indexOfSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
    479 internal ssize_t indexOfSmallBytesSmallJson(smallJsont *self, smallBytest *value);
    480 internal ssize_t indexOfSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
    481 internal ssize_t indexOfSmallIntSmallJson(smallJsont *self, smallIntt *value);
    482 internal ssize_t indexOfSmallJsonSmallJson(smallJsont *self, smallJsont *value);
    483 internal ssize_t indexOfSmallStringSmallJson(smallJsont *self, smallStringt *string);
    484 internal ssize_t indexOfSmallContainerSmallJson(smallJsont *self UNUSED, smallContainert *container UNUSED);
    485 internal ssize_t binarySearchSmallJson(smallJsont *self, baset *value);
    486 internal ssize_t binarySearchUndefinedSmallJson(smallJsont *self UNUSED, undefinedt *u UNUSED);
    487 internal ssize_t binarySearchBoolSmallJson(smallJsont *self, bool value);
    488 internal ssize_t binarySearchDoubleSmallJson(smallJsont *self, double value);
    489 internal ssize_t binarySearchIntSmallJson(smallJsont *self, int64_t value);
    490 internal ssize_t binarySearchSSmallJson(smallJsont *self, const char *string);
    491 internal ssize_t binarySearchCharSmallJson(smallJsont *self, char c);
    492 internal ssize_t binarySearchDictSmallJson(smallJsont *self, smallDictt *dict);
    493 internal ssize_t binarySearchArraySmallJson(smallJsont *self, smallArrayt *array);
    494 internal ssize_t binarySearchArraycSmallJson(smallJsont *self, char **array);
    495 internal ssize_t binarySearchCArraycSmallJson(smallJsont *self, const char **array);
    496 internal ssize_t binarySearchSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
    497 internal ssize_t binarySearchSmallBytesSmallJson(smallJsont *self, smallBytest *value);
    498 internal ssize_t binarySearchSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
    499 internal ssize_t binarySearchSmallIntSmallJson(smallJsont *self, smallIntt *value);
    500 internal ssize_t binarySearchSmallJsonSmallJson(smallJsont *self, smallJsont *value);
    501 internal ssize_t binarySearchSmallStringSmallJson(smallJsont *self, smallStringt *string);
    502 internal ssize_t binarySearchSmallContainerSmallJson(smallJsont *self UNUSED, smallContainert *container UNUSED);
    503 internal bool icHasSmallJson(smallJsont *self, baset *value);
    504 internal bool icHasSSmallJson(smallJsont *self, const char *string);
    505 internal bool icHasCharSmallJson(smallJsont *self, char c);
    506 internal bool icHasDictSmallJson(smallJsont *self, smallDictt *dict);
    507 internal bool icHasArraySmallJson(smallJsont *self, smallArrayt *array);
    508 internal bool icHasArraycSmallJson(smallJsont *self, char **array);
    509 internal bool icHasCArraycSmallJson(smallJsont *self, const char **array);
    510 internal bool icHasSmallStringSmallJson(smallJsont *self, smallStringt *string);
    511 internal smallJsont* icFindSmallJson(smallJsont *self, const char *needle);
    512 internal smallJsont* icFindCharSmallJson(smallJsont *self, char c);
    513 internal smallJsont* icFindSmallStringSmallJson(smallJsont *self, smallStringt *needle);
    514 internal smallJsont* icFindJsonSmallJson(smallJsont *self, smallJsont *needle);
    515 internal ssize_t icIndexOfSmallJson(smallJsont *self, baset *value);
    516 internal ssize_t icIndexOfSSmallJson(smallJsont *self, const char *string);
    517 internal ssize_t icIndexOfCharSmallJson(smallJsont *self, char c);
    518 internal ssize_t icIndexOfDictSmallJson(smallJsont *self, smallDictt *dict);
    519 internal ssize_t icIndexOfArraySmallJson(smallJsont *self, smallArrayt *array);
    520 internal ssize_t icIndexOfArraycSmallJson(smallJsont *self, char **array);
    521 internal ssize_t icIndexOfCArraycSmallJson(smallJsont *self, const char **array);
    522 internal ssize_t icIndexOfSmallStringSmallJson(smallJsont *self, smallStringt *string);
    523 internal ssize_t icBinarySearchSmallJson(smallJsont *self, baset *value);
    524 internal ssize_t icBinarySearchSSmallJson(smallJsont *self, const char *string);
    525 internal ssize_t icBinarySearchCharSmallJson(smallJsont *self, char c);
    526 internal ssize_t icBinarySearchDictSmallJson(smallJsont *self, smallDictt *dict);
    527 internal ssize_t icBinarySearchArraySmallJson(smallJsont *self, smallArrayt *array);
    528 internal ssize_t icBinarySearchArraycSmallJson(smallJsont *self, char **array);
    529 internal ssize_t icBinarySearchCArraycSmallJson(smallJsont *self, const char **array);
    530 internal ssize_t icBinarySearchSmallStringSmallJson(smallJsont *self, smallStringt *string);
    531 internal char* keyBySmallJson(smallJsont *self, baset *value);
    532 internal char* keyByUndefinedSmallJson(smallJsont *self, undefinedt *u);
    533 internal char* keyByBoolSmallJson(smallJsont *self, bool value);
    534 internal char* keyByDoubleSmallJson(smallJsont *self, double value);
    535 internal char* keyByIntSmallJson(smallJsont *self, int64_t value);
    536 internal char* keyBySSmallJson(smallJsont *self, const char *string);
    537 internal char* keyByCharSmallJson(smallJsont *self, char c);
    538 internal char* keyByDictSmallJson(smallJsont *self, smallDictt *dict);
    539 internal char* keyByArraySmallJson(smallJsont *self, smallArrayt *array);
    540 internal char* keyByArraycSmallJson(smallJsont *self, char **array);
    541 internal char* keyByCArraycSmallJson(smallJsont *self, const char **array);
    542 internal char* keyBySmallBoolSmallJson(smallJsont *self, smallBoolt *value);
    543 internal char* keyBySmallBytesSmallJson(smallJsont *self, smallBytest *value);
    544 internal char* keyBySmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
    545 internal char* keyBySmallIntSmallJson(smallJsont *self, smallIntt *value);
    546 internal char* keyBySmallJsonSmallJson(smallJsont *self, smallJsont *value);
    547 internal char* keyBySmallStringSmallJson(smallJsont *self, smallStringt *string);
    548 internal char* keyBySmallContainerSmallJson(smallJsont *self, smallContainert *container);
    549 internal char* icKeyBySmallJson(smallJsont *self, baset *value);
    550 internal char* icKeyBySSmallJson(smallJsont *self, const char *string);
    551 internal char* icKeyByCharSmallJson(smallJsont *self, char c);
    552 internal char* icKeyByDictSmallJson(smallJsont *self, smallDictt *dict);
    553 internal char* icKeyByArraySmallJson(smallJsont *self, smallArrayt *array);
    554 internal char* icKeyByArraycSmallJson(smallJsont *self, char **array);
    555 internal char* icKeyByCArraycSmallJson(smallJsont *self, const char **array);
    556 internal char* icKeyBySmallStringSmallJson(smallJsont *self, smallStringt *string);
    557 internal smallJsont* replaceSmallJson(smallJsont *self, const char *olds, const char *news, size_t max);
    558 internal smallJsont* replaceCharSSmallJson(smallJsont *self, char olds, const char *news, size_t max);
    559 internal smallJsont* replaceSCharSmallJson(smallJsont *self, const char *olds, char news, size_t max);
    560 internal smallJsont* replaceCharCharSmallJson(smallJsont *self, char olds, char news, size_t max);
    561 internal smallJsont* replaceSmallStringSmallStringSmallJson(smallJsont *self, smallStringt *olds, smallStringt *news, size_t max);
    562 internal smallJsont* replaceSmallStringSSmallJson(smallJsont *self, smallStringt *olds, const char *news, size_t max);
    563 internal smallJsont* replaceSmallStringCharSmallJson(smallJsont *self, smallStringt *olds, char news, size_t max);
    564 internal smallJsont* replaceSSmallStringSmallJson(smallJsont *self, const char *olds, smallStringt *news, size_t max);
    565 internal smallJsont* replaceCharSmallStringSmallJson(smallJsont *self, char olds, smallStringt *news, size_t max);
    566 internal smallJsont* replaceJsonJsonSmallJson(smallJsont *self, smallJsont *olds, smallJsont *news, size_t max);
    567 internal smallJsont* replaceJsonSmallStringSmallJson(smallJsont *self, smallJsont *olds, smallStringt *news, size_t max);
    568 internal smallJsont* replaceJsonSSmallJson(smallJsont *self, smallJsont *olds, const char *news, size_t max);
    569 internal smallJsont* replaceJsonCharSmallJson(smallJsont *self, smallJsont *olds, char news, size_t max);
    570 internal smallJsont* replaceSmallStringJsonSmallJson(smallJsont *self, smallStringt *olds, smallJsont *news, size_t max);
    571 internal smallJsont* replaceSJsonSmallJson(smallJsont *self, const char *olds, smallJsont *news, size_t max);
    572 internal smallJsont* replaceCharJsonSmallJson(smallJsont *self, char olds, smallJsont *news, size_t max);
    573 internal smallJsont* replaceManySmallJson(smallJsont *self, const char *paramType, ...);
    574 internal smallJsont* icReplaceSmallJson(smallJsont *self, const char *olds, const char *news, size_t max);
    575 internal smallJsont* icReplaceCharSSmallJson(smallJsont *self, char olds, const char *news, size_t max);
    576 internal smallJsont* icReplaceSCharSmallJson(smallJsont *self, const char *olds, char news, size_t max);
    577 internal smallJsont* icReplaceCharCharSmallJson(smallJsont *self, char olds, char news, size_t max);
    578 internal smallJsont* icReplaceSmallStringSmallStringSmallJson(smallJsont *self, smallStringt *olds, smallStringt *news, size_t max);
    579 internal smallJsont* icReplaceSmallStringSSmallJson(smallJsont *self, smallStringt *olds, const char *news, size_t max);
    580 internal smallJsont* icReplaceSmallStringCharSmallJson(smallJsont *self, smallStringt *olds, char news, size_t max);
    581 internal smallJsont* icReplaceSSmallStringSmallJson(smallJsont *self, const char *olds, smallStringt *news, size_t max);
    582 internal smallJsont* icReplaceCharSmallStringSmallJson(smallJsont *self, char olds, smallStringt *news, size_t max);
    583 internal smallJsont* icReplaceJsonJsonSmallJson(smallJsont *self, smallJsont *olds, smallJsont *news, size_t max);
    584 internal smallJsont* icReplaceJsonSmallStringSmallJson(smallJsont *self, smallJsont *olds, smallStringt *news, size_t max);
    585 internal smallJsont* icReplaceJsonSSmallJson(smallJsont *self, smallJsont *olds, const char *news, size_t max);
    586 internal smallJsont* icReplaceJsonCharSmallJson(smallJsont *self, smallJsont *olds, char news, size_t max);
    587 internal smallJsont* icReplaceSmallStringJsonSmallJson(smallJsont *self, smallStringt *olds, smallJsont *news, size_t max);
    588 internal smallJsont* icReplaceSJsonSmallJson(smallJsont *self, const char *olds, smallJsont *news, size_t max);
    589 internal smallJsont* icReplaceCharJsonSmallJson(smallJsont *self, char olds, smallJsont *news, size_t max);
    590 internal smallJsont* icReplaceManySmallJson(smallJsont *self, const char *paramType, ...);
    591 internal bool equalSmallJsonSmallArray(smallJsont *self, smallArrayt *array);
    592 bool equalSmallJsonArray(smallJsont *self, char ** p2);
    593 bool equalSmallJsonCArray(smallJsont *self, const char ** p2);
    594 bool equalSmallJsonBase(smallJsont *self, baset* p2);
    595 internal bool equalSmallJsonCha(smallJsont* self, char p2);
    596 internal bool equalSmallJsonChar(smallJsont* self, const char * p2);
    597 internal bool equalSmallJsonBool(smallJsont* self, bool p2);
    598 internal bool equalSmallJsonDouble(smallJsont* self, double p2);
    599 internal bool equalSmallJsonInt64(smallJsont* self, int64_t p2);
    600 internal bool equalSmallJsonInt32(smallJsont* self, int32_t p2);
    601 internal bool equalSmallJsonUint32(smallJsont* self, uint32_t p2);
    602 internal bool equalSmallJsonUint64(smallJsont* self, uint64_t p2);
    603 internal bool equalSmallJsonSmallBool(smallJsont* self, smallBoolt* p2);
    604 internal bool equalSmallJsonSmallBytes(smallJsont* self, smallBytest* p2);
    605 internal bool equalSmallJsonSmallDouble(smallJsont* self, smallDoublet* p2);
    606 internal bool equalSmallJsonSmallInt(smallJsont* self, smallIntt* p2);
    607 internal bool equalSmallJsonSmallJson(smallJsont* self, smallJsont* p2);
    608 internal bool equalSmallJsonSmallString(smallJsont* self, smallStringt* p2);
    609 internal bool equalSmallJsonSmallDict(smallJsont* self, smallDictt* p2);
    610 internal bool icEqualSmallJsonSmallArray(smallJsont *self, smallArrayt *array);
    611 bool icEqualSmallJsonArray(smallJsont *self, char ** p2);
    612 bool icEqualSmallJsonCArray(smallJsont *self, const char ** p2);
    613 bool icEqualSmallJsonBase(smallJsont *self, baset* p2);
    614 internal bool icEqualSmallJsonSmallDict(smallJsont* self, smallDictt* p2);
    615 internal bool icEqualSmallJsonSmallJson(smallJsont *self, smallJsont *string);
    616 internal bool icEqualSmallJsonSmallString(smallJsont *self, smallStringt *string);
    617 internal bool icEqualSSmallJson(smallJsont *self, const char *string);
    618 internal bool icEqualCharSmallJson(smallJsont *self, char c);
    619 internal bool equalISSmallJson(smallJsont *self, const char *string, int64_t index);
    620 internal bool equalICharSmallJson(smallJsont *self, char c, int64_t index);
    621 internal bool equalIJsonSmallJson(smallJsont *self, smallJsont *string, int64_t index);
    622 internal bool equalISmallStringSmallJson(smallJsont *self, smallStringt *string, int64_t index);
    623 internal bool startsWithSSmallJson(smallJsont *self, const char *string);
    624 internal bool startsWithCharSmallJson(smallJsont *self, char c);
    625 internal bool startsWithSmallStringSmallJson(smallJsont *self, smallStringt *string);
    626 internal bool startsWithJsonSmallJson(smallJsont *self, smallJsont *string);
    627 internal bool endsWithSSmallJson(smallJsont *self, const char *string);
    628 internal bool endsWithCharSmallJson(smallJsont *self, char c);
    629 internal bool endsWithSmallStringSmallJson(smallJsont *self, smallStringt *string);
    630 internal bool endsWithJsonSmallJson(smallJsont *self, smallJsont *string);
    631 internal ssize_t countSSmallJson(smallJsont *self, const char *string);
    632 internal ssize_t countCharSmallJson(smallJsont *self, char c);
    633 internal ssize_t countSmallStringSmallJson(smallJsont *self, smallStringt *string);
    634 internal ssize_t countJsonSmallJson(smallJsont *self, smallJsont *string);
    635 internal bool icStartsWithSSmallJson(smallJsont *self, const char *string);
    636 internal bool icStartsWithCharSmallJson(smallJsont *self, char c);
    637 internal bool icStartsWithSmallStringSmallJson(smallJsont *self, smallStringt *string);
    638 internal bool icStartsWithJsonSmallJson(smallJsont *self, smallJsont *string);
    639 internal bool icEndsWithSSmallJson(smallJsont *self, const char *string);
    640 internal bool icEndsWithCharSmallJson(smallJsont *self, char c);
    641 internal bool icEndsWithSmallStringSmallJson(smallJsont *self, smallStringt *string);
    642 internal bool icEndsWithJsonSmallJson(smallJsont *self, smallJsont *string);
    643 internal ssize_t icCountSSmallJson(smallJsont *self, const char *string);
    644 internal ssize_t icCountCharSmallJson(smallJsont *self, char c);
    645 internal ssize_t icCountSmallStringSmallJson(smallJsont *self, smallStringt *string);
    646 internal ssize_t icCountJsonSmallJson(smallJsont *self, smallJsont *string);
    647 internal bool isNumberSmallJson(smallJsont *self);
    648 internal bool isIntSmallJson(smallJsont *self);
    649 internal int64_t parseIntSmallJson(smallJsont *self);
    650 internal double parseDoubleSmallJson(smallJsont *self);
    651 internal smallJsont* intToSmallJson(smallJsont *self, int64_t n);
    652 internal smallJsont* doubleToSmallJson(smallJsont *self, double n);
    653 internal size_t lenSmallJson(smallJsont *self);
    654 internal smallJsont* upperSmallJson(smallJsont *self);
    655 internal smallJsont* lowerSmallJson(smallJsont *self);
    656 internal smallJsont* trimSmallJson(smallJsont *self);
    657 internal smallJsont* lTrimSmallJson(smallJsont *self);
    658 internal smallJsont* rTrimSmallJson(smallJsont *self);
    659 internal char** keysSmallJson(smallJsont *self);
    660 internal smallArrayt* keysSmallStringSmallJson(smallJsont *self);
    661 internal smallArrayt* valuesSmallJson(smallJsont *self);
    662 internal smallJsont* compactSmallJson(smallJsont *self);
    663 internal smallJsont* emptySmallJson(smallJsont *self);
    664 internal bool isEmptySmallJson(smallJsont *self);
    665 internal bool isBlankSmallJson(smallJsont *self);
    666 internal void forEachSmallJsonF(smallJsont *self, void *closure, forEachElementSmallArrayFt funcElem);
    667 internal void enumerateSmallJsonF(smallJsont *self, void *closure, enumerateElementSmallArrayFt funcElem);
    668 internal void enumerateDictSmallJson(smallJsont *self, void *closure, enumerateDictElementSmallJsonFt funcElem);
    669 internal smallStringt* joinSmallJson(smallJsont *self, const char* delim);
    670 internal smallStringt* joinCharSmallJson(smallJsont *self, char c);
    671 internal smallStringt* joinSmallJsonSmallJson(smallJsont *self, smallJsont* delim);
    672 internal smallStringt* joinSmallStringSmallJson(smallJsont *self, smallStringt* delim);
    673 internal char* joinSSmallJson(smallJsont *self, const char* delim);
    674 internal char* joinCharSSmallJson(smallJsont *self, char c);
    675 internal char* joinSmallJsonSSmallJson(smallJsont *self, smallJsont* delim);
    676 internal char* joinSmallStringSSmallJson(smallJsont *self, smallStringt* delim);
    677 internal smallJsont* splitSmallJson(smallJsont *self, const char *delim);
    678 internal smallJsont* splitCharSmallJson(smallJsont *self, char c);
    679 internal smallJsont* splitSmallJsonSmallJson(smallJsont *self, smallJsont *delim);
    680 internal smallJsont* splitSmallStringSmallJson(smallJsont *self, smallStringt *delim);
    681 internal char** splitSSmallJson(smallJsont *self, const char *delim);
    682 internal char** splitCharSSmallJson(smallJsont *self, char c);
    683 internal char** splitSmallJsonSSmallJson(smallJsont *self, smallJsont *delim);
    684 internal char** splitSmallStringSSmallJson(smallJsont *self, smallStringt *delim);
    685 internal smallJsont* extractSmallJson(smallJsont *self, const char* delim1, const char* delim2);
    686 internal smallJsont* extractCharSSmallJson(smallJsont *self, char delim1, const char* delim2);
    687 internal smallJsont* extractSCharSmallJson(smallJsont *self, const char* delim1, char delim2);
    688 internal smallJsont* extractCharCharSmallJson(smallJsont *self, char delim1, char delim2);
    689 internal smallJsont* extractSmallJsonSmallJsonSmallJson(smallJsont *self, smallJsont* delim1, smallJsont* delim2);
    690 internal smallJsont* extractSmallJsonSmallStringSmallJson(smallJsont *self, smallJsont* delim1, smallStringt* delim2);
    691 internal smallJsont* extractSmallJsonSSmallJson(smallJsont *self, smallJsont* delim1, const char* delim2);
    692 internal smallJsont* extractSmallJsonCharSmallJson(smallJsont *self, smallJsont* delim1, char delim2);
    693 internal smallJsont* extractSmallStringSmallJsonSmallJson(smallJsont *self, smallStringt* delim1, smallJsont* delim2);
    694 internal smallJsont* extractSmallStringSmallStringSmallJson(smallJsont *self, smallStringt* delim1, smallStringt* delim2);
    695 internal smallJsont* extractSmallStringSSmallJson(smallJsont *self, smallStringt* delim1, const char* delim2);
    696 internal smallJsont* extractSmallStringCharSmallJson(smallJsont *self, smallStringt* delim1, char delim2);
    697 internal smallJsont* extractSSmallJsonSmallJson(smallJsont *self, const char* delim1, smallJsont* delim2);
    698 internal smallJsont* extractSSmallStringSmallJson(smallJsont *self, const char* delim1, smallStringt* delim2);
    699 internal smallJsont* extractCharSmallJsonSmallJson(smallJsont *self, char delim1, smallJsont* delim2);
    700 internal smallJsont* extractCharSmallStringSmallJson(smallJsont *self, char delim1, smallStringt* delim2);
    701 internal smallJsont* icSplitSmallJson(smallJsont *self, const char *delim);
    702 internal smallJsont* icSplitCharSmallJson(smallJsont *self, char c);
    703 internal smallJsont* icSplitSmallJsonSmallJson(smallJsont *self, smallJsont *delim);
    704 internal smallJsont* icSplitSmallStringSmallJson(smallJsont *self, smallStringt *delim);
    705 internal char** icSplitSSmallJson(smallJsont *self, const char *delim);
    706 internal char** icSplitCharSSmallJson(smallJsont *self, char c);
    707 internal char** icSplitSmallJsonSSmallJson(smallJsont *self, smallJsont *delim);
    708 internal char** icSplitSmallStringSSmallJson(smallJsont *self, smallStringt *delim);
    709 internal smallJsont* icExtractSmallJson(smallJsont *self, const char* delim1, const char* delim2);
    710 internal smallJsont* icExtractCharSSmallJson(smallJsont *self, char delim1, const char* delim2);
    711 internal smallJsont* icExtractSCharSmallJson(smallJsont *self, const char* delim1, char delim2);
    712 internal smallJsont* icExtractCharCharSmallJson(smallJsont *self, char delim1, char delim2);
    713 internal smallJsont* icExtractSmallJsonSmallJsonSmallJson(smallJsont *self, smallJsont* delim1, smallJsont* delim2);
    714 internal smallJsont* icExtractSmallJsonSmallStringSmallJson(smallJsont *self, smallJsont* delim1, smallStringt* delim2);
    715 internal smallJsont* icExtractSmallJsonSSmallJson(smallJsont *self, smallJsont* delim1, const char* delim2);
    716 internal smallJsont* icExtractSmallJsonCharSmallJson(smallJsont *self, smallJsont* delim1, char delim2);
    717 internal smallJsont* icExtractSmallStringSmallJsonSmallJson(smallJsont *self, smallStringt* delim1, smallJsont* delim2);
    718 internal smallJsont* icExtractSmallStringSmallStringSmallJson(smallJsont *self, smallStringt* delim1, smallStringt* delim2);
    719 internal smallJsont* icExtractSmallStringSSmallJson(smallJsont *self, smallStringt* delim1, const char* delim2);
    720 internal smallJsont* icExtractSmallStringCharSmallJson(smallJsont *self, smallStringt* delim1, char delim2);
    721 internal smallJsont* icExtractSSmallJsonSmallJson(smallJsont *self, const char* delim1, smallJsont* delim2);
    722 internal smallJsont* icExtractSSmallStringSmallJson(smallJsont *self, const char* delim1, smallStringt* delim2);
    723 internal smallJsont* icExtractCharSmallJsonSmallJson(smallJsont *self, char delim1, smallJsont* delim2);
    724 internal smallJsont* icExtractCharSmallStringSmallJson(smallJsont *self, char delim1, smallStringt* delim2);
    725 internal smallJsont* colorSmallJson(smallJsont *self, const char *colr);
    726 internal char* colordSmallJson(smallJsont *self, const char *color);
    727 internal smallJsont* zipSmallJson(smallJsont *self, smallArrayt *array1, smallArrayt *array2);
    728 internal smallJsont* zipArraySmallJson(smallJsont *self, char** array1, smallArrayt *array2);
    729 internal smallJsont* zipCArraySmallJson(smallJsont *self, const char** array1, smallArrayt *array2);
    730 internal smallJsont* zipCharSmallJson(smallJsont *self, smallArrayt *array1, char** array2);
    731 internal smallJsont* zipCCharSmallJson(smallJsont *self, smallArrayt *array1, const char** array2);
    732 internal smallJsont* zipArrayCharSmallJson(smallJsont *self, char** array1, char** array2);
    733 internal smallJsont* zipCArrayCharSmallJson(smallJsont *self, const char** array1, char** array2);
    734 internal smallJsont* zipArrayCCharSmallJson(smallJsont *self, char** array1, const char** array2);
    735 internal smallJsont* zipCArrayCCharSmallJson(smallJsont *self, const char** array1, const char** array2);
    736 smallJsont* zipJsonSmallJson(smallJsont *self, smallJsont *array1, smallJsont *array2);
    737 smallJsont* zipJsonSmallArraySmallJson(smallJsont *self, smallJsont *array1, smallArrayt *array2);
    738 smallJsont* zipJsonArraySmallJson(smallJsont *self, smallJsont *array1, char** array2);
    739 smallJsont* zipJsonCArraySmallJson(smallJsont *self, smallJsont *array1, const char** array2);
    740 smallJsont* zipSmallArrayJsonSmallJson(smallJsont *self, smallArrayt *array1, smallJsont *array2);
    741 smallJsont* zipArrayJsonSmallJson(smallJsont *self, char** array1, smallJsont *array2);
    742 smallJsont* zipCArrayJsonSmallJson(smallJsont *self, const char** array1, smallJsont *array2);
    743 internal baset* iterStartSmallJson(smallJsont *self);
    744 internal const char* iterStartKeySmallJson(smallJsont *self);
    745 internal baset* iterStartLastSmallJson(smallJsont *self);
    746 internal baset* iterStartFromSmallJson(smallJsont *self, int64_t index);
    747 internal baset* iterStartFromStepSmallJson(smallJsont *self, int64_t index, int64_t step);
    748 internal baset* iterNextSmallJson(smallJsont *self);
    749 internal const char* iterNextKeySmallJson(smallJsont *self);
    750 internal baset* iterElementSmallJson(smallJsont *self);
    751 internal const char* iterKeySmallJson(smallJsont *self);
    752 internal ssize_t iterIndexSmallJson(smallJsont *self);
    753 internal int64_t iterStepSmallJson(smallJsont *self);
    754 internal baset* getSmallJson(smallJsont *self, const char *key);
    755 internal undefinedt* getUndefinedSmallJson(smallJsont *self, const char *key);
    756 internal bool getBoolSmallJson(smallJsont *self, const char *key);
    757 internal bool* getBoolPSmallJson(smallJsont *self, const char *key);
    758 internal double getDoubleSmallJson(smallJsont *self, const char *key);
    759 internal double* getDoublePSmallJson(smallJsont *self, const char *key);
    760 internal int64_t getIntSmallJson(smallJsont *self, const char *key);
    761 internal int64_t* getIntPSmallJson(smallJsont *self, const char *key);
    762 internal int32_t getInt32SmallJson(smallJsont *self, const char *key);
    763 internal int32_t* getInt32PSmallJson(smallJsont *self, const char *key);
    764 internal uint64_t getUintSmallJson(smallJsont *self, const char *key);
    765 internal uint64_t* getUintPSmallJson(smallJsont *self, const char *key);
    766 internal uint32_t getUint32SmallJson(smallJsont *self, const char *key);
    767 internal uint32_t* getUint32PSmallJson(smallJsont *self, const char *key);
    768 internal char* getSSmallJson(smallJsont *self, const char *key);
    769 internal smallDictt* getDictSmallJson(smallJsont *self, const char *key);
    770 internal smallArrayt* getArraySmallJson(smallJsont *self, const char *key);
    771 internal smallBoolt* getSmallBoolSmallJson(smallJsont *self, const char *key);
    772 internal smallBytest* getSmallBytesSmallJson(smallJsont *self, const char *key);
    773 internal smallDoublet* getSmallDoubleSmallJson(smallJsont *self, const char *key);
    774 internal smallIntt* getSmallIntSmallJson(smallJsont *self, const char *key);
    775 internal smallJsont* getSmallJsonSmallJson(smallJsont *self, const char *key);
    776 internal smallStringt* getSmallStringSmallJson(smallJsont *self, const char *key);
    777 internal void* getVoidSmallJson(smallJsont *self, const char *key);
    778 internal smallContainert* getSmallContainerSmallJson(smallJsont *self, const char *key);
    779 internal baset* getNDupSmallJson(smallJsont *self, const char *key);
    780 internal undefinedt* getNDupUndefinedSmallJson(smallJsont *self, const char *key);
    781 internal bool getNDupBoolSmallJson(smallJsont *self, const char *key);
    782 internal double getNDupDoubleSmallJson(smallJsont *self, const char *key);
    783 internal int64_t getNDupIntSmallJson(smallJsont *self, const char *key);
    784 internal int32_t getNDupInt32SmallJson(smallJsont *self, const char *key);
    785 internal uint64_t getNDupUintSmallJson(smallJsont *self, const char *key);
    786 internal uint32_t getNDupUint32SmallJson(smallJsont *self, const char *key);
    787 internal char* getNDupSSmallJson(smallJsont *self, const char *key);
    788 internal smallDictt* getNDupDictSmallJson(smallJsont *self, const char *key);
    789 internal smallArrayt* getNDupArraySmallJson(smallJsont *self, const char *key);
    790 internal smallBoolt* getNDupSmallBoolSmallJson(smallJsont *self, const char *key);
    791 internal smallBytest* getNDupSmallBytesSmallJson(smallJsont *self, const char *key);
    792 internal smallDoublet* getNDupSmallDoubleSmallJson(smallJsont *self, const char *key);
    793 internal smallIntt* getNDupSmallIntSmallJson(smallJsont *self, const char *key);
    794 internal smallJsont* getNDupSmallJsonSmallJson(smallJsont *self, const char *key);
    795 internal smallStringt* getNDupSmallStringSmallJson(smallJsont *self, const char *key);
    796 internal void* getNDupVoidSmallJson(smallJsont *self, const char *key);
    797 internal smallContainert* getNDupSmallContainerSmallJson(smallJsont *self, const char *key);
    798 baset* getAtSmallJson(smallJsont *self, int64_t index);
    799 internal undefinedt* getAtUndefinedSmallJson(smallJsont *self, int64_t index);
    800 internal bool getAtBoolSmallJson(smallJsont *self, int64_t index);
    801 internal bool* getAtBoolPSmallJson(smallJsont *self, int64_t index);
    802 internal double getAtDoubleSmallJson(smallJsont *self, int64_t index);
    803 internal double* getAtDoublePSmallJson(smallJsont *self, int64_t index);
    804 internal int64_t getAtIntSmallJson(smallJsont *self, int64_t index);
    805 internal int64_t* getAtIntPSmallJson(smallJsont *self, int64_t index);
    806 internal int32_t getAtInt32SmallJson(smallJsont *self, int64_t index);
    807 internal int32_t* getAtInt32PSmallJson(smallJsont *self, int64_t index);
    808 internal uint64_t getAtUintSmallJson(smallJsont *self, int64_t index);
    809 internal uint64_t* getAtUintPSmallJson(smallJsont *self, int64_t index);
    810 internal uint32_t getAtUint32SmallJson(smallJsont *self, int64_t index);
    811 internal uint32_t* getAtUint32PSmallJson(smallJsont *self, int64_t index);
    812 internal char* getAtSSmallJson(smallJsont *self, int64_t index);
    813 internal smallDictt* getAtDictSmallJson(smallJsont *self, int64_t index);
    814 internal smallArrayt* getAtArraySmallJson(smallJsont *self, int64_t index);
    815 internal smallBoolt* getAtSmallBoolSmallJson(smallJsont *self, int64_t index);
    816 internal smallBytest* getAtSmallBytesSmallJson(smallJsont *self, int64_t index);
    817 internal smallDoublet* getAtSmallDoubleSmallJson(smallJsont *self, int64_t index);
    818 internal smallIntt* getAtSmallIntSmallJson(smallJsont *self, int64_t index);
    819 internal smallJsont* getAtSmallJsonSmallJson(smallJsont *self, int64_t index);
    820 internal smallStringt* getAtSmallStringSmallJson(smallJsont *self, int64_t index);
    821 internal void* getAtVoidSmallJson(smallJsont *self, int64_t index);
    822 internal smallContainert* getAtSmallContainerSmallJson(smallJsont *self, int64_t index);
    823 baset* getAtNDupSmallJson(smallJsont *self, int64_t index);
    824 internal undefinedt* getAtNDupUndefinedSmallJson(smallJsont *self, int64_t index);
    825 internal bool getAtNDupBoolSmallJson(smallJsont *self, int64_t index);
    826 internal double getAtNDupDoubleSmallJson(smallJsont *self, int64_t index);
    827 internal int64_t getAtNDupIntSmallJson(smallJsont *self, int64_t index);
    828 internal int32_t getAtNDupInt32SmallJson(smallJsont *self, int64_t index);
    829 internal uint64_t getAtNDupUintSmallJson(smallJsont *self, int64_t index);
    830 internal uint32_t getAtNDupUint32SmallJson(smallJsont *self, int64_t index);
    831 internal char* getAtNDupSSmallJson(smallJsont *self, int64_t index);
    832 internal smallDictt* getAtNDupDictSmallJson(smallJsont *self, int64_t index);
    833 internal smallArrayt* getAtNDupArraySmallJson(smallJsont *self, int64_t index);
    834 internal smallBoolt* getAtNDupSmallBoolSmallJson(smallJsont *self, int64_t index);
    835 internal smallBytest* getAtNDupSmallBytesSmallJson(smallJsont *self, int64_t index);
    836 internal smallDoublet* getAtNDupSmallDoubleSmallJson(smallJsont *self, int64_t index);
    837 internal smallIntt* getAtNDupSmallIntSmallJson(smallJsont *self, int64_t index);
    838 internal smallJsont* getAtNDupSmallJsonSmallJson(smallJsont *self, int64_t index);
    839 internal smallStringt* getAtNDupSmallStringSmallJson(smallJsont *self, int64_t index);
    840 internal void* getAtNDupVoidSmallJson(smallJsont *self, int64_t index);
    841 internal smallContainert* getAtNDupSmallContainerSmallJson(smallJsont *self, int64_t index);
    842 internal double getNumSmallJson(smallJsont *self, const char *key);
    843 internal double getNumAtSmallJson(smallJsont *self, int64_t index);
    844 internal smallJsont* delElemSmallJson(smallJsont *self, const char *key);
    845 internal smallJsont* delSmallJson(smallJsont *self, int64_t start, int64_t end);
    846 internal smallJsont* delElemIndexSmallJson(smallJsont *self, int64_t index);
    847 internal smallJsont* removeElemSmallJson(smallJsont *self, const char *key);
    848 internal smallJsont* removeSmallJson(smallJsont *self, int64_t start, int64_t end);
    849 internal smallJsont* removeElemIndexSmallJson(smallJsont *self, int64_t index);
    850 internal char** sDictStringifyForeach(sDictElemt *e, char *indentS2, int indent, int level);
    851 internal char** sDictStringify(sDictt *dict, int indent, int level);
    852 internal char** sArrayStringify(sArrayt *array, int indent, int level);
    853 internal char* stringifySmallJson(smallJsont *self, int indent);
    854 internal smallStringt* stringifySmallStringSmallJson(smallJsont *self, int indent);
    855 internal char** sDictToYMLForeach(sDictElemt *e, char *indentS2, int indent, int level);
    856 internal char **sDictToYML(sDictt* dict, int indent, int level);
    857 internal char **sArrayToYML(sArrayt* array, int indent, int level);
    858 internal char* toYMLSmallJson(smallJsont *self, int indent);
    859 internal smallStringt* toYMLSmallStringSmallJson(smallJsont *self, int indent);
    860 internal bool parseSmallJson(smallJsont *self, const char *input);
    861 internal bool parseSmallJsonSmallJson(smallJsont *self, smallJsont *input);
    862 internal bool parseSmallStringSmallJson(smallJsont *self, smallStringt *input);
    863 internal void addObject(smallJsont *self, smallt *obj);
    864 internal int on_string(struct LaxJsonContext *context, enum LaxJsonType type, const char *value, int length UNUSED);
    865 internal int on_number(struct LaxJsonContext *context, char *x);
    866 internal int on_primitive(struct LaxJsonContext *context, enum LaxJsonType type);
    867 internal int on_begin(struct LaxJsonContext *context, enum LaxJsonType type);
    868 internal int on_end(struct LaxJsonContext *context, enum LaxJsonType type UNUSED);
    869 internal bool parseYMLSmallJson(smallJsont *self, const char *input);
    870 internal bool parseYMLSmallJsonSmallJson(smallJsont *self, smallJsont *input);
    871 internal bool parseYMLSmallStringSmallJson(smallJsont *self, smallStringt *input);
    872 internal int on_stringY(smallJsont *self, const char *value, enum LaxJsonType type);
    873 internal int on_beginYDict(smallJsont *self);
    874 internal int on_beginYArray(smallJsont *self);
    875 internal int on_endY(smallJsont *self);
    876 internal int on_primitiveY(smallJsont *self, enum LaxJsonType type);
    877 internal int on_numberY(smallJsont *self UNUSED, char *x);
    878 internal void pushTypeY(smallJsont *self, char *v);
    879 internal smallBytest* serialSmallJson(smallJsont *self);
    880 internal smallJsont* deserialSmallJson(smallJsont *self, smallBytest *data);
    881 internal void logSmallJson(smallJsont *self);
    882 internal smallJsont* readFileSmallJson(smallJsont *self, const char *filePath);
    883 internal smallJsont* readFileSmallStringSmallJson(smallJsont *self, smallStringt *filePath);
    884 internal smallJsont* readFileJsonSmallJson(smallJsont *self, smallJsont *filePath);
    885 internal smallJsont* readStreamSmallJson(smallJsont *self, FILE *fp);
    886 internal int writeFileSmallJson(smallJsont *self, const char *filePath);
    887 internal int writeFileSmallStringSmallJson(smallJsont *self, smallStringt *filePath);
    888 internal int writeFileJsonSmallJson(smallJsont *self, smallJsont *filePath);
    889 internal int writeStreamSmallJson(smallJsont *self, FILE *fp);
    890 internal int appendFileSmallJson(smallJsont *self, const char *filePath);
    891 internal int appendFileSmallStringSmallJson(smallJsont *self, smallStringt *filePath);
    892 internal int appendFileJsonSmallJson(smallJsont *self, smallJsont *filePath);
    893 internal smallJsont* readTextSmallJson(smallJsont *self, const char *filePath);
    894 internal smallJsont* readTextSmallStringSmallJson(smallJsont *self, smallStringt *filePath);
    895 internal smallJsont* readTextJsonSmallJson(smallJsont *self, smallJsont *filePath);
    896 internal smallJsont* readTextStreamSmallJson(smallJsont *self, FILE *fp);
    897 internal bool writeTextSmallJson(smallJsont *self, const char *filePath);
    898 internal bool writeTextSmallStringSmallJson(smallJsont *self, smallStringt *filePath);
    899 internal bool writeTextJsonSmallJson(smallJsont *self, smallJsont *filePath);
    900 internal bool writeTextStreamSmallJson(smallJsont *self, FILE *fp);
    901 internal bool appendTextSmallJson(smallJsont *self, const char *filePath);
    902 internal bool appendTextSmallStringSmallJson(smallJsont *self, smallStringt *filePath);
    903 internal bool appendTextJsonSmallJson(smallJsont *self, smallJsont *filePath);
    904 internal const char* typeStringSmallJson(smallJsont *self, const char *key);
    905 internal smallStringt* typeSmallStringSmallJson(smallJsont *self, const char *key);
    906 internal const char* typeAtStringSmallJson(smallJsont *self, int64_t index);
    907 internal smallStringt* typeAtSmallStringSmallJson(smallJsont *self, int64_t index);
    908 internal const char* typeStringKCharSmallJson(smallJsont *self, char key);
    909 internal smallStringt* typeSmallStringKCharSmallJson(smallJsont *self, char key);
    910 internal char typeSmallJson(smallJsont *self, const char *key);
    911 internal char typeKCharSmallJson(smallJsont *self, char key);
    912 internal char typeAtSmallJson(smallJsont *self, int64_t index);
    913 internal smallJsont* typeStringsSmallJson(smallJsont *self);
    914 internal smallBytest* typesSmallJson(smallJsont *self);
    915 internal bool isETypeAtSmallJson(smallJsont *self, int64_t index, const char *type);
    916 internal bool isEUndefinedAtSmallJson(smallJsont *self, int64_t index);
    917 internal bool isEBoolAtSmallJson(smallJsont *self, int64_t index);
    918 internal bool isEContainerAtSmallJson(smallJsont *self, int64_t index);
    919 internal bool isEDictAtSmallJson(smallJsont *self, int64_t index);
    920 internal bool isEDoubleAtSmallJson(smallJsont *self, int64_t index);
    921 internal bool isEIntAtSmallJson(smallJsont *self, int64_t index);
    922 internal bool isEStringAtSmallJson(smallJsont *self, int64_t index);
    923 internal bool isEFaststringAtSmallJson(smallJsont *self, int64_t index);
    924 internal bool isEArrayAtSmallJson(smallJsont *self, int64_t index);
    925 internal bool isEBytesAtSmallJson(smallJsont *self, int64_t index);
    926 internal bool isETypeSmallJson(smallJsont *self, const char *key, const char *type);
    927 internal bool isEUndefinedSmallJson(smallJsont *self, const char *key);
    928 internal bool isEBoolSmallJson(smallJsont *self, const char *key);
    929 internal bool isEContainerSmallJson(smallJsont *self, const char *key);
    930 internal bool isEDictSmallJson(smallJsont *self, const char *key);
    931 internal bool isEDoubleSmallJson(smallJsont *self, const char *key);
    932 internal bool isEIntSmallJson(smallJsont *self, const char *key);
    933 internal bool isEStringSmallJson(smallJsont *self, const char *key);
    934 internal bool isEFaststringSmallJson(smallJsont *self, const char *key);
    935 internal bool isEArraySmallJson(smallJsont *self, const char *key);
    936 internal bool isEBytesSmallJson(smallJsont *self, const char *key);
    937 internal bool areAllETypeSmallJson(smallJsont *self, const char *type);
    938 internal bool areAllEUndefinedSmallJson(smallJsont *self);
    939 internal bool areAllEBoolSmallJson(smallJsont *self);
    940 internal bool areAllEContainerSmallJson(smallJsont *self);
    941 internal bool areAllEDictSmallJson(smallJsont *self);
    942 internal bool areAllEDoubleSmallJson(smallJsont *self);
    943 internal bool areAllEIntSmallJson(smallJsont *self);
    944 internal bool areAllEStringSmallJson(smallJsont *self);
    945 internal bool areAllEFaststringSmallJson(smallJsont *self);
    946 internal bool areAllEArraySmallJson(smallJsont *self);
    947 internal bool areAllEBytesSmallJson(smallJsont *self);
    948 smallJsont* allocSmallJsonG(smallJsont *self UNUSED);
    949 smallJsont* duplicateSmallJsonG (smallJsont *self);
    950 smallJsont* setTopSmallJsonG           (smallJsont *self, baset *value);
    951 smallJsont* setTopBoolSmallJsonG       (smallJsont *self, bool value);
    952 smallJsont* setTopDoubleSmallJsonG     (smallJsont *self, double value);
    953 smallJsont* setTopIntSmallJsonG        (smallJsont *self, int64_t value);
    954 smallJsont* setTopStringSmallJsonG     (smallJsont *self, const char *value);
    955 smallJsont* setTopCharSmallJsonG(smallJsont *self, char c);
    956 smallJsont* setTopDictSmallJsonG       (smallJsont *self, smallDictt *value);
    957 smallJsont* setTopArraySmallJsonG      (smallJsont *self, smallArrayt *value);
    958 smallJsont* setTopArraycSmallJsonG     (smallJsont *self, char **value);
    959 smallJsont* setTopCArraycSmallJsonG    (smallJsont *self, const char **value);
    960 smallJsont* setTopSmallBoolSmallJsonG  (smallJsont *self, smallBoolt *value);
    961 smallJsont* setTopSmallDoubleSmallJsonG(smallJsont *self, smallDoublet *value);
    962 smallJsont* setTopSmallIntSmallJsonG   (smallJsont *self, smallIntt *value);
    963 smallJsont* setTopSmallJsonSmallJsonG(smallJsont *self, smallJsont *value);
    964 smallJsont* setTopSmallStringSmallJsonG(smallJsont *self, smallStringt *value);
    965 smallJsont* setTopNFreeSmallJsonG           (smallJsont *self, baset *value);
    966 smallJsont* setTopNFreeBoolSmallJsonG       (smallJsont *self, bool value);
    967 smallJsont* setTopNFreeDoubleSmallJsonG     (smallJsont *self, double value);
    968 smallJsont* setTopNFreeIntSmallJsonG        (smallJsont *self, int64_t value);
    969 smallJsont* setTopNFreeStringSmallJsonG     (smallJsont *self, char *value);
    970 smallJsont* setTopNFreeDictSmallJsonG       (smallJsont *self, smallDictt *value);
    971 smallJsont* setTopNFreeArraySmallJsonG      (smallJsont *self, smallArrayt *value);
    972 smallJsont* setTopNFreeArraycSmallJsonG      (smallJsont *self, char **value);
    973 smallJsont* setTopNFreeSmallBoolSmallJsonG  (smallJsont *self, smallBoolt *value);
    974 smallJsont* setTopNFreeSmallDoubleSmallJsonG(smallJsont *self, smallDoublet *value);
    975 smallJsont* setTopNFreeSmallIntSmallJsonG   (smallJsont *self, smallIntt *value);
    976 smallJsont* setTopNFreeSmallJsonSmallJsonG  (smallJsont *self, smallJsont *value);
    977 smallJsont* setTopNFreeSmallStringSmallJsonG(smallJsont *self, smallStringt *value);
    978 smallJsont*  fromArraySmallJsonG    (smallJsont *self, char **array, size_t size);
    979 smallJsont*  fromCArraySmallJsonG   (smallJsont *self, const char **array, size_t size);
    980 baset*        getTopSmallJsonG           (smallJsont *self,baset* retType UNUSED);
    981 undefinedt*   getTopUndefinedSmallJsonG  (smallJsont *self,undefinedt* retType UNUSED);
    982 bool          getTopBoolSmallJsonG      (smallJsont *self,bool retType UNUSED);
    983 bool*         getTopBoolPSmallJsonG      (smallJsont *self,bool* retType UNUSED);
    984 double        getTopDoubleSmallJsonG    (smallJsont *self,double retType UNUSED);
    985 double*       getTopDoublePSmallJsonG    (smallJsont *self,double* retType UNUSED);
    986 int64_t       getTopIntSmallJsonG       (smallJsont *self,int64_t retType UNUSED);
    987 int64_t*      getTopIntPSmallJsonG       (smallJsont *self,int64_t* retType UNUSED);
    988 int32_t       getTopInt32SmallJsonG     (smallJsont *self,int32_t retType UNUSED);
    989 int32_t*      getTopInt32PSmallJsonG     (smallJsont *self,int32_t* retType UNUSED);
    990 uint64_t      getTopUintSmallJsonG      (smallJsont *self,uint64_t retType UNUSED);
    991 uint64_t*     getTopUintPSmallJsonG      (smallJsont *self,uint64_t* retType UNUSED);
    992 uint32_t      getTopUint32SmallJsonG    (smallJsont *self,uint32_t retType UNUSED);
    993 uint32_t*     getTopUint32PSmallJsonG    (smallJsont *self,uint32_t* retType UNUSED);
    994 char*         getTopSSmallJsonG          (smallJsont *self,char* retType UNUSED);
    995 smallDictt*   getTopDictSmallJsonG       (smallJsont *self,smallDictt* retType UNUSED);
    996 smallArrayt*  getTopArraySmallJsonG      (smallJsont *self,smallArrayt* retType UNUSED);
    997 smallBoolt*   getTopSmallBoolSmallJsonG  (smallJsont *self,smallBoolt* retType UNUSED);
    998 smallDoublet* getTopSmallDoubleSmallJsonG(smallJsont *self,smallDoublet* retType UNUSED);
    999 smallIntt*    getTopSmallIntSmallJsonG   (smallJsont *self,smallIntt* retType UNUSED);
   1000 smallStringt* getTopSmallStringSmallJsonG(smallJsont *self,smallStringt* retType UNUSED);
   1001 smallJsont* pushSmallJsonG         (smallJsont *self, baset *value);
   1002 smallJsont* pushUndefinedSmallJsonG(smallJsont *self, void *value UNUSED);
   1003 smallJsont* pushBoolSmallJsonG     (smallJsont *self, bool value);
   1004 smallJsont* pushDoubleSmallJsonG   (smallJsont *self, double value);
   1005 smallJsont* pushIntSmallJsonG      (smallJsont *self, int64_t value);
   1006 smallJsont* pushSSmallJsonG        (smallJsont *self, const char *string);
   1007 smallJsont* pushCharSmallJsonG(smallJsont *self, char c);
   1008 smallJsont* pushDictSmallJsonG     (smallJsont *self, smallDictt *dict);
   1009 smallJsont* pushArraySmallJsonG    (smallJsont *self, smallArrayt *array);
   1010 smallJsont* pushArraycSmallJsonG   (smallJsont *self, char **array);
   1011 smallJsont* pushCArraycSmallJsonG  (smallJsont *self, const char **array);
   1012 smallJsont* pushVoidSmallJsonG     (smallJsont *self, void *value);
   1013 smallJsont* pushSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value);
   1014 smallJsont* pushSmallBytesSmallJsonG     (smallJsont *self, smallBytest *value);
   1015 smallJsont* pushSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value);
   1016 smallJsont* pushSmallIntSmallJsonG      (smallJsont *self, smallIntt *value);
   1017 smallJsont* pushSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value);
   1018 smallJsont* pushSmallStringSmallJsonG   (smallJsont *self, smallStringt *string);
   1019 smallJsont* pushSmallContainerSmallJsonG(smallJsont *self, smallContainert *container);
   1020 smallJsont* pushNFreeSmallJsonG         (smallJsont *self, baset *value);
   1021 smallJsont* pushNFreeUndefinedSmallJsonG(smallJsont *self, undefinedt *value);
   1022 smallJsont* pushNFreeSSmallJsonG        (smallJsont *self, char *string);
   1023 smallJsont* pushNFreeDictSmallJsonG     (smallJsont *self, smallDictt *dict);
   1024 smallJsont* pushNFreeArraySmallJsonG    (smallJsont *self, smallArrayt *array);
   1025 smallJsont* pushNFreeArraycSmallJsonG   (smallJsont *self, char **array);
   1026 smallJsont* pushNFreeSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value);
   1027 smallJsont* pushNFreeSmallBytesSmallJsonG     (smallJsont *self, smallBytest *value);
   1028 smallJsont* pushNFreeSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value);
   1029 smallJsont* pushNFreeSmallIntSmallJsonG      (smallJsont *self, smallIntt *value);
   1030 smallJsont* pushNFreeSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value);
   1031 smallJsont* pushNFreeSmallStringSmallJsonG   (smallJsont *self, smallStringt *string);
   1032 smallJsont* pushNFreeSmallContainerSmallJsonG(smallJsont *self, smallContainert *container);
   1033 baset*           popSmallJsonG              (smallJsont *self, baset* retType UNUSED);
   1034 undefinedt*      popUndefinedSmallJsonG     (smallJsont *self, undefinedt* retType UNUSED);
   1035 bool             popBoolSmallJsonG          (smallJsont *self, bool retType UNUSED);
   1036 double           popDoubleSmallJsonG        (smallJsont *self, double retType UNUSED);
   1037 int64_t          popIntSmallJsonG           (smallJsont *self, int64_t retType UNUSED);
   1038 int32_t          popInt32SmallJsonG         (smallJsont *self, int32_t retType UNUSED);
   1039 uint64_t         popUintSmallJsonG          (smallJsont *self, uint64_t retType UNUSED);
   1040 uint32_t         popUint32SmallJsonG        (smallJsont *self, uint32_t retType UNUSED);
   1041 char*            popSSmallJsonG             (smallJsont *self, char* retType UNUSED);
   1042 smallDictt*      popDictSmallJsonG          (smallJsont *self, smallDictt* retType UNUSED);
   1043 smallArrayt*     popArraySmallJsonG         (smallJsont *self, smallArrayt* retType UNUSED);
   1044 smallBoolt*      popSmallBoolSmallJsonG     (smallJsont *self, smallBoolt* retType UNUSED);
   1045 smallBytest*      popSmallBytesSmallJsonG     (smallJsont *self, smallBytest* retType UNUSED);
   1046 smallDoublet*    popSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet* retType UNUSED);
   1047 smallIntt*       popSmallIntSmallJsonG      (smallJsont *self, smallIntt* retType UNUSED);
   1048 smallJsont*      popSmallJsonSmallJsonG     (smallJsont *self, smallJsont* retType UNUSED);
   1049 smallStringt*    popSmallStringSmallJsonG   (smallJsont *self, smallStringt* retType UNUSED);
   1050 void*            popVoidSmallJsonG          (smallJsont *self, void* retType UNUSED);
   1051 smallContainert* popSmallContainerSmallJsonG(smallJsont *self, smallContainert* retType UNUSED);
   1052 smallJsont*   setSmallJsonG       (smallJsont *self, const char *key, baset *value);
   1053 smallJsont* setUndefinedSmallJsonG(smallJsont *self, const char *key, void *value UNUSED);
   1054 smallJsont* setBoolSmallJsonG     (smallJsont *self, const char *key, bool value);
   1055 smallJsont* setDoubleSmallJsonG   (smallJsont *self, const char *key, double value);
   1056 smallJsont* setIntSmallJsonG      (smallJsont *self, const char *key, int64_t value);
   1057 smallJsont* setSSmallJsonG        (smallJsont *self, const char *key, const char *string);
   1058 smallJsont* setCharSmallJsonG(smallJsont *self, const char *key, char c);
   1059 smallJsont* setDictSmallJsonG     (smallJsont *self, const char *key, smallDictt *dict);
   1060 smallJsont* setArraySmallJsonG    (smallJsont *self, const char *key, smallArrayt *array);
   1061 smallJsont* setArraycSmallJsonG   (smallJsont *self, const char *key, char **array);
   1062 smallJsont* setCArraycSmallJsonG  (smallJsont *self, const char *key, const char **array);
   1063 smallJsont* setVoidSmallJsonG     (smallJsont *self, const char *key, void *value);
   1064 smallJsont* setSmallBoolSmallJsonG     (smallJsont *self, const char *key, smallBoolt *value);
   1065 smallJsont* setSmallBytesSmallJsonG    (smallJsont *self, const char *key, smallBytest *value);
   1066 smallJsont* setSmallDoubleSmallJsonG   (smallJsont *self, const char *key, smallDoublet *value);
   1067 smallJsont* setSmallIntSmallJsonG      (smallJsont *self, const char *key, smallIntt *value);
   1068 smallJsont* setSmallJsonSmallJsonG     (smallJsont *self, const char *key, smallJsont *value);
   1069 smallJsont* setSmallStringSmallJsonG   (smallJsont *self, const char *key, smallStringt *string);
   1070 smallJsont* setSmallContainerSmallJsonG(smallJsont *self, const char *key, smallContainert *container);
   1071 smallJsont* setNFreeSmallJsonG         (smallJsont *self, const char *key, baset *value);
   1072 smallJsont* setNFreeUndefinedSmallJsonG(smallJsont *self, const char *key, undefinedt *value);
   1073 smallJsont* setNFreeSSmallJsonG        (smallJsont *self, const char *key, char *string);
   1074 smallJsont* setNFreeDictSmallJsonG     (smallJsont *self, const char *key, smallDictt *dict);
   1075 smallJsont* setNFreeArraySmallJsonG    (smallJsont *self, const char *key, smallArrayt *array);
   1076 smallJsont* setNFreeArraycSmallJsonG   (smallJsont *self, const char *key, char **array);
   1077 smallJsont* setNFreeSmallBoolSmallJsonG     (smallJsont *self, const char *key, smallBoolt *value);
   1078 smallJsont* setNFreeSmallBytesSmallJsonG    (smallJsont *self, const char *key, smallBytest *value);
   1079 smallJsont* setNFreeSmallDoubleSmallJsonG   (smallJsont *self, const char *key, smallDoublet *value);
   1080 smallJsont* setNFreeSmallIntSmallJsonG      (smallJsont *self, const char *key, smallIntt *value);
   1081 smallJsont* setNFreeSmallJsonSmallJsonG     (smallJsont *self, const char *key, smallJsont *value);
   1082 smallJsont* setNFreeSmallStringSmallJsonG   (smallJsont *self, const char *key, smallStringt *string);
   1083 smallJsont* setNFreeSmallContainerSmallJsonG(smallJsont *self, const char *key, smallContainert *container);
   1084 smallJsont* setPDictSmallJsonG    (smallJsont *self, const char *key, smallDictt *dict);
   1085 smallJsont* setPArraySmallJsonG   (smallJsont *self, const char *key, smallArrayt *array);
   1086 smallJsont* setPSmallJsonSmallJsonG(smallJsont *self, const char *key, smallJsont *value);
   1087 smallJsont* setPSmallStringSmallJsonG(smallJsont *self, const char *key, smallStringt *string);
   1088 smallJsont* setNFreePDictSmallJsonG    (smallJsont *self, const char *key, smallDictt *dict);
   1089 smallJsont* setNFreePArraySmallJsonG   (smallJsont *self, const char *key, smallArrayt *array);
   1090 smallJsont* setNFreePSmallJsonSmallJsonG(smallJsont *self, const char *key, smallJsont *value);
   1091 smallJsont* setNFreePSmallStringSmallJsonG(smallJsont *self, const char *key, smallStringt *string);
   1092 smallJsont* setAtSmallJsonG         (smallJsont *self, int64_t index, baset *value);
   1093 smallJsont* setAtUndefinedSmallJsonG(smallJsont *self, int64_t index, void *value);
   1094 smallJsont* setAtBoolSmallJsonG     (smallJsont *self, int64_t index, bool value);
   1095 smallJsont* setAtDoubleSmallJsonG   (smallJsont *self, int64_t index, double value);
   1096 smallJsont* setAtIntSmallJsonG      (smallJsont *self, int64_t index, int64_t value);
   1097 smallJsont* setAtSSmallJsonG        (smallJsont *self, int64_t index, const char *string);
   1098 smallJsont* setAtCharSmallJsonG(smallJsont *self, int64_t index, char c);
   1099 smallJsont* setAtDictSmallJsonG     (smallJsont *self, int64_t index, smallDictt *dict);
   1100 smallJsont* setAtArraySmallJsonG    (smallJsont *self, int64_t index, smallArrayt *array);
   1101 smallJsont* setAtArraycSmallJsonG   (smallJsont *self, int64_t index, char **array);
   1102 smallJsont* setAtCArraycSmallJsonG  (smallJsont *self, int64_t index, const char **array);
   1103 smallJsont* setAtVoidSmallJsonG     (smallJsont *self, int64_t index, void *value);
   1104 smallJsont* setAtSmallBoolSmallJsonG     (smallJsont *self, int64_t index, smallBoolt *value);
   1105 smallJsont* setAtSmallBytesSmallJsonG    (smallJsont *self, int64_t index, smallBytest *value);
   1106 smallJsont* setAtSmallDoubleSmallJsonG   (smallJsont *self, int64_t index, smallDoublet *value);
   1107 smallJsont* setAtSmallIntSmallJsonG      (smallJsont *self, int64_t index, smallIntt *value);
   1108 smallJsont* setAtSmallJsonSmallJsonG     (smallJsont *self, int64_t index, smallJsont *value);
   1109 smallJsont* setAtSmallStringSmallJsonG   (smallJsont *self, int64_t index, smallStringt *string);
   1110 smallJsont* setAtSmallContainerSmallJsonG(smallJsont *self, int64_t index, smallContainert *container);
   1111 smallJsont* setAtNFreeSmallJsonG    (smallJsont *self, int64_t index, baset *value);
   1112 smallJsont* setAtNFreeUndefinedSmallJsonG(smallJsont *self, int64_t index, void *value);
   1113 smallJsont* setAtNFreeSSmallJsonG        (smallJsont *self, int64_t index, char *string);
   1114 smallJsont* setAtNFreeDictSmallJsonG     (smallJsont *self, int64_t index, smallDictt *dict);
   1115 smallJsont* setAtNFreeArraySmallJsonG    (smallJsont *self, int64_t index, smallArrayt *array);
   1116 smallJsont* setAtNFreeArraycSmallJsonG   (smallJsont *self, int64_t index, char **array);
   1117 smallJsont* setAtNFreeSmallBoolSmallJsonG     (smallJsont *self, int64_t index, smallBoolt *value);
   1118 smallJsont* setAtNFreeSmallBytesSmallJsonG    (smallJsont *self, int64_t index, smallBytest *value);
   1119 smallJsont* setAtNFreeSmallDoubleSmallJsonG   (smallJsont *self, int64_t index, smallDoublet *value);
   1120 smallJsont* setAtNFreeSmallIntSmallJsonG      (smallJsont *self, int64_t index, smallIntt *value);
   1121 smallJsont* setAtNFreeSmallJsonSmallJsonG     (smallJsont *self, int64_t index, smallJsont *value);
   1122 smallJsont* setAtNFreeSmallStringSmallJsonG   (smallJsont *self, int64_t index, smallStringt *string);
   1123 smallJsont* setAtNFreeSmallContainerSmallJsonG(smallJsont *self, int64_t index, smallContainert *container);
   1124 smallJsont* setPAtDictSmallJsonG     (smallJsont *self, int64_t index, smallDictt *dict);
   1125 smallJsont* setPAtArraySmallJsonG    (smallJsont *self, int64_t index, smallArrayt *array);
   1126 smallJsont* setPAtSmallJsonSmallJsonG     (smallJsont *self, int64_t index, smallJsont *value);
   1127 smallJsont* setPAtSmallStringSmallJsonG     (smallJsont *self, int64_t index, smallStringt *string);
   1128 smallJsont* setPAtNFreeDictSmallJsonG     (smallJsont *self, int64_t index, smallDictt *dict);
   1129 smallJsont* setPAtNFreeArraySmallJsonG    (smallJsont *self, int64_t index, smallArrayt *array);
   1130 smallJsont* setPAtNFreeSmallJsonSmallJsonG     (smallJsont *self, int64_t index, smallJsont *value);
   1131 smallJsont* setPAtNFreeSmallStringSmallJsonG     (smallJsont *self, int64_t index, smallStringt *string);
   1132 baset*           getSmallJsonG              (smallJsont *self, baset* retType UNUSED, const char *key);
   1133 undefinedt*      getUndefinedSmallJsonG     (smallJsont *self, undefinedt* retType UNUSED, const char *key);
   1134 bool             getBoolSmallJsonG          (smallJsont *self, bool retType UNUSED, const char *key);
   1135 bool*            getBoolPSmallJsonG         (smallJsont *self, bool* retType UNUSED, const char *key);
   1136 double           getDoubleSmallJsonG        (smallJsont *self, double retType UNUSED, const char *key);
   1137 double*          getDoublePSmallJsonG       (smallJsont *self, double* retType UNUSED, const char *key);
   1138 int64_t          getIntSmallJsonG           (smallJsont *self, int64_t retType UNUSED, const char *key);
   1139 int64_t*         getIntPSmallJsonG          (smallJsont *self, int64_t* retType UNUSED, const char *key);
   1140 int32_t          getInt32SmallJsonG         (smallJsont *self, int32_t retType UNUSED, const char *key);
   1141 int32_t*         getInt32PSmallJsonG        (smallJsont *self, int32_t* retType UNUSED, const char *key);
   1142 uint64_t         getUintSmallJsonG          (smallJsont *self, uint64_t retType UNUSED, const char *key);
   1143 uint64_t*        getUintPSmallJsonG         (smallJsont *self, uint64_t* retType UNUSED, const char *key);
   1144 uint32_t         getUint32SmallJsonG        (smallJsont *self, uint32_t retType UNUSED, const char *key);
   1145 uint32_t*        getUint32PSmallJsonG       (smallJsont *self, uint32_t* retType UNUSED, const char *key);
   1146 char*            getSSmallJsonG             (smallJsont *self, char* retType UNUSED, const char *key);
   1147 smallDictt*      getDictSmallJsonG          (smallJsont *self, smallDictt* retType UNUSED, const char *key);
   1148 smallArrayt*     getArraySmallJsonG         (smallJsont *self, smallArrayt* retType UNUSED, const char *key);
   1149 smallBoolt*      getSmallBoolSmallJsonG     (smallJsont *self, smallBoolt* retType UNUSED, const char *key);
   1150 smallBytest*     getSmallBytesSmallJsonG    (smallJsont *self, smallBytest* retType UNUSED, const char *key);
   1151 smallDoublet*    getSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet* retType UNUSED, const char *key);
   1152 smallIntt*       getSmallIntSmallJsonG      (smallJsont *self, smallIntt* retType UNUSED, const char *key);
   1153 smallJsont*       getSmallJsonSmallJsonG    (smallJsont *self, smallJsont* retType UNUSED, const char *key);
   1154 smallStringt*    getSmallStringSmallJsonG   (smallJsont *self, smallStringt* retType UNUSED, const char *key);
   1155 void*            getVoidSmallJsonG          (smallJsont *self, void* retType UNUSED, const char *key);
   1156 smallContainert* getSmallContainerSmallJsonG(smallJsont *self, smallContainert* retType UNUSED, const char *key);
   1157 baset*           getNDupSmallJsonG              (smallJsont *self, baset* retType UNUSED, const char *key);
   1158 undefinedt*      getNDupUndefinedSmallJsonG     (smallJsont *self, undefinedt* retType UNUSED, const char *key);
   1159 bool             getNDupBoolSmallJsonG          (smallJsont *self, bool retType UNUSED, const char *key);
   1160 double           getNDupDoubleSmallJsonG        (smallJsont *self, double retType UNUSED, const char *key);
   1161 int64_t          getNDupIntSmallJsonG           (smallJsont *self, int64_t retType UNUSED, const char *key);
   1162 int32_t          getNDupInt32SmallJsonG         (smallJsont *self, int32_t retType UNUSED, const char *key);
   1163 uint64_t         getNDupUintSmallJsonG          (smallJsont *self, uint64_t retType UNUSED, const char *key);
   1164 uint32_t         getNDupUint32SmallJsonG        (smallJsont *self, uint32_t retType UNUSED, const char *key);
   1165 char*            getNDupSSmallJsonG             (smallJsont *self, char* retType UNUSED, const char *key);
   1166 smallDictt*      getNDupDictSmallJsonG          (smallJsont *self, smallDictt* retType UNUSED, const char *key);
   1167 smallArrayt*     getNDupArraySmallJsonG         (smallJsont *self, smallArrayt* retType UNUSED, const char *key);
   1168 smallBoolt*      getNDupSmallBoolSmallJsonG     (smallJsont *self, smallBoolt* retType UNUSED, const char *key);
   1169 smallBytest*     getNDupSmallBytesSmallJsonG    (smallJsont *self, smallBytest* retType UNUSED, const char *key);
   1170 smallDoublet*    getNDupSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet* retType UNUSED, const char *key);
   1171 smallIntt*       getNDupSmallIntSmallJsonG      (smallJsont *self, smallIntt* retType UNUSED, const char *key);
   1172 smallJsont*       getNDupSmallJsonSmallJsonG    (smallJsont *self, smallJsont* retType UNUSED, const char *key);
   1173 smallStringt*    getNDupSmallStringSmallJsonG   (smallJsont *self, smallStringt* retType UNUSED, const char *key);
   1174 void*            getNDupVoidSmallJsonG          (smallJsont *self, void* retType UNUSED, const char *key);
   1175 smallContainert* getNDupSmallContainerSmallJsonG(smallJsont *self, smallContainert* retType UNUSED, const char *key);
   1176 baset*           getAtSmallJsonG              (smallJsont *self, baset* retType UNUSED, int64_t index);
   1177 undefinedt*      getAtUndefinedSmallJsonG     (smallJsont *self, undefinedt* retType UNUSED, int64_t index);
   1178 bool             getAtBoolSmallJsonG          (smallJsont *self, bool retType UNUSED, int64_t index);
   1179 bool*            getAtBoolPSmallJsonG         (smallJsont *self, bool* retType UNUSED, int64_t index);
   1180 double           getAtDoubleSmallJsonG        (smallJsont *self, double retType UNUSED, int64_t index);
   1181 double*          getAtDoublePSmallJsonG       (smallJsont *self, double* retType UNUSED, int64_t index);
   1182 int64_t          getAtIntSmallJsonG           (smallJsont *self, int64_t retType UNUSED, int64_t index);
   1183 int64_t*         getAtIntPSmallJsonG          (smallJsont *self, int64_t* retType UNUSED, int64_t index);
   1184 int32_t          getAtInt32SmallJsonG         (smallJsont *self, int32_t retType UNUSED, int64_t index);
   1185 int32_t*         getAtInt32PSmallJsonG        (smallJsont *self, int32_t* retType UNUSED, int64_t index);
   1186 uint64_t         getAtUintSmallJsonG          (smallJsont *self, uint64_t retType UNUSED, int64_t index);
   1187 uint64_t*        getAtUintPSmallJsonG         (smallJsont *self, uint64_t* retType UNUSED, int64_t index);
   1188 uint32_t         getAtUint32SmallJsonG        (smallJsont *self, uint32_t retType UNUSED, int64_t index);
   1189 uint32_t*        getAtUint32PSmallJsonG       (smallJsont *self, uint32_t* retType UNUSED, int64_t index);
   1190 char*            getAtSSmallJsonG             (smallJsont *self, char* retType UNUSED, int64_t index);
   1191 smallDictt*      getAtDictSmallJsonG          (smallJsont *self, smallDictt* retType UNUSED, int64_t index);
   1192 smallArrayt*     getAtArraySmallJsonG         (smallJsont *self, smallArrayt* retType UNUSED, int64_t index);
   1193 smallBoolt*      getAtSmallBoolSmallJsonG     (smallJsont *self, smallBoolt* retType UNUSED, int64_t index);
   1194 smallBytest*     getAtSmallBytesSmallJsonG    (smallJsont *self, smallBytest* retType UNUSED, int64_t index);
   1195 smallDoublet*    getAtSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet* retType UNUSED, int64_t index);
   1196 smallIntt*       getAtSmallIntSmallJsonG      (smallJsont *self, smallIntt* retType UNUSED, int64_t index);
   1197 smallJsont*       getAtSmallJsonSmallJsonG    (smallJsont *self, smallJsont* retType UNUSED, int64_t index);
   1198 smallStringt*    getAtSmallStringSmallJsonG   (smallJsont *self, smallStringt* retType UNUSED, int64_t index);
   1199 void*            getAtVoidSmallJsonG          (smallJsont *self, void* retType UNUSED, int64_t index);
   1200 smallContainert* getAtSmallContainerSmallJsonG(smallJsont *self, smallContainert* retType UNUSED, int64_t index);
   1201 baset*           getAtNDupSmallJsonG              (smallJsont *self, baset* retType UNUSED, int64_t index);
   1202 undefinedt*      getAtNDupUndefinedSmallJsonG     (smallJsont *self, undefinedt* retType UNUSED, int64_t index);
   1203 bool             getAtNDupBoolSmallJsonG          (smallJsont *self, bool retType UNUSED, int64_t index);
   1204 double           getAtNDupDoubleSmallJsonG        (smallJsont *self, double retType UNUSED, int64_t index);
   1205 int64_t          getAtNDupIntSmallJsonG           (smallJsont *self, int64_t retType UNUSED, int64_t index);
   1206 int32_t          getAtNDupInt32SmallJsonG         (smallJsont *self, int32_t retType UNUSED, int64_t index);
   1207 uint64_t         getAtNDupUintSmallJsonG          (smallJsont *self, uint64_t retType UNUSED, int64_t index);
   1208 uint32_t         getAtNDupUint32SmallJsonG        (smallJsont *self, uint32_t retType UNUSED, int64_t index);
   1209 char*            getAtNDupSSmallJsonG             (smallJsont *self, char* retType UNUSED, int64_t index);
   1210 smallDictt*      getAtNDupDictSmallJsonG          (smallJsont *self, smallDictt* retType UNUSED, int64_t index);
   1211 smallArrayt*     getAtNDupArraySmallJsonG         (smallJsont *self, smallArrayt* retType UNUSED, int64_t index);
   1212 smallBoolt*      getAtNDupSmallBoolSmallJsonG     (smallJsont *self, smallBoolt* retType UNUSED, int64_t index);
   1213 smallBytest*     getAtNDupSmallBytesSmallJsonG    (smallJsont *self, smallBytest* retType UNUSED, int64_t index);
   1214 smallDoublet*    getAtNDupSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet* retType UNUSED, int64_t index);
   1215 smallIntt*       getAtNDupSmallIntSmallJsonG      (smallJsont *self, smallIntt* retType UNUSED, int64_t index);
   1216 smallJsont*       getAtNDupSmallJsonSmallJsonG    (smallJsont *self, smallJsont* retType UNUSED, int64_t index);
   1217 smallStringt*    getAtNDupSmallStringSmallJsonG   (smallJsont *self, smallStringt* retType UNUSED, int64_t index);
   1218 void*            getAtNDupVoidSmallJsonG          (smallJsont *self, void* retType UNUSED, int64_t index);
   1219 smallContainert* getAtNDupSmallContainerSmallJsonG(smallJsont *self, smallContainert* retType UNUSED, int64_t index);
   1220 double getNumSmallJsonG(smallJsont *self, const char *key);
   1221 double getNumAtSmallJsonG(smallJsont *self, int64_t index);
   1222 smallJsont* delKeySmallJsonG(smallJsont *self, const char *key, int unused UNUSED);
   1223 smallJsont* delSmallJsonG(smallJsont *self, int64_t start, int64_t end);
   1224 smallJsont* delElemSmallJsonG(smallJsont *self, const char *key);
   1225 smallJsont* delElemIndexSmallJsonG(smallJsont *self, int64_t index);
   1226 smallJsont* prependSmallJsonG         (smallJsont *self, baset *value);
   1227 smallJsont* prependUndefinedSmallJsonG(smallJsont *self, void *value UNUSED);
   1228 smallJsont* prependBoolSmallJsonG     (smallJsont *self, bool value);
   1229 smallJsont* prependDoubleSmallJsonG   (smallJsont *self, double value);
   1230 smallJsont* prependIntSmallJsonG      (smallJsont *self, int64_t value);
   1231 smallJsont* prependSSmallJsonG        (smallJsont *self, const char *string);
   1232 smallJsont* prependCharSmallJsonG(smallJsont *self, char c);
   1233 smallJsont* prependDictSmallJsonG     (smallJsont *self, smallDictt *dict);
   1234 smallJsont* prependArraySmallJsonG    (smallJsont *self, smallArrayt *array);
   1235 smallJsont* prependArraycSmallJsonG   (smallJsont *self, char **array);
   1236 smallJsont* prependCArraycSmallJsonG  (smallJsont *self, const char **array);
   1237 smallJsont* prependVoidSmallJsonG     (smallJsont *self, void *value);
   1238 smallJsont* prependSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value);
   1239 smallJsont* prependSmallBytesSmallJsonG    (smallJsont *self, smallBytest *value);
   1240 smallJsont* prependSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value);
   1241 smallJsont* prependSmallIntSmallJsonG      (smallJsont *self, smallIntt *value);
   1242 smallJsont* prependSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value);
   1243 smallJsont* prependSmallStringSmallJsonG   (smallJsont *self, smallStringt *string);
   1244 smallJsont* prependSmallContainerSmallJsonG(smallJsont *self, smallContainert *container);
   1245 smallJsont* prependNFreeSmallJsonG         (smallJsont *self, baset *value);
   1246 smallJsont* prependNFreeUndefinedSmallJsonG(smallJsont *self, undefinedt *value);
   1247 smallJsont* prependNFreeSSmallJsonG        (smallJsont *self, char *string);
   1248 smallJsont* prependNFreeDictSmallJsonG     (smallJsont *self, smallDictt *dict);
   1249 smallJsont* prependNFreeArraySmallJsonG    (smallJsont *self, smallArrayt *array);
   1250 smallJsont* prependNFreeArraycSmallJsonG         (smallJsont *self, char **array);
   1251 smallJsont* prependNFreeSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value);
   1252 smallJsont* prependNFreeSmallBytesSmallJsonG    (smallJsont *self, smallBytest *value);
   1253 smallJsont* prependNFreeSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value);
   1254 smallJsont* prependNFreeSmallIntSmallJsonG      (smallJsont *self, smallIntt *value);
   1255 smallJsont* prependNFreeSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value);
   1256 smallJsont* prependNFreeSmallStringSmallJsonG   (smallJsont *self, smallStringt *string);
   1257 smallJsont* prependNFreeSmallContainerSmallJsonG(smallJsont *self, smallContainert *container);
   1258 baset*           dequeueSmallJsonG              (smallJsont *self, baset* retType UNUSED);
   1259 undefinedt*      dequeueUndefinedSmallJsonG     (smallJsont *self, undefinedt* retType UNUSED);
   1260 bool             dequeueBoolSmallJsonG          (smallJsont *self, bool retType UNUSED);
   1261 double           dequeueDoubleSmallJsonG        (smallJsont *self, double retType UNUSED);
   1262 int64_t          dequeueIntSmallJsonG           (smallJsont *self, int64_t retType UNUSED);
   1263 int32_t          dequeueInt32SmallJsonG         (smallJsont *self, int32_t retType UNUSED);
   1264 uint64_t         dequeueUintSmallJsonG          (smallJsont *self, uint64_t retType UNUSED);
   1265 uint32_t         dequeueUint32SmallJsonG        (smallJsont *self, uint32_t retType UNUSED);
   1266 char*            dequeueSSmallJsonG             (smallJsont *self, char* retType UNUSED);
   1267 smallDictt*      dequeueDictSmallJsonG          (smallJsont *self, smallDictt* retType UNUSED);
   1268 smallArrayt*     dequeueArraySmallJsonG         (smallJsont *self, smallArrayt* retType UNUSED);
   1269 smallBoolt*      dequeueSmallBoolSmallJsonG     (smallJsont *self, smallBoolt* retType UNUSED);
   1270 smallBytest*     dequeueSmallBytesSmallJsonG    (smallJsont *self, smallBytest* retType UNUSED);
   1271 smallDoublet*    dequeueSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet* retType UNUSED);
   1272 smallIntt*       dequeueSmallIntSmallJsonG      (smallJsont *self, smallIntt* retType UNUSED);
   1273 smallJsont*       dequeueSmallJsonSmallJsonG     (smallJsont *self, smallJsont* retType UNUSED);
   1274 smallStringt*    dequeueSmallStringSmallJsonG   (smallJsont *self, smallStringt* retType UNUSED);
   1275 void*            dequeueVoidSmallJsonG          (smallJsont *self, void* retType UNUSED);
   1276 smallContainert* dequeueSmallContainerSmallJsonG(smallJsont *self, smallContainert* retType UNUSED);
   1277 smallJsont* reverseSmallJsonG       (smallJsont *self);
   1278 smallJsont*  mergeDictSmallJsonG       (smallJsont *self, smallDictt *smallDict);
   1279 smallJsont*  mergeDictNSmashSmallJsonG (smallJsont *self, smallDictt *smallDict);
   1280 smallJsont*  mergeSmallJsonG       (smallJsont *self, smallJsont *smallJson);
   1281 smallJsont*  mergeNSmashSmallJsonG (smallJsont *self, smallJsont *smallJson);
   1282 smallJsont* appendSmallJsonG        (smallJsont *self, smallArrayt *array);
   1283 smallJsont* appendNSmashSmallJsonG  (smallJsont *self, smallArrayt *array);
   1284 smallJsont* appendArraySmallJsonG        (smallJsont *self, char **array);
   1285 smallJsont* appendNSmashArraySmallJsonG  (smallJsont *self, char **array);
   1286 smallJsont* appendCArraySmallJsonG        (smallJsont *self, const char **array);
   1287 smallJsont* shiftSmallJsonG        (smallJsont *self, smallArrayt *array);
   1288 smallJsont* shiftNSmashSmallJsonG  (smallJsont *self, smallArrayt *array);
   1289 smallJsont* shiftSmallJsonSmallJsonG(smallJsont *self, smallJsont *array);
   1290 smallJsont* shiftNSmashSmallJsonSmallJsonG(smallJsont *self, smallJsont *array);
   1291 smallJsont* addSmallJsonG  (smallJsont *self, smallArrayt *array);
   1292 smallJsont* addJsonSmallJsonG  (smallJsont *self, smallJsont *array);
   1293 smallJsont* sliceSmallJsonG(smallJsont *self, int64_t start, int64_t end);
   1294 smallJsont* cropSmallJsonG                          (smallJsont *self, int64_t start, int64_t end);
   1295 char* cropSSmallJsonG                               (smallJsont *self, int64_t start, int64_t end);
   1296 smallStringt* cropSmallStringSmallJsonG             (smallJsont *self, int64_t start, int64_t end);
   1297 baset* cropElemAtSmallJsonG                         (smallJsont *self, int64_t index);
   1298 undefinedt* cropElemAtUndefinedSmallJsonG           (smallJsont *self, int64_t index);
   1299 bool cropElemAtBoolSmallJsonG                       (smallJsont *self, int64_t index);
   1300 double cropElemAtDoubleSmallJsonG                   (smallJsont *self, int64_t index);
   1301 int64_t cropElemAtIntSmallJsonG                     (smallJsont *self, int64_t index);
   1302 int32_t cropElemAtInt32SmallJsonG                   (smallJsont *self, int64_t index);
   1303 uint64_t cropElemAtUintSmallJsonG                   (smallJsont *self, int64_t index);
   1304 uint32_t cropElemAtUint32SmallJsonG                 (smallJsont *self, int64_t index);
   1305 char* cropElemAtSSmallJsonG                         (smallJsont *self, int64_t index);
   1306 char cropElemAtCharSmallJsonG                       (smallJsont *self, int64_t index);
   1307 smallDictt* cropElemAtDictSmallJsonG                (smallJsont *self, int64_t index);
   1308 smallArrayt* cropElemAtArraySmallJsonG              (smallJsont *self, int64_t index);
   1309 smallBoolt* cropElemAtSmallBoolSmallJsonG           (smallJsont *self, int64_t index);
   1310 smallBytest* cropElemAtSmallBytesSmallJsonG         (smallJsont *self, int64_t index);
   1311 smallDoublet* cropElemAtSmallDoubleSmallJsonG       (smallJsont *self, int64_t index);
   1312 smallIntt* cropElemAtSmallIntSmallJsonG             (smallJsont *self, int64_t index);
   1313 smallJsont* cropElemAtSmallJsonSmallJsonG           (smallJsont *self, int64_t index);
   1314 smallStringt* cropElemAtSmallStringSmallJsonG       (smallJsont *self, int64_t index);
   1315 void* cropElemAtVoidSmallJsonG                      (smallJsont *self, int64_t index);
   1316 smallContainert* cropElemAtSmallContainerSmallJsonG (smallJsont *self, int64_t index);
   1317 baset* cropElemKeySmallJsonG                        (smallJsont *self, const char* key);
   1318 undefinedt* cropElemKeyUndefinedSmallJsonG          (smallJsont *self, const char* key);
   1319 bool cropElemKeyBoolSmallJsonG                      (smallJsont *self, const char* key);
   1320 double cropElemKeyDoubleSmallJsonG                  (smallJsont *self, const char* key);
   1321 int64_t cropElemKeyIntSmallJsonG                    (smallJsont *self, const char* key);
   1322 int32_t cropElemKeyInt32SmallJsonG                  (smallJsont *self, const char* key);
   1323 uint64_t cropElemKeyUintSmallJsonG                  (smallJsont *self, const char* key);
   1324 uint32_t cropElemKeyUint32SmallJsonG                (smallJsont *self, const char* key);
   1325 char* cropElemKeySSmallJsonG                        (smallJsont *self, const char* key);
   1326 smallDictt* cropElemKeyDictSmallJsonG               (smallJsont *self, const char* key);
   1327 smallArrayt* cropElemKeyArraySmallJsonG             (smallJsont *self, const char* key);
   1328 smallBoolt* cropElemKeySmallBoolSmallJsonG          (smallJsont *self, const char* key);
   1329 smallBytest* cropElemKeySmallBytesSmallJsonG        (smallJsont *self, const char* key);
   1330 smallDoublet* cropElemKeySmallDoubleSmallJsonG      (smallJsont *self, const char* key);
   1331 smallIntt* cropElemKeySmallIntSmallJsonG            (smallJsont *self, const char* key);
   1332 smallJsont* cropElemKeySmallJsonSmallJsonG          (smallJsont *self, const char* key);
   1333 smallStringt* cropElemKeySmallStringSmallJsonG      (smallJsont *self, const char* key);
   1334 void* cropElemKeyVoidSmallJsonG                     (smallJsont *self, const char* key);
   1335 smallContainert* cropElemKeySmallContainerSmallJsonG(smallJsont *self, const char* key);
   1336 smallJsont* copySmallJsonG (smallJsont *self, int64_t start, int64_t end);
   1337 smallJsont*          insertSmallJsonG(smallJsont *self, int64_t index, smallArrayt *toInsert);
   1338 smallJsont*          insertNSmashSmallJsonG(smallJsont *self, int64_t index, smallArrayt *toInsert);
   1339 smallJsont*          insertSmallJsonSmallJsonG(smallJsont *self, int64_t index, smallJsont *toInsert);
   1340 smallJsont*          insertNSmashSmallJsonSmallJsonG(smallJsont *self, int64_t index, smallJsont *toInsert);
   1341 smallJsont*    insertStringSmallJsonG     (smallJsont *self, int64_t index, smallStringt *toInsert);
   1342 smallJsont*    insertSSmallJsonG    (smallJsont *self, int64_t index, const char *toInsert);
   1343 smallJsont*    insertNFreeStringSmallJsonG(smallJsont *self, int64_t index, smallStringt *toInsert);
   1344 smallJsont*    insertNFreeSSmallJsonG(smallJsont *self, int64_t index, char *toInsert);
   1345 smallJsont* injectSmallJsonG         (smallJsont *self, int64_t index, baset *value);
   1346 smallJsont* injectUndefinedSmallJsonG(smallJsont *self, int64_t index, void *value UNUSED);
   1347 smallJsont* injectBoolSmallJsonG     (smallJsont *self, int64_t index, bool value);
   1348 smallJsont* injectDoubleSmallJsonG   (smallJsont *self, int64_t index, double value);
   1349 smallJsont* injectIntSmallJsonG      (smallJsont *self, int64_t index, int64_t value);
   1350 smallJsont* injectSSmallJsonG        (smallJsont *self, int64_t index, const char *string);
   1351 smallJsont* injectCharSmallJsonG(smallJsont *self, int64_t index, char c);
   1352 smallJsont* injectDictSmallJsonG     (smallJsont *self, int64_t index, smallDictt *dict);
   1353 smallJsont* injectArraySmallJsonG    (smallJsont *self, int64_t index, smallArrayt *array);
   1354 smallJsont* injectArraycSmallJsonG   (smallJsont *self, int64_t index, char **array);
   1355 smallJsont* injectCArraycSmallJsonG   (smallJsont *self, int64_t index, const char **array);
   1356 smallJsont* injectVoidSmallJsonG     (smallJsont *self, int64_t index, void *value);
   1357 smallJsont* injectSmallBoolSmallJsonG     (smallJsont *self, int64_t index, smallBoolt *value);
   1358 smallJsont* injectSmallBytesSmallJsonG    (smallJsont *self, int64_t index, smallBytest *value);
   1359 smallJsont* injectSmallDoubleSmallJsonG   (smallJsont *self, int64_t index, smallDoublet *value);
   1360 smallJsont* injectSmallIntSmallJsonG      (smallJsont *self, int64_t index, smallIntt *value);
   1361 smallJsont* injectSmallJsonSmallJsonG     (smallJsont *self, int64_t index, smallJsont *value);
   1362 smallJsont* injectSmallStringSmallJsonG   (smallJsont *self, int64_t index, smallStringt *string);
   1363 smallJsont* injectSmallContainerSmallJsonG(smallJsont *self, int64_t index, smallContainert *container);
   1364 smallJsont* injectNFreeSmallJsonG    (smallJsont *self, int64_t index, baset *value);
   1365 smallJsont* injectNFreeUndefinedSmallJsonG(smallJsont *self, int64_t index, void *value);
   1366 smallJsont* injectNFreeSSmallJsonG        (smallJsont *self, int64_t index, char *string);
   1367 smallJsont* injectNFreeDictSmallJsonG     (smallJsont *self, int64_t index, smallDictt *dict);
   1368 smallJsont* injectNFreeArraySmallJsonG    (smallJsont *self, int64_t index, smallArrayt *array);
   1369 smallJsont* injectNFreeArraycSmallJsonG   (smallJsont *self, int64_t index, char **array);
   1370 smallJsont* injectNFreeSmallBoolSmallJsonG     (smallJsont *self, int64_t index, smallBoolt *value);
   1371 smallJsont* injectNFreeSmallBytesSmallJsonG    (smallJsont *self, int64_t index, smallBytest *value);
   1372 smallJsont* injectNFreeSmallDoubleSmallJsonG   (smallJsont *self, int64_t index, smallDoublet *value);
   1373 smallJsont* injectNFreeSmallIntSmallJsonG      (smallJsont *self, int64_t index, smallIntt *value);
   1374 smallJsont* injectNFreeSmallJsonSmallJsonG     (smallJsont *self, int64_t index, smallJsont *value);
   1375 smallJsont* injectNFreeSmallStringSmallJsonG   (smallJsont *self, int64_t index, smallStringt *string);
   1376 smallJsont* injectNFreeSmallContainerSmallJsonG(smallJsont *self, int64_t index, smallContainert *container);
   1377 smallJsont* uniqSmallJsonG(smallJsont *self, char c);
   1378 smallJsont* sortSmallJsonG          (smallJsont *self);
   1379 smallJsont* sortFSmallJsonG(smallJsont *self, shCmpt compareFunction);
   1380 smallJsont* icSortSmallJsonG          (smallJsont *self);
   1381 smallJsont* icUniqSmallJsonG(smallJsont *self, char c);
   1382 bool hasSmallJsonG         (smallJsont *self, baset *value);
   1383 bool hasUndefinedSmallJsonG(smallJsont *self, undefinedt *value);
   1384 bool hasBoolSmallJsonG     (smallJsont *self, bool value);
   1385 bool hasDoubleSmallJsonG   (smallJsont *self, double value);
   1386 bool hasIntSmallJsonG      (smallJsont *self, int64_t value);
   1387 bool hasSSmallJsonG        (smallJsont *self, const char *string);
   1388 bool hasCharSmallJsonG(smallJsont *self, char c);
   1389 bool hasDictSmallJsonG     (smallJsont *self, smallDictt *dict);
   1390 bool hasArraySmallJsonG    (smallJsont *self, smallArrayt *array);
   1391 bool hasArraycSmallJsonG   (smallJsont *self, char **array);
   1392 bool hasCArraycSmallJsonG  (smallJsont *self, const char **array);
   1393 bool hasSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value);
   1394 bool hasSmallBytesSmallJsonG    (smallJsont *self, smallBytest *value);
   1395 bool hasSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value);
   1396 bool hasSmallIntSmallJsonG      (smallJsont *self, smallIntt *value);
   1397 bool hasSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value);
   1398 bool hasSmallStringSmallJsonG   (smallJsont *self, smallStringt *string);
   1399 bool hasSmallContainerSmallJsonG(smallJsont *self, smallContainert *container);
   1400 smallJsont* findSmallJsonG(smallJsont *self, const char *needle);
   1401 smallJsont* findCharSmallJsonG(smallJsont *self, char c);
   1402 smallJsont* findSmallStringSmallJsonG(smallJsont *self, smallStringt *needle);
   1403 smallJsont* findJsonSmallJsonG(smallJsont *self, smallJsont *needle);
   1404 ssize_t indexOfSmallJsonG         (smallJsont *self, baset *value);
   1405 ssize_t indexOfUndefinedSmallJsonG(smallJsont *self, undefinedt *value);
   1406 ssize_t indexOfBoolSmallJsonG     (smallJsont *self, bool value);
   1407 ssize_t indexOfDoubleSmallJsonG   (smallJsont *self, double value);
   1408 ssize_t indexOfIntSmallJsonG      (smallJsont *self, int64_t value);
   1409 ssize_t indexOfSSmallJsonG        (smallJsont *self, const char *string);
   1410 ssize_t indexOfCharSmallJsonG(smallJsont *self, char c);
   1411 ssize_t indexOfDictSmallJsonG     (smallJsont *self, smallDictt *dict);
   1412 ssize_t indexOfArraySmallJsonG    (smallJsont *self, smallArrayt *array);
   1413 ssize_t indexOfArraycSmallJsonG    (smallJsont *self, char **array);
   1414 ssize_t indexOfCArraycSmallJsonG   (smallJsont *self, const char **array);
   1415 ssize_t indexOfSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value);
   1416 ssize_t indexOfSmallBytesSmallJsonG    (smallJsont *self, smallBytest *value);
   1417 ssize_t indexOfSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value);
   1418 ssize_t indexOfSmallIntSmallJsonG      (smallJsont *self, smallIntt *value);
   1419 ssize_t indexOfSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value);
   1420 ssize_t indexOfSmallStringSmallJsonG   (smallJsont *self, smallStringt *string);
   1421 ssize_t indexOfSmallContainerSmallJsonG(smallJsont *self, smallContainert *container);
   1422 ssize_t binarySearchSmallJsonG         (smallJsont *self, baset *value);
   1423 ssize_t binarySearchUndefinedSmallJsonG(smallJsont *self, undefinedt *value);
   1424 ssize_t binarySearchBoolSmallJsonG     (smallJsont *self, bool value);
   1425 ssize_t binarySearchDoubleSmallJsonG   (smallJsont *self, double value);
   1426 ssize_t binarySearchIntSmallJsonG      (smallJsont *self, int64_t value);
   1427 ssize_t binarySearchSSmallJsonG        (smallJsont *self, const char *string);
   1428 ssize_t binarySearchCharSmallJsonG(smallJsont *self, char c);
   1429 ssize_t binarySearchDictSmallJsonG     (smallJsont *self, smallDictt *dict);
   1430 ssize_t binarySearchArraySmallJsonG    (smallJsont *self, smallArrayt *array);
   1431 ssize_t binarySearchArraycSmallJsonG   (smallJsont *self, char **array);
   1432 ssize_t binarySearchCArraycSmallJsonG   (smallJsont *self, const char **array);
   1433 ssize_t binarySearchSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value);
   1434 ssize_t binarySearchSmallBytesSmallJsonG    (smallJsont *self, smallBytest *value);
   1435 ssize_t binarySearchSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value);
   1436 ssize_t binarySearchSmallIntSmallJsonG      (smallJsont *self, smallIntt *value);
   1437 ssize_t binarySearchSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value);
   1438 ssize_t binarySearchSmallStringSmallJsonG   (smallJsont *self, smallStringt *string);
   1439 ssize_t binarySearchSmallContainerSmallJsonG(smallJsont *self, smallContainert *container);
   1440 bool icHasSmallJsonG         (smallJsont *self, baset *value);
   1441 bool icHasSSmallJsonG        (smallJsont *self, const char *string);
   1442 bool icHasCharSmallJsonG(smallJsont *self, char c);
   1443 bool icHasDictSmallJsonG     (smallJsont *self, smallDictt *dict);
   1444 bool icHasArraySmallJsonG    (smallJsont *self, smallArrayt *array);
   1445 bool icHasArraycSmallJsonG   (smallJsont *self, char **array);
   1446 bool icHasCArraycSmallJsonG  (smallJsont *self, const char **array);
   1447 bool icHasSmallStringSmallJsonG   (smallJsont *self, smallStringt *string);
   1448 smallJsont* icFindSmallJsonG(smallJsont *self, const char *needle);
   1449 smallJsont* icFindCharSmallJsonG(smallJsont *self, char c);
   1450 smallJsont* icFindSmallStringSmallJsonG(smallJsont *self, smallStringt *needle);
   1451 smallJsont* icFindJsonSmallJsonG(smallJsont *self, smallJsont *needle);
   1452 ssize_t icIndexOfSmallJsonG         (smallJsont *self, baset *value);
   1453 ssize_t icIndexOfSSmallJsonG        (smallJsont *self, const char *string);
   1454 ssize_t icIndexOfCharSmallJsonG(smallJsont *self, char c);
   1455 ssize_t icIndexOfDictSmallJsonG     (smallJsont *self, smallDictt *dict);
   1456 ssize_t icIndexOfArraySmallJsonG    (smallJsont *self, smallArrayt *array);
   1457 ssize_t icIndexOfArraycSmallJsonG   (smallJsont *self, char **array);
   1458 ssize_t icIndexOfCArraycSmallJsonG  (smallJsont *self, const char **array);
   1459 ssize_t icIndexOfSmallStringSmallJsonG   (smallJsont *self, smallStringt *string);
   1460 ssize_t icBinarySearchSmallJsonG         (smallJsont *self, baset *value);
   1461 ssize_t icBinarySearchSSmallJsonG        (smallJsont *self, const char *string);
   1462 ssize_t icBinarySearchCharSmallJsonG(smallJsont *self, char c);
   1463 ssize_t icBinarySearchDictSmallJsonG     (smallJsont *self, smallDictt *dict);
   1464 ssize_t icBinarySearchArraySmallJsonG    (smallJsont *self, smallArrayt *array);
   1465 ssize_t icBinarySearchArraycSmallJsonG   (smallJsont *self, char **array);
   1466 ssize_t icBinarySearchCArraycSmallJsonG  (smallJsont *self, const char **array);
   1467 ssize_t icBinarySearchSmallStringSmallJsonG   (smallJsont *self, smallStringt *string);
   1468 char* keyBySmallJsonG(smallJsont *self, baset *value);
   1469 char* keyByUndefinedSmallJsonG(smallJsont *self, undefinedt *u);
   1470 char* keyByBoolSmallJsonG(smallJsont *self, bool value);
   1471 char* keyByDoubleSmallJsonG(smallJsont *self, double value);
   1472 char* keyByIntSmallJsonG(smallJsont *self, int64_t value);
   1473 char* keyBySSmallJsonG(smallJsont *self, const char *string);
   1474 char* keyByCharSmallJsonG(smallJsont *self, char c);
   1475 char* keyByDictSmallJsonG(smallJsont *self, smallDictt *dict);
   1476 char* keyByArraySmallJsonG(smallJsont *self, smallArrayt *array);
   1477 char* keyByArraycSmallJsonG(smallJsont *self, char **array);
   1478 char* keyByCArraycSmallJsonG(smallJsont *self, const char **array);
   1479 char* keyBySmallBoolSmallJsonG(smallJsont *self, smallBoolt *value);
   1480 char* keyBySmallBytesSmallJsonG(smallJsont *self, smallBytest *value);
   1481 char* keyBySmallDoubleSmallJsonG(smallJsont *self, smallDoublet *value);
   1482 char* keyBySmallIntSmallJsonG(smallJsont *self, smallIntt *value);
   1483 char* keyBySmallJsonSmallJsonG(smallJsont *self, smallJsont *value);
   1484 char* keyBySmallStringSmallJsonG(smallJsont *self, smallStringt *string);
   1485 char* keyBySmallContainerSmallJsonG(smallJsont *self, smallContainert *container);
   1486 char* icKeyBySmallJsonG(smallJsont *self, baset *value);
   1487 char* icKeyBySSmallJsonG(smallJsont *self, const char *string);
   1488 char* icKeyByCharSmallJsonG(smallJsont *self, char c);
   1489 char* icKeyByDictSmallJsonG(smallJsont *self, smallDictt *dict);
   1490 char* icKeyByArraySmallJsonG(smallJsont *self, smallArrayt *array);
   1491 char* icKeyByArraycSmallJsonG(smallJsont *self, char **array);
   1492 char* icKeyByCArraycSmallJsonG(smallJsont *self, const char **array);
   1493 char* icKeyBySmallStringSmallJsonG(smallJsont *self, smallStringt *string);
   1494 smallJsont*  replaceSmallJsonG      (smallJsont *self, const char *olds, const char *news, size_t max);
   1495 smallJsont* replaceCharSSmallJsonG(smallJsont *self, char olds, const char *news, size_t max);
   1496 smallJsont* replaceSCharSmallJsonG(smallJsont *self, const char *olds, char news, size_t max);
   1497 smallJsont* replaceCharCharSmallJsonG(smallJsont *self, char olds, char news, size_t max);
   1498 smallJsont* replaceSmallStringSmallStringSmallJsonG(smallJsont *self, smallStringt *olds, smallStringt *news, size_t max);
   1499 smallJsont* replaceSmallStringSSmallJsonG(smallJsont *self, smallStringt *olds, const char *news, size_t max);
   1500 smallJsont* replaceSmallStringCharSmallJsonG(smallJsont *self, smallStringt *olds, char news, size_t max);
   1501 smallJsont* replaceSSmallStringSmallJsonG(smallJsont *self, const char *olds, smallStringt *news, size_t max);
   1502 smallJsont* replaceCharSmallStringSmallJsonG(smallJsont *self, char olds, smallStringt *news, size_t max);
   1503 smallJsont* replaceJsonJsonSmallJsonG       (smallJsont *self, smallJsont *olds, smallJsont *news, size_t max);
   1504 smallJsont* replaceJsonSmallStringSmallJsonG(smallJsont *self, smallJsont *olds, smallStringt *news, size_t max);
   1505 smallJsont* replaceJsonSSmallJsonG          (smallJsont *self, smallJsont *olds, const char *news, size_t max);
   1506 smallJsont* replaceJsonCharSmallJsonG       (smallJsont *self, smallJsont *olds, char news, size_t max);
   1507 smallJsont* replaceSmallStringJsonSmallJsonG(smallJsont *self, smallStringt *olds, smallJsont *news, size_t max);
   1508 smallJsont* replaceSJsonSmallJsonG          (smallJsont *self, const char *olds, smallJsont *news, size_t max);
   1509 smallJsont* replaceCharJsonSmallJsonG       (smallJsont *self, char olds, smallJsont *news, size_t max);
   1510 smallJsont*  icReplaceSmallJsonG      (smallJsont *self, const char *olds, const char *news, size_t max);
   1511 smallJsont* icReplaceCharSSmallJsonG(smallJsont *self, char olds, const char *news, size_t max);
   1512 smallJsont* icReplaceSCharSmallJsonG(smallJsont *self, const char *olds, char news, size_t max);
   1513 smallJsont* icReplaceCharCharSmallJsonG(smallJsont *self, char olds, char news, size_t max);
   1514 smallJsont* icReplaceSmallStringSmallStringSmallJsonG(smallJsont *self, smallStringt *olds, smallStringt *news, size_t max);
   1515 smallJsont* icReplaceSmallStringSSmallJsonG(smallJsont *self, smallStringt *olds, const char *news, size_t max);
   1516 smallJsont* icReplaceSmallStringCharSmallJsonG(smallJsont *self, smallStringt *olds, char news, size_t max);
   1517 smallJsont* icReplaceSSmallStringSmallJsonG(smallJsont *self, const char *olds, smallStringt *news, size_t max);
   1518 smallJsont* icReplaceCharSmallStringSmallJsonG(smallJsont *self, char olds, smallStringt *news, size_t max);
   1519 smallJsont* icReplaceJsonJsonSmallJsonG       (smallJsont *self, smallJsont *olds, smallJsont *news, size_t max);
   1520 smallJsont* icReplaceJsonSmallStringSmallJsonG(smallJsont *self, smallJsont *olds, smallStringt *news, size_t max);
   1521 smallJsont* icReplaceJsonSSmallJsonG          (smallJsont *self, smallJsont *olds, const char *news, size_t max);
   1522 smallJsont* icReplaceJsonCharSmallJsonG       (smallJsont *self, smallJsont *olds, char news, size_t max);
   1523 smallJsont* icReplaceSmallStringJsonSmallJsonG(smallJsont *self, smallStringt *olds, smallJsont *news, size_t max);
   1524 smallJsont* icReplaceSJsonSmallJsonG          (smallJsont *self, const char *olds, smallJsont *news, size_t max);
   1525 smallJsont* icReplaceCharJsonSmallJsonG       (smallJsont *self, char olds, smallJsont *news, size_t max);
   1526 bool equalSmallJsonSmallArrayG(smallJsont *self, smallArrayt *array);
   1527 bool equalSmallJsonArrayG(smallJsont *self, char ** p2);
   1528 bool equalSmallJsonCArrayG(smallJsont *self, const char ** p2);
   1529 bool equalSmallJsonBaseG(smallJsont *self, baset* p2);
   1530 bool equalSmallJsonChaG(smallJsont* self, char p2);
   1531 bool equalSmallJsonCharG(smallJsont* self, const char * p2);
   1532 bool equalSmallJsonBoolG(smallJsont* self, bool p2);
   1533 bool equalSmallJsonDoubleG(smallJsont* self, double p2);
   1534 bool equalSmallJsonInt64G(smallJsont* self, int64_t p2);
   1535 bool equalSmallJsonInt32G(smallJsont* self, int32_t p2);
   1536 bool equalSmallJsonUint32G(smallJsont* self, uint32_t p2);
   1537 bool equalSmallJsonUint64G(smallJsont* self, uint64_t p2);
   1538 bool equalSmallJsonSmallBoolG(smallJsont* self, smallBoolt* p2);
   1539 bool equalSmallJsonSmallBytesG(smallJsont* self, smallBytest* p2);
   1540 bool equalSmallJsonSmallDoubleG(smallJsont* self, smallDoublet* p2);
   1541 bool equalSmallJsonSmallIntG(smallJsont* self, smallIntt* p2);
   1542 bool equalSmallJsonSmallJsonG(smallJsont* self, smallJsont* p2);
   1543 bool equalSmallJsonSmallStringG(smallJsont* self, smallStringt* p2);
   1544 bool equalSmallJsonSmallDictG(smallJsont* self, smallDictt* p2);
   1545 bool icEqualSmallJsonSmallArrayG(smallJsont *self, smallArrayt *array);
   1546 bool icEqualSmallJsonArrayG(smallJsont *self, char ** p2);
   1547 bool icEqualSmallJsonCArrayG(smallJsont *self, const char ** p2);
   1548 bool icEqualSmallJsonBaseG(smallJsont *self, baset* p2);
   1549 bool icEqualSmallJsonSmallDictG(smallJsont* self, smallDictt* p2);
   1550 bool icEqualSmallJsonSmallJsonG(smallJsont* self, smallJsont* p2);
   1551 bool icEqualSmallJsonSmallStringG(smallJsont* self, smallStringt* p2);
   1552 bool icEqualCharSmallJsonG(smallJsont *self, char c);
   1553 bool icEqualSSmallJsonG       (smallJsont *self, const char *string);
   1554 bool equalISSmallJsonG      (smallJsont *self, const char *string, int64_t index);
   1555 bool equalICharSmallJsonG(smallJsont *self, char c, int64_t index);
   1556 bool equalIJsonSmallJsonG(smallJsont *self, smallJsont *string, int64_t index);
   1557 bool equalISmallStringSmallJsonG(smallJsont *self, smallStringt *string, int64_t index);
   1558 bool startsWithSSmallJsonG  (smallJsont *self, const char *string);
   1559 bool startsWithCharSmallJsonG(smallJsont *self, char c);
   1560 bool startsWithSmallStringSmallJsonG(smallJsont *self, smallStringt *string);
   1561 bool startsWithJsonSmallJsonG(smallJsont *self, smallJsont *string);
   1562 bool endsWithSSmallJsonG    (smallJsont *self, const char *string);
   1563 bool endsWithCharSmallJsonG(smallJsont *self, char c);
   1564 bool endsWithSmallStringSmallJsonG(smallJsont *self, smallStringt *string);
   1565 bool endsWithJsonSmallJsonG(smallJsont *self, smallJsont *string);
   1566 ssize_t countSSmallJsonG    (smallJsont *self, const char *string);
   1567 ssize_t countCharSmallJsonG(smallJsont *self, char c);
   1568 ssize_t countSmallStringSmallJsonG(smallJsont *self, smallStringt *string);
   1569 ssize_t countJsonSmallJsonG(smallJsont *self, smallJsont *string);
   1570 bool icStartsWithSSmallJsonG  (smallJsont *self, const char *string);
   1571 bool icStartsWithCharSmallJsonG(smallJsont *self, char c);
   1572 bool icStartsWithSmallStringSmallJsonG(smallJsont *self, smallStringt *string);
   1573 bool icStartsWithJsonSmallJsonG(smallJsont *self, smallJsont *string);
   1574 bool icEndsWithSSmallJsonG    (smallJsont *self, const char *string);
   1575 bool icEndsWithCharSmallJsonG(smallJsont *self, char c);
   1576 bool icEndsWithSmallStringSmallJsonG(smallJsont *self, smallStringt *string);
   1577 bool icEndsWithJsonSmallJsonG(smallJsont *self, smallJsont *string);
   1578 ssize_t icCountSSmallJsonG    (smallJsont *self, const char *string);
   1579 ssize_t icCountCharSmallJsonG(smallJsont *self, char c);
   1580 ssize_t icCountSmallStringSmallJsonG(smallJsont *self, smallStringt *string);
   1581 ssize_t icCountJsonSmallJsonG(smallJsont *self, smallJsont *string);
   1582 bool isNumberSmallJsonG(smallJsont *self);
   1583 bool isIntSmallJsonG(smallJsont *self);
   1584 int64_t parseIntSmallJsonG (smallJsont *self);
   1585 double parseDoubleSmallJsonG (smallJsont *self);
   1586 smallJsont* intToSmallJsonG        (smallJsont *self, int64_t n);
   1587 smallJsont* doubleToSmallJsonG     (smallJsont *self, double n);
   1588 size_t      lenSmallJsonG       (smallJsont *self);
   1589 smallJsont*    upperSmallJsonG      (smallJsont *self);
   1590 smallJsont*    lowerSmallJsonG      (smallJsont *self);
   1591 smallJsont*    trimSmallJsonG       (smallJsont *self);
   1592 smallJsont*    lTrimSmallJsonG       (smallJsont *self);
   1593 smallJsont*    rTrimSmallJsonG       (smallJsont *self);
   1594 smallJsont* compactSmallJsonG       (smallJsont *self);
   1595 smallJsont* emptySmallJsonG     (smallJsont *self);
   1596 bool        isEmptySmallJsonG   (smallJsont *self);
   1597 bool isBlankSmallJsonG      (smallJsont *self);
   1598 smallStringt* joinSmallJsonG(smallJsont *self, const char* delim);
   1599 smallStringt* joinCharSmallJsonG(smallJsont *self, char c);
   1600 smallStringt* joinSmallJsonSmallJsonG  (smallJsont *self, smallJsont* delim);
   1601 smallStringt* joinSmallStringSmallJsonG(smallJsont *self, smallStringt* delim);
   1602 char* joinSSmallJsonG(smallJsont *self, const char* delim);
   1603 char* joinCharSSmallJsonG(smallJsont *self, char c);
   1604 char* joinSmallJsonSSmallJsonG  (smallJsont *self, smallJsont* delim);
   1605 char* joinSmallStringSSmallJsonG(smallJsont *self, smallStringt* delim);
   1606 smallJsont* splitSmallJsonG(smallJsont *self, const char *delim);
   1607 smallJsont* splitCharSmallJsonG(smallJsont *self, char c);
   1608 smallJsont* splitSmallJsonSmallJsonG  (smallJsont *self, smallJsont *delim);
   1609 smallJsont* splitSmallStringSmallJsonG(smallJsont *self, smallStringt *delim);
   1610 char** splitSSmallJsonG(smallJsont *self, char* delim);
   1611 char** splitCharSSmallJsonG(smallJsont *self, char c);
   1612 char** splitSmallJsonSSmallJsonG  (smallJsont *self, smallJsont *delim);
   1613 char** splitSmallStringSSmallJsonG(smallJsont *self, smallStringt *delim);
   1614 smallJsont* extractSmallJsonG(smallJsont *self, const char* delim1, const char* delim2);
   1615 smallJsont* extractCharSSmallJsonG(smallJsont *self, char delim1, const char* delim2);
   1616 smallJsont* extractSCharSmallJsonG(smallJsont *self, const char* delim1, char delim2);
   1617 smallJsont* extractCharCharSmallJsonG(smallJsont *self, char delim1, char delim2);
   1618 smallJsont* extractSmallJsonSmallJsonSmallJsonG(smallJsont *self, smallJsont* delim1, smallJsont* delim2);
   1619 smallJsont* extractSmallJsonSmallStringSmallJsonG(smallJsont *self, smallJsont* delim1, smallStringt* delim2);
   1620 smallJsont* extractSmallJsonSSmallJsonG(smallJsont *self, smallJsont* delim1, const char* delim2);
   1621 smallJsont* extractSmallJsonCharSmallJsonG(smallJsont *self, smallJsont* delim1, char delim2);
   1622 smallJsont* extractSmallStringSmallJsonSmallJsonG(smallJsont *self, smallStringt* delim1, smallJsont* delim2);
   1623 smallJsont* extractSmallStringSmallStringSmallJsonG(smallJsont *self, smallStringt* delim1, smallStringt* delim2);
   1624 smallJsont* extractSmallStringSSmallJsonG(smallJsont *self, smallStringt* delim1, const char* delim2);
   1625 smallJsont* extractSmallStringCharSmallJsonG(smallJsont *self, smallStringt* delim1, char delim2);
   1626 smallJsont* extractSSmallJsonSmallJsonG(smallJsont *self, const char* delim1, smallJsont* delim2);
   1627 smallJsont* extractSSmallStringSmallJsonG(smallJsont *self, const char* delim1, smallStringt* delim2);
   1628 smallJsont* extractCharSmallJsonSmallJsonG(smallJsont *self, char delim1, smallJsont* delim2);
   1629 smallJsont* extractCharSmallStringSmallJsonG(smallJsont *self, char delim1, smallStringt* delim2);
   1630 smallJsont* icSplitSmallJsonG(smallJsont *self, const char *delim);
   1631 smallJsont* icSplitCharSmallJsonG(smallJsont *self, char c);
   1632 smallJsont* icSplitSmallJsonSmallJsonG  (smallJsont *self, smallJsont *delim);
   1633 smallJsont* icSplitSmallStringSmallJsonG(smallJsont *self, smallStringt *delim);
   1634 char** icSplitSSmallJsonG(smallJsont *self, char* delim);
   1635 char** icSplitCharSSmallJsonG(smallJsont *self, char c);
   1636 char** icSplitSmallJsonSSmallJsonG(smallJsont *self, smallJsont *delim);
   1637 char** icSplitSmallStringSSmallJsonG(smallJsont *self, smallStringt *delim);
   1638 smallJsont* icExtractSmallJsonG(smallJsont *self, const char* delim1, const char* delim2);
   1639 smallJsont* icExtractCharSSmallJsonG(smallJsont *self, char delim1, const char* delim2);
   1640 smallJsont* icExtractSCharSmallJsonG(smallJsont *self, const char* delim1, char delim2);
   1641 smallJsont* icExtractCharCharSmallJsonG(smallJsont *self, char delim1, char delim2);
   1642 smallJsont* icExtractSmallJsonSmallJsonSmallJsonG(smallJsont *self, smallJsont* delim1, smallJsont* delim2);
   1643 smallJsont* icExtractSmallJsonSmallStringSmallJsonG(smallJsont *self, smallJsont* delim1, smallStringt* delim2);
   1644 smallJsont* icExtractSmallJsonSSmallJsonG(smallJsont *self, smallJsont* delim1, const char* delim2);
   1645 smallJsont* icExtractSmallJsonCharSmallJsonG(smallJsont *self, smallJsont* delim1, char delim2);
   1646 smallJsont* icExtractSmallStringSmallJsonSmallJsonG(smallJsont *self, smallStringt* delim1, smallJsont* delim2);
   1647 smallJsont* icExtractSmallStringSmallStringSmallJsonG(smallJsont *self, smallStringt* delim1, smallStringt* delim2);
   1648 smallJsont* icExtractSmallStringSSmallJsonG(smallJsont *self, smallStringt* delim1, const char* delim2);
   1649 smallJsont* icExtractSmallStringCharSmallJsonG(smallJsont *self, smallStringt* delim1, char delim2);
   1650 smallJsont* icExtractSSmallJsonSmallJsonG(smallJsont *self, const char* delim1, smallJsont* delim2);
   1651 smallJsont* icExtractSSmallStringSmallJsonG(smallJsont *self, const char* delim1, smallStringt* delim2);
   1652 smallJsont* icExtractCharSmallJsonSmallJsonG(smallJsont *self, char delim1, smallJsont* delim2);
   1653 smallJsont* icExtractCharSmallStringSmallJsonG(smallJsont *self, char delim1, smallStringt* delim2);
   1654 smallJsont* zipSmallJsonG(smallJsont *self, smallArrayt *array1, smallArrayt *array2);
   1655 smallJsont* zipArraySmallJsonG(smallJsont *self, char** array1, smallArrayt *array2);
   1656 smallJsont* zipCArraySmallJsonG(smallJsont *self, const char** array1, smallArrayt *array2);
   1657 smallJsont* zipCharSmallJsonG(smallJsont *self, smallArrayt *array1, char** array2);
   1658 smallJsont* zipCCharSmallJsonG(smallJsont *self, smallArrayt *array1, const char** array2);
   1659 smallJsont* zipArrayCharSmallJsonG(smallJsont *self, char** array1, char** array2);
   1660 smallJsont* zipArrayCCharSmallJsonG(smallJsont *self, char** array1, const char** array2);
   1661 smallJsont* zipCArrayCharSmallJsonG(smallJsont *self, const char** array1, char** array2);
   1662 smallJsont* zipCArrayCCharSmallJsonG(smallJsont *self, const char** array1, const char** array2);
   1663 smallJsont* zipJsonSmallJsonG          (smallJsont *self, smallJsont *array1, smallJsont *array2);
   1664 smallJsont* zipJsonSmallArraySmallJsonG(smallJsont *self, smallJsont *array1, smallArrayt *array2);
   1665 smallJsont* zipJsonArraySmallJsonG     (smallJsont *self, smallJsont *array1, char** array2);
   1666 smallJsont* zipJsonCArraySmallJsonG    (smallJsont *self, smallJsont *array1, const char** array2);
   1667 smallJsont* zipSmallArrayJsonSmallJsonG(smallJsont *self, smallArrayt *array1, smallJsont *array2);
   1668 smallJsont* zipArrayJsonSmallJsonG     (smallJsont *self, char** array1, smallJsont *array2);
   1669 smallJsont* zipCArrayJsonSmallJsonG    (smallJsont *self, const char** array1, smallJsont *array2);
   1670 smallStringt* stringifySmallStringSmallJsonG(smallJsont *self, int indent);
   1671 smallStringt* toYMLSmallStringSmallJsonG(smallJsont *self, int indent);
   1672 bool parseSmallJsonG            (smallJsont *self, const char *input);
   1673 bool parseSmallJsonSmallJsonG(smallJsont *self, smallJsont *input);
   1674 bool parseSmallStringSmallJsonG(smallJsont *self, smallStringt *input);
   1675 bool parseYMLSmallJsonG            (smallJsont *self, const char *input);
   1676 bool parseYMLSmallJsonSmallJsonG(smallJsont *self, smallJsont *input);
   1677 bool parseYMLSmallStringSmallJsonG(smallJsont *self, smallStringt *input);
   1678 void logSmallJsonG(smallJsont *self);
   1679 smallJsont* readFileSmallJsonG(smallJsont *self, const char *filePath);
   1680 smallJsont* readFileSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath);
   1681 smallJsont* readFileJsonSmallJsonG(smallJsont *self, smallJsont *filePath);
   1682 smallJsont* readStreamSmallJsonG  (smallJsont *self, FILE *fp);
   1683 int writeFileSmallJsonG(smallJsont *self, const char *filePath);
   1684 int writeFileSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath);
   1685 int writeFileJsonSmallJsonG(smallJsont *self, smallJsont *filePath);
   1686 int writeStreamSmallJsonG         (smallJsont *self, FILE *fp);
   1687 int appendFileSmallJsonG           (smallJsont *self, const char *filePath);
   1688 int appendFileSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath);
   1689 int appendFileJsonSmallJsonG(smallJsont *self, smallJsont *filePath);
   1690 smallJsont* readTextSmallJsonG     (smallJsont *self, const char *filePath);
   1691 smallJsont* readTextSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath);
   1692 smallJsont* readTextJsonSmallJsonG(smallJsont *self, smallJsont *filePath);
   1693 smallJsont* readTextStreamSmallJsonG   (smallJsont *self, FILE *fp);
   1694 bool writeTextSmallJsonG    (smallJsont *self, const char *filePath);
   1695 bool writeTextSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath);
   1696 bool writeTextJsonSmallJsonG(smallJsont *self, smallJsont *filePath);
   1697 bool writeTextStreamSmallJsonG      (smallJsont *self, FILE *fp);
   1698 bool appendTextSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath);
   1699 bool appendTextJsonSmallJsonG(smallJsont *self, smallJsont *filePath);
   1700 
   1701 // default max value size used in lax_json_create
   1702 // default is 1MB
   1703 size_t jsonMaxValueBufferSize = 1048576;
   1704 
   1705 enum {SMALLJSON_IS_EMPTY, TOP_IS_UNDEFINED, TOP_IS_BOOL, TOP_IS_DOUBLE, TOP_IS_INT, TOP_IS_STRING, TOP_IS_DICT, TOP_IS_ARRAY};
   1706 
   1707 const char *jsonPathResS[] = {"KEY_IS_NULL", "NOT_A_PATH", "ARRAY_PATH", "DICT_PATH", NULL};
   1708 
   1709 #define eprintf   shEPrintfS
   1710 
   1711 void initiateSmallJson(smallJsont *self) {
   1712 
   1713   self->type = "smallJson";;
   1714   if (!smallJsonF) {
   1715     isError(smallJsonF, malloc(sizeof(smallJsonFunctionst))) {
   1716       self->f = NULL;
   1717       return;
   1718     }
   1719     registerMethodsSmallJson(smallJsonF);
   1720   }
   1721   self->f                   = smallJsonF;
   1722   self->topU                = NULL;
   1723   self->topB                = NULL;
   1724   self->topD                = NULL;
   1725   self->topI                = NULL;
   1726   self->topS                = NULL;
   1727   self->top                 = NULL;
   1728   self->topA                = NULL;
   1729   self->topIsA              = SMALLJSON_IS_EMPTY;
   1730   self->iterIndex           = -1;
   1731   self->iterKey             = NULL;
   1732   self->iterStep            = 0;
   1733   self->iterElement         = NULL;
   1734   self->iterElementDataType = 0;
   1735 }
   1736 
   1737 void registerMethodsSmallJson(smallJsonFunctionst *f) {
   1738 
   1739   f->free                                 = freeSmallJson;
   1740   f->terminate                            = terminateSmallJson;
   1741   f->toString                             = toStringSmallJson;
   1742   f->duplicate                            = duplicateSmallJson;
   1743 
   1744   f->escape                               = escapeSmallJson;
   1745   f->dispose                              = disposeSmallJson;
   1746   f->reset                                = resetSmallJson;
   1747   f->smash                                = smashSmallJson;
   1748   f->finish                               = finishSmallJson;
   1749   f->help                                 = helpSmallJson;
   1750   f->getso                                = getsoSmallJson;
   1751   f->setso                                = setsoSmallJson;
   1752   f->mirror                               = mirrorSmallJson;
   1753   f->getTopType                           = getTopTypeSmallJson;
   1754   f->setTypeUndefined                     = setTypeUndefinedSmallJson;
   1755   f->setTypeBool                          = setTypeBoolSmallJson;
   1756   f->setTypeDouble                        = setTypeDoubleSmallJson;
   1757   f->setTypeInt                           = setTypeIntSmallJson;
   1758   f->setTypeString                        = setTypeStringSmallJson;
   1759   f->setTypeDict                          = setTypeDictSmallJson;
   1760   f->setTypeArray                         = setTypeArraySmallJson;
   1761   f->setTop                               = setTopSmallJson;
   1762   f->setTopBool                           = setTopBoolSmallJson;
   1763   f->setTopDouble                         = setTopDoubleSmallJson;
   1764   f->setTopInt                            = setTopIntSmallJson;
   1765   f->setTopString                         = setTopStringSmallJson;
   1766   f->setTopChar                           = setTopCharSmallJson;
   1767   f->setTopDict                           = setTopDictSmallJson;
   1768   f->setTopArray                          = setTopArraySmallJson;
   1769   f->setTopArrayc                         = setTopArraycSmallJson;
   1770   f->setTopCArrayc                        = setTopCArraycSmallJson;
   1771   f->setTopSmallBool                      = setTopSmallBoolSmallJson;
   1772   f->setTopSmallDouble                    = setTopSmallDoubleSmallJson;
   1773   f->setTopSmallInt                       = setTopSmallIntSmallJson;
   1774   f->setTopSmallJson                      = setTopSmallJsonSmallJson;
   1775   f->setTopSmallString                    = setTopSmallStringSmallJson;
   1776   f->setTopNFree                          = setTopNFreeSmallJson;
   1777   f->setTopNFreeBool                      = setTopNFreeBoolSmallJson;
   1778   f->setTopNFreeDouble                    = setTopNFreeDoubleSmallJson;
   1779   f->setTopNFreeInt                       = setTopNFreeIntSmallJson;
   1780   f->setTopNFreeString                    = setTopNFreeStringSmallJson;
   1781   f->setTopNFreeDict                      = setTopNFreeDictSmallJson;
   1782   f->setTopNFreeArray                     = setTopNFreeArraySmallJson;
   1783   f->setTopNFreeArrayc                    = setTopNFreeArraycSmallJson;
   1784   f->setTopNFreeSmallBool                 = setTopNFreeSmallBoolSmallJson;
   1785   f->setTopNFreeSmallDouble               = setTopNFreeSmallDoubleSmallJson;
   1786   f->setTopNFreeSmallInt                  = setTopNFreeSmallIntSmallJson;
   1787   f->setTopNFreeSmallJson                 = setTopNFreeSmallJsonSmallJson;
   1788   f->setTopNFreeSmallString               = setTopNFreeSmallStringSmallJson;
   1789   f->fromArray                            = fromArraySmallJson;
   1790   f->fromCArray                           = fromCArraySmallJson;
   1791   f->fromArrayNFree                       = fromArrayNFreeSmallJson;
   1792   f->fromArrayDict                        = fromArrayDictSmallJson;
   1793   f->toArrayDict                          = toArrayDictSmallJson;
   1794   f->getTop                               = getTopSmallJson;
   1795   f->getTopUndefined                      = getTopUndefinedSmallJson;
   1796   f->getTopBool                           = getTopBoolSmallJson;
   1797   f->getTopBoolP                          = getTopBoolPSmallJson;
   1798   f->getTopDouble                         = getTopDoubleSmallJson;
   1799   f->getTopDoubleP                        = getTopDoublePSmallJson;
   1800   f->getTopInt                            = getTopIntSmallJson;
   1801   f->getTopIntP                           = getTopIntPSmallJson;
   1802   f->getTopInt32                          = getTopInt32SmallJson;
   1803   f->getTopInt32P                         = getTopInt32PSmallJson;
   1804   f->getTopUint                           = getTopUintSmallJson;
   1805   f->getTopUintP                          = getTopUintPSmallJson;
   1806   f->getTopUint32                         = getTopUint32SmallJson;
   1807   f->getTopUint32P                        = getTopUint32PSmallJson;
   1808   f->getTopS                              = getTopSSmallJson;
   1809   f->getTopDict                           = getTopDictSmallJson;
   1810   f->getTopArray                          = getTopArraySmallJson;
   1811   f->getTopSmallBool                      = getTopSmallBoolSmallJson;
   1812   f->getTopSmallDouble                    = getTopSmallDoubleSmallJson;
   1813   f->getTopSmallInt                       = getTopSmallIntSmallJson;
   1814   f->getTopSmallString                    = getTopSmallStringSmallJson;
   1815   f->keyIs                                = keyIsSmallJson;
   1816   f->keyIsS                               = keyIsSSmallJson;
   1817   f->makeKey                              = makeKeySmallJson;
   1818   f->iMakeKey                             = iMakeKeySmallJson;
   1819   f->bMakeKey                             = bMakeKeySmallJson;
   1820   f->bLMakeKey                            = bLMakeKeySmallJson;
   1821   f->makeKeyLen                           = makeKeyLenSmallJson;
   1822   f->set                                  = setSmallJson;
   1823   f->setUndefined                         = setUndefinedSmallJson;
   1824   f->setBool                              = setBoolSmallJson;
   1825   f->setDouble                            = setDoubleSmallJson;
   1826   f->setInt                               = setIntSmallJson;
   1827   f->setS                                 = setSSmallJson;
   1828   f->setChar                              = setCharSmallJson;
   1829   f->setDict                              = setDictSmallJson;
   1830   f->setArray                             = setArraySmallJson;
   1831   f->setArrayc                            = setArraycSmallJson;
   1832   f->setCArrayc                           = setCArraycSmallJson;
   1833   f->setSmallBool                         = setSmallBoolSmallJson;
   1834   f->setSmallBytes                        = setSmallBytesSmallJson;
   1835   f->setSmallDouble                       = setSmallDoubleSmallJson;
   1836   f->setSmallInt                          = setSmallIntSmallJson;
   1837   f->setSmallJson                         = setSmallJsonSmallJson;
   1838   f->setSmallString                       = setSmallStringSmallJson;
   1839   f->setSmallContainer                    = setSmallContainerSmallJson;
   1840   f->setNFree                             = setNFreeSmallJson;
   1841   f->setNFreeUndefined                    = setNFreeUndefinedSmallJson;
   1842   f->setNFreeS                            = setNFreeSSmallJson;
   1843   f->setNFreeDict                         = setNFreeDictSmallJson;
   1844   f->setNFreeArray                        = setNFreeArraySmallJson;
   1845   f->setNFreeArrayc                       = setNFreeArraycSmallJson;
   1846   f->setNFreeSmallBool                    = setNFreeSmallBoolSmallJson;
   1847   f->setNFreeSmallBytes                   = setNFreeSmallBytesSmallJson;
   1848   f->setNFreeSmallDouble                  = setNFreeSmallDoubleSmallJson;
   1849   f->setNFreeSmallInt                     = setNFreeSmallIntSmallJson;
   1850   f->setNFreeSmallJson                    = setNFreeSmallJsonSmallJson;
   1851   f->setNFreeSmallString                  = setNFreeSmallStringSmallJson;
   1852   f->setNFreeSmallContainer               = setNFreeSmallContainerSmallJson;
   1853   f->setPDict                             = setPDictSmallJson;
   1854   f->setPArray                            = setPArraySmallJson;
   1855   f->setPSmallJson                        = setPSmallJsonSmallJson;
   1856   f->setPSmallString                      = setPSmallStringSmallJson;
   1857   f->setNFreePDict                        = setNFreePDictSmallJson;
   1858   f->setNFreePArray                       = setNFreePArraySmallJson;
   1859   f->setNFreePSmallJson                   = setNFreePSmallJsonSmallJson;
   1860   f->setNFreePSmallString                 = setNFreePSmallStringSmallJson;
   1861   f->setAt                                = setAtSmallJson;
   1862   f->setAtUndefined                       = setAtUndefinedSmallJson;
   1863   f->setAtBool                            = setAtBoolSmallJson;
   1864   f->setAtDouble                          = setAtDoubleSmallJson;
   1865   f->setAtInt                             = setAtIntSmallJson;
   1866   f->setAtS                               = setAtSSmallJson;
   1867   f->setAtChar                            = setAtCharSmallJson;
   1868   f->setAtDict                            = setAtDictSmallJson;
   1869   f->setAtArray                           = setAtArraySmallJson;
   1870   f->setAtArrayc                          = setAtArraycSmallJson;
   1871   f->setAtCArrayc                         = setAtCArraycSmallJson;
   1872   f->setAtSmallBool                       = setAtSmallBoolSmallJson;
   1873   f->setAtSmallBytes                      = setAtSmallBytesSmallJson;
   1874   f->setAtSmallDouble                     = setAtSmallDoubleSmallJson;
   1875   f->setAtSmallInt                        = setAtSmallIntSmallJson;
   1876   f->setAtSmallJson                       = setAtSmallJsonSmallJson;
   1877   f->setAtSmallString                     = setAtSmallStringSmallJson;
   1878   f->setAtSmallContainer                  = setAtSmallContainerSmallJson;
   1879   f->setAtNFree                           = setAtNFreeSmallJson;
   1880   f->setAtNFreeUndefined                  = setAtNFreeUndefinedSmallJson;
   1881   f->setAtNFreeS                          = setAtNFreeSSmallJson;
   1882   f->setAtNFreeDict                       = setAtNFreeDictSmallJson;
   1883   f->setAtNFreeArray                      = setAtNFreeArraySmallJson;
   1884   f->setAtNFreeArrayc                     = setAtNFreeArraycSmallJson;
   1885   f->setAtNFreeSmallBool                  = setAtNFreeSmallBoolSmallJson;
   1886   f->setAtNFreeSmallBytes                 = setAtNFreeSmallBytesSmallJson;
   1887   f->setAtNFreeSmallDouble                = setAtNFreeSmallDoubleSmallJson;
   1888   f->setAtNFreeSmallInt                   = setAtNFreeSmallIntSmallJson;
   1889   f->setAtNFreeSmallJson                  = setAtNFreeSmallJsonSmallJson;
   1890   f->setAtNFreeSmallString                = setAtNFreeSmallStringSmallJson;
   1891   f->setAtNFreeSmallContainer             = setAtNFreeSmallContainerSmallJson;
   1892   f->setPAtDict                           = setPAtDictSmallJson;
   1893   f->setPAtArray                          = setPAtArraySmallJson;
   1894   f->setPAtSmallJson                      = setPAtSmallJsonSmallJson;
   1895   f->setPAtSmallString                    = setPAtSmallStringSmallJson;
   1896   f->setPAtNFreeDict                      = setPAtNFreeDictSmallJson;
   1897   f->setPAtNFreeArray                     = setPAtNFreeArraySmallJson;
   1898   f->setPAtNFreeSmallJson                 = setPAtNFreeSmallJsonSmallJson;
   1899   f->setPAtNFreeSmallString               = setPAtNFreeSmallStringSmallJson;
   1900   f->get                                  = getSmallJson;
   1901   f->getUndefined                         = getUndefinedSmallJson;
   1902   f->getBool                              = getBoolSmallJson;
   1903   f->getBoolP                             = getBoolPSmallJson;
   1904   f->getDouble                            = getDoubleSmallJson;
   1905   f->getDoubleP                           = getDoublePSmallJson;
   1906   f->getInt                               = getIntSmallJson;
   1907   f->getIntP                              = getIntPSmallJson;
   1908   f->getInt32                             = getInt32SmallJson;
   1909   f->getInt32P                            = getInt32PSmallJson;
   1910   f->getUint                              = getUintSmallJson;
   1911   f->getUintP                             = getUintPSmallJson;
   1912   f->getUint32                            = getUint32SmallJson;
   1913   f->getUint32P                           = getUint32PSmallJson;
   1914   f->getS                                 = getSSmallJson;
   1915   f->getDict                              = getDictSmallJson;
   1916   f->getArray                             = getArraySmallJson;
   1917   f->getSmallBool                         = getSmallBoolSmallJson;
   1918   f->getSmallBytes                        = getSmallBytesSmallJson;
   1919   f->getSmallDouble                       = getSmallDoubleSmallJson;
   1920   f->getSmallInt                          = getSmallIntSmallJson;
   1921   f->getSmallJson                         = getSmallJsonSmallJson;
   1922   f->getSmallString                       = getSmallStringSmallJson;
   1923   f->getVoid                              = getVoidSmallJson;
   1924   f->getSmallContainer                    = getSmallContainerSmallJson;
   1925   f->getNDup                              = getNDupSmallJson;
   1926   f->getNDupUndefined                     = getNDupUndefinedSmallJson;
   1927   f->getNDupBool                          = getNDupBoolSmallJson;
   1928   f->getNDupDouble                        = getNDupDoubleSmallJson;
   1929   f->getNDupInt                           = getNDupIntSmallJson;
   1930   f->getNDupInt32                         = getNDupInt32SmallJson;
   1931   f->getNDupUint                          = getNDupUintSmallJson;
   1932   f->getNDupUint32                        = getNDupUint32SmallJson;
   1933   f->getNDupS                             = getNDupSSmallJson;
   1934   f->getNDupDict                          = getNDupDictSmallJson;
   1935   f->getNDupArray                         = getNDupArraySmallJson;
   1936   f->getNDupSmallBool                     = getNDupSmallBoolSmallJson;
   1937   f->getNDupSmallBytes                    = getNDupSmallBytesSmallJson;
   1938   f->getNDupSmallDouble                   = getNDupSmallDoubleSmallJson;
   1939   f->getNDupSmallInt                      = getNDupSmallIntSmallJson;
   1940   f->getNDupSmallJson                     = getNDupSmallJsonSmallJson;
   1941   f->getNDupSmallString                   = getNDupSmallStringSmallJson;
   1942   f->getNDupVoid                          = getNDupVoidSmallJson;
   1943   f->getNDupSmallContainer                = getNDupSmallContainerSmallJson;
   1944   f->getAt                                = getAtSmallJson;
   1945   f->getAtUndefined                       = getAtUndefinedSmallJson;
   1946   f->getAtBool                            = getAtBoolSmallJson;
   1947   f->getAtBoolP                           = getAtBoolPSmallJson;
   1948   f->getAtDouble                          = getAtDoubleSmallJson;
   1949   f->getAtDoubleP                         = getAtDoublePSmallJson;
   1950   f->getAtInt                             = getAtIntSmallJson;
   1951   f->getAtIntP                            = getAtIntPSmallJson;
   1952   f->getAtInt32                           = getAtInt32SmallJson;
   1953   f->getAtInt32P                          = getAtInt32PSmallJson;
   1954   f->getAtUint                            = getAtUintSmallJson;
   1955   f->getAtUintP                           = getAtUintPSmallJson;
   1956   f->getAtUint32                          = getAtUint32SmallJson;
   1957   f->getAtUint32P                         = getAtUint32PSmallJson;
   1958   f->getAtS                               = getAtSSmallJson;
   1959   f->getAtDict                            = getAtDictSmallJson;
   1960   f->getAtArray                           = getAtArraySmallJson;
   1961   f->getAtSmallBool                       = getAtSmallBoolSmallJson;
   1962   f->getAtSmallBytes                      = getAtSmallBytesSmallJson;
   1963   f->getAtSmallDouble                     = getAtSmallDoubleSmallJson;
   1964   f->getAtSmallInt                        = getAtSmallIntSmallJson;
   1965   f->getAtSmallJson                       = getAtSmallJsonSmallJson;
   1966   f->getAtSmallString                     = getAtSmallStringSmallJson;
   1967   f->getAtVoid                            = getAtVoidSmallJson;
   1968   f->getAtSmallContainer                  = getAtSmallContainerSmallJson;
   1969   f->getAtNDup                            = getAtNDupSmallJson;
   1970   f->getAtNDupUndefined                   = getAtNDupUndefinedSmallJson;
   1971   f->getAtNDupBool                        = getAtNDupBoolSmallJson;
   1972   f->getAtNDupDouble                      = getAtNDupDoubleSmallJson;
   1973   f->getAtNDupInt                         = getAtNDupIntSmallJson;
   1974   f->getAtNDupInt32                       = getAtNDupInt32SmallJson;
   1975   f->getAtNDupUint                        = getAtNDupUintSmallJson;
   1976   f->getAtNDupUint32                      = getAtNDupUint32SmallJson;
   1977   f->getAtNDupS                           = getAtNDupSSmallJson;
   1978   f->getAtNDupDict                        = getAtNDupDictSmallJson;
   1979   f->getAtNDupArray                       = getAtNDupArraySmallJson;
   1980   f->getAtNDupSmallBool                   = getAtNDupSmallBoolSmallJson;
   1981   f->getAtNDupSmallBytes                  = getAtNDupSmallBytesSmallJson;
   1982   f->getAtNDupSmallDouble                 = getAtNDupSmallDoubleSmallJson;
   1983   f->getAtNDupSmallInt                    = getAtNDupSmallIntSmallJson;
   1984   f->getAtNDupSmallJson                   = getAtNDupSmallJsonSmallJson;
   1985   f->getAtNDupSmallString                 = getAtNDupSmallStringSmallJson;
   1986   f->getAtNDupVoid                        = getAtNDupVoidSmallJson;
   1987   f->getAtNDupSmallContainer              = getAtNDupSmallContainerSmallJson;
   1988   f->getNum                               = getNumSmallJson;
   1989   f->getNumAt                             = getNumAtSmallJson;
   1990   f->delElem                              = delElemSmallJson;
   1991   f->del                                  = delSmallJson;
   1992   f->delElemIndex                         = delElemIndexSmallJson;
   1993   f->removeElem                           = removeElemSmallJson;
   1994   f->remove                               = removeSmallJson;
   1995   f->removeElemIndex                      = removeElemIndexSmallJson;
   1996   f->push                                 = pushSmallJson;
   1997   f->pushUndefined                        = pushUndefinedSmallJson;
   1998   f->pushBool                             = pushBoolSmallJson;
   1999   f->pushDouble                           = pushDoubleSmallJson;
   2000   f->pushInt                              = pushIntSmallJson;
   2001   f->pushS                                = pushSSmallJson;
   2002   f->pushChar                             = pushCharSmallJson;
   2003   f->pushDict                             = pushDictSmallJson;
   2004   f->pushArray                            = pushArraySmallJson;
   2005   f->pushArrayc                           = pushArraycSmallJson;
   2006   f->pushCArrayc                          = pushCArraycSmallJson;
   2007   f->pushSmallBool                        = pushSmallBoolSmallJson;
   2008   f->pushSmallBytes                       = pushSmallBytesSmallJson;
   2009   f->pushSmallDouble                      = pushSmallDoubleSmallJson;
   2010   f->pushSmallInt                         = pushSmallIntSmallJson;
   2011   f->pushSmallJson                        = pushSmallJsonSmallJson;
   2012   f->pushSmallString                      = pushSmallStringSmallJson;
   2013   f->pushSmallContainer                   = pushSmallContainerSmallJson;
   2014   f->pushNFree                            = pushNFreeSmallJson;
   2015   f->pushNFreeUndefined                   = pushNFreeUndefinedSmallJson;
   2016   f->pushNFreeS                           = pushNFreeSSmallJson;
   2017   f->pushNFreeDict                        = pushNFreeDictSmallJson;
   2018   f->pushNFreeArray                       = pushNFreeArraySmallJson;
   2019   f->pushNFreeArrayc                      = pushNFreeArraycSmallJson;
   2020   f->pushNFreeSmallBool                   = pushNFreeSmallBoolSmallJson;
   2021   f->pushNFreeSmallBytes                  = pushNFreeSmallBytesSmallJson;
   2022   f->pushNFreeSmallDouble                 = pushNFreeSmallDoubleSmallJson;
   2023   f->pushNFreeSmallInt                    = pushNFreeSmallIntSmallJson;
   2024   f->pushNFreeSmallJson                   = pushNFreeSmallJsonSmallJson;
   2025   f->pushNFreeSmallString                 = pushNFreeSmallStringSmallJson;
   2026   f->pushNFreeSmallContainer              = pushNFreeSmallContainerSmallJson;
   2027   f->pushMany                             = pushManySmallJson;
   2028   f->pushManyS                            = pushManySSmallJson;
   2029   f->catSt                                = pushManySSmallJson;
   2030   f->pushNFreeMany                        = pushNFreeManySmallJson;
   2031   f->pushNFreeManyS                       = pushNFreeManySSmallJson;
   2032   f->pop                                  = popSmallJson;
   2033   f->popUndefined                         = popUndefinedSmallJson;
   2034   f->popBool                              = popBoolSmallJson;
   2035   f->popDouble                            = popDoubleSmallJson;
   2036   f->popInt                               = popIntSmallJson;
   2037   f->popInt32                             = popInt32SmallJson;
   2038   f->popUint                              = popUintSmallJson;
   2039   f->popUint32                            = popUint32SmallJson;
   2040   f->popS                                 = popSSmallJson;
   2041   f->popDict                              = popDictSmallJson;
   2042   f->popArray                             = popArraySmallJson;
   2043   f->popSmallBool                         = popSmallBoolSmallJson;
   2044   f->popSmallBytes                        = popSmallBytesSmallJson;
   2045   f->popSmallDouble                       = popSmallDoubleSmallJson;
   2046   f->popSmallInt                          = popSmallIntSmallJson;
   2047   f->popSmallJson                         = popSmallJsonSmallJson;
   2048   f->popSmallString                       = popSmallStringSmallJson;
   2049   f->popVoid                              = popVoidSmallJson;
   2050   f->popSmallContainer                    = popSmallContainerSmallJson;
   2051   f->popNum                               = popNumSmallJson;
   2052   f->prepend                              = prependSmallJson;
   2053   f->prependUndefined                     = prependUndefinedSmallJson;
   2054   f->prependBool                          = prependBoolSmallJson;
   2055   f->prependDouble                        = prependDoubleSmallJson;
   2056   f->prependInt                           = prependIntSmallJson;
   2057   f->prependS                             = prependSSmallJson;
   2058   f->prependChar                          = prependCharSmallJson;
   2059   f->prependDict                          = prependDictSmallJson;
   2060   f->prependArray                         = prependArraySmallJson;
   2061   f->prependArrayc                        = prependArraycSmallJson;
   2062   f->prependCArrayc                       = prependCArraycSmallJson;
   2063   f->prependSmallBool                     = prependSmallBoolSmallJson;
   2064   f->prependSmallBytes                    = prependSmallBytesSmallJson;
   2065   f->prependSmallDouble                   = prependSmallDoubleSmallJson;
   2066   f->prependSmallInt                      = prependSmallIntSmallJson;
   2067   f->prependSmallJson                     = prependSmallJsonSmallJson;
   2068   f->prependSmallString                   = prependSmallStringSmallJson;
   2069   f->prependSmallContainer                = prependSmallContainerSmallJson;
   2070   f->prependNFree                         = prependNFreeSmallJson;
   2071   f->prependNFreeUndefined                = prependNFreeUndefinedSmallJson;
   2072   f->prependNFreeS                        = prependNFreeSSmallJson;
   2073   f->prependNFreeDict                     = prependNFreeDictSmallJson;
   2074   f->prependNFreeArray                    = prependNFreeArraySmallJson;
   2075   f->prependNFreeArrayc                   = prependNFreeArraycSmallJson;
   2076   f->prependNFreeSmallBool                = prependNFreeSmallBoolSmallJson;
   2077   f->prependNFreeSmallBytes               = prependNFreeSmallBytesSmallJson;
   2078   f->prependNFreeSmallDouble              = prependNFreeSmallDoubleSmallJson;
   2079   f->prependNFreeSmallInt                 = prependNFreeSmallIntSmallJson;
   2080   f->prependNFreeSmallJson                = prependNFreeSmallJsonSmallJson;
   2081   f->prependNFreeSmallString              = prependNFreeSmallStringSmallJson;
   2082   f->prependNFreeSmallContainer           = prependNFreeSmallContainerSmallJson;
   2083   f->dequeue                              = dequeueSmallJson;
   2084   f->dequeueUndefined                     = dequeueUndefinedSmallJson;
   2085   f->dequeueBool                          = dequeueBoolSmallJson;
   2086   f->dequeueDouble                        = dequeueDoubleSmallJson;
   2087   f->dequeueInt                           = dequeueIntSmallJson;
   2088   f->dequeueInt32                         = dequeueInt32SmallJson;
   2089   f->dequeueUint                          = dequeueUintSmallJson;
   2090   f->dequeueUint32                        = dequeueUint32SmallJson;
   2091   f->dequeueS                             = dequeueSSmallJson;
   2092   f->dequeueDict                          = dequeueDictSmallJson;
   2093   f->dequeueArray                         = dequeueArraySmallJson;
   2094   f->dequeueSmallBool                     = dequeueSmallBoolSmallJson;
   2095   f->dequeueSmallBytes                    = dequeueSmallBytesSmallJson;
   2096   f->dequeueSmallDouble                   = dequeueSmallDoubleSmallJson;
   2097   f->dequeueSmallInt                      = dequeueSmallIntSmallJson;
   2098   f->dequeueSmallJson                     = dequeueSmallJsonSmallJson;
   2099   f->dequeueSmallString                   = dequeueSmallStringSmallJson;
   2100   f->dequeueVoid                          = dequeueVoidSmallJson;
   2101   f->dequeueSmallContainer                = dequeueSmallContainerSmallJson;
   2102   f->dequeueNum                           = dequeueNumSmallJson;
   2103   f->reverse                              = reverseSmallJson;
   2104   f->cat                                  = catSmallJson;
   2105   f->mergeDict                            = mergeDictSmallJson;
   2106   f->mergeDictNSmash                      = mergeDictNSmashSmallJson;
   2107   f->merge                                = mergeSmallJson;
   2108   f->mergeNSmash                          = mergeNSmashSmallJson;
   2109   f->append                               = appendSmallJson;
   2110   f->appendNSmash                         = appendNSmashSmallJson;
   2111   // not used, included in mergeSmallJson
   2112   /* f->appendSmallJson                   = appendSmallJsonSmallJson */
   2113   /* f->appendSmallJsonNSmash             = appendSmallJsonNSmashSmallJson */
   2114   f->appendArray                          = appendArraySmallJson;
   2115   f->appendCArray                         = appendCArraySmallJson;
   2116   f->appendNSmashArray                    = appendNSmashArraySmallJson;
   2117   f->shift                                = shiftSmallJson; {
   2118   f->shiftNSmash                          = shiftNSmashSmallJson; {
   2119   f->shiftSmallJson                       = shiftSmallJsonSmallJson; {
   2120   f->shiftNSmashSmallJson                 = shiftNSmashSmallJsonSmallJson; {
   2121   f->add                                  = addSmallJson;
   2122   f->addJson                              = addJsonSmallJson;
   2123   f->slice                                = sliceSmallJson;
   2124   f->crop                                 = cropSmallJson;
   2125   f->cropS                                = cropSSmallJson;;
   2126   f->cropSmallString                      = cropSmallStringSmallJson;;
   2127   f->cropElemAt                           = cropElemAtSmallJson;
   2128   f->cropElemAtUndefined                  = cropElemAtUndefinedSmallJson;
   2129   f->cropElemAtBool                       = cropElemAtBoolSmallJson;
   2130   f->cropElemAtDouble                     = cropElemAtDoubleSmallJson;
   2131   f->cropElemAtInt                        = cropElemAtIntSmallJson;
   2132   f->cropElemAtInt32                      = cropElemAtInt32SmallJson;
   2133   f->cropElemAtUint                       = cropElemAtUintSmallJson;
   2134   f->cropElemAtUint32                     = cropElemAtUint32SmallJson;
   2135   f->cropElemAtS                          = cropElemAtSSmallJson;
   2136   f->cropElemAtChar                       = cropElemAtCharSmallJson;;
   2137   f->cropElemAtDict                       = cropElemAtDictSmallJson;
   2138   f->cropElemAtArray                      = cropElemAtArraySmallJson;
   2139   f->cropElemAtSmallBool                  = cropElemAtSmallBoolSmallJson;
   2140   f->cropElemAtSmallBytes                 = cropElemAtSmallBytesSmallJson;
   2141   f->cropElemAtSmallDouble                = cropElemAtSmallDoubleSmallJson;
   2142   f->cropElemAtSmallInt                   = cropElemAtSmallIntSmallJson;
   2143   f->cropElemAtSmallJson                  = cropElemAtSmallJsonSmallJson;
   2144   f->cropElemAtSmallString                = cropElemAtSmallStringSmallJson;
   2145   f->cropElemAtVoid                       = cropElemAtVoidSmallJson;
   2146   f->cropElemAtSmallContainer             = cropElemAtSmallContainerSmallJson;
   2147   f->cropElemKey                          = cropElemKeySmallJson;
   2148   f->cropElemKeyUndefined                 = cropElemKeyUndefinedSmallJson;
   2149   f->cropElemKeyBool                      = cropElemKeyBoolSmallJson;
   2150   f->cropElemKeyDouble                    = cropElemKeyDoubleSmallJson;
   2151   f->cropElemKeyInt                       = cropElemKeyIntSmallJson;
   2152   f->cropElemKeyInt32                     = cropElemKeyInt32SmallJson;
   2153   f->cropElemKeyUint                      = cropElemKeyUintSmallJson;
   2154   f->cropElemKeyUint32                    = cropElemKeyUint32SmallJson;
   2155   f->cropElemKeyS                         = cropElemKeySSmallJson;
   2156   f->cropElemKeyDict                      = cropElemKeyDictSmallJson;
   2157   f->cropElemKeyArray                     = cropElemKeyArraySmallJson;
   2158   f->cropElemKeySmallBool                 = cropElemKeySmallBoolSmallJson;
   2159   f->cropElemKeySmallBytes                = cropElemKeySmallBytesSmallJson;
   2160   f->cropElemKeySmallDouble               = cropElemKeySmallDoubleSmallJson;
   2161   f->cropElemKeySmallInt                  = cropElemKeySmallIntSmallJson;
   2162   f->cropElemKeySmallJson                 = cropElemKeySmallJsonSmallJson;
   2163   f->cropElemKeySmallString               = cropElemKeySmallStringSmallJson;
   2164   f->cropElemKeyVoid                      = cropElemKeyVoidSmallJson;
   2165   f->cropElemKeySmallContainer            = cropElemKeySmallContainerSmallJson;
   2166   f->copy                                 = copySmallJson;
   2167   f->insert                               = insertSmallJson;
   2168   f->insertNSmash                         = insertNSmashSmallJson;
   2169   f->insertSmallJson                      = insertSmallJsonSmallJson;
   2170   f->insertNSmashSmallJson                = insertNSmashSmallJsonSmallJson;
   2171   f->insertString                         = insertStringSmallJson;
   2172   f->insertS                              = insertSSmallJson;
   2173   f->insertNFreeString                    = insertNFreeStringSmallJson;
   2174   f->insertSNFree                         = insertSNFreeSmallJson;
   2175   f->inject                               = injectSmallJson;
   2176   f->injectUndefined                      = injectUndefinedSmallJson;
   2177   f->injectBool                           = injectBoolSmallJson;
   2178   f->injectDouble                         = injectDoubleSmallJson;
   2179   f->injectInt                            = injectIntSmallJson;
   2180   f->injectS                              = injectSSmallJson;
   2181   f->injectChar                           = injectCharSmallJson;
   2182   f->injectDict                           = injectDictSmallJson;
   2183   f->injectArray                          = injectArraySmallJson;
   2184   f->injectArrayc                         = injectArraycSmallJson;
   2185   f->injectCArrayc                        = injectCArraycSmallJson;
   2186   f->injectSmallBool                      = injectSmallBoolSmallJson;
   2187   f->injectSmallBytes                     = injectSmallBytesSmallJson;
   2188   f->injectSmallDouble                    = injectSmallDoubleSmallJson;
   2189   f->injectSmallInt                       = injectSmallIntSmallJson;
   2190   f->injectSmallJson                      = injectSmallJsonSmallJson;
   2191   f->injectSmallString                    = injectSmallStringSmallJson;
   2192   f->injectSmallContainer                 = injectSmallContainerSmallJson;
   2193   f->injectNFree                          = injectNFreeSmallJson;
   2194   f->injectNFreeUndefined                 = injectNFreeUndefinedSmallJson;
   2195   f->injectNFreeS                         = injectNFreeSSmallJson;
   2196   f->injectNFreeDict                      = injectNFreeDictSmallJson;
   2197   f->injectNFreeArray                     = injectNFreeArraySmallJson;
   2198   f->injectNFreeArrayc                    = injectNFreeArraycSmallJson;
   2199   f->injectNFreeSmallBool                 = injectNFreeSmallBoolSmallJson;
   2200   f->injectNFreeSmallBytes                = injectNFreeSmallBytesSmallJson;
   2201   f->injectNFreeSmallDouble               = injectNFreeSmallDoubleSmallJson;
   2202   f->injectNFreeSmallInt                  = injectNFreeSmallIntSmallJson;
   2203   f->injectNFreeSmallJson                 = injectNFreeSmallJsonSmallJson;
   2204   f->injectNFreeSmallString               = injectNFreeSmallStringSmallJson;
   2205   f->injectNFreeSmallContainer            = injectNFreeSmallContainerSmallJson;
   2206   f->uniq                                 = uniqSmallJson;
   2207   f->icUniq                               = icUniqSmallJson;
   2208   f->uniqChar                             = uniqCharSmallJson;
   2209   f->icUniqChar                           = icUniqCharSmallJson;
   2210   f->sort                                 = sortSmallJson;
   2211   f->sortF                                = sortFSmallJson;
   2212   f->icSort                               = icSortSmallJson;
   2213   f->has                                  = hasSmallJson;
   2214   f->hasUndefined                         = hasUndefinedSmallJson;
   2215   f->hasBool                              = hasBoolSmallJson;
   2216   f->hasDouble                            = hasDoubleSmallJson;
   2217   f->hasInt                               = hasIntSmallJson;
   2218   f->hasS                                 = hasSSmallJson;
   2219   f->hasChar                              = hasCharSmallJson;
   2220   f->hasDict                              = hasDictSmallJson;
   2221   f->hasArray                             = hasArraySmallJson;
   2222   f->hasArrayc                            = hasArraycSmallJson;
   2223   f->hasCArrayc                           = hasCArraycSmallJson;
   2224   f->hasSmallBool                         = hasSmallBoolSmallJson;
   2225   f->hasSmallBytes                        = hasSmallBytesSmallJson;
   2226   f->hasSmallDouble                       = hasSmallDoubleSmallJson;
   2227   f->hasSmallInt                          = hasSmallIntSmallJson;
   2228   f->hasSmallJson                         = hasSmallJsonSmallJson;
   2229   f->hasSmallString                       = hasSmallStringSmallJson;
   2230   f->hasSmallContainer                    = hasSmallContainerSmallJson;
   2231   f->find                                 = findSmallJson;
   2232   f->findChar                             = findCharSmallJson;
   2233   f->findSmallString                      = findSmallStringSmallJson;
   2234   f->findJson                             = findJsonSmallJson;
   2235   f->indexOf                              = indexOfSmallJson;
   2236   f->indexOfUndefined                     = indexOfUndefinedSmallJson;
   2237   f->indexOfBool                          = indexOfBoolSmallJson;
   2238   f->indexOfDouble                        = indexOfDoubleSmallJson;
   2239   f->indexOfInt                           = indexOfIntSmallJson;
   2240   f->indexOfS                             = indexOfSSmallJson;
   2241   f->indexOfChar                          = indexOfCharSmallJson;
   2242   f->indexOfDict                          = indexOfDictSmallJson;
   2243   f->indexOfArray                         = indexOfArraySmallJson;
   2244   f->indexOfArrayc                        = indexOfArraycSmallJson;
   2245   f->indexOfCArrayc                       = indexOfCArraycSmallJson;
   2246   f->indexOfSmallBool                     = indexOfSmallBoolSmallJson;
   2247   f->indexOfSmallBytes                    = indexOfSmallBytesSmallJson;
   2248   f->indexOfSmallDouble                   = indexOfSmallDoubleSmallJson;
   2249   f->indexOfSmallInt                      = indexOfSmallIntSmallJson;
   2250   f->indexOfSmallJson                     = indexOfSmallJsonSmallJson;
   2251   f->indexOfSmallString                   = indexOfSmallStringSmallJson;
   2252   f->indexOfSmallContainer                = indexOfSmallContainerSmallJson;
   2253   f->binarySearch                         = binarySearchSmallJson;
   2254   f->binarySearchUndefined                = binarySearchUndefinedSmallJson;
   2255   f->binarySearchBool                     = binarySearchBoolSmallJson;
   2256   f->binarySearchDouble                   = binarySearchDoubleSmallJson;
   2257   f->binarySearchInt                      = binarySearchIntSmallJson;
   2258   f->binarySearchS                        = binarySearchSSmallJson;
   2259   f->binarySearchChar                     = binarySearchCharSmallJson;
   2260   f->binarySearchDict                     = binarySearchDictSmallJson;
   2261   f->binarySearchArray                    = binarySearchArraySmallJson;
   2262   f->binarySearchArrayc                   = binarySearchArraycSmallJson;
   2263   f->binarySearchCArrayc                  = binarySearchCArraycSmallJson;
   2264   f->binarySearchSmallBool                = binarySearchSmallBoolSmallJson;
   2265   f->binarySearchSmallBytes               = binarySearchSmallBytesSmallJson;
   2266   f->binarySearchSmallDouble              = binarySearchSmallDoubleSmallJson;
   2267   f->binarySearchSmallInt                 = binarySearchSmallIntSmallJson;
   2268   f->binarySearchSmallJson                = binarySearchSmallJsonSmallJson;
   2269   f->binarySearchSmallString              = binarySearchSmallStringSmallJson;
   2270   f->binarySearchSmallContainer           = binarySearchSmallContainerSmallJson;
   2271   f->icHas                                = icHasSmallJson;
   2272   f->icHasS                               = icHasSSmallJson;
   2273   f->icHasChar                            = icHasCharSmallJson;
   2274   f->icHasDict                            = icHasDictSmallJson;
   2275   f->icHasArray                           = icHasArraySmallJson;
   2276   f->icHasArrayc                          = icHasArraycSmallJson;
   2277   f->icHasCArrayc                         = icHasCArraycSmallJson;
   2278   f->icHasSmallString                     = icHasSmallStringSmallJson;
   2279   f->icFind                               = icFindSmallJson;
   2280   f->icFindChar                           = icFindCharSmallJson;
   2281   f->icFindSmallString                    = icFindSmallStringSmallJson;
   2282   f->icFindJson                           = icFindJsonSmallJson;
   2283   f->icIndexOf                            = icIndexOfSmallJson;
   2284   f->icIndexOfS                           = icIndexOfSSmallJson;
   2285   f->icIndexOfChar                        = icIndexOfCharSmallJson;
   2286   f->icIndexOfDict                        = icIndexOfDictSmallJson;
   2287   f->icIndexOfArray                       = icIndexOfArraySmallJson;
   2288   f->icIndexOfArrayc                      = icIndexOfArraycSmallJson;
   2289   f->icIndexOfCArrayc                     = icIndexOfCArraycSmallJson;
   2290   f->icIndexOfSmallString                 = icIndexOfSmallStringSmallJson;
   2291   f->icBinarySearch                       = icBinarySearchSmallJson;
   2292   f->icBinarySearchS                      = icBinarySearchSSmallJson;
   2293   f->icBinarySearchChar                   = icBinarySearchCharSmallJson;
   2294   f->icBinarySearchDict                   = icBinarySearchDictSmallJson;
   2295   f->icBinarySearchArray                  = icBinarySearchArraySmallJson;
   2296   f->icBinarySearchArrayc                 = icBinarySearchArraycSmallJson;
   2297   f->icBinarySearchCArrayc                = icBinarySearchCArraycSmallJson;
   2298   f->icBinarySearchSmallString            = icBinarySearchSmallStringSmallJson;
   2299   f->keyBy                                = keyBySmallJson;
   2300   f->keyByUndefined                       = keyByUndefinedSmallJson;
   2301   f->keyByBool                            = keyByBoolSmallJson;
   2302   f->keyByDouble                          = keyByDoubleSmallJson;
   2303   f->keyByInt                             = keyByIntSmallJson;
   2304   f->keyByS                               = keyBySSmallJson;
   2305   f->keyByChar                            = keyByCharSmallJson;
   2306   f->keyByDict                            = keyByDictSmallJson;
   2307   f->keyByArray                           = keyByArraySmallJson;
   2308   f->keyByArrayc                          = keyByArraycSmallJson;
   2309   f->keyByCArrayc                         = keyByCArraycSmallJson;
   2310   f->keyBySmallBool                       = keyBySmallBoolSmallJson;
   2311   f->keyBySmallBytes                      = keyBySmallBytesSmallJson;
   2312   f->keyBySmallDouble                     = keyBySmallDoubleSmallJson;
   2313   f->keyBySmallInt                        = keyBySmallIntSmallJson;
   2314   f->keyBySmallJson                       = keyBySmallJsonSmallJson;
   2315   f->keyBySmallString                     = keyBySmallStringSmallJson;
   2316   f->keyBySmallContainer                  = keyBySmallContainerSmallJson;
   2317   f->icKeyBy                              = icKeyBySmallJson;
   2318   f->icKeyByS                             = icKeyBySSmallJson;
   2319   f->icKeyByChar                          = icKeyByCharSmallJson;
   2320   f->icKeyByDict                          = icKeyByDictSmallJson;
   2321   f->icKeyByArray                         = icKeyByArraySmallJson;
   2322   f->icKeyByArrayc                        = icKeyByArraycSmallJson;
   2323   f->icKeyByCArrayc                       = icKeyByCArraycSmallJson;
   2324   f->icKeyBySmallString                   = icKeyBySmallStringSmallJson;
   2325   f->replace                              = replaceSmallJson;
   2326   f->replaceCharS                         = replaceCharSSmallJson;
   2327   f->replaceSChar                         = replaceSCharSmallJson;
   2328   f->replaceCharChar                      = replaceCharCharSmallJson;
   2329   f->replaceSmallStringSmallString        = replaceSmallStringSmallStringSmallJson;
   2330   f->replaceSmallStringS                  = replaceSmallStringSSmallJson;
   2331   f->replaceSmallStringChar               = replaceSmallStringCharSmallJson;
   2332   f->replaceSSmallString                  = replaceSSmallStringSmallJson;
   2333   f->replaceCharSmallString               = replaceCharSmallStringSmallJson;
   2334   f->replaceJsonJson                      = replaceJsonJsonSmallJson;
   2335   f->replaceJsonSmallString               = replaceJsonSmallStringSmallJson;
   2336   f->replaceJsonS                         = replaceJsonSSmallJson;
   2337   f->replaceJsonChar                      = replaceJsonCharSmallJson;
   2338   f->replaceSmallStringJson               = replaceSmallStringJsonSmallJson;
   2339   f->replaceSJson                         = replaceSJsonSmallJson;
   2340   f->replaceCharJson                      = replaceCharJsonSmallJson;
   2341   f->replaceMany                          = replaceManySmallJson;
   2342   f->icReplace                            = icReplaceSmallJson;
   2343   f->icReplaceCharS                       = icReplaceCharSSmallJson;
   2344   f->icReplaceSChar                       = icReplaceSCharSmallJson;
   2345   f->icReplaceCharChar                    = icReplaceCharCharSmallJson;
   2346   f->icReplaceSmallStringSmallString      = icReplaceSmallStringSmallStringSmallJson;
   2347   f->icReplaceSmallStringS                = icReplaceSmallStringSSmallJson;
   2348   f->icReplaceSmallStringChar             = icReplaceSmallStringCharSmallJson;
   2349   f->icReplaceSSmallString                = icReplaceSSmallStringSmallJson;
   2350   f->icReplaceCharSmallString             = icReplaceCharSmallStringSmallJson;
   2351   f->icReplaceJsonJson                    = icReplaceJsonJsonSmallJson;
   2352   f->icReplaceJsonSmallString             = icReplaceJsonSmallStringSmallJson;
   2353   f->icReplaceJsonS                       = icReplaceJsonSSmallJson;
   2354   f->icReplaceJsonChar                    = icReplaceJsonCharSmallJson;
   2355   f->icReplaceSmallStringJson             = icReplaceSmallStringJsonSmallJson;
   2356   f->icReplaceSJson                       = icReplaceSJsonSmallJson;
   2357   f->icReplaceCharJson                    = icReplaceCharJsonSmallJson;
   2358   f->icReplaceMany                        = icReplaceManySmallJson;
   2359   f->equalSmallArray                      = equalSmallJsonSmallArray;
   2360   f->equalArray                           = equalSmallJsonArray;
   2361   f->equalCArray                          = equalSmallJsonCArray;
   2362   f->equalBase                            = equalSmallJsonBase;
   2363   f->equalCha                             = equalSmallJsonCha;
   2364   f->equalChar                            = equalSmallJsonChar;
   2365   f->equalBool                            = equalSmallJsonBool;
   2366   f->equalDouble                          = equalSmallJsonDouble;
   2367   f->equalInt64                           = equalSmallJsonInt64;
   2368   f->equalInt32                           = equalSmallJsonInt32;
   2369   f->equalUint32                          = equalSmallJsonUint32;
   2370   f->equalUint64                          = equalSmallJsonUint64;
   2371   f->equalSmallBool                       = equalSmallJsonSmallBool;
   2372   f->equalSmallBytes                      = equalSmallJsonSmallBytes;
   2373   f->equalSmallDouble                     = equalSmallJsonSmallDouble;
   2374   f->equalSmallInt                        = equalSmallJsonSmallInt;
   2375   f->equalSmallJson                       = equalSmallJsonSmallJson;
   2376   f->equalSmallString                     = equalSmallJsonSmallString;
   2377   f->equalSmallDict                       = equalSmallJsonSmallDict;;
   2378   f->icEqualSmallArray                    = icEqualSmallJsonSmallArray;
   2379   f->icEqualArray                         = icEqualSmallJsonArray;
   2380   f->icEqualCArray                        = icEqualSmallJsonCArray;
   2381   f->icEqualBase                          = icEqualSmallJsonBase;
   2382   f->icEqualSmallDict                     = icEqualSmallJsonSmallDict;;
   2383   f->icEqualSmallJson                     = icEqualSmallJsonSmallJson;
   2384   f->icEqualSmallString                   = icEqualSmallJsonSmallString;
   2385   f->icEqualS                             = icEqualSSmallJson;
   2386   f->icEqualChar                          = icEqualCharSmallJson;
   2387   f->equalIS                              = equalISSmallJson;
   2388   f->equalIChar                           = equalICharSmallJson;
   2389   f->equalIJson                           = equalIJsonSmallJson;
   2390   f->equalISmallString                    = equalISmallStringSmallJson;
   2391   f->startsWithS                          = startsWithSSmallJson;
   2392   f->startsWithChar                       = startsWithCharSmallJson;
   2393   f->startsWithSmallString                = startsWithSmallStringSmallJson;
   2394   f->startsWithJson                       = startsWithJsonSmallJson;
   2395   f->endsWithS                            = endsWithSSmallJson;
   2396   f->endsWithChar                         = endsWithCharSmallJson;
   2397   f->endsWithSmallString                  = endsWithSmallStringSmallJson;
   2398   f->endsWithJson                         = endsWithJsonSmallJson;
   2399   f->countS                               = countSSmallJson;
   2400   f->countChar                            = countCharSmallJson;
   2401   f->countSmallString                     = countSmallStringSmallJson;
   2402   f->countJson                            = countJsonSmallJson;
   2403   f->icStartsWithS                        = icStartsWithSSmallJson;
   2404   f->icStartsWithChar                     = icStartsWithCharSmallJson;
   2405   f->icStartsWithSmallString              = icStartsWithSmallStringSmallJson;
   2406   f->icStartsWithJson                     = icStartsWithJsonSmallJson;
   2407   f->icEndsWithS                          = icEndsWithSSmallJson;
   2408   f->icEndsWithChar                       = icEndsWithCharSmallJson;
   2409   f->icEndsWithSmallString                = icEndsWithSmallStringSmallJson;
   2410   f->icEndsWithJson                       = icEndsWithJsonSmallJson;
   2411   f->icCountS                             = icCountSSmallJson;
   2412   f->icCountChar                          = icCountCharSmallJson;
   2413   f->icCountSmallString                   = icCountSmallStringSmallJson;
   2414   f->icCountJson                          = icCountJsonSmallJson;
   2415   f->isNumber                             = isNumberSmallJson;
   2416   f->isInt                                = isIntSmallJson;
   2417   f->parseInt                             = parseIntSmallJson;
   2418   f->parseDouble                          = parseDoubleSmallJson;
   2419   f->intTo                                = intToSmallJson;
   2420   f->doubleTo                             = doubleToSmallJson;
   2421   f->len                                  = lenSmallJson;
   2422   f->upper                                = upperSmallJson;
   2423   f->lower                                = lowerSmallJson;
   2424   f->trim                                 = trimSmallJson;
   2425   f->lTrim                                = lTrimSmallJson;
   2426   f->rTrim                                = rTrimSmallJson;
   2427   f->keys                                 = keysSmallJson;
   2428   f->keysSmallString                      = keysSmallStringSmallJson;
   2429   f->values                               = valuesSmallJson;
   2430   f->compact                              = compactSmallJson;
   2431   f->empty                                = emptySmallJson;
   2432   f->isEmpty                              = isEmptySmallJson;
   2433   f->isBlank                              = isBlankSmallJson;
   2434   f->forEach                              = forEachSmallJsonF; {
   2435   // cg_c bug
   2436   f->enumerate                            = enumerateSmallJsonF; {
   2437   f->enumerateDict                        = enumerateDictSmallJson; {
   2438   f->join                                 = joinSmallJson;
   2439   f->joinChar                             = joinCharSmallJson;
   2440   f->joinSmallJson                        = joinSmallJsonSmallJson;
   2441   f->joinSmallString                      = joinSmallStringSmallJson;
   2442   f->joinS                                = joinSSmallJson;
   2443   f->joinCharS                            = joinCharSSmallJson;
   2444   f->joinSmallJsonS                       = joinSmallJsonSSmallJson;
   2445   f->joinSmallStringS                     = joinSmallStringSSmallJson;
   2446   f->split                                = splitSmallJson;
   2447   f->splitChar                            = splitCharSmallJson;
   2448   f->splitSmallJson                       = splitSmallJsonSmallJson;
   2449   f->splitSmallString                     = splitSmallStringSmallJson;
   2450   f->splitS                               = splitSSmallJson;
   2451   f->splitCharS                           = splitCharSSmallJson;
   2452   f->splitSmallJsonS                      = splitSmallJsonSSmallJson;
   2453   f->splitSmallStringS                    = splitSmallStringSSmallJson;
   2454   f->extract                              = extractSmallJson;
   2455   f->extractCharS                         = extractCharSSmallJson;
   2456   f->extractSChar                         = extractSCharSmallJson;
   2457   f->extractCharChar                      = extractCharCharSmallJson;
   2458   f->extractSmallJsonSmallJson            = extractSmallJsonSmallJsonSmallJson;
   2459   f->extractSmallJsonSmallString          = extractSmallJsonSmallStringSmallJson;
   2460   f->extractSmallJsonS                    = extractSmallJsonSSmallJson;
   2461   f->extractSmallJsonChar                 = extractSmallJsonCharSmallJson;
   2462   f->extractSmallStringSmallJson          = extractSmallStringSmallJsonSmallJson;
   2463   f->extractSmallStringSmallString        = extractSmallStringSmallStringSmallJson;
   2464   f->extractSmallStringS                  = extractSmallStringSSmallJson;
   2465   f->extractSmallStringChar               = extractSmallStringCharSmallJson;
   2466   f->extractSSmallJson                    = extractSSmallJsonSmallJson;
   2467   f->extractSSmallString                  = extractSSmallStringSmallJson;
   2468   f->extractCharSmallJson                 = extractCharSmallJsonSmallJson;
   2469   f->extractCharSmallString               = extractCharSmallStringSmallJson;
   2470   f->icSplit                              = icSplitSmallJson;
   2471   f->icSplitChar                          = icSplitCharSmallJson;
   2472   f->icSplitSmallJson                     = icSplitSmallJsonSmallJson;
   2473   f->icSplitSmallString                   = icSplitSmallStringSmallJson;
   2474   f->icSplitS                             = icSplitSSmallJson;
   2475   f->icSplitCharS                         = icSplitCharSSmallJson;
   2476   f->icSplitSmallJsonS                    = icSplitSmallJsonSSmallJson;
   2477   f->icSplitSmallStringS                  = icSplitSmallStringSSmallJson;
   2478   f->icExtract                            = icExtractSmallJson;
   2479   f->icExtractCharS                       = icExtractCharSSmallJson;
   2480   f->icExtractSChar                       = icExtractSCharSmallJson;
   2481   f->icExtractCharChar                    = icExtractCharCharSmallJson;
   2482   f->icExtractSmallJsonSmallJson          = icExtractSmallJsonSmallJsonSmallJson;
   2483   f->icExtractSmallJsonSmallString        = icExtractSmallJsonSmallStringSmallJson;
   2484   f->icExtractSmallJsonS                  = icExtractSmallJsonSSmallJson;
   2485   f->icExtractSmallJsonChar               = icExtractSmallJsonCharSmallJson;
   2486   f->icExtractSmallStringSmallJson        = icExtractSmallStringSmallJsonSmallJson;
   2487   f->icExtractSmallStringSmallString      = icExtractSmallStringSmallStringSmallJson;
   2488   f->icExtractSmallStringS                = icExtractSmallStringSSmallJson;
   2489   f->icExtractSmallStringChar             = icExtractSmallStringCharSmallJson;
   2490   f->icExtractSSmallJson                  = icExtractSSmallJsonSmallJson;
   2491   f->icExtractSSmallString                = icExtractSSmallStringSmallJson;
   2492   f->icExtractCharSmallJson               = icExtractCharSmallJsonSmallJson;
   2493   f->icExtractCharSmallString             = icExtractCharSmallStringSmallJson;
   2494   f->color                                = colorSmallJson;
   2495   f->colord                               = colordSmallJson;
   2496   f->zip                                  = zipSmallJson;
   2497   f->zipArray                             = zipArraySmallJson;
   2498   f->zipCArray                            = zipCArraySmallJson;
   2499   f->zipChar                              = zipCharSmallJson;
   2500   f->zipCChar                             = zipCCharSmallJson;
   2501   f->zipArrayChar                         = zipArrayCharSmallJson;
   2502   f->zipCArrayChar                        = zipCArrayCharSmallJson;
   2503   f->zipArrayCChar                        = zipArrayCCharSmallJson;
   2504   f->zipCArrayCChar                       = zipCArrayCCharSmallJson;
   2505   f->zipJson                              = zipJsonSmallJson;
   2506   f->zipJsonSmallArray                    = zipJsonSmallArraySmallJson;
   2507   f->zipJsonArray                         = zipJsonArraySmallJson;
   2508   f->zipJsonCArray                        = zipJsonCArraySmallJson;
   2509   f->zipSmallArrayJson                    = zipSmallArrayJsonSmallJson;
   2510   f->zipArrayJson                         = zipArrayJsonSmallJson;
   2511   f->zipCArrayJson                        = zipCArrayJsonSmallJson;
   2512   f->iterStart                            = iterStartSmallJson;
   2513   f->iterStartKey                         = iterStartKeySmallJson;
   2514   f->iterStartLast                        = iterStartLastSmallJson;
   2515   f->iterStartFrom                        = iterStartFromSmallJson;
   2516   f->iterStartFromStep                    = iterStartFromStepSmallJson;
   2517   f->iterNext                             = iterNextSmallJson;
   2518   f->iterNextKey                          = iterNextKeySmallJson;
   2519   f->iterElement                          = iterElementSmallJson;
   2520   f->iterKey                              = iterKeySmallJson;
   2521   f->iterIndex                            = iterIndexSmallJson;
   2522   f->iterStep                             = iterStepSmallJson;
   2523   f->stringify                            = stringifySmallJson; {
   2524   f->stringifySmallString                 = stringifySmallStringSmallJson; {
   2525   f->toYML                                = toYMLSmallJson;
   2526   f->toYMLSmallString                     = toYMLSmallStringSmallJson;
   2527   f->parse                                = parseSmallJson;
   2528   f->parseSmallJson                       = parseSmallJsonSmallJson;
   2529   f->parseSmallString                     = parseSmallStringSmallJson;
   2530   f->parseYML                             = parseYMLSmallJson;
   2531   f->parseYMLSmallJson                    = parseYMLSmallJsonSmallJson;
   2532   f->parseYMLSmallString                  = parseYMLSmallStringSmallJson;
   2533   f->serial                               = serialSmallJson;
   2534   f->deserial                             = deserialSmallJson;
   2535   f->log                                  = logSmallJson;
   2536   f->readFile                             = readFileSmallJson;
   2537   f->readFileSmallString                  = readFileSmallStringSmallJson;
   2538   f->readFileJson                         = readFileJsonSmallJson;
   2539   f->readStream                           = readStreamSmallJson;
   2540   f->writeFile                            = writeFileSmallJson;
   2541   f->writeFileSmallString                 = writeFileSmallStringSmallJson;
   2542   f->writeFileJson                        = writeFileJsonSmallJson;
   2543   f->writeStream                          = writeStreamSmallJson;
   2544   f->appendFile                           = appendFileSmallJson;
   2545   f->appendFileSmallString                = appendFileSmallStringSmallJson;
   2546   f->appendFileJson                       = appendFileJsonSmallJson;
   2547   f->readText                             = readTextSmallJson;
   2548   f->readTextSmallString                  = readTextSmallStringSmallJson;
   2549   f->readTextJson                         = readTextJsonSmallJson;
   2550   f->readTextStream                       = readTextStreamSmallJson;
   2551   f->writeText                            = writeTextSmallJson;
   2552   f->writeTextSmallString                 = writeTextSmallStringSmallJson;
   2553   f->writeTextJson                        = writeTextJsonSmallJson;
   2554   f->writeTextStream                      = writeTextStreamSmallJson;
   2555   f->appendText                           = appendTextSmallJson;
   2556   f->appendTextSmallString                = appendTextSmallStringSmallJson;
   2557   f->appendTextJson                       = appendTextJsonSmallJson;
   2558   f->typeString                           = typeStringSmallJson;
   2559   f->typeSmallString                      = typeSmallStringSmallJson;
   2560   f->typeAtString                         = typeAtStringSmallJson;
   2561   f->typeAtSmallString                    = typeAtSmallStringSmallJson;
   2562   f->typeStringKChar                      = typeStringKCharSmallJson;
   2563   f->typeSmallStringKChar                 = typeSmallStringKCharSmallJson;
   2564   f->type                                 = typeSmallJson;
   2565   f->typeKChar                            = typeKCharSmallJson;
   2566   f->typeAt                               = typeAtSmallJson;
   2567   f->typeStrings                          = typeStringsSmallJson;
   2568   f->types                                = typesSmallJson;
   2569   f->isETypeAt                            = isETypeAtSmallJson;
   2570   f->isEUndefinedAt                       = isEUndefinedAtSmallJson;
   2571   f->isEBoolAt                            = isEBoolAtSmallJson;
   2572   f->isEContainerAt                       = isEContainerAtSmallJson;
   2573   f->isEDictAt                            = isEDictAtSmallJson;
   2574   f->isEDoubleAt                          = isEDoubleAtSmallJson;
   2575   f->isEIntAt                             = isEIntAtSmallJson;
   2576   f->isEStringAt                          = isEStringAtSmallJson;
   2577   f->isEFaststringAt                      = isEFaststringAtSmallJson;
   2578   f->isEArrayAt                           = isEArrayAtSmallJson;
   2579   f->isEBytesAt                           = isEBytesAtSmallJson;
   2580   f->isEType                              = isETypeSmallJson;
   2581   f->isEUndefined                         = isEUndefinedSmallJson;
   2582   f->isEBool                              = isEBoolSmallJson;
   2583   f->isEContainer                         = isEContainerSmallJson;
   2584   f->isEDict                              = isEDictSmallJson;
   2585   f->isEDouble                            = isEDoubleSmallJson;
   2586   f->isEInt                               = isEIntSmallJson;
   2587   f->isEString                            = isEStringSmallJson;
   2588   f->isEFaststring                        = isEFaststringSmallJson;
   2589   f->isEArray                             = isEArraySmallJson;
   2590   f->isEBytes                             = isEBytesSmallJson;
   2591   f->areAllEType                          = areAllETypeSmallJson;
   2592   f->areAllEUndefined                     = areAllEUndefinedSmallJson;
   2593   f->areAllEBool                          = areAllEBoolSmallJson;
   2594   f->areAllEContainer                     = areAllEContainerSmallJson;
   2595   f->areAllEDict                          = areAllEDictSmallJson;
   2596   f->areAllEDouble                        = areAllEDoubleSmallJson;
   2597   f->areAllEInt                           = areAllEIntSmallJson;
   2598   f->areAllEString                        = areAllEStringSmallJson;
   2599   f->areAllEFaststring                    = areAllEFaststringSmallJson;
   2600   f->areAllEArray                         = areAllEArraySmallJson;
   2601   f->areAllEBytes                         = areAllEBytesSmallJson;
   2602 }
   2603   }
   2604   }
   2605   }
   2606   }
   2607   }
   2608   }
   2609   }
   2610   }
   2611   }
   2612 
   2613 void initiateAllocateSmallJson(smallJsont **self) {
   2614 
   2615   if (self) {
   2616     #if (recycleContainers)
   2617     initAllocateRecycle(smallJsont);
   2618     #else
   2619     isError(*self, malloc(sizeof(smallJsont)))
   2620       return;
   2621     #endif
   2622     if (*self) {
   2623       initiateSmallJson(*self);
   2624       if (!(*self)->f) {
   2625         finishSmallJson(self);
   2626 }
   2627   }
   2628     }
   2629       }
   2630 
   2631 smallJsont* createSJF(const char *paramType, ...) {
   2632   va_list pl;
   2633   smallJsont *r = NULL;
   2634 
   2635   isError(r, allocSmallJson()) return(NULL);
   2636 
   2637   // push arguments to a list
   2638   va_start(pl, paramType);
   2639   char *param = va_arg(pl, char *);
   2640   while (param) {
   2641     pushSSmallJson(r, param);
   2642     param = va_arg(pl, char *);
   2643   }
   2644   va_end(pl);
   2645   return(r);
   2646 }
   2647 
   2648 void finalizeRecycleSmallJson(void *arg UNUSED) {
   2649 
   2650   #if (recycleContainers)
   2651   finalizeRecycle
   2652   #endif
   2653   // recycleContainers
   2654 }
   2655 
   2656 void finalizeSmallJson(void) {
   2657 
   2658   if (smallJsonF) {
   2659     free(smallJsonF);
   2660     smallJsonF = NULL;
   2661   }
   2662   finalizeRecycleSmallJson(NULL);
   2663 }
   2664 
   2665 smallJsont* allocSmallJson(void) {
   2666   smallJsont *r = NULL;
   2667 
   2668   initiateAllocateSmallJson(&r);
   2669   if (!r) {
   2670     return(NULL);
   2671   }
   2672   return(r);
   2673 }
   2674 
   2675 void cleanUpSmallJsonTerminateG(smallJsont **val) {
   2676 
   2677   terminateO(*val);
   2678 }
   2679 
   2680 void cleanUpSmallJsonFreeLocalG(smallJsont *val) {
   2681 
   2682   freeO(val);
   2683 }
   2684 
   2685 void cleanUpSmallJsonFreeG(smallJsont **val) {
   2686 
   2687   freeO(*val);
   2688 }
   2689 
   2690 void cleanUpSmallJsonFinishG(smallJsont **val) {
   2691 
   2692   finishO(*val);
   2693 }
   2694 
   2695 void cleanUpSmallJsonDisposeG(smallJsont *val) {
   2696 
   2697   disposeO(val);
   2698 }
   2699 
   2700 void cleanUpSmallJsonSmashG(smallJsont **val) {
   2701 
   2702   smashO(*val);
   2703 }
   2704 
   2705 
   2706 internal void freeSmallJson(smallJsont *self) {
   2707 
   2708   self->topIsA = SMALLJSON_IS_EMPTY;
   2709 
   2710   sFree((smallt *)self->topU);
   2711   sFree((smallt *)self->topB);
   2712   sFree((smallt *)self->topD);
   2713   sFree((smallt *)self->topI);
   2714   sFree((smallt *)self->topS);
   2715   sFree((smallt *)self->top);
   2716   sFree((smallt *)self->topA);
   2717 
   2718   resetSmallJson(self);
   2719 }
   2720 
   2721 internal void terminateSmallJson(smallJsont **self) {
   2722 
   2723   freeSmallJson(*self);
   2724   finishSmallJson(self);
   2725 }
   2726 
   2727 
   2728 internal char* toStringSmallJson(smallJsont *self) {
   2729 
   2730   switch(self->topIsA) {
   2731     case SMALLJSON_IS_EMPTY:
   2732       return(strdup("{}"));
   2733     case TOP_IS_UNDEFINED:
   2734       return(sToString((smallt *)self->topU));
   2735     case TOP_IS_BOOL:
   2736       return(sToString((smallt *)self->topB));
   2737     case TOP_IS_DOUBLE:
   2738       return(sToString((smallt *)self->topD));
   2739     case TOP_IS_INT:
   2740       return(sToString((smallt *)self->topI));
   2741     case TOP_IS_STRING:
   2742       return(sToString((smallt *)self->topS));
   2743     case TOP_IS_DICT:
   2744       return(sToString((smallt *)self->top));
   2745     case TOP_IS_ARRAY:
   2746       return(sToString((smallt *)self->topA));
   2747     default:;
   2748       logC("Unsupported type in smallJson object!");
   2749   }
   2750   // return never taken, avoid warning
   2751   return(NULL);
   2752 }
   2753 
   2754 internal smallJsont* duplicateSmallJson(smallJsont *self) {
   2755 
   2756   createAllocateSmallJson(dup);
   2757   if (!dup) {
   2758     return(NULL);
   2759   }
   2760   dup->topIsA              = self->topIsA;
   2761   dup->iterElementDataType = self->iterElementDataType;
   2762   switch(self->topIsA) {
   2763     case TOP_IS_UNDEFINED:
   2764       isError(dup->topU, allocSUndefined()) {
   2765         terminateG(dup);
   2766         return(NULL);
   2767       }
   2768       break;
   2769     case TOP_IS_BOOL:
   2770       isError(dup->topB, (sBoolt *)sDuplicateTiny((smallt *)self->topB)) {
   2771         terminateG(dup);
   2772         return(NULL);
   2773       }
   2774       break;
   2775     case TOP_IS_DOUBLE:
   2776       isError(dup->topD, (sDoublet *)sDuplicateTiny((smallt *)self->topD)) {
   2777         terminateG(dup);
   2778         return(NULL);
   2779       }
   2780       break;
   2781     case TOP_IS_INT:
   2782       isError(dup->topI, (sIntt *)sDuplicateTiny((smallt *)self->topI)) {
   2783         terminateG(dup);
   2784         return(NULL);
   2785       }
   2786       break;
   2787     case TOP_IS_STRING:
   2788       isError(dup->topS, (sStringt *)sDuplicateTiny((smallt *)self->topS)) {
   2789         terminateG(dup);
   2790         return(NULL);
   2791       }
   2792       break;
   2793     case TOP_IS_DICT:
   2794       isError(dup->top , (sDictt *)sDuplicateTiny((smallt *)self->top)) {
   2795         terminateG(dup);
   2796         return(NULL);
   2797       }
   2798       dup->iterIndex = self->iterIndex;
   2799       if (dup->iterIndex != -1) {
   2800         dup->iterKey     = (&((dup->top)->elements) + dup->iterIndex)->key;
   2801       }
   2802       dup->iterStep  = self->iterStep;
   2803       if (dup->iterIndex != -1) {
   2804         dup->iterElement = toBaset((&((dup->top)->elements) + dup->iterIndex)->data);
   2805       }
   2806       break;
   2807     case TOP_IS_ARRAY:
   2808       isError(dup->topA     , (sArrayt *)sDuplicateTiny((smallt *)self->topA)) {
   2809         terminateG(dup);
   2810         return(NULL);
   2811       }
   2812       dup->iterIndex = self->iterIndex;
   2813       dup->iterKey   = NULL;
   2814       dup->iterStep  = self->iterStep;
   2815       if (dup->iterIndex != -1) {
   2816         dup->iterElement = toBaset(sArrayGetTiny(dup->topA, (uint32_t)dup->iterIndex));
   2817       }
   2818       break;
   2819     default:;
   2820       // self is empty, there is nothing to copy
   2821   }
   2822   return(dup);
   2823 }
   2824 
   2825 internal char* escapeSmallJson(smallJsont *self) {
   2826 
   2827   switch(self->topIsA) {
   2828     case SMALLJSON_IS_EMPTY:
   2829       return(strdup("{}"));
   2830     case TOP_IS_UNDEFINED:
   2831       return(sToString((smallt *)self->topU));
   2832     case TOP_IS_BOOL:
   2833       return(sToString((smallt *)self->topB));
   2834     case TOP_IS_DOUBLE:
   2835       return(sToString((smallt *)self->topD));
   2836     case TOP_IS_INT:
   2837       return(sToString((smallt *)self->topI));
   2838     case TOP_IS_STRING:
   2839       return(sEscape((smallt *)self->topS));
   2840     case TOP_IS_DICT:
   2841       return(sEscape((smallt *)self->top));
   2842     case TOP_IS_ARRAY:
   2843       return(sEscape((smallt *)self->topA));
   2844     default:;
   2845       logC("Unsupported type in smallJson object!");
   2846   }
   2847   // return never taken, avoid warning
   2848   return(NULL);
   2849 }
   2850 
   2851 internal void disposeSmallJson(smallJsont *self) {
   2852 
   2853   switch(self->topIsA) {
   2854     case TOP_IS_UNDEFINED:
   2855       sFree((smallt *)self->topU);
   2856       break;
   2857     case TOP_IS_BOOL:
   2858       sFree((smallt *)self->topB);
   2859       break;
   2860     case TOP_IS_DOUBLE:
   2861       sFree((smallt *)self->topD);
   2862       break;
   2863     case TOP_IS_INT:
   2864       sFree((smallt *)self->topI);
   2865       break;
   2866     case TOP_IS_STRING:
   2867       sFree((smallt *)self->topS);
   2868       break;
   2869     case TOP_IS_DICT:
   2870       if (self->top) {
   2871         forEachSDict(self->top, e) {
   2872           if (e->key) {
   2873             free(e->key);
   2874             // free containers of baset object to avoid leaks
   2875             // e->data is valid only when e->key is not null
   2876             if (e->data && e->data->type == CONTAINER && (((sContainert*)e->data)->dataType == SH_DT_BASET)) {
   2877               free(e->data);
   2878         }
   2879           }
   2880             }
   2881         free(self->top);
   2882         self->top = NULL;
   2883       }
   2884       break;
   2885     case TOP_IS_ARRAY:
   2886       if (self->topA) {
   2887         // free containers of baset object to avoid leaks
   2888         forEachSArray(self->topA, o) {
   2889           if (o && o->type == CONTAINER && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   2890             free(o);
   2891         }
   2892           }
   2893         free(self->topA);
   2894         self->topA = NULL;
   2895       }
   2896       break;
   2897     default:;
   2898       // self is empty, there is nothing to free
   2899   }
   2900 
   2901   resetSmallJson(self);
   2902 }
   2903 
   2904 
   2905 internal void smashSmallJson(smallJsont **self) {
   2906 
   2907   (*self)->f->dispose(*self);
   2908   finishSmallJson(self);
   2909 }
   2910 
   2911 #if (NFreeStackCheck)
   2912 internal void finishSmallJson(smallJsont **self) {
   2913 
   2914   resetSmallJson(*self);
   2915 
   2916   register u64 rsp asm("rsp");
   2917   if ((u64)*self > rsp) {
   2918     logW("Probably trying to free a smallJson on stack: "BLD PRIx64 RST" sp: "BLD PRIx64 RST, *self, rsp);
   2919     logBtrace;
   2920   }
   2921   else {
   2922     #if (recycleContainers)
   2923     finishRecycle
   2924     #else
   2925     free(*self);
   2926     #endif
   2927     // recycleContainers
   2928     *self = NULL;
   2929 }
   2930   }
   2931 
   2932 #else
   2933 // #if NFreeStackCheck
   2934 internal void finishSmallJson(smallJsont **self) {
   2935 
   2936   resetSmallJson(*self);
   2937 
   2938   #if (recycleContainers)
   2939   finishRecycle
   2940   #else
   2941   free(*self);
   2942   #endif
   2943   // recycleContainers
   2944   *self = NULL;
   2945 }
   2946 
   2947 #endif
   2948 // #if NFreeStackCheck
   2949 
   2950 internal const char* helpSmallJson(smallJsont UNUSED *self) {
   2951 
   2952   return(helpTextSmallJson);
   2953 }
   2954 
   2955 internal void resetSmallJson(smallJsont *self) {
   2956 
   2957   if (self->iterIndex != -1) {
   2958     if (self->iterElementDataType != SH_DT_BASET) {
   2959       finishO(self->iterElement);
   2960     }
   2961     self->iterElement = NULL;
   2962     self->iterIndex   = -1;
   2963   }
   2964   self->topU   = NULL;
   2965   self->topB   = NULL;
   2966   self->topD   = NULL;
   2967   self->topI   = NULL;
   2968   self->topS   = NULL;
   2969   self->top    = NULL;
   2970   self->topA   = NULL;
   2971   self->topIsA = SMALLJSON_IS_EMPTY;
   2972 }
   2973 
   2974 internal smallt* getsoSmallJson(smallJsont *self) {
   2975 
   2976   switch(self->topIsA) {
   2977     case TOP_IS_UNDEFINED:
   2978       return((smallt*)self->topU);
   2979     case TOP_IS_BOOL:
   2980       return((smallt*)self->topB);
   2981     case TOP_IS_DOUBLE:
   2982       return((smallt*)self->topD);
   2983     case TOP_IS_INT:
   2984       return((smallt*)self->topI);
   2985     case TOP_IS_STRING:
   2986       return((smallt*)self->topS);
   2987     case TOP_IS_DICT:
   2988       return((smallt*)self->top);
   2989     case TOP_IS_ARRAY:
   2990       return((smallt*)self->topA);
   2991     default:;
   2992       // self is empty, there is nothing to get
   2993   }
   2994   return(NULL);
   2995 }
   2996 
   2997 internal void setsoSmallJson(smallJsont *self, smallt *so) {
   2998 
   2999   if (so) {
   3000     resetSmallJson(self);
   3001     switch (getSType(so)) {
   3002       case UNDEFINED:
   3003         self->topIsA = TOP_IS_UNDEFINED;
   3004         self->topU = (sUndefinedt *)so;
   3005         break;
   3006       case BOOL:
   3007         self->topIsA = TOP_IS_BOOL;
   3008         self->topB = (sBoolt *)so;
   3009         break;
   3010       case DOUBLE:
   3011         self->topIsA = TOP_IS_DOUBLE;
   3012         self->topD = (sDoublet *)so;
   3013         break;
   3014       case INT:
   3015         self->topIsA = TOP_IS_INT;
   3016         self->topI = (sIntt *)so;
   3017         break;
   3018       case STRING:
   3019         self->topIsA = TOP_IS_STRING;
   3020         self->topS = (sStringt *)so;
   3021         break;
   3022       case DICT:
   3023         self->topIsA = TOP_IS_DICT;
   3024         self->top    = (sDictt*) so;
   3025         break;
   3026       case ARRAY:
   3027         self->topIsA = TOP_IS_ARRAY;
   3028         self->topA   = (sArrayt*) so;
   3029         break;
   3030       default:
   3031         sFree(so);
   3032     }
   3033 }
   3034   }
   3035 
   3036 internal smallJsont* mirrorSmallJson(smallJsont *self) {
   3037   smallJsont *mirror = NULL;
   3038 
   3039   switch(self->topIsA) {
   3040     case TOP_IS_DICT:
   3041       initiateAllocateSmallJson(&mirror);
   3042       if (!mirror) {
   3043         return(NULL);
   3044       }
   3045       mirror->topIsA = self->topIsA;
   3046       mirror->top    = self->top;
   3047       if (self->top) {
   3048         mirror->iterElementDataType = self->iterElementDataType;
   3049         mirror->iterIndex           = self->iterIndex;
   3050         if (mirror->iterIndex != -1) {
   3051           mirror->iterKey     = (&((mirror->top)->elements) + mirror->iterIndex)->key;
   3052         }
   3053         mirror->iterStep  = self->iterStep;
   3054         if (mirror->iterIndex != -1) {
   3055           mirror->iterElement = toBaset((&((mirror->top)->elements) + mirror->iterIndex)->data);
   3056       }
   3057         }
   3058       break;
   3059     case TOP_IS_ARRAY:
   3060       initiateAllocateSmallJson(&mirror);
   3061       if (!mirror) {
   3062         return(NULL);
   3063       }
   3064       mirror->topIsA    = self->topIsA;
   3065       mirror->topA      = self->topA;
   3066       if (self->topA) {
   3067         mirror->iterElementDataType = self->iterElementDataType;
   3068         mirror->iterIndex           = self->iterIndex;
   3069         mirror->iterKey             = NULL;
   3070         mirror->iterStep            = self->iterStep;
   3071         if (mirror->iterIndex != -1) {
   3072           mirror->iterElement = toBaset(sArrayGetTiny(mirror->topA, (uint32_t)mirror->iterIndex));
   3073       }
   3074         }
   3075       break;
   3076     default:;
   3077       // there is no need to mirror other types
   3078   }
   3079   return(mirror);
   3080 }
   3081 
   3082 
   3083 internal const char* getTopTypeSmallJson(smallJsont *self) {
   3084 
   3085   switch(self->topIsA) {
   3086     case TOP_IS_UNDEFINED:
   3087       return(getSTypeS(self->topU));
   3088     case TOP_IS_BOOL:
   3089       return(getSTypeS(self->topB));
   3090     case TOP_IS_DOUBLE:
   3091       return(getSTypeS(self->topD));
   3092     case TOP_IS_INT:
   3093       return(getSTypeS(self->topI));
   3094     case TOP_IS_STRING:
   3095       return(getSTypeS(self->topS));
   3096     case TOP_IS_DICT:
   3097       return(getSTypeS(self->top));
   3098     case TOP_IS_ARRAY:
   3099       return(getSTypeS(self->topA));
   3100     default:;
   3101       // self is empty, there is nothing to get
   3102   }
   3103   return(NULL);
   3104 }
   3105 
   3106 internal smallJsont* setTypeUndefinedSmallJson(smallJsont *self) {
   3107 
   3108   freeSmallJson(self);
   3109   isError(self->topU  , allocSUndefined()) return(NULL);
   3110   self->topIsA = TOP_IS_UNDEFINED;
   3111   return(self);
   3112 }
   3113 
   3114 internal smallJsont* setTypeBoolSmallJson(smallJsont *self) {
   3115 
   3116   freeSmallJson(self);
   3117   isError(self->topB  , allocSBool(false)) return(NULL);
   3118   self->topIsA = TOP_IS_BOOL;
   3119   return(self);
   3120 }
   3121 
   3122 internal smallJsont* setTypeDoubleSmallJson(smallJsont *self) {
   3123 
   3124   freeSmallJson(self);
   3125   isError(self->topD  , allocSDouble(0)) return(NULL);
   3126   self->topIsA = TOP_IS_DOUBLE;
   3127   return(self);
   3128 }
   3129 
   3130 internal smallJsont* setTypeIntSmallJson(smallJsont *self) {
   3131 
   3132   freeSmallJson(self);
   3133   isError(self->topI  , allocSInt(0)) return(NULL);
   3134   self->topIsA = TOP_IS_INT;
   3135   return(self);
   3136 }
   3137 
   3138 internal smallJsont* setTypeStringSmallJson(smallJsont *self) {
   3139 
   3140   freeSmallJson(self);
   3141   isError(self->topS  , allocSStringTiny("")) return(NULL);
   3142   self->topIsA = TOP_IS_STRING;
   3143   return(self);
   3144 }
   3145 
   3146 internal smallJsont* setTypeDictSmallJson(smallJsont *self) {
   3147 
   3148   freeSmallJson(self);
   3149   isError(self->top   , allocSDict()) return(NULL);
   3150   self->topIsA = TOP_IS_DICT;
   3151   return(self);
   3152 }
   3153 
   3154 internal smallJsont* setTypeArraySmallJson(smallJsont *self) {
   3155 
   3156   freeSmallJson(self);
   3157   isError(self->topA  , allocSArray()) return(NULL);
   3158   self->topIsA = TOP_IS_ARRAY;
   3159   return(self);
   3160 }
   3161 
   3162 internal smallJsont* setTopSmallJson(smallJsont *self, baset *value) {
   3163 
   3164   if (!value) {
   3165     return(NULL);
   3166   }
   3167 
   3168   // reset iterator
   3169   if (self->iterIndex != -1) {
   3170     if (self->iterElementDataType != SH_DT_BASET) {
   3171       finishO(self->iterElement);
   3172     }
   3173     self->iterElement = NULL;
   3174     self->iterIndex   = -1;
   3175   }
   3176   self->iterKey     = NULL;
   3177   self->iterStep    = 0;
   3178 
   3179   if (isOType(value, "undefined") && (self->topIsA == SMALLJSON_IS_EMPTY || self->topIsA == TOP_IS_UNDEFINED)) {
   3180     self->topIsA = TOP_IS_UNDEFINED;
   3181     sFree((smallt *)self->topU);
   3182     self->topU = (sUndefinedt *)toSmallt(value);
   3183     return(self);
   3184   }
   3185   if (isOType(value, "smallBool") && (self->topIsA == SMALLJSON_IS_EMPTY || self->topIsA == TOP_IS_BOOL)) {
   3186     self->topIsA = TOP_IS_BOOL;
   3187     sFree((smallt *)self->topB);
   3188     self->topB = (sBoolt *)toSmallt(value);
   3189     return(self);
   3190   }
   3191   if (isOType(value, "smallDouble") && (self->topIsA == SMALLJSON_IS_EMPTY || self->topIsA == TOP_IS_DOUBLE)) {
   3192     self->topIsA = TOP_IS_DOUBLE;
   3193     sFree((smallt *)self->topD);
   3194     self->topD = (sDoublet *)toSmallt(value);
   3195     return(self);
   3196   }
   3197   if (isOType(value, "smallInt") && (self->topIsA == SMALLJSON_IS_EMPTY || self->topIsA == TOP_IS_INT)) {
   3198     self->topIsA = TOP_IS_INT;
   3199     sFree((smallt *)self->topI);
   3200     self->topI = (sIntt *)toSmallt(value);
   3201     return(self);
   3202   }
   3203   if (isOType(value, "smallString") && (self->topIsA == SMALLJSON_IS_EMPTY || self->topIsA == TOP_IS_STRING)) {
   3204     self->topIsA = TOP_IS_STRING;
   3205     sFree((smallt *)self->topS);
   3206     self->topS = (sStringt *)toSmallt(value);
   3207     return(self);
   3208   }
   3209   if (isOType(value, "smallDict") && (self->topIsA == SMALLJSON_IS_EMPTY || self->topIsA == TOP_IS_DICT)) {
   3210     self->topIsA = TOP_IS_DICT;
   3211     sFree((smallt *)self->top);
   3212     self->top = (sDictt *)toSmallt(value);
   3213     return(self);
   3214   }
   3215   if (isOType(value, "smallArray") && (self->topIsA == SMALLJSON_IS_EMPTY || self->topIsA == TOP_IS_ARRAY)) {
   3216     self->topIsA = TOP_IS_ARRAY;
   3217     sFree((smallt *)self->topA);
   3218     self->topA = (sArrayt *)toSmallt(value);
   3219     return(self);
   3220   }
   3221   if (isOType(value, "smallJson")) {
   3222     cast(smallJsont*, v, value);
   3223     switch(v->topIsA) {
   3224       case TOP_IS_UNDEFINED:
   3225         self->topIsA = v->topIsA;
   3226         sFree((smallt *)self->topU);
   3227         self->topU = v->topU;
   3228         break;
   3229       case TOP_IS_BOOL:
   3230         self->topIsA = v->topIsA;
   3231         sFree((smallt *)self->topB);
   3232         self->topB = v->topB;
   3233         break;
   3234       case TOP_IS_DOUBLE:
   3235         self->topIsA = v->topIsA;
   3236         sFree((smallt *)self->topD);
   3237         self->topD = v->topD;
   3238         break;
   3239       case TOP_IS_INT:
   3240         self->topIsA = v->topIsA;
   3241         sFree((smallt *)self->topI);
   3242         self->topI = v->topI;
   3243         break;
   3244       case TOP_IS_STRING:
   3245         self->topIsA = v->topIsA;
   3246         sFree((smallt *)self->topS);
   3247         self->topS = v->topS;
   3248         break;
   3249       case TOP_IS_DICT:
   3250         self->topIsA = v->topIsA;
   3251         sFree((smallt *)self->top);
   3252         self->top = v->top;
   3253         break;
   3254       case TOP_IS_ARRAY:
   3255         self->topIsA = v->topIsA;
   3256         sFree((smallt *)self->topA);
   3257         self->topA = v->topA;
   3258         break;
   3259       default:;
   3260         // value is empty, there is nothing to set
   3261     }
   3262     return(self);
   3263   }
   3264   return(NULL);
   3265 }
   3266 
   3267 internal smallJsont* setTopBoolSmallJson(smallJsont *self, bool value) {
   3268 
   3269   smallBoolt *v = allocSmallBool(value);
   3270   if (!v) {
   3271     return(NULL);
   3272   }
   3273   smallJsont *r = setTopNFreeSmallJson(self, (baset*) v);;
   3274   if (!r) {
   3275     terminateO(v);
   3276   }
   3277   return(self);
   3278 }
   3279 
   3280 internal smallJsont* setTopDoubleSmallJson(smallJsont *self, double value) {
   3281 
   3282   smallDoublet *v = allocSmallDouble(value);;
   3283   if (!v) {
   3284     return(NULL);
   3285   }
   3286   smallJsont *r   = setTopNFreeSmallJson(self, (baset*) v);;
   3287   if (!r) {
   3288     terminateO(v);
   3289   }
   3290   return(self);
   3291 }
   3292 
   3293 internal smallJsont* setTopIntSmallJson(smallJsont *self, int64_t value) {
   3294 
   3295   smallIntt *v  = allocSmallInt(value);;
   3296   if (!v) {
   3297     return(NULL);
   3298   }
   3299   smallJsont *r = setTopNFreeSmallJson(self, (baset*) v);;
   3300   if (!r) {
   3301     terminateO(v);
   3302   }
   3303   return(self);
   3304 }
   3305 
   3306 internal smallJsont* setTopStringSmallJson(smallJsont *self, const char *value) {
   3307 
   3308   if (!value) {
   3309     return(NULL);
   3310   }
   3311   smallStringt *v = allocSmallString(value);;
   3312   if (!v) {
   3313     return(NULL);
   3314   }
   3315   smallJsont *r   = setTopNFreeSmallJson(self, (baset*) v);;
   3316   if (!r) {
   3317     terminateO(v);
   3318   }
   3319   return(self);
   3320 }
   3321 
   3322 internal smallJsont* setTopCharSmallJson(smallJsont *self, char c) {
   3323 
   3324   charToS(s, c);
   3325   return(setTopStringSmallJson(self, s));
   3326 }
   3327 
   3328 internal smallJsont* setTopDictSmallJson(smallJsont *self, smallDictt *value) {
   3329 
   3330   if (checkObjectTypes && value && !isOSmallDict(value)) {
   3331     return(NULL);
   3332   }
   3333 
   3334   smallJsont *r = setTopSmallJson(self, (baset*) value);;
   3335   return(r);
   3336 }
   3337 
   3338 internal smallJsont* setTopArraySmallJson(smallJsont *self, smallArrayt *value) {
   3339 
   3340   if (checkObjectTypes && value && !isOSmallArray(value)) {
   3341     return(NULL);
   3342   }
   3343 
   3344   smallJsont *r = setTopSmallJson(self, (baset*) value);;
   3345   return(r);
   3346 }
   3347 
   3348 internal smallJsont* setTopArraycSmallJson(smallJsont *self, char **value) {
   3349 
   3350   if (!value) {
   3351     return(NULL);
   3352   }
   3353 
   3354   smallArrayt *a = allocArraySmallArray(value);
   3355   if (!a) {
   3356     return(NULL);
   3357   }
   3358   smallJsont *r  =  setTopNFreeArraySmallJson(self, a);
   3359   if (!r) {
   3360     terminateO(a);
   3361   }
   3362   return(r);
   3363 }
   3364 
   3365 internal smallJsont* setTopCArraycSmallJson(smallJsont *self, const char **value) {
   3366 
   3367   if (!value) {
   3368     return(NULL);
   3369   }
   3370 
   3371   smallArrayt *a = allocCArraySmallArray(value);
   3372   if (!a) {
   3373     return(NULL);
   3374   }
   3375   smallJsont *r  =  setTopNFreeArraySmallJson(self, a);
   3376   if (!r) {
   3377     terminateO(a);
   3378   }
   3379   return(r);
   3380 }
   3381 
   3382 internal smallJsont* setTopSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
   3383 
   3384   if (checkObjectTypes && value && !isOSmallBool(value)) {
   3385     return(NULL);
   3386   }
   3387 
   3388   smallJsont *r = setTopSmallJson(self, (baset*) value);;
   3389   return(r);
   3390 }
   3391 
   3392 internal smallJsont* setTopSmallDoubleSmallJson(smallJsont *self, smallDoublet *value) {
   3393 
   3394   if (checkObjectTypes && value && !isOSmallDouble(value)) {
   3395     return(NULL);
   3396   }
   3397 
   3398   smallJsont *r = setTopSmallJson(self, (baset*) value);;
   3399   return(r);
   3400 }
   3401 
   3402 internal smallJsont* setTopSmallIntSmallJson(smallJsont *self, smallIntt *value) {
   3403 
   3404   if (checkObjectTypes && value && !isOSmallInt(value)) {
   3405     return(NULL);
   3406   }
   3407 
   3408   smallJsont *r =setTopSmallJson(self, (baset*) value);;
   3409   return(r);
   3410 }
   3411 
   3412 internal smallJsont* setTopSmallJsonSmallJson(smallJsont *self, smallJsont *value) {
   3413 
   3414   if (checkObjectTypes && value && !isOSmallJson(value)) {
   3415     return(NULL);
   3416   }
   3417 
   3418   smallJsont *r =setTopSmallJson(self, (baset*) value);;
   3419   return(r);
   3420 }
   3421 
   3422 internal smallJsont* setTopSmallStringSmallJson(smallJsont *self, smallStringt *value) {
   3423 
   3424   if (checkObjectTypes && value && !isOSmallString(value)) {
   3425     return(NULL);
   3426   }
   3427 
   3428   smallJsont *r =setTopSmallJson(self, (baset*) value);;
   3429   return(r);
   3430 }
   3431 
   3432 internal smallJsont* setTopNFreeSmallJson(smallJsont *self, baset *value) {
   3433 
   3434   smallJsont *r = setTopSmallJson(self, value);;
   3435   if (r) {
   3436     finishO(value);
   3437   }
   3438   return(r);
   3439 }
   3440 
   3441 internal smallJsont* setTopNFreeBoolSmallJson(smallJsont *self, bool value) {
   3442 
   3443   smallBoolt *v = allocSmallBool(value);
   3444   if (!v) {
   3445     return(NULL);
   3446   }
   3447   smallJsont *r = setTopNFreeSmallJson(self, (baset*) v);;
   3448   if (!r) {
   3449     terminateO(v);
   3450   }
   3451   return(r);
   3452 }
   3453 
   3454 internal smallJsont* setTopNFreeDoubleSmallJson(smallJsont *self, double value) {
   3455 
   3456   smallDoublet *v = allocSmallDouble(value);;
   3457   if (!v) {
   3458     return(NULL);
   3459   }
   3460   smallJsont *r   = setTopNFreeSmallJson(self, (baset*) v);;
   3461   if (!r) {
   3462     terminateO(v);
   3463   }
   3464   return(r);
   3465 }
   3466 
   3467 internal smallJsont* setTopNFreeIntSmallJson(smallJsont *self, int64_t value) {
   3468 
   3469   smallIntt *v  = allocSmallInt(value);;
   3470   if (!v) {
   3471     return(NULL);
   3472   }
   3473   smallJsont *r = setTopNFreeSmallJson(self, (baset*) v);;
   3474   if (!r) {
   3475     terminateO(v);
   3476   }
   3477   return(r);
   3478 }
   3479 
   3480 internal smallJsont* setTopNFreeStringSmallJson(smallJsont *self, char *value) {
   3481 
   3482   if (!value) {
   3483     return(NULL);
   3484   }
   3485   smallStringt *v = allocSmallString(value);;
   3486   if (!v) {
   3487     return(NULL);
   3488   }
   3489   smallJsont *r   = setTopNFreeSmallJson(self, (baset*) v);;
   3490   if (r) {
   3491     free(value);
   3492   }
   3493   else {
   3494     terminateO(v);
   3495   }
   3496   return(r);
   3497 }
   3498 
   3499 internal smallJsont* setTopNFreeDictSmallJson(smallJsont *self, smallDictt *value) {
   3500 
   3501   if (checkObjectTypes && value && !isOSmallDict(value)) {
   3502     return(NULL);
   3503   }
   3504 
   3505   return(setTopNFreeSmallJson(self, (baset*) value));
   3506 }
   3507 
   3508 internal smallJsont* setTopNFreeArraySmallJson(smallJsont *self, smallArrayt *value) {
   3509 
   3510   if (checkObjectTypes && value && !isOSmallArray(value)) {
   3511     return(NULL);
   3512   }
   3513 
   3514   return(setTopNFreeSmallJson(self, (baset*) value));
   3515 }
   3516 
   3517 internal smallJsont* setTopNFreeArraycSmallJson(smallJsont *self, char **value) {
   3518 
   3519   if (!value) {
   3520     return(NULL);
   3521   }
   3522 
   3523   smallArrayt *a = allocArraySmallArray(value);
   3524   if (!a) {
   3525     return(NULL);
   3526   }
   3527   smallJsont *r  = setTopNFreeArraySmallJson(self, a);
   3528   if (r) {
   3529     listFreeS(value);
   3530   }
   3531   else {
   3532     terminateO(a);
   3533   }
   3534   return(r);
   3535 }
   3536 
   3537 internal smallJsont* setTopNFreeSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
   3538 
   3539   if (checkObjectTypes && value && !isOSmallBool(value)) {
   3540     return(NULL);
   3541   }
   3542 
   3543   return(setTopNFreeSmallJson(self, (baset*) value));
   3544 }
   3545 
   3546 internal smallJsont* setTopNFreeSmallDoubleSmallJson(smallJsont *self, smallDoublet *value) {
   3547 
   3548   if (checkObjectTypes && value && !isOSmallDouble(value)) {
   3549     return(NULL);
   3550   }
   3551 
   3552   return(setTopNFreeSmallJson(self, (baset*) value));
   3553 }
   3554 
   3555 internal smallJsont* setTopNFreeSmallIntSmallJson(smallJsont *self, smallIntt *value) {
   3556 
   3557   if (checkObjectTypes && value && !isOSmallInt(value)) {
   3558     return(NULL);
   3559   }
   3560 
   3561   return(setTopNFreeSmallJson(self, (baset*) value));
   3562 }
   3563 
   3564 internal smallJsont* setTopNFreeSmallJsonSmallJson(smallJsont *self, smallJsont *value) {
   3565 
   3566   if (checkObjectTypes && value && !isOSmallJson(value)) {
   3567     return(NULL);
   3568   }
   3569 
   3570   return(setTopNFreeSmallJson(self, (baset*) value));
   3571 }
   3572 
   3573 internal smallJsont* setTopNFreeSmallStringSmallJson(smallJsont *self, smallStringt *value) {
   3574 
   3575   if (checkObjectTypes && value && !isOSmallString(value)) {
   3576     return(NULL);
   3577   }
   3578 
   3579   return(setTopNFreeSmallJson(self, (baset*) value));
   3580 }
   3581 
   3582 // size 0 means NULL terminated array
   3583 internal smallJsont* fromArraySmallJson(smallJsont *self, char **array, size_t size) {
   3584 
   3585   // sanity checks
   3586   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   3587     return(NULL);
   3588   }
   3589 
   3590   if (!array) {
   3591     return(NULL);
   3592   }
   3593 
   3594   if (self->topIsA != SMALLJSON_IS_EMPTY) {
   3595     freeSmallJson(self);
   3596   }
   3597   self->topIsA = TOP_IS_ARRAY;
   3598 
   3599   if (!size) {
   3600     forEachCharP(array, e) {
   3601       sStringt *s = allocSStringTiny(*e);
   3602       if (!s) {
   3603         return(NULL);
   3604       }
   3605       sArrayPushTiny(&(self->topA), (smallt *) s);
   3606     }
   3607     return(self);
   3608   }
   3609 
   3610   // copy array content
   3611   for (size_t i = 0 ; i < size ; i++) {
   3612     if (array[i]) {
   3613       // remove NULL strings
   3614       sStringt *s = allocSStringTiny(array[i]);
   3615       if (!s) {
   3616         return(NULL);
   3617       }
   3618       sArrayPushTiny(&(self->topA), (smallt *) s);
   3619     }
   3620     else {
   3621       sArrayPushTiny(&(self->topA), NULL);
   3622   }
   3623     }
   3624 
   3625   return(self);
   3626 }
   3627 
   3628 // size 0 means NULL terminated array
   3629 internal smallJsont* fromCArraySmallJson(smallJsont *self, const char **array, size_t size) {
   3630 
   3631   // sanity checks
   3632   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   3633     return(NULL);
   3634   }
   3635 
   3636   if (!array) {
   3637     return(NULL);
   3638   }
   3639 
   3640   if (self->topIsA != SMALLJSON_IS_EMPTY) {
   3641     freeSmallJson(self);
   3642   }
   3643   self->topIsA = TOP_IS_ARRAY;
   3644 
   3645   if (!size) {
   3646     forEachCCharP(array, e) {
   3647       sStringt *s = allocSStringTiny(*e);
   3648       if (!s) {
   3649         return(NULL);
   3650       }
   3651       sArrayPushTiny(&(self->topA), (smallt *) s);
   3652     }
   3653     return(self);
   3654   }
   3655 
   3656   // copy array content
   3657   for (size_t i = 0 ; i < size ; i++) {
   3658     if (array[i]) {
   3659       // remove NULL strings
   3660       sStringt *s = allocSStringTiny(array[i]);
   3661       if (!s) {
   3662         return(NULL);
   3663       }
   3664       sArrayPushTiny(&(self->topA), (smallt *) s);
   3665     }
   3666     else {
   3667       sArrayPushTiny(&(self->topA), NULL);
   3668   }
   3669     }
   3670 
   3671   return(self);
   3672 }
   3673 
   3674 internal smallJsont* fromArrayNFreeSmallJson(smallJsont *self, char **array, size_t size) {
   3675 
   3676   smallJsont *r = fromArraySmallJson(self, array, size);
   3677 
   3678   if (r) {
   3679     if (!size) {
   3680       listFreeS(array);
   3681     }
   3682     else {
   3683       for (size_t i = 0 ; i < size ; i++) {
   3684         free(array[i]);
   3685       }
   3686       free(array);
   3687   }
   3688     }
   3689   return(r);
   3690 }
   3691 
   3692 internal smallJsont* fromArrayDictSmallJson(smallJsont *self, smallArrayt *items) {
   3693 
   3694   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT) {
   3695     return(NULL);
   3696   }
   3697 
   3698   if (!items) {
   3699     return(NULL);
   3700   }
   3701 
   3702   if (checkObjectTypes && !isOSmallArray(items)) {
   3703     return(NULL);
   3704   }
   3705 
   3706   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   3707     setTypeDictSmallJson(self);
   3708   }
   3709 
   3710   forEachSmallArray(items, E) {
   3711     if (!isOType(E, "smallArray")) {
   3712       goto cont;
   3713     }
   3714     cast(smallArrayt*, a, E);
   3715     if (lenO(a) != 2) {
   3716       goto cont;
   3717     }
   3718     smallStringt *s = a->f->getAtSmallString(a, 0);;
   3719     if (!isOType(s, "smallString")) {
   3720       finishO(s);
   3721       goto cont;
   3722     }
   3723     setNFreeSmallJson(self, ssGet(s), a->f->getNDup(a, 1));
   3724     finishO(s);
   3725     cont:
   3726     finishO(E);
   3727   }
   3728   return(self);
   3729 }
   3730 
   3731 internal smallArrayt* toArrayDictSmallJson(smallJsont *self) {
   3732 
   3733   if (self->topIsA != TOP_IS_DICT) {
   3734     return(NULL);
   3735   }
   3736 
   3737   if (!lenSmallJson(self)) {
   3738     return(NULL);
   3739   }
   3740 
   3741   createAllocateSmallArray(r);
   3742   if (!r) {
   3743     return(NULL);
   3744   }
   3745 
   3746   forEachSDict(self->top, e) {
   3747     if (e->key) {
   3748       createAllocateSmallArray(a);
   3749       if (!a) {
   3750         terminateO(r);
   3751         return(NULL);
   3752       }
   3753       a->f->pushS(a, e->key);
   3754       pushNFreeO(a, toBaset(sDuplicate(e->data)));
   3755       r->f->pushNFreeArray(r, a);
   3756   }
   3757     }
   3758   return(r);
   3759 }
   3760 
   3761 internal baset* getTopSmallJson(smallJsont *self) {
   3762 
   3763   switch(self->topIsA) {
   3764     case TOP_IS_UNDEFINED:
   3765       return((baset *)toBaset((smallt *)self->topU));
   3766     case TOP_IS_BOOL:
   3767       return((baset *)toBaset((smallt *)self->topB));
   3768     case TOP_IS_DOUBLE:
   3769       return((baset *)toBaset((smallt *)self->topD));
   3770     case TOP_IS_INT:
   3771       return((baset *)toBaset((smallt *)self->topI));
   3772     case TOP_IS_STRING:
   3773       return((baset *)toBaset((smallt *)self->topS));
   3774     case TOP_IS_DICT:
   3775       return((baset *)toBaset((smallt *)self->top));
   3776     case TOP_IS_ARRAY:
   3777       return((baset *)toBaset((smallt *)self->topA));
   3778     default:;
   3779       // self is empty, there is nothing to get
   3780   }
   3781   return(NULL);
   3782 }
   3783 
   3784 internal undefinedt*   getTopUndefinedSmallJson(smallJsont *self) {
   3785 
   3786   if (checkObjectTypes && self->topIsA != TOP_IS_UNDEFINED) {
   3787     return(NULL);
   3788   }
   3789 
   3790   return((undefinedt*)getTopSmallJson(self));
   3791 }
   3792 
   3793 internal bool          getTopBoolSmallJson(smallJsont *self) {
   3794   smallBoolt *e = NULL;
   3795   bool r = false;;
   3796 
   3797   e = getTopSmallBoolSmallJson(self);
   3798   if (e) {
   3799     r = e->f->get(e);
   3800     finishO(e);
   3801   }
   3802   return(r);
   3803 }
   3804 
   3805 internal bool*         getTopBoolPSmallJson(smallJsont *self) {
   3806   smallBoolt *e = NULL;
   3807   bool* r = NULL;
   3808 
   3809   e = getTopSmallBoolSmallJson(self);
   3810   if (e) {
   3811     r = e->f->getP(e);
   3812     finishO(e);
   3813   }
   3814   return(r);
   3815 }
   3816 
   3817 internal double        getTopDoubleSmallJson(smallJsont *self) {
   3818   smallDoublet *e = NULL;
   3819   double r = 0;;
   3820 
   3821   e = getTopSmallDoubleSmallJson(self);
   3822   if (e) {
   3823     r = e->f->get(e);
   3824     finishO(e);
   3825   }
   3826   return(r);
   3827 }
   3828 
   3829 internal double*       getTopDoublePSmallJson(smallJsont *self) {
   3830   smallDoublet *e = NULL;
   3831   double* r = NULL;
   3832 
   3833   e = getTopSmallDoubleSmallJson(self);
   3834   if (e) {
   3835     r = e->f->getP(e);
   3836     finishO(e);
   3837   }
   3838   return(r);
   3839 }
   3840 
   3841 internal int64_t       getTopIntSmallJson(smallJsont *self) {
   3842   smallIntt *e = NULL;
   3843   int64_t r = 0;;
   3844 
   3845   e = getTopSmallIntSmallJson(self);
   3846   if (e) {
   3847     r = e->f->get(e);
   3848     finishO(e);
   3849   }
   3850   return(r);
   3851 }
   3852 
   3853 internal int64_t*      getTopIntPSmallJson(smallJsont *self) {
   3854   smallIntt *e = NULL;
   3855   int64_t* r = NULL;
   3856 
   3857   e = getTopSmallIntSmallJson(self);
   3858   if (e) {
   3859     r = e->f->getP(e);
   3860     finishO(e);
   3861   }
   3862   return(r);
   3863 }
   3864 
   3865 internal int32_t       getTopInt32SmallJson(smallJsont *self) {
   3866   smallIntt *e = NULL;
   3867   int32_t r = 0;;
   3868 
   3869   e = getTopSmallIntSmallJson(self);
   3870   if (e) {
   3871     r = (int32_t)e->f->get(e);
   3872     finishO(e);
   3873   }
   3874   return(r);
   3875 }
   3876 
   3877 internal int32_t*      getTopInt32PSmallJson(smallJsont *self) {
   3878   smallIntt *e = NULL;
   3879   int32_t* r = NULL;
   3880 
   3881   e = getTopSmallIntSmallJson(self);
   3882   if (e) {
   3883     r = (int32_t *)e->f->getP(e);
   3884     finishO(e);
   3885   }
   3886   return(r);
   3887 }
   3888 
   3889 internal uint64_t      getTopUintSmallJson(smallJsont *self) {
   3890   smallIntt *e = NULL;
   3891   uint64_t r = 0;;
   3892 
   3893   e = getTopSmallIntSmallJson(self);
   3894   if (e) {
   3895     r = (uint64_t)e->f->get(e);
   3896     finishO(e);
   3897   }
   3898   return(r);
   3899 }
   3900 
   3901 internal uint64_t*     getTopUintPSmallJson(smallJsont *self) {
   3902   smallIntt *e = NULL;
   3903   uint64_t* r = NULL;
   3904 
   3905   e = getTopSmallIntSmallJson(self);
   3906   if (e) {
   3907     r = (uint64_t *)e->f->getP(e);
   3908     finishO(e);
   3909   }
   3910   return(r);
   3911 }
   3912 
   3913 internal uint32_t      getTopUint32SmallJson(smallJsont *self) {
   3914   smallIntt *e = NULL;
   3915   uint32_t r = 0;;
   3916 
   3917   e = getTopSmallIntSmallJson(self);
   3918   if (e) {
   3919     r = (uint32_t)e->f->get(e);
   3920     finishO(e);
   3921   }
   3922   return(r);
   3923 }
   3924 
   3925 internal uint32_t*     getTopUint32PSmallJson(smallJsont *self) {
   3926   smallIntt *e = NULL;
   3927   uint32_t* r = NULL;
   3928 
   3929   e = getTopSmallIntSmallJson(self);
   3930   if (e) {
   3931     r = (uint32_t *)e->f->getP(e);
   3932     finishO(e);
   3933   }
   3934   return(r);
   3935 }
   3936 
   3937 internal char*         getTopSSmallJson(smallJsont *self) {
   3938   smallStringt *e = NULL;
   3939   char* r = NULL;
   3940 
   3941   e = getTopSmallStringSmallJson(self);
   3942   if (e) {
   3943     r = e->f->get(e);
   3944     finishO(e);
   3945   }
   3946   return(r);
   3947 }
   3948 
   3949 internal smallDictt*   getTopDictSmallJson(smallJsont *self) {
   3950 
   3951   if (checkObjectTypes && self->topIsA != TOP_IS_DICT) {
   3952     return(NULL);
   3953   }
   3954 
   3955   return((smallDictt*)getTopSmallJson(self));
   3956 }
   3957 
   3958 internal smallArrayt*  getTopArraySmallJson(smallJsont *self) {
   3959 
   3960   if (checkObjectTypes && self->topIsA != TOP_IS_ARRAY) {
   3961     return(NULL);
   3962   }
   3963 
   3964   return((smallArrayt*)getTopSmallJson(self));
   3965 }
   3966 
   3967 internal smallBoolt*   getTopSmallBoolSmallJson(smallJsont *self) {
   3968 
   3969   if (checkObjectTypes && self->topIsA != TOP_IS_BOOL) {
   3970     return(NULL);
   3971   }
   3972 
   3973   return((smallBoolt*)getTopSmallJson(self));
   3974 }
   3975 
   3976 internal smallDoublet* getTopSmallDoubleSmallJson(smallJsont *self) {
   3977 
   3978   if (checkObjectTypes && self->topIsA != TOP_IS_DOUBLE) {
   3979     return(NULL);
   3980   }
   3981 
   3982   return((smallDoublet*)getTopSmallJson(self));
   3983 }
   3984 
   3985 internal smallIntt* getTopSmallIntSmallJson(smallJsont *self) {
   3986 
   3987   if (checkObjectTypes && self->topIsA != TOP_IS_INT) {
   3988     return(NULL);
   3989   }
   3990 
   3991   return((smallIntt*)getTopSmallJson(self));
   3992 }
   3993 
   3994 internal smallStringt* getTopSmallStringSmallJson(smallJsont *self) {
   3995 
   3996   if (checkObjectTypes && self->topIsA != TOP_IS_STRING) {
   3997     return(NULL);
   3998   }
   3999 
   4000   return((smallStringt*)getTopSmallJson(self));
   4001 }
   4002 
   4003 
   4004 internal bool isPythonIndex(const char *start, size_t len) {
   4005 
   4006   char s[len+1];
   4007   memcpy(s, start, len);
   4008   s[len] = 0;
   4009   return(isInt(s));
   4010 }
   4011 
   4012 internal jsonPathRest keyIsSmallJson(smallJsont *self UNUSED, const char *key) {
   4013 
   4014   if (!key) {
   4015     return(KEY_IS_NULL);
   4016   }
   4017 
   4018   /* detect if key is a dict key or a path */
   4019   /* path must start with " or [ */
   4020   /* the chars between [ and ] must be integers */
   4021   /* key chars must be surrounded with " */
   4022   /* invalid path are dict keys */
   4023   /* escape \" \\ */
   4024 
   4025   jsonPathRest keyIs = NOT_A_PATH;
   4026 
   4027   enum {SEARCH, IN_STRING, IN_INDEX};
   4028   int state = SEARCH;
   4029 
   4030   if (key[0]=='"' || key[0]=='[') {
   4031     /* path must start with " or [ */
   4032     bool escape       = false;
   4033     const char *start = NULL;
   4034     size_t startIdx   = 0;
   4035     for (size_t i = 0 ; key[i] ; i++) {
   4036       if (escape) {
   4037         escape = false;
   4038         continue;
   4039       }
   4040 
   4041       switch (key[i]) {
   4042         case '"':
   4043           /* key chars must be surrounded with " */
   4044           switch(state) {
   4045             case SEARCH:
   4046               state = IN_STRING;
   4047               break;
   4048             case IN_STRING:
   4049               state = SEARCH;
   4050               break;
   4051             default:
   4052               goto endKeyParse;
   4053           }
   4054           break;
   4055        case '[':
   4056           switch(state) {
   4057             case SEARCH:
   4058               state    = IN_INDEX;
   4059               start    = &key[i+1];
   4060               startIdx = i+1;
   4061               break;
   4062             case IN_INDEX:
   4063               /* 2 [ following each other, not a path */
   4064               goto endKeyParse;
   4065             default:;
   4066               // do nothing
   4067           }
   4068           break;
   4069        case ']':
   4070           switch(state) {
   4071             case IN_INDEX:
   4072               state = SEARCH;
   4073               /* check if there is an int between the [] */
   4074               if (!isPythonIndex(start, i-startIdx)) {
   4075                 goto endKeyParse;
   4076               }
   4077               break;
   4078             case SEARCH:
   4079               /* missing [, not a path */
   4080               goto endKeyParse;
   4081             default:;
   4082               // do nothing
   4083           }
   4084           break;
   4085        default:
   4086           switch(state) {
   4087             case SEARCH:
   4088               if (key[i]!='.') {
   4089                 goto endKeyParse;
   4090               }
   4091               break;
   4092             case IN_INDEX:
   4093               /* the chars between [ and ] must be integers */
   4094               if (!isdigit(key[i]) && key[i]!=']' && key[i]!='-') {
   4095                 goto endKeyParse;
   4096               }
   4097               break;
   4098             case IN_STRING:
   4099               /* escape \" \\ */
   4100               if (key[i]=='\\') {
   4101                 escape = true;
   4102               }
   4103               break;
   4104             default:;
   4105               // do nothing
   4106           }
   4107           break;
   4108       }
   4109     }
   4110 
   4111     if (state==SEARCH) {
   4112       /* all path elements must be closed */
   4113       switch(key[0]) {
   4114         case '"':
   4115           keyIs = DICT_PATH;
   4116           break;
   4117         case '[':
   4118           keyIs = ARRAY_PATH;
   4119           break;
   4120         default:;
   4121           // do nothing
   4122       }
   4123   }
   4124     }
   4125 
   4126   endKeyParse:
   4127   return(keyIs);
   4128 }
   4129 
   4130 internal const char* keyIsSSmallJson(smallJsont *self UNUSED, const char *key) {
   4131 
   4132   if (!key) {
   4133     return(NULL);
   4134   }
   4135 
   4136   jsonPathRest keyIs = keyIsSmallJson(self, key);
   4137 
   4138   return(jsonPathResS[keyIs]);
   4139 }
   4140 
   4141 internal char*  makeKeySmallJson(smallJsont *self UNUSED, const char *key) {
   4142 
   4143   if (!key) {
   4144     return(NULL);
   4145   }
   4146 
   4147   char *r = strdup(_);
   4148 
   4149   for (size_t i = 0 ; key[i] ; i++) {
   4150     if (key[i]=='"' || key[i]=='\\') {
   4151       pErrorNULL(iAppendS(&r, BSLH));
   4152     }
   4153     pErrorNULL(iAppendCharS(&r, key[i]));
   4154   }
   4155 
   4156   // close quote
   4157   pErrorNULL(iAppendS(&r, _));
   4158   return(r);
   4159 }
   4160 
   4161 internal char*  iMakeKeySmallJson(smallJsont *self UNUSED, char **key) {
   4162 
   4163   if (!key || !*key) {
   4164     return(NULL);
   4165   }
   4166 
   4167   char *r = makeKeySmallJson(self, *key);
   4168   free(*key);
   4169   *key    = r;
   4170   return(r);
   4171 }
   4172 
   4173 internal char*  bMakeKeySmallJson(smallJsont *self UNUSED, char *dest, const char *key) {
   4174 
   4175   if (!key || !dest) {
   4176     return(NULL);
   4177   }
   4178 
   4179   size_t di  =  0;
   4180   dest[di++] = '"';
   4181 
   4182   for (size_t i = 0 ; key[i] ; i++) {
   4183     if (key[i]=='"' || key[i]=='\\') {
   4184       dest[di++] = '\\';
   4185     }
   4186     dest[di++] = key[i];
   4187   }
   4188 
   4189   // close quote
   4190   dest[di++] = '"';
   4191   dest[di] = 0;
   4192   return(dest);
   4193 }
   4194 
   4195 internal char*  bLMakeKeySmallJson(smallJsont *self UNUSED, char *dest, size_t size, const char *key) {
   4196 
   4197   if (!key || !dest || !size) {
   4198     return(NULL);
   4199   }
   4200 
   4201   if (makeKeyLenSmallJson(self, key)+1 > size) {
   4202     return(NULL);
   4203   }
   4204 
   4205   size_t di  =  0;
   4206   dest[di++] = '"';
   4207 
   4208   for (size_t i = 0 ; key[i] ; i++) {
   4209     if (key[i]=='"' || key[i]=='\\') {
   4210       dest[di++] = '\\';
   4211     }
   4212     dest[di++] = key[i];;
   4213   }
   4214 
   4215   // close quote
   4216   dest[di++] = '"';
   4217   dest[di] = 0;
   4218   return(dest);
   4219 }
   4220 
   4221 internal size_t makeKeyLenSmallJson(smallJsont *self UNUSED, const char *key) {
   4222 
   4223   if (!key) {
   4224     return(0);
   4225   }
   4226 
   4227   size_t r = 1;
   4228 
   4229   for (size_t i = 0 ; key[i] ; i++) {
   4230     if (key[i]=='"' || key[i]=='\\') {
   4231       r++;
   4232     }
   4233     r++;
   4234   }
   4235 
   4236   // close quote
   4237   r++;
   4238   return(r);
   4239 }
   4240 
   4241 internal void unescapeKey(char *dest, char *key, size_t length) {
   4242 
   4243   bool skipped = false;
   4244   size_t j     = 0;
   4245   range(i, length) {
   4246     if (skipped) {
   4247       skipped = false;
   4248       if (key[i-1] == '\\') {
   4249         goto keepBackSlash;
   4250     }
   4251       }
   4252     if (key[i] == '\\' && !skipped) {
   4253       skipped = true;
   4254     }
   4255     keepBackSlash:
   4256     if (!skipped) {
   4257       dest[j++] = key[i];
   4258     }
   4259   }
   4260   dest[j] = 0;
   4261 }
   4262 
   4263 
   4264 internal smallJsont* setSmallJson(smallJsont *self, const char *key, baset *value) {
   4265 
   4266   mainSetJsonPath(if (!value) return NULL/*initValue*/, isError(o,toSmallt(value)) return NULL; if (!isOSmallContainer(value) && o->type == CONTAINER) isNew = true/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4267   // cg_c bug
   4268 }
   4269 
   4270 internal smallJsont* setUndefinedSmallJson(smallJsont *self, const char *key) {
   4271 
   4272   mainSetJsonPath(/*initValue*/, isError(o,(smallt*)allocSUndefined()) return NULL; isNew = true/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4273   // cg_c bug
   4274 }
   4275 
   4276 internal smallJsont* setBoolSmallJson(smallJsont *self, const char *key, bool value) {
   4277 
   4278   mainSetJsonPath(/*initValue*/, isError(o,(smallt*)allocSBool(value)) return NULL; isNew = true/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4279   // cg_c bug
   4280 }
   4281 
   4282 internal smallJsont* setDoubleSmallJson(smallJsont *self, const char *key, double value) {
   4283 
   4284   mainSetJsonPath(/*initValue*/, isError(o,(smallt*)allocSDouble(value)) return NULL; isNew = true/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4285   // cg_c bug
   4286 }
   4287 
   4288 internal smallJsont* setIntSmallJson(smallJsont *self, const char *key, int64_t value) {
   4289 
   4290   mainSetJsonPath(/*initValue*/, isError(o,(smallt*)allocSInt(value)) return NULL; isNew = true/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4291   // cg_c bug
   4292 }
   4293 
   4294 internal smallJsont* setSSmallJson(smallJsont *self, const char *key, const char *string) {
   4295 
   4296   mainSetJsonPath(if (!string) return NULL/*initValue*/, isError(o,(smallt*)allocSStringTiny(string)) return NULL; isNew = true/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4297   // cg_c bug
   4298 }
   4299 
   4300 internal smallJsont* setCharSmallJson(smallJsont *self, const char *key, char c) {
   4301 
   4302   charToS(s, c);
   4303   return(setSSmallJson(self, key, s));
   4304 }
   4305 
   4306 internal smallJsont* setDictSmallJson(smallJsont *self, const char *key, smallDictt *dict) {
   4307 
   4308   mainSetJsonPath(if (!dict) return NULL; if (checkObjectTypes && dict && !isOSmallDict(dict)) return NULL/*initValue*/, if (!dict->d) {isError(dict->d, allocSDict()) return NULL;}o = (smallt *)dict->d/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4309   // cg_c bug
   4310 }
   4311 
   4312 internal smallJsont* setArraySmallJson(smallJsont *self, const char *key, smallArrayt *array) {
   4313 
   4314   mainSetJsonPath(if (!array) return NULL; if (checkObjectTypes && array && !isOSmallArray(array)) return NULL/*initValue*/, if (!array->a) {/*allocate empty array*/ isError(array->a, allocSArray()) return NULL;} o = (smallt *)array->a/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4315   // cg_c bug
   4316 }
   4317 
   4318 internal smallJsont* setArraycSmallJson(smallJsont *self, const char *key, char **array) {
   4319 
   4320   mainSetJsonPath(if (!array) return NULL/*initValue*/, sArrayt *A = allocSArray(); if (!A) return NULL;forEachCharP(array, e){sStringt *s = allocSStringTiny(*e);if (!s) {if (A) sArrayFreeTiny(A); return NULL;};sArrayPushTiny(&A, (smallt *) s);}o = (smallt *)A; isNew = true/*allocValue*/, setJsonPathsFree/*subSetJsonPath*/);
   4321   // cg_c bug
   4322 }
   4323 
   4324 internal smallJsont* setCArraycSmallJson(smallJsont *self, const char *key, const char **array) {
   4325 
   4326   mainSetJsonPath(if (!array) return NULL/*initValue*/, sArrayt *A = allocSArray(); if (!A) return NULL;forEachCCharP(array, e){sStringt *s = allocSStringTiny(*e);if (!s) {if (A) sArrayFreeTiny(A); return NULL;};sArrayPushTiny(&A, (smallt *) s);}o = (smallt *)A; isNew = true/*allocValue*/, setJsonPathsFree/*subSetJsonPath*/);
   4327   // cg_c bug
   4328 }
   4329 
   4330 internal smallJsont* setSmallBoolSmallJson(smallJsont *self, const char *key, smallBoolt *value) {
   4331 
   4332   mainSetJsonPath(if (!value) return NULL; if (checkObjectTypes && value && !isOSmallBool(value)) return NULL/*initValue*/, if (!value->value) {isError(value->value, allocSBool(false)) return NULL;} o = (smallt*)value->value/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4333   // cg_c bug
   4334 }
   4335 
   4336 internal smallJsont* setSmallBytesSmallJson(smallJsont *self, const char *key, smallBytest *value) {
   4337 
   4338   mainSetJsonPath(if (!value) return NULL; if (checkObjectTypes && value && !isOSmallBytes(value)) return NULL/*initValue*/, if (!value->B) {isError(value->B, allocSBytes()) return NULL;} o = (smallt*)value->B/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4339   // cg_c bug
   4340 }
   4341 
   4342 internal smallJsont* setSmallDoubleSmallJson(smallJsont *self, const char *key, smallDoublet *value) {
   4343 
   4344   mainSetJsonPath(if (!value) return NULL; if (checkObjectTypes && value && !isOSmallDouble(value)) return NULL/*initValue*/, if (!value->value) {isError(value->value, allocSDouble(0)) return NULL;} o = (smallt*)value->value/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4345   // cg_c bug
   4346 }
   4347 
   4348 internal smallJsont* setSmallIntSmallJson(smallJsont *self, const char *key, smallIntt *value) {
   4349 
   4350   mainSetJsonPath(if (!value) return NULL; if (checkObjectTypes && value && !isOSmallInt(value)) return NULL/*initValue*/, if (!value->value) {isError(value->value, allocSInt(0)) return NULL;} o = (smallt*)value->value/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4351   // cg_c bug
   4352 }
   4353 
   4354 internal smallJsont* setSmallJsonSmallJson(smallJsont *self, const char *key, smallJsont *value) {
   4355 
   4356   mainSetJsonPath(if (!value) return NULL; if (checkObjectTypes && value && !isOSmallJson(value)) return NULL/*initValue*/, o = getsoO(value); if (!o) {isError(o, (smallt*)allocSDict()) return NULL; setsoO(value, o);}/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4357   // cg_c bug
   4358 }
   4359 
   4360 internal smallJsont* setSmallStringSmallJson(smallJsont *self, const char *key, smallStringt *string) {
   4361 
   4362   mainSetJsonPath(if (!string) return NULL; if (checkObjectTypes && string && !isOSmallString(string)) return NULL/*initValue*/, if (!string->data) {isError(string->data, allocSStringTiny("")) return NULL;} o = (smallt*)string->data/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4363   // cg_c bug
   4364 }
   4365 
   4366 internal smallJsont* setSmallContainerSmallJson(smallJsont *self, const char *key, smallContainert *container) {
   4367 
   4368   mainSetJsonPath(if (!container) return NULL; if (checkObjectTypes && container && !isOSmallContainer(container)) return NULL/*initValue*/, if (!container->data) {isError(container->data, allocSContainer(0)) return NULL;} o = (smallt*)container->data/*allocValue*/, setJsonPath/*subSetJsonPath*/);
   4369   // cg_c bug
   4370 }
   4371 
   4372 internal smallJsont* setNFreeSmallJson(smallJsont *self, const char *key, baset *value) {
   4373 
   4374   mainSetJsonPathWithoutReturn(if (!value) return NULL/*initValue*/, isError(o,toSmallt(value)) return NULL; if (!isOSmallContainer(value) && o->type == CONTAINER) isNew = true/*allocValue*/, setJsonPathWithoutReturn/*subSetJsonPath*/);
   4375   // cg_c bug
   4376 
   4377   if (!(o->type == CONTAINER && (((sContainert*)o)->dataType == SH_DT_BASET))) {
   4378     /* free parameter only when successfully stored in self */
   4379     finishO(value);
   4380   }
   4381   return(self);
   4382 }
   4383 
   4384 internal smallJsont* setNFreeUndefinedSmallJson(smallJsont *self, const char *key, undefinedt *u) {
   4385 
   4386   if (!u) {
   4387     return(NULL);
   4388   }
   4389 
   4390   smallJsont *r = setUndefinedSmallJson(self, key);
   4391   if (r) {
   4392     /* free parameter only when successfully stored in self */
   4393     terminateO(u);
   4394   }
   4395   return(r);
   4396 }
   4397 
   4398 internal smallJsont* setNFreeSSmallJson(smallJsont *self, const char *key, char *string) {
   4399 
   4400   if (!string) {
   4401     return(NULL);
   4402   }
   4403 
   4404   smallJsont *r = setSSmallJson(self, key, string);
   4405   if (r) {
   4406     /* free parameter only when successfully stored in self */
   4407     free(string);
   4408   }
   4409   return(r);
   4410 }
   4411 
   4412 internal smallJsont* setNFreeDictSmallJson(smallJsont *self, const char *key, smallDictt *dict) {
   4413 
   4414   smallJsont *r = setDictSmallJson(self, key, dict);
   4415   if (r) {
   4416     /* free parameter only when successfully stored in self */
   4417     finishO(dict);
   4418   }
   4419   return(r);
   4420 }
   4421 
   4422 internal smallJsont* setNFreeArraySmallJson(smallJsont *self, const char *key, smallArrayt *array) {
   4423 
   4424   smallJsont *r = setArraySmallJson(self, key, array);
   4425   if (r) {
   4426     /* free parameter only when successfully stored in self */
   4427     finishO(array);
   4428   }
   4429   return(r);
   4430 }
   4431 
   4432 internal smallJsont* setNFreeArraycSmallJson(smallJsont *self, const char *key, char **array) {
   4433 
   4434   if (!array) {
   4435     return(NULL);
   4436   }
   4437 
   4438   smallJsont *r = setArraycSmallJson(self, key, array);
   4439   if (r) {
   4440     listFreeS(array);
   4441   }
   4442   return(r);
   4443 }
   4444 
   4445 internal smallJsont* setNFreeSmallBoolSmallJson(smallJsont *self, const char *key, smallBoolt *value) {
   4446 
   4447   smallJsont *r = setSmallBoolSmallJson(self, key, value);
   4448   if (r) {
   4449     finishO(value);
   4450   }
   4451   return(r);
   4452 }
   4453 
   4454 internal smallJsont* setNFreeSmallBytesSmallJson(smallJsont *self, const char *key, smallBytest *value) {
   4455 
   4456   smallJsont *r = setSmallBytesSmallJson(self, key, value);
   4457   if (r) {
   4458     finishO(value);
   4459   }
   4460   return(r);
   4461 }
   4462 
   4463 internal smallJsont* setNFreeSmallDoubleSmallJson(smallJsont *self, const char *key, smallDoublet *value) {
   4464 
   4465   smallJsont *r = setSmallDoubleSmallJson(self, key, value);
   4466   if (r) {
   4467     finishO(value);
   4468   }
   4469   return(r);
   4470 }
   4471 
   4472 internal smallJsont* setNFreeSmallIntSmallJson(smallJsont *self, const char *key, smallIntt *value) {
   4473 
   4474   smallJsont *r = setSmallIntSmallJson(self, key, value);
   4475   if (r) {
   4476     finishO(value);
   4477   }
   4478   return(r);
   4479 }
   4480 
   4481 internal smallJsont* setNFreeSmallJsonSmallJson(smallJsont *self, const char *key, smallJsont *value) {
   4482 
   4483   smallJsont *r = setSmallJsonSmallJson(self, key, value);
   4484   if (r) {
   4485     finishO(value);
   4486   }
   4487   return(r);
   4488 }
   4489 
   4490 internal smallJsont* setNFreeSmallStringSmallJson(smallJsont *self, const char *key, smallStringt *string) {
   4491 
   4492   smallJsont *r = setSmallStringSmallJson(self, key, string);
   4493   if (r) {
   4494     finishO(string);
   4495   }
   4496   return(r);
   4497 }
   4498 
   4499 internal smallJsont* setNFreeSmallContainerSmallJson(smallJsont *self, const char *key, smallContainert *container) {
   4500 
   4501   smallJsont *r = setSmallContainerSmallJson(self, key, container);
   4502   if (r) {
   4503     finishO(container);
   4504   }
   4505   return(r);
   4506 }
   4507 
   4508 internal smallJsont* setPDictSmallJson(smallJsont *self, const char *key, smallDictt *dict) {
   4509 
   4510   mainSetJsonPath(if (!dict) return NULL; if (checkObjectTypes && dict && !isOSmallDict(dict)) return NULL; if (!dict->d) return NULL; o = (smallt *)dict->d/*initValue*/,/*allocValue*/, setPJsonPath(o)/*subSetJsonPath*/);
   4511   // cg_c bug
   4512 }
   4513 
   4514 internal smallJsont* setPArraySmallJson(smallJsont *self, const char *key, smallArrayt *array) {
   4515 
   4516   mainSetJsonPath(if (!array) return NULL; if (checkObjectTypes && array && !isOSmallArray(array)) return NULL; if (!array->a) return NULL; o = (smallt *)array->a/*initValue*/, /*allocValue*/, setPJsonPath(o)/*subSetJsonPath*/);
   4517   // cg_c bug
   4518 }
   4519 
   4520 internal smallJsont* setPSmallJsonSmallJson(smallJsont *self, const char *key, smallJsont *value) {
   4521 
   4522   mainSetJsonPath(if (!value) return NULL; if (checkObjectTypes && value && !isOSmallJson(value)) return NULL; o = getsoO(value); if (!o) return NULL/*initValue*/, /*allocValue*/, setPJsonPath(o)/*subSetJsonPath*/);
   4523   // cg_c bug
   4524 }
   4525 
   4526 internal smallJsont* setPSmallStringSmallJson(smallJsont *self, const char *key, smallStringt *string) {
   4527 
   4528   mainSetJsonPath(if (!string) return NULL; if (checkObjectTypes && string && !isOSmallString(string)) return NULL; if (!string->data) return NULL; o = (smallt*)string->data;/*initValue*/, /*allocValue*/, setPJsonPath(o)/*subSetJsonPath*/);
   4529   // cg_c bug
   4530 }
   4531 
   4532 internal smallJsont* setNFreePDictSmallJson(smallJsont *self, const char *key, smallDictt *dict) {
   4533 
   4534   mainSetJsonPath(if (!dict) return NULL; if (checkObjectTypes && dict && !isOSmallDict(dict)) return NULL; if (!dict->d) return NULL; o = (smallt *)dict->d/*initValue*/,/*allocValue*/, setPNFreeJsonPath(o,finishO(dict));finishO(dict)/*subSetJsonPath*/);
   4535   // cg_c bug
   4536 }
   4537 
   4538 internal smallJsont* setNFreePArraySmallJson(smallJsont *self, const char *key, smallArrayt *array) {
   4539 
   4540   mainSetJsonPath(if (!array) return NULL; if (checkObjectTypes && array && !isOSmallArray(array)) return NULL; if (!array->a) return NULL; o = (smallt *)array->a/*initValue*/, /*allocValue*/, setPNFreeJsonPath(o,finishO(array));finishO(array)/*subSetJsonPath*/);
   4541   // cg_c bug
   4542 }
   4543 
   4544 internal smallJsont* setNFreePSmallJsonSmallJson(smallJsont *self, const char *key, smallJsont *value) {
   4545 
   4546   mainSetJsonPath(if (!value) return NULL; if (checkObjectTypes && value && !isOSmallJson(value)) return NULL; o = getsoO(value); if (!o) return NULL;/*initValue*/, /*allocValue*/, setPNFreeJsonPath(o,finishO(value));finishO(value)/*subSetJsonPath*/);
   4547   // cg_c bug
   4548 }
   4549 
   4550 internal smallJsont* setNFreePSmallStringSmallJson(smallJsont *self, const char *key, smallStringt *string) {
   4551 
   4552   mainSetJsonPath(if (!string) return NULL; if (checkObjectTypes && string && !isOSmallString(string)) return NULL; if (!string->data) return NULL; o = (smallt*)string->data;/*initValue*/, /*allocValue*/, setPNFreeJsonPath(o,finishO(string));finishO(string)/*subSetJsonPath*/);
   4553   // cg_c bug
   4554 }
   4555 
   4556 internal smallJsont* setAtSmallJson(smallJsont *self, int64_t index, baset *value) {
   4557 
   4558   if (self->topIsA != TOP_IS_ARRAY || !value) {
   4559     return(NULL);
   4560   }
   4561 
   4562   if (index >= (int64_t)lenSmallJson(self)) {
   4563     return(NULL);
   4564   }
   4565   if (index < -(int64_t)lenSmallJson(self)) {
   4566     return(NULL);
   4567   }
   4568   if (index < 0) {
   4569     index = (int64_t)lenSmallJson(self) + index;
   4570   }
   4571 
   4572   sArraySetTiny(self->topA, (uint32_t)index, toSmallt(value));
   4573   return(self);
   4574 }
   4575 
   4576 internal smallJsont* setAtUndefinedSmallJson(smallJsont *self, int64_t index) {
   4577 
   4578   if (self->topIsA != TOP_IS_ARRAY) {
   4579     return(NULL);
   4580   }
   4581 
   4582   if (index >= (int64_t)lenSmallJson(self)) {
   4583     return(NULL);
   4584   }
   4585   if (index < -(int64_t)lenSmallJson(self)) {
   4586     return(NULL);
   4587   }
   4588   if (index < 0) {
   4589     index = (int64_t)lenSmallJson(self) + index;
   4590   }
   4591 
   4592   smallt *o = (smallt *) allocSUndefined();
   4593   if (!o) {
   4594     return(NULL);
   4595   }
   4596   sArraySetTiny(self->topA, (uint32_t)index, o);
   4597   return(self);
   4598 }
   4599 
   4600 internal smallJsont* setAtBoolSmallJson(smallJsont *self, int64_t index, bool value) {
   4601 
   4602   if (self->topIsA != TOP_IS_ARRAY) {
   4603     return(NULL);
   4604   }
   4605 
   4606   if (index >= (int64_t)lenSmallJson(self)) {
   4607     return(NULL);
   4608   }
   4609   if (index < -(int64_t)lenSmallJson(self)) {
   4610     return(NULL);
   4611   }
   4612   if (index < 0) {
   4613     index = (int64_t)lenSmallJson(self) + index;
   4614   }
   4615 
   4616   smallt *o = (smallt *) allocSBool(value);
   4617   if (!o) {
   4618     return(NULL);
   4619   }
   4620   sArraySetTiny(self->topA, (uint32_t)index, o);
   4621   return(self);
   4622 }
   4623 
   4624 internal smallJsont* setAtDoubleSmallJson(smallJsont *self, int64_t index, double value) {
   4625 
   4626   if (self->topIsA != TOP_IS_ARRAY) {
   4627     return(NULL);
   4628   }
   4629 
   4630   if (index >= (int64_t)lenSmallJson(self)) {
   4631     return(NULL);
   4632   }
   4633   if (index < -(int64_t)lenSmallJson(self)) {
   4634     return(NULL);
   4635   }
   4636   if (index < 0) {
   4637     index = (int64_t)lenSmallJson(self) + index;
   4638   }
   4639 
   4640   smallt *o = (smallt *) allocSDouble(value);
   4641   if (!o) {
   4642     return(NULL);
   4643   }
   4644   sArraySetTiny(self->topA, (uint32_t)index, o);
   4645   return(self);
   4646 }
   4647 
   4648 internal smallJsont* setAtIntSmallJson(smallJsont *self, int64_t index, int64_t value) {
   4649 
   4650   if (self->topIsA != TOP_IS_ARRAY) {
   4651     return(NULL);
   4652   }
   4653 
   4654   if (index >= (int64_t)lenSmallJson(self)) {
   4655     return(NULL);
   4656   }
   4657   if (index < -(int64_t)lenSmallJson(self)) {
   4658     return(NULL);
   4659   }
   4660   if (index < 0) {
   4661     index = (int64_t)lenSmallJson(self) + index;
   4662   }
   4663 
   4664   smallt *o = (smallt *) allocSInt(value);
   4665   if (!o) {
   4666     return(NULL);
   4667   }
   4668   sArraySetTiny(self->topA, (uint32_t)index, o);
   4669   return(self);
   4670 }
   4671 
   4672 internal smallJsont* setAtSSmallJson(smallJsont *self, int64_t index, const char *string) {
   4673 
   4674   if (self->topIsA != TOP_IS_ARRAY || !string) {
   4675     return(NULL);
   4676   }
   4677 
   4678   if (index >= (int64_t)lenSmallJson(self)) {
   4679     return(NULL);
   4680   }
   4681   if (index < -(int64_t)lenSmallJson(self)) {
   4682     return(NULL);
   4683   }
   4684   if (index < 0) {
   4685     index = (int64_t)lenSmallJson(self) + index;
   4686   }
   4687 
   4688   smallt *o;
   4689   o = (smallt *) allocSStringTiny(string);
   4690   if (!o) {
   4691     return(NULL);
   4692   }
   4693   sArraySetTiny(self->topA, (uint32_t)index, o);
   4694   return(self);
   4695 }
   4696 
   4697 internal smallJsont* setAtCharSmallJson(smallJsont *self, int64_t index, char c) {
   4698 
   4699   if (self->topIsA != TOP_IS_ARRAY) {
   4700     return(NULL);
   4701   }
   4702 
   4703   charToS(s, c);
   4704   return(setAtSSmallJson(self, index, s));
   4705 }
   4706 
   4707 internal smallJsont* setAtDictSmallJson(smallJsont *self, int64_t index, smallDictt *dict) {
   4708 
   4709   if (self->topIsA != TOP_IS_ARRAY || !dict) {
   4710     return(NULL);
   4711   }
   4712 
   4713   if (checkObjectTypes && dict && !isOSmallDict(dict)) {
   4714     return(NULL);
   4715   }
   4716 
   4717   if (index >= (int64_t)lenSmallJson(self)) {
   4718     return(NULL);
   4719   }
   4720   if (index < -(int64_t)lenSmallJson(self)) {
   4721     return(NULL);
   4722   }
   4723   if (index < 0) {
   4724     index = (int64_t)lenSmallJson(self) + index;
   4725   }
   4726 
   4727   if (!dict->d) {
   4728     isError(dict->d, allocSDict()) return(NULL);
   4729   }
   4730 
   4731   sArraySetTiny(self->topA, (uint32_t)index, (smallt *)dict->d);
   4732   return(self);
   4733 }
   4734 
   4735 
   4736 internal smallJsont* setAtArraySmallJson(smallJsont *self, int64_t index, smallArrayt *array) {
   4737 
   4738   if (self->topIsA != TOP_IS_ARRAY || !array) {
   4739     return(NULL);
   4740   }
   4741 
   4742   if (checkObjectTypes && array && !isOSmallArray(array)) {
   4743     return(NULL);
   4744   }
   4745 
   4746   if (index >= (int64_t)lenSmallJson(self)) {
   4747     return(NULL);
   4748   }
   4749   if (index < -(int64_t)lenSmallJson(self)) {
   4750     return(NULL);
   4751   }
   4752   if (index < 0) {
   4753     index = (int64_t)lenSmallJson(self) + index;
   4754   }
   4755 
   4756   if (!array->a) {
   4757     // allocate empty array
   4758     isError(array->a, allocSArray()) return(NULL);
   4759   }
   4760 
   4761   sArraySetTiny(self->topA, (uint32_t)index, (smallt *)array->a);
   4762   return(self);
   4763 }
   4764 
   4765 internal smallJsont* setAtArraycSmallJson(smallJsont *self, int64_t index, char **array) {
   4766 
   4767   if (self->topIsA != TOP_IS_ARRAY || !array) {
   4768     return(NULL);
   4769   }
   4770 
   4771   if (index >= (int64_t)lenSmallJson(self)) {
   4772     return(NULL);
   4773   }
   4774   if (index < -(int64_t)lenSmallJson(self)) {
   4775     return(NULL);
   4776   }
   4777   if (index < 0) {
   4778     index = (int64_t)lenSmallJson(self) + index;
   4779   }
   4780 
   4781   sArrayt *a = allocSArray();
   4782   if (!a) {
   4783     return(NULL);
   4784   }
   4785 
   4786   forEachCharP(array, e) {
   4787     sStringt *s = allocSStringTiny(*e);
   4788     if (!s) {
   4789       if (a) {
   4790         sArrayFreeTiny(a);
   4791       }
   4792       return(NULL);
   4793     }
   4794     sArrayPushTiny(&a, (smallt *) s);
   4795   }
   4796 
   4797   sArraySetTiny(self->topA, (uint32_t)index, (smallt *)a);
   4798   return(self);
   4799 }
   4800 
   4801 internal smallJsont* setAtCArraycSmallJson(smallJsont *self, int64_t index, const char **array) {
   4802 
   4803   if (self->topIsA != TOP_IS_ARRAY || !array) {
   4804     return(NULL);
   4805   }
   4806 
   4807   if (index >= (int64_t)lenSmallJson(self)) {
   4808     return(NULL);
   4809   }
   4810   if (index < -(int64_t)lenSmallJson(self)) {
   4811     return(NULL);
   4812   }
   4813   if (index < 0) {
   4814     index = (int64_t)lenSmallJson(self) + index;
   4815   }
   4816 
   4817   sArrayt *a = allocSArray();
   4818   if (!a) {
   4819     return(NULL);
   4820   }
   4821 
   4822   forEachCCharP(array, e) {
   4823     sStringt *s = allocSStringTiny(*e);
   4824     if (!s) {
   4825       if (a) {
   4826         sArrayFreeTiny(a);
   4827       }
   4828       return(NULL);
   4829     }
   4830     sArrayPushTiny(&a, (smallt *) s);
   4831   }
   4832 
   4833   sArraySetTiny(self->topA, (uint32_t)index, (smallt *)a);
   4834   return(self);
   4835 }
   4836 
   4837 internal smallJsont* setAtSmallBoolSmallJson(smallJsont *self, int64_t index, smallBoolt *value) {
   4838 
   4839   if (self->topIsA != TOP_IS_ARRAY || !value) {
   4840     return(NULL);
   4841   }
   4842 
   4843   if (checkObjectTypes && value && !isOSmallBool(value)) {
   4844     return(NULL);
   4845   }
   4846 
   4847   if (index >= (int64_t)lenSmallJson(self)) {
   4848     return(NULL);
   4849   }
   4850   if (index < -(int64_t)lenSmallJson(self)) {
   4851     return(NULL);
   4852   }
   4853   if (index < 0) {
   4854     index = (int64_t)lenSmallJson(self) + index;
   4855   }
   4856 
   4857   if (!value->value) {
   4858     isError(value->value, allocSBool(false)) return(NULL);
   4859   }
   4860   sArraySetTiny(self->topA, (uint32_t)index, (smallt *) value->value);
   4861   return(self);
   4862 }
   4863 
   4864 internal smallJsont* setAtSmallBytesSmallJson(smallJsont *self, int64_t index, smallBytest *value) {
   4865 
   4866   if (self->topIsA != TOP_IS_ARRAY || !value) {
   4867     return(NULL);
   4868   }
   4869 
   4870   if (checkObjectTypes && value && !isOSmallBytes(value)) {
   4871     return(NULL);
   4872   }
   4873 
   4874   if (index >= (int64_t)lenSmallJson(self)) {
   4875     return(NULL);
   4876   }
   4877   if (index < -(int64_t)lenSmallJson(self)) {
   4878     return(NULL);
   4879   }
   4880   if (index < 0) {
   4881     index = (int64_t)lenSmallJson(self) + index;
   4882   }
   4883 
   4884   if (!value->B) {
   4885     isError(value->B, allocSBytes()) return(NULL);
   4886   }
   4887   sArraySetTiny(self->topA, (uint32_t)index, (smallt*) value->B);
   4888   return(self);
   4889 }
   4890 
   4891 internal smallJsont* setAtSmallDoubleSmallJson(smallJsont *self, int64_t index, smallDoublet *value) {
   4892 
   4893   if (self->topIsA != TOP_IS_ARRAY || !value) {
   4894     return(NULL);
   4895   }
   4896 
   4897   if (checkObjectTypes && value && !isOSmallDouble(value)) {
   4898     return(NULL);
   4899   }
   4900 
   4901   if (index >= (int64_t)lenSmallJson(self)) {
   4902     return(NULL);
   4903   }
   4904   if (index < -(int64_t)lenSmallJson(self)) {
   4905     return(NULL);
   4906   }
   4907   if (index < 0) {
   4908     index = (int64_t)lenSmallJson(self) + index;
   4909   }
   4910 
   4911   if (!value->value) {
   4912     isError(value->value, allocSDouble(0)) return(NULL);
   4913   }
   4914   sArraySetTiny(self->topA, (uint32_t)index, (smallt*) value->value);
   4915   return(self);
   4916 }
   4917 
   4918 internal smallJsont* setAtSmallIntSmallJson(smallJsont *self, int64_t index, smallIntt *value) {
   4919 
   4920   if (self->topIsA != TOP_IS_ARRAY || !value) {
   4921     return(NULL);
   4922   }
   4923 
   4924   if (checkObjectTypes && value && !isOSmallInt(value)) {
   4925     return(NULL);
   4926   }
   4927 
   4928   if (index >= (int64_t)lenSmallJson(self)) {
   4929     return(NULL);
   4930   }
   4931   if (index < -(int64_t)lenSmallJson(self)) {
   4932     return(NULL);
   4933   }
   4934   if (index < 0) {
   4935     index = (int64_t)lenSmallJson(self) + index;
   4936   }
   4937 
   4938   if (!value->value) {
   4939     isError(value->value, allocSInt(0)) return(NULL);
   4940   }
   4941   sArraySetTiny(self->topA, (uint32_t)index, (smallt*) value->value);
   4942   return(self);
   4943 }
   4944 
   4945 internal smallJsont* setAtSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *value) {
   4946 
   4947   if (self->topIsA != TOP_IS_ARRAY || !value) {
   4948     return(NULL);
   4949   }
   4950 
   4951   if (checkObjectTypes && value && !isOSmallJson(value)) {
   4952     return(NULL);
   4953   }
   4954 
   4955   if (index >= (int64_t)lenSmallJson(self)) {
   4956     return(NULL);
   4957   }
   4958   if (index < -(int64_t)lenSmallJson(self)) {
   4959     return(NULL);
   4960   }
   4961   if (index < 0) {
   4962     index = (int64_t)lenSmallJson(self) + index;
   4963   }
   4964 
   4965   smallt *o = getsoO(value);
   4966   if (!o) {
   4967     // smallJson is empty, create an empty dict
   4968     isError(o, (smallt*) allocSDict()) return(NULL);
   4969     setsoO(value, o);
   4970   }
   4971 
   4972   sArraySetTiny(self->topA, (uint32_t)index, o);
   4973   return(self);
   4974 }
   4975 
   4976 internal smallJsont* setAtSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *string) {
   4977 
   4978   if (self->topIsA != TOP_IS_ARRAY || !string) {
   4979     return(NULL);
   4980   }
   4981 
   4982   if (checkObjectTypes && string && !isOSmallString(string)) {
   4983     return(NULL);
   4984   }
   4985 
   4986   if (index >= (int64_t)lenSmallJson(self)) {
   4987     return(NULL);
   4988   }
   4989   if (index < -(int64_t)lenSmallJson(self)) {
   4990     return(NULL);
   4991   }
   4992   if (index < 0) {
   4993     index = (int64_t)lenSmallJson(self) + index;
   4994   }
   4995 
   4996   if (!string->data) {
   4997     isError(string->data, allocSStringTiny("")) return(NULL);
   4998   }
   4999   sArraySetTiny(self->topA, (uint32_t)index, (smallt *)string->data);
   5000   return(self);
   5001 }
   5002 
   5003 internal smallJsont* setAtSmallContainerSmallJson(smallJsont *self, int64_t index, smallContainert *container) {
   5004 
   5005   if (self->topIsA != TOP_IS_ARRAY || !container) {
   5006     return(NULL);
   5007   }
   5008 
   5009 
   5010   if (checkObjectTypes && container && !isOSmallContainer(container)) {
   5011     return(NULL);
   5012   }
   5013 
   5014   if (index >= (int64_t)lenSmallJson(self)) {
   5015     return(NULL);
   5016   }
   5017   if (index < -(int64_t)lenSmallJson(self)) {
   5018     return(NULL);
   5019   }
   5020   if (index < 0) {
   5021     index = (int64_t)lenSmallJson(self) + index;
   5022   }
   5023 
   5024   if (!container->data) {
   5025     isError(container->data, allocSContainer(NULL)) return(NULL);
   5026   }
   5027   sArraySetTiny(self->topA, (uint32_t)index, (smallt *) container->data);
   5028   return(self);
   5029 }
   5030 
   5031 internal smallJsont* setAtNFreeSmallJson(smallJsont *self, int64_t index, baset *value) {
   5032 
   5033   if (self->topIsA != TOP_IS_ARRAY || !value) {
   5034     return(NULL);
   5035   }
   5036 
   5037   if (index >= (int64_t)lenSmallJson(self)) {
   5038     return(NULL);
   5039   }
   5040   if (index < -(int64_t)lenSmallJson(self)) {
   5041     return(NULL);
   5042   }
   5043   if (index < 0) {
   5044     index = (int64_t)lenSmallJson(self) + index;
   5045   }
   5046 
   5047   smallt *o =  toSmallt(value);
   5048   if (!o) {
   5049     return(NULL);
   5050   }
   5051   sArraySetTiny(self->topA, (uint32_t)index, o);
   5052 
   5053   if (!(o->type == CONTAINER && (((sContainert*)o)->dataType == SH_DT_BASET))) {
   5054     finishO(value);
   5055   }
   5056   return(self);
   5057 }
   5058 
   5059 internal smallJsont* setAtNFreeUndefinedSmallJson(smallJsont *self, int64_t index, undefinedt *u) {
   5060 
   5061   if (self->topIsA != TOP_IS_ARRAY) {
   5062     return(NULL);
   5063   }
   5064 
   5065   smallJsont *r = setAtUndefinedSmallJson(self, index);;
   5066   if (r) {
   5067     terminateO(u);
   5068   }
   5069   return(r);
   5070 }
   5071 
   5072 internal smallJsont* setAtNFreeSSmallJson(smallJsont *self, int64_t index, char *string) {
   5073 
   5074   if (self->topIsA != TOP_IS_ARRAY) {
   5075     return(NULL);
   5076   }
   5077 
   5078   smallJsont *r = setAtSSmallJson(self, index, string);;
   5079   if (r) {
   5080     free(string);
   5081   }
   5082   return(r);
   5083 }
   5084 
   5085 internal smallJsont* setAtNFreeDictSmallJson(smallJsont *self, int64_t index, smallDictt *dict) {
   5086 
   5087   if (self->topIsA != TOP_IS_ARRAY) {
   5088     return(NULL);
   5089   }
   5090 
   5091   smallJsont *r = setAtDictSmallJson(self, index, dict);
   5092   if (r) {
   5093     finishO(dict);
   5094   }
   5095   return(r);
   5096 }
   5097 
   5098 internal smallJsont* setAtNFreeArraySmallJson(smallJsont *self, int64_t index, smallArrayt *array) {
   5099 
   5100   if (self->topIsA != TOP_IS_ARRAY) {
   5101     return(NULL);
   5102   }
   5103 
   5104   smallJsont *r = setAtArraySmallJson(self, index, array);
   5105   if (r) {
   5106     finishO(array);
   5107   }
   5108   return(r);
   5109 }
   5110 
   5111 internal smallJsont* setAtNFreeArraycSmallJson(smallJsont *self, int64_t index, char **array) {
   5112 
   5113   if (self->topIsA != TOP_IS_ARRAY) {
   5114     return(NULL);
   5115   }
   5116 
   5117   smallJsont *r = setAtArraycSmallJson(self, index, array);;
   5118   if (r) {
   5119     listFreeS(array);
   5120   }
   5121   return(r);
   5122 }
   5123 
   5124 internal smallJsont* setAtNFreeSmallBoolSmallJson(smallJsont *self, int64_t index, smallBoolt *value) {
   5125 
   5126   if (self->topIsA != TOP_IS_ARRAY) {
   5127     return(NULL);
   5128   }
   5129 
   5130   smallJsont *r = setAtSmallBoolSmallJson(self, index, value);
   5131   if (r) {
   5132     finishO(value);
   5133   }
   5134   return(r);
   5135 }
   5136 
   5137 internal smallJsont* setAtNFreeSmallBytesSmallJson(smallJsont *self, int64_t index, smallBytest *value) {
   5138 
   5139   if (self->topIsA != TOP_IS_ARRAY) {
   5140     return(NULL);
   5141   }
   5142 
   5143   smallJsont *r = setAtSmallBytesSmallJson(self, index, value);
   5144   if (r) {
   5145     finishO(value);
   5146   }
   5147   return(r);
   5148 }
   5149 
   5150 internal smallJsont* setAtNFreeSmallDoubleSmallJson(smallJsont *self, int64_t index, smallDoublet *value) {
   5151 
   5152   if (self->topIsA != TOP_IS_ARRAY) {
   5153     return(NULL);
   5154   }
   5155 
   5156   smallJsont *r = setAtSmallDoubleSmallJson(self, index, value);
   5157   if (r) {
   5158     finishO(value);
   5159   }
   5160   return(r);
   5161 }
   5162 
   5163 internal smallJsont* setAtNFreeSmallIntSmallJson(smallJsont *self, int64_t index, smallIntt *value) {
   5164 
   5165   if (self->topIsA != TOP_IS_ARRAY) {
   5166     return(NULL);
   5167   }
   5168 
   5169   smallJsont *r = setAtSmallIntSmallJson(self, index, value);
   5170   if (r) {
   5171     finishO(value);
   5172   }
   5173   return(r);
   5174 }
   5175 
   5176 internal smallJsont* setAtNFreeSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *value) {
   5177 
   5178   if (self->topIsA != TOP_IS_ARRAY) {
   5179     return(NULL);
   5180   }
   5181 
   5182   smallJsont *r = setAtSmallJsonSmallJson(self, index, value);
   5183   if (r) {
   5184     finishO(value);
   5185   }
   5186   return(r);
   5187 }
   5188 
   5189 internal smallJsont* setAtNFreeSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *string) {
   5190 
   5191   if (self->topIsA != TOP_IS_ARRAY) {
   5192     return(NULL);
   5193   }
   5194 
   5195   smallJsont *r = setAtSmallStringSmallJson(self, index, string);
   5196   if (r) {
   5197     finishO(string);
   5198   }
   5199   return(r);
   5200 }
   5201 
   5202 internal smallJsont* setAtNFreeSmallContainerSmallJson(smallJsont *self, int64_t index, smallContainert *container) {
   5203 
   5204   if (self->topIsA != TOP_IS_ARRAY) {
   5205     return(NULL);
   5206   }
   5207 
   5208   smallJsont *r = setAtSmallContainerSmallJson(self, index, container);
   5209   if (r) {
   5210     finishO(container);
   5211   }
   5212   return(r);
   5213 }
   5214 
   5215 
   5216 internal smallJsont* setPAtDictSmallJson(smallJsont *self, int64_t index, smallDictt *dict) {
   5217 
   5218   if (self->topIsA != TOP_IS_ARRAY || !dict) {
   5219     return(NULL);
   5220   }
   5221 
   5222   if (checkObjectTypes && dict && !isOSmallDict(dict)) {
   5223     return(NULL);
   5224   }
   5225 
   5226   if (index >= (int64_t)lenSmallJson(self)) {
   5227     return(NULL);
   5228   }
   5229   if (index < -(int64_t)lenSmallJson(self)) {
   5230     return(NULL);
   5231   }
   5232   if (index < 0) {
   5233     index = (int64_t)lenSmallJson(self) + index;
   5234   }
   5235 
   5236   if (!dict->d) {
   5237     // realloc error
   5238     return(NULL);
   5239   }
   5240 
   5241   sArraySetP(self->topA, (uint32_t)index, (smallt *)dict->d);
   5242   return(self);
   5243 }
   5244 
   5245 internal smallJsont* setPAtArraySmallJson(smallJsont *self, int64_t index, smallArrayt *array) {
   5246 
   5247   if (self->topIsA != TOP_IS_ARRAY || !array) {
   5248     return(NULL);
   5249   }
   5250 
   5251   if (checkObjectTypes && array && !isOSmallArray(array)) {
   5252     return(NULL);
   5253   }
   5254 
   5255   if (index >= (int64_t)lenSmallJson(self)) {
   5256     return(NULL);
   5257   }
   5258   if (index < -(int64_t)lenSmallJson(self)) {
   5259     return(NULL);
   5260   }
   5261   if (index < 0) {
   5262     index = (int64_t)lenSmallJson(self) + index;
   5263   }
   5264 
   5265   if (!array->a) {
   5266     // realloc error
   5267     return(NULL);
   5268   }
   5269 
   5270   sArraySetP(self->topA, (uint32_t)index, (smallt *)array->a);
   5271   return(self);
   5272 }
   5273 
   5274 internal smallJsont* setPAtSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *value) {
   5275 
   5276   if (self->topIsA != TOP_IS_ARRAY || !value) {
   5277     return(NULL);
   5278   }
   5279 
   5280   if (checkObjectTypes && value && !isOSmallJson(value)) {
   5281     return(NULL);
   5282   }
   5283 
   5284   if (index >= (int64_t)lenSmallJson(self)) {
   5285     return(NULL);
   5286   }
   5287   if (index < -(int64_t)lenSmallJson(self)) {
   5288     return(NULL);
   5289   }
   5290   if (index < 0) {
   5291     index = (int64_t)lenSmallJson(self) + index;
   5292   }
   5293 
   5294   smallt *o;
   5295   o = getsoO(value);
   5296   if (!o) {
   5297     // realloc error
   5298     return(NULL);
   5299   }
   5300   sArraySetP(self->topA, (uint32_t)index, o);
   5301   return(self);
   5302 }
   5303 
   5304 internal smallJsont* setPAtSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *string) {
   5305 
   5306   if (self->topIsA != TOP_IS_ARRAY || !string) {
   5307     return(NULL);
   5308   }
   5309 
   5310   if (checkObjectTypes && string && !isOSmallString(string)) {
   5311     return(NULL);
   5312   }
   5313 
   5314   if (index >= (int64_t)lenSmallJson(self)) {
   5315     return(NULL);
   5316   }
   5317   if (index < -(int64_t)lenSmallJson(self)) {
   5318     return(NULL);
   5319   }
   5320   if (index < 0) {
   5321     index = (int64_t)lenSmallJson(self) + index;
   5322   }
   5323 
   5324   if (!string->data) {
   5325     // realloc error
   5326     return(NULL);
   5327   }
   5328 
   5329   smallt *o = (smallt *) string->data;
   5330   sArraySetP(self->topA, (uint32_t)index, o);
   5331   return(self);
   5332 }
   5333 
   5334 internal smallJsont* setPAtNFreeDictSmallJson(smallJsont *self, int64_t index, smallDictt *dict) {
   5335 
   5336   if (self->topIsA != TOP_IS_ARRAY || !dict) {
   5337     return(NULL);
   5338   }
   5339 
   5340   if (checkObjectTypes && dict && !isOSmallDict(dict)) {
   5341     return(NULL);
   5342   }
   5343 
   5344   if (index >= (int64_t)lenSmallJson(self)) {
   5345     return(NULL);
   5346   }
   5347   if (index < -(int64_t)lenSmallJson(self)) {
   5348     return(NULL);
   5349   }
   5350   if (index < 0) {
   5351     index = (int64_t)lenSmallJson(self) + index;
   5352   }
   5353 
   5354   if (!dict->d) {
   5355     // realloc error
   5356     return(NULL);
   5357   }
   5358 
   5359   sArraySetP(self->topA, (uint32_t)index, (smallt *)dict->d);
   5360   finishO(dict);
   5361   return(self);
   5362 }
   5363 
   5364 
   5365 internal smallJsont* setPAtNFreeArraySmallJson(smallJsont *self, int64_t index, smallArrayt *array) {
   5366 
   5367   if (self->topIsA != TOP_IS_ARRAY || !array) {
   5368     return(NULL);
   5369   }
   5370 
   5371   if (checkObjectTypes && array && !isOSmallArray(array)) {
   5372     return(NULL);
   5373   }
   5374 
   5375   if (index >= (int64_t)lenSmallJson(self)) {
   5376     return(NULL);
   5377   }
   5378   if (index < -(int64_t)lenSmallJson(self)) {
   5379     return(NULL);
   5380   }
   5381   if (index < 0) {
   5382     index = (int64_t)lenSmallJson(self) + index;
   5383   }
   5384 
   5385   if (!array->a) {
   5386     // realloc error
   5387     return(NULL);
   5388   }
   5389 
   5390   sArraySetP(self->topA, (uint32_t)index, (smallt *)array->a);
   5391   finishO(array);
   5392   return(self);
   5393 }
   5394 
   5395 internal smallJsont* setPAtNFreeSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *value) {
   5396 
   5397   if (self->topIsA != TOP_IS_ARRAY || !value) {
   5398     return(NULL);
   5399   }
   5400 
   5401   if (checkObjectTypes && value && !isOSmallJson(value)) {
   5402     return(NULL);
   5403   }
   5404 
   5405   if (index >= (int64_t)lenSmallJson(self)) {
   5406     return(NULL);
   5407   }
   5408   if (index < -(int64_t)lenSmallJson(self)) {
   5409     return(NULL);
   5410   }
   5411   if (index < 0) {
   5412     index = (int64_t)lenSmallJson(self) + index;
   5413   }
   5414 
   5415   smallt *o;
   5416   o = getsoO(value);;
   5417   if (!o) {
   5418     // realloc error
   5419     return(NULL);
   5420   }
   5421   sArraySetP(self->topA, (uint32_t)index, o);
   5422   finishO(value);
   5423   return(self);
   5424 }
   5425 
   5426 internal smallJsont* setPAtNFreeSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *string) {
   5427 
   5428   if (self->topIsA != TOP_IS_ARRAY || !string) {
   5429     return(NULL);
   5430   }
   5431 
   5432   if (checkObjectTypes && string && !isOSmallString(string)) {
   5433     return(NULL);
   5434   }
   5435 
   5436   if (index >= (int64_t)lenSmallJson(self)) {
   5437     return(NULL);
   5438   }
   5439   if (index < -(int64_t)lenSmallJson(self)) {
   5440     return(NULL);
   5441   }
   5442   if (index < 0) {
   5443     index = (int64_t)lenSmallJson(self) + index;
   5444   }
   5445 
   5446   if (!string->data) {
   5447     // realloc error
   5448     return(NULL);
   5449   }
   5450 
   5451   smallt *o = (smallt *) string->data;
   5452   finishO(string);
   5453   sArraySetP(self->topA, (uint32_t)index, o);
   5454   return(self);
   5455 }
   5456 
   5457 internal smallJsont* pushSmallJson(smallJsont *self, baset *value) {
   5458 
   5459   if (!value) {
   5460     return(NULL);
   5461   }
   5462 
   5463   switch(self->topIsA) {
   5464     case SMALLJSON_IS_EMPTY:
   5465       self->topIsA = TOP_IS_ARRAY;
   5466       FALLTHRU;
   5467     case TOP_IS_ARRAY:
   5468       sArrayPushTiny(&(self->topA), toSmallt(value));
   5469       break;
   5470     default:
   5471       return(NULL);
   5472   }
   5473   return(self);
   5474 }
   5475 
   5476 internal smallJsont* pushUndefinedSmallJson(smallJsont *self) {
   5477   smallt *o = NULL;
   5478 
   5479   switch(self->topIsA) {
   5480     case SMALLJSON_IS_EMPTY:
   5481       self->topIsA = TOP_IS_ARRAY;
   5482       FALLTHRU;
   5483     case TOP_IS_ARRAY:
   5484       isError(o, (smallt *) allocSUndefined()) return(NULL);
   5485       sArrayPushTiny(&(self->topA), o);
   5486       break;
   5487     default:
   5488       return(NULL);
   5489   }
   5490   return(self);
   5491 }
   5492 
   5493 internal smallJsont* pushBoolSmallJson(smallJsont *self, bool value) {
   5494   smallt *o = NULL;
   5495 
   5496   switch(self->topIsA) {
   5497     case SMALLJSON_IS_EMPTY:
   5498       self->topIsA = TOP_IS_ARRAY;
   5499       FALLTHRU;
   5500     case TOP_IS_ARRAY:
   5501       isError(o, (smallt *) allocSBool(value)) return(NULL);
   5502       sArrayPushTiny(&(self->topA), o);
   5503       break;
   5504     default:
   5505       return(NULL);
   5506   }
   5507   return(self);
   5508 }
   5509 
   5510 internal smallJsont* pushDoubleSmallJson(smallJsont *self, double value) {
   5511   smallt *o = NULL;
   5512 
   5513   switch(self->topIsA) {
   5514     case SMALLJSON_IS_EMPTY:
   5515       self->topIsA = TOP_IS_ARRAY;
   5516       FALLTHRU;
   5517     case TOP_IS_ARRAY:
   5518       isError(o, (smallt *) allocSDouble(value)) return(NULL);
   5519       sArrayPushTiny(&(self->topA), o);
   5520       break;
   5521     default:
   5522       return(NULL);
   5523   }
   5524   return(self);
   5525 }
   5526 
   5527 internal smallJsont* pushIntSmallJson(smallJsont *self, int64_t value) {
   5528   smallt *o = NULL;
   5529 
   5530   switch(self->topIsA) {
   5531     case SMALLJSON_IS_EMPTY:
   5532       self->topIsA = TOP_IS_ARRAY;
   5533       FALLTHRU;
   5534     case TOP_IS_ARRAY:
   5535       isError(o, (smallt *) allocSInt(value)) return(NULL);
   5536       sArrayPushTiny(&(self->topA), o);
   5537       break;
   5538     default:
   5539       return(NULL);
   5540   }
   5541   return(self);
   5542 }
   5543 
   5544 internal smallJsont* pushSSmallJson(smallJsont *self, const char *string) {
   5545   smallt *o = NULL;
   5546 
   5547   if (!string) {
   5548     return(NULL);
   5549   }
   5550 
   5551   switch(self->topIsA) {
   5552     case SMALLJSON_IS_EMPTY:
   5553       self->topIsA = TOP_IS_ARRAY;
   5554       FALLTHRU;
   5555     case TOP_IS_ARRAY:
   5556       isError(o, (smallt *) allocSStringTiny(string)) return(NULL);
   5557       sArrayPushTiny(&(self->topA), o);
   5558       break;
   5559     case TOP_IS_STRING:;
   5560       size_t len = strlen(string);
   5561 
   5562       if (!self->topS) {
   5563         sStringSetTiny(&self->topS, string);
   5564         //TODO self->_len = len
   5565         return(self);
   5566       }
   5567 
   5568       if (!len) {
   5569         return(self);
   5570       }
   5571 
   5572       char *tmp;
   5573 
   5574       // +1 for 0 at the end +1 for sType at the start
   5575       tmp = realloc(self->topS, lenSmallJson(self) + len + 2);
   5576       if (!tmp) {
   5577         return(self);
   5578       }
   5579 
   5580       self->topS = (sStringt *)tmp;
   5581       strcat((char *)self->topS, string);
   5582       //TODO self->_len += len
   5583       break;
   5584     default:
   5585       return(NULL);
   5586   }
   5587   return(self);
   5588 }
   5589 
   5590 internal smallJsont* pushCharSmallJson(smallJsont *self, char c) {
   5591 
   5592   charToS(s, c);
   5593   return(pushSSmallJson(self, s));
   5594 }
   5595 
   5596 internal smallJsont* pushDictSmallJson(smallJsont *self, smallDictt *dict) {
   5597 
   5598   if (!dict) {
   5599     return(NULL);
   5600   }
   5601 
   5602   if (checkObjectTypes && dict && !isOSmallDict(dict)) {
   5603     return(NULL);
   5604   }
   5605 
   5606   switch(self->topIsA) {
   5607     case SMALLJSON_IS_EMPTY:
   5608       self->topIsA = TOP_IS_ARRAY;
   5609       FALLTHRU;
   5610     case TOP_IS_ARRAY:
   5611       if (!dict->d) {
   5612         isError(dict->d, allocSDict()) return(NULL);
   5613       }
   5614 
   5615       sArrayPushTiny(&(self->topA), (smallt *)dict->d);
   5616       break;
   5617     default:
   5618       return(NULL);
   5619   }
   5620   return(self);
   5621 }
   5622 
   5623 internal smallJsont* pushArraySmallJson(smallJsont *self, smallArrayt *array) {
   5624 
   5625   if (!array) {
   5626     return(NULL);
   5627   }
   5628 
   5629   if (checkObjectTypes && array && !isOSmallArray(array)) {
   5630     return(NULL);
   5631   }
   5632 
   5633   switch(self->topIsA) {
   5634     case SMALLJSON_IS_EMPTY:
   5635       self->topIsA = TOP_IS_ARRAY;
   5636       FALLTHRU;
   5637     case TOP_IS_ARRAY:
   5638       if (!array->a) {
   5639         // allocate empty array
   5640         isError(array->a, allocSArray()) return(NULL);
   5641       }
   5642 
   5643       sArrayPushTiny(&(self->topA), (smallt *)array->a);
   5644       break;
   5645     default:
   5646       return(NULL);
   5647   }
   5648   return(self);
   5649 }
   5650 
   5651 internal smallJsont* pushArraycSmallJson(smallJsont *self, char **array) {
   5652 
   5653   if (!array) {
   5654     return(NULL);
   5655   }
   5656 
   5657   switch(self->topIsA) {
   5658     case SMALLJSON_IS_EMPTY:
   5659       self->topIsA = TOP_IS_ARRAY;
   5660       FALLTHRU;
   5661     case TOP_IS_ARRAY:
   5662       ;sArrayt *a = allocSArray();
   5663       if (!a) {
   5664         return(NULL);
   5665       }
   5666 
   5667       forEachCharP(array, e) {
   5668         sStringt *s = allocSStringTiny(*e);
   5669         if (!s) {
   5670           if (a) {
   5671             sArrayFreeTiny(a);
   5672           }
   5673           return(NULL);
   5674         }
   5675         sArrayPushTiny(&a, (smallt *) s);
   5676       }
   5677       sArrayPushTiny(&(self->topA), (smallt *) a);
   5678       break;
   5679     default:
   5680       return(NULL);
   5681   }
   5682   return(self);
   5683 }
   5684 
   5685 internal smallJsont* pushCArraycSmallJson(smallJsont *self, const char **array) {
   5686 
   5687   if (!array) {
   5688     return(NULL);
   5689   }
   5690 
   5691   switch(self->topIsA) {
   5692     case SMALLJSON_IS_EMPTY:
   5693       self->topIsA = TOP_IS_ARRAY;
   5694       FALLTHRU;
   5695     case TOP_IS_ARRAY:
   5696       ;sArrayt *a = allocSArray();
   5697       if (!a) {
   5698         return(NULL);
   5699       }
   5700 
   5701       forEachCCharP(array, e) {
   5702         sStringt *s = allocSStringTiny(*e);
   5703         if (!s) {
   5704           if (a) {
   5705             sArrayFreeTiny(a);
   5706           }
   5707           return(NULL);
   5708         }
   5709         sArrayPushTiny(&a, (smallt *) s);
   5710       }
   5711       sArrayPushTiny(&(self->topA), (smallt *) a);
   5712       break;
   5713     default:
   5714       return(NULL);
   5715   }
   5716   return(self);
   5717 }
   5718 
   5719 internal smallJsont* pushSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
   5720 
   5721   if (!value) {
   5722     return(NULL);
   5723   }
   5724 
   5725   if (checkObjectTypes && value && !isOSmallBool(value)) {
   5726     return(NULL);
   5727   }
   5728 
   5729   switch(self->topIsA) {
   5730     case SMALLJSON_IS_EMPTY:
   5731       self->topIsA = TOP_IS_ARRAY;
   5732       FALLTHRU;
   5733     case TOP_IS_ARRAY:
   5734       if (!value->value) {
   5735         isError(value->value, allocSBool(false)) return(NULL);
   5736       }
   5737       sArrayPushTiny(&(self->topA), (smallt *) value->value);
   5738       break;
   5739     default:
   5740       return(NULL);
   5741   }
   5742   return(self);
   5743 }
   5744 
   5745 internal smallJsont* pushSmallBytesSmallJson(smallJsont *self, smallBytest *value) {
   5746 
   5747   if (!value) {
   5748     return(NULL);
   5749   }
   5750 
   5751   if (checkObjectTypes && value && !isOSmallBytes(value)) {
   5752     return(NULL);
   5753   }
   5754 
   5755   switch(self->topIsA) {
   5756     case SMALLJSON_IS_EMPTY:
   5757       self->topIsA = TOP_IS_ARRAY;
   5758       FALLTHRU;
   5759     case TOP_IS_ARRAY:
   5760       if (!value->B) {
   5761         isError(value->B, allocSBytes()) return(NULL);
   5762       }
   5763       sArrayPushTiny(&(self->topA), (smallt*) value->B);
   5764       break;
   5765     default:
   5766       return(NULL);
   5767   }
   5768   return(self);
   5769 }
   5770 
   5771 internal smallJsont* pushSmallDoubleSmallJson(smallJsont *self, smallDoublet *value) {
   5772 
   5773   if (!value) {
   5774     return(NULL);
   5775   }
   5776 
   5777   if (checkObjectTypes && value && !isOSmallDouble(value)) {
   5778     return(NULL);
   5779   }
   5780 
   5781   switch(self->topIsA) {
   5782     case SMALLJSON_IS_EMPTY:
   5783       self->topIsA = TOP_IS_ARRAY;
   5784       FALLTHRU;
   5785     case TOP_IS_ARRAY:
   5786       if (!value->value) {
   5787         isError(value->value, allocSDouble(0)) return(NULL);
   5788       }
   5789       sArrayPushTiny(&(self->topA), (smallt *) value->value);
   5790       break;
   5791     default:
   5792       return(NULL);
   5793   }
   5794   return(self);
   5795 }
   5796 
   5797 internal smallJsont* pushSmallIntSmallJson(smallJsont *self, smallIntt *value) {
   5798 
   5799   if (!value) {
   5800     return(NULL);
   5801   }
   5802 
   5803   if (checkObjectTypes && value && !isOSmallInt(value)) {
   5804     return(NULL);
   5805   }
   5806 
   5807   switch(self->topIsA) {
   5808     case SMALLJSON_IS_EMPTY:
   5809       self->topIsA = TOP_IS_ARRAY;
   5810       FALLTHRU;
   5811     case TOP_IS_ARRAY:
   5812       if (!value->value) {
   5813         isError(value->value, allocSInt(0)) return(NULL);
   5814       }
   5815       sArrayPushTiny(&(self->topA), (smallt *) value->value);
   5816       break;
   5817     default:
   5818       return(NULL);
   5819   }
   5820   return(self);
   5821 }
   5822 
   5823 internal smallJsont* pushSmallJsonSmallJson(smallJsont *self, smallJsont *value) {
   5824   smallt *o = NULL;
   5825 
   5826   if (!value) {
   5827     return(NULL);
   5828   }
   5829 
   5830   if (checkObjectTypes && value && !isOSmallJson(value)) {
   5831     return(NULL);
   5832   }
   5833 
   5834   switch(self->topIsA) {
   5835     case SMALLJSON_IS_EMPTY:
   5836       self->topIsA = TOP_IS_ARRAY;
   5837       FALLTHRU;
   5838     case TOP_IS_ARRAY:
   5839       o = getsoO(value);
   5840       if (!o) {
   5841         // smallJson is empty, create an empty dict
   5842         isError(o, (smallt*)allocSDict()) return(NULL);
   5843         setsoO(value, o);
   5844       }
   5845 
   5846       sArrayPushTiny(&(self->topA), o);
   5847       break;
   5848     default:
   5849       return(NULL);
   5850   }
   5851   return(self);
   5852 }
   5853 
   5854 internal smallJsont* pushSmallStringSmallJson(smallJsont *self, smallStringt *string) {
   5855 
   5856   if (!string) {
   5857     return(NULL);
   5858   }
   5859 
   5860   if (checkObjectTypes && string && !isOSmallString(string)) {
   5861     return(NULL);
   5862   }
   5863 
   5864   switch(self->topIsA) {
   5865     case SMALLJSON_IS_EMPTY:
   5866       self->topIsA = TOP_IS_ARRAY;
   5867       FALLTHRU;
   5868     case TOP_IS_ARRAY:
   5869       if (!string->data) {
   5870         isError(string->data, allocSStringTiny("")) return(NULL);
   5871       }
   5872       sArrayPushTiny(&(self->topA), (smallt*) string->data);
   5873       break;
   5874     case TOP_IS_STRING:
   5875       if (!string->data) {
   5876         return(self);
   5877       }
   5878 
   5879       if (!self->topS) {
   5880         self->topS = (sStringt *)strdup((char *)string->data);
   5881         //TODO self->_len = string->_len
   5882         return(self);
   5883       }
   5884 
   5885       if (!string->_len) {
   5886         // empty string
   5887         return(self);
   5888       }
   5889 
   5890       char *tmp;
   5891       // +1 for 0 at the end +1 for sType at the start
   5892       tmp = realloc(self->topS, lenSmallJson(self) + string->_len + 2);
   5893       if (!tmp) {
   5894         return(self);
   5895       }
   5896 
   5897       self->topS = (sStringt *)tmp;
   5898       strcat((char *)self->topS, sStringGetTiny(string->data));
   5899       //TODO self->_len += string->_len
   5900       break;
   5901     default:
   5902       return(NULL);
   5903   }
   5904   return(self);
   5905 }
   5906 
   5907 internal smallJsont* pushSmallContainerSmallJson(smallJsont *self, smallContainert *container) {
   5908 
   5909   if (!container) {
   5910     return(NULL);
   5911   }
   5912 
   5913   if (checkObjectTypes && container && !isOSmallContainer(container)) {
   5914     return(NULL);
   5915   }
   5916 
   5917   switch(self->topIsA) {
   5918     case SMALLJSON_IS_EMPTY:
   5919       self->topIsA = TOP_IS_ARRAY;
   5920       FALLTHRU;
   5921     case TOP_IS_ARRAY:
   5922       if (!container->data) {
   5923         isError(container->data, allocSContainer(NULL)) return(NULL);
   5924       }
   5925       sArrayPushTiny(&(self->topA), (smallt *) container->data);
   5926       break;
   5927     default:
   5928       return(NULL);
   5929   }
   5930   return(self);
   5931 }
   5932 
   5933 internal smallJsont* pushNFreeSmallJson(smallJsont *self, baset *value) {
   5934   smallt *o = NULL;
   5935 
   5936   if (!value) {
   5937     return(NULL);
   5938   }
   5939 
   5940   switch(self->topIsA) {
   5941     case SMALLJSON_IS_EMPTY:
   5942       self->topIsA = TOP_IS_ARRAY;
   5943       FALLTHRU;
   5944     case TOP_IS_ARRAY:
   5945       o = toSmallt(value);
   5946       if (!o) {
   5947         return(NULL);
   5948       }
   5949       sArrayPushTiny(&(self->topA), o);
   5950       break;
   5951     default:
   5952       return(NULL);
   5953   }
   5954   if (!o) {
   5955     return(NULL);
   5956   }
   5957   if (!(o->type == CONTAINER && (((sContainert*)o)->dataType == SH_DT_BASET))) {
   5958     finishO(value);
   5959   }
   5960   return(self);
   5961 }
   5962 
   5963 internal smallJsont* pushNFreeUndefinedSmallJson(smallJsont *self, undefinedt *u) {
   5964 
   5965   smallJsont *r = pushUndefinedSmallJson(self);;
   5966   if (r) {
   5967     terminateO(u);
   5968   }
   5969   return(r);
   5970 }
   5971 
   5972 internal smallJsont* pushNFreeSSmallJson(smallJsont *self, char *string) {
   5973 
   5974   smallJsont *r = pushSSmallJson(self, string);;
   5975   if (r) {
   5976     free(string);
   5977   }
   5978   return(r);
   5979 }
   5980 
   5981 internal smallJsont* pushNFreeDictSmallJson(smallJsont *self, smallDictt *dict) {
   5982 
   5983   smallJsont *r = pushDictSmallJson(self, dict);
   5984   if (r) {
   5985     finishO(dict);
   5986   }
   5987   return(r);
   5988 }
   5989 
   5990 internal smallJsont* pushNFreeArraySmallJson(smallJsont *self, smallArrayt *array) {
   5991 
   5992   smallJsont *r = pushArraySmallJson(self, array);
   5993   if (r) {
   5994     finishO(array);
   5995   }
   5996   return(r);
   5997 }
   5998 
   5999 internal smallJsont* pushNFreeArraycSmallJson(smallJsont *self, char **array) {
   6000 
   6001   smallJsont *r = pushArraycSmallJson(self, array);;
   6002   if (r) {
   6003     listFreeS(array);
   6004   }
   6005   return(r);
   6006 }
   6007 
   6008 internal smallJsont* pushNFreeSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
   6009 
   6010   smallJsont *r = pushSmallBoolSmallJson(self, value);
   6011   if (r) {
   6012     finishO(value);
   6013   }
   6014   return(r);
   6015 }
   6016 
   6017 internal smallJsont* pushNFreeSmallBytesSmallJson(smallJsont *self, smallBytest *value) {
   6018 
   6019   smallJsont *r = pushSmallBytesSmallJson(self, value);
   6020   if (r) {
   6021     finishO(value);
   6022   }
   6023   return(r);
   6024 }
   6025 
   6026 internal smallJsont* pushNFreeSmallDoubleSmallJson(smallJsont *self, smallDoublet *value) {
   6027 
   6028   smallJsont *r = pushSmallDoubleSmallJson(self, value);
   6029   if (r) {
   6030     finishO(value);
   6031   }
   6032   return(r);
   6033 }
   6034 
   6035 internal smallJsont* pushNFreeSmallIntSmallJson(smallJsont *self, smallIntt *value) {
   6036 
   6037   smallJsont *r = pushSmallIntSmallJson(self, value);
   6038   if (r) {
   6039     finishO(value);
   6040   }
   6041   return(r);
   6042 }
   6043 
   6044 internal smallJsont* pushNFreeSmallJsonSmallJson(smallJsont *self, smallJsont *value) {
   6045 
   6046   smallJsont *r = pushSmallJsonSmallJson(self, value);
   6047   if (r) {
   6048     finishO(value);
   6049   }
   6050   return(r);
   6051 }
   6052 
   6053 internal smallJsont* pushNFreeSmallStringSmallJson(smallJsont *self, smallStringt *string) {
   6054 
   6055   smallJsont *r = pushSmallStringSmallJson(self, string);
   6056   if (r) {
   6057     finishO(string);
   6058   }
   6059   return(r);
   6060 }
   6061 
   6062 internal smallJsont* pushNFreeSmallContainerSmallJson(smallJsont *self, smallContainert *container) {
   6063 
   6064   smallJsont *r = pushSmallContainerSmallJson(self, container);
   6065   if (r) {
   6066     finishO(container);
   6067   }
   6068   return(r);
   6069 }
   6070 
   6071 internal smallJsont* pushManySmallJson(smallJsont *self, ...) {
   6072 
   6073   switch(self->topIsA) {
   6074     case SMALLJSON_IS_EMPTY:
   6075       self->topIsA = TOP_IS_ARRAY;
   6076       FALLTHRU;
   6077     case TOP_IS_ARRAY:
   6078       ;va_list pl;
   6079       baset *paramType;
   6080 
   6081       // add arguments to a list
   6082       va_start(pl, self);
   6083       paramType = va_arg(pl, baset*);
   6084       while (paramType) {
   6085         smallJsont *r = pushSmallJson(self, paramType);
   6086         if (!r) {
   6087           va_end(pl);
   6088           return(NULL);
   6089         }
   6090         paramType = va_arg(pl, baset*);
   6091       }
   6092       va_end(pl);
   6093       break;
   6094     case TOP_IS_STRING:
   6095       ;va_list pls;
   6096       smallStringt *paramTypes;
   6097 
   6098       createSmallArray(l);
   6099       if (!l.f) {
   6100         return(NULL);
   6101       }
   6102       if (self->topS) {
   6103         // add self to result
   6104         createSmallString(ss);
   6105         ss.data = self->topS;
   6106         l.f->pushSmallString(&l, &ss);
   6107       }
   6108 
   6109       // add arguments to a list
   6110       va_start(pls, self);
   6111       paramTypes = va_arg(pls, smallStringt*);
   6112       while (paramTypes) {
   6113         if (checkObjectTypes && !isOSmallString(paramTypes)) {
   6114           disposeO(&l);
   6115           va_end(pls);
   6116           return(NULL);
   6117         }
   6118         l.f->pushSmallString(&l, paramTypes);
   6119         paramTypes = va_arg(pls, smallStringt*);
   6120       }
   6121       va_end(pls);
   6122       // join list with empty delimiter
   6123       smallStringt *r = l.f->join(&l, "");
   6124       free(self->topS);
   6125       self->topS = r->data;
   6126       //TODO self->_len = r->_len
   6127       finishO(r);
   6128       disposeO(&l);
   6129       break;
   6130     default:;
   6131       // self type doesn't support push, TODO return NULL to signal error
   6132   }
   6133   return(self);
   6134 }
   6135 
   6136 internal smallJsont* pushManySSmallJson(smallJsont *self, ...) {
   6137 
   6138   switch(self->topIsA) {
   6139     case SMALLJSON_IS_EMPTY:
   6140       self->topIsA = TOP_IS_ARRAY;
   6141       FALLTHRU;
   6142     case TOP_IS_ARRAY:
   6143       ;va_list pl;
   6144       char *paramType;
   6145 
   6146       // add arguments to a list
   6147       va_start(pl, self);
   6148       paramType = va_arg(pl, char*);
   6149       while (paramType) {
   6150         smallJsont *r = pushSSmallJson(self, paramType);
   6151         if (!r) {
   6152           va_end(pl);
   6153           return(NULL);
   6154         }
   6155         paramType = va_arg(pl, char*);
   6156       }
   6157       va_end(pl);
   6158       break;
   6159     case TOP_IS_STRING:
   6160       ;va_list pls;
   6161       char *paramTypes;
   6162 
   6163       createSmallArray(l);
   6164       if (!l.f) {
   6165         return(NULL);
   6166       }
   6167       if (self->topS) {
   6168         // add self to result
   6169         createSmallString(ss);
   6170         ss.data = self->topS;
   6171         l.f->pushSmallString(&l, &ss);
   6172       }
   6173 
   6174       // add arguments to a list
   6175       va_start(pls, self);
   6176       paramTypes = va_arg(pls, char *);
   6177       while (paramTypes) {
   6178         l.f->pushS(&l, (char *)paramTypes);
   6179         paramTypes = va_arg(pls, char *);
   6180       }
   6181       va_end(pls);
   6182       // join list with empty delimiter
   6183       smallStringt *r = l.f->join(&l, "");
   6184       self->topS = r->data;
   6185       //TODO self->_len = r->_len
   6186       finishO(r);
   6187       freeO(&l);
   6188       break;
   6189     default:;
   6190       // self type doesn't support push, TODO return NULL to signal error
   6191   }
   6192   return(self);
   6193 }
   6194 
   6195 internal smallJsont* pushNFreeManySmallJson(smallJsont *self, ...) {
   6196 
   6197   switch(self->topIsA) {
   6198     case SMALLJSON_IS_EMPTY:
   6199       self->topIsA = TOP_IS_ARRAY;
   6200       FALLTHRU;
   6201     case TOP_IS_ARRAY:
   6202       ;va_list pl;
   6203       baset *paramType;
   6204 
   6205       // add arguments to a list
   6206       va_start(pl, self);
   6207       paramType = va_arg(pl, baset*);
   6208       while (paramType) {
   6209         smallJsont *r = pushNFreeSmallJson(self, paramType);
   6210         if (!r) {
   6211           va_end(pl);
   6212           return(NULL);
   6213         }
   6214         paramType = va_arg(pl, baset*);
   6215       }
   6216       va_end(pl);
   6217       break;
   6218     case TOP_IS_STRING:
   6219       ;va_list pls;
   6220       smallStringt *paramTypes;
   6221 
   6222       createSmallArray(l);
   6223       if (!l.f) {
   6224         return(NULL);
   6225       }
   6226       if (self->topS) {
   6227         // add self to result
   6228         createSmallString(ss);
   6229         ss.data = self->topS;
   6230         l.f->pushSmallString(&l, &ss);
   6231       }
   6232 
   6233       // TODO free parameters after all have been added to the l array without error
   6234       // add arguments to a list
   6235       va_start(pls, self);
   6236       paramTypes = va_arg(pls, smallStringt*);
   6237       while (paramTypes) {
   6238         if (checkObjectTypes && !isOSmallString(paramTypes)) {
   6239           delO(&l, 1, 0);
   6240           disposeO(&l);
   6241           return(NULL);
   6242         }
   6243         l.f->pushNFreeSmallString(&l, paramTypes);
   6244         paramTypes = va_arg(pls, smallStringt*);
   6245       }
   6246       va_end(pls);
   6247       // join list with empty delimiter
   6248       smallStringt *r = l.f->join(&l, "");
   6249       freeO(&l);
   6250       self->topS = r->data;
   6251       //TODO self->_len = r->_len
   6252       finishO(r);
   6253       break;
   6254     default:;
   6255       // self type doesn't support push, TODO return NULL to signal error
   6256   }
   6257   return(self);
   6258 }
   6259 
   6260 internal smallJsont* pushNFreeManySSmallJson(smallJsont *self, ...) {
   6261 
   6262   switch(self->topIsA) {
   6263     case SMALLJSON_IS_EMPTY:
   6264       self->topIsA = TOP_IS_ARRAY;
   6265       FALLTHRU;
   6266     case TOP_IS_ARRAY:
   6267       ;va_list pl;
   6268       char *paramType;
   6269 
   6270       // add arguments to a list
   6271       va_start(pl, self);
   6272       paramType = va_arg(pl, char*);
   6273       while (paramType) {
   6274         smallJsont *r = pushNFreeSSmallJson(self, paramType);
   6275         if (!r) {
   6276           va_end(pl);
   6277           return(NULL);
   6278         }
   6279         paramType = va_arg(pl, char*);
   6280       }
   6281       va_end(pl);
   6282       break;
   6283     case TOP_IS_STRING:
   6284       ;va_list pls;
   6285       char *paramTypes;
   6286 
   6287       createSmallArray(l);
   6288       if (!l.f) {
   6289         return(NULL);
   6290       }
   6291       if (self->topS) {
   6292         // add self to result
   6293         createSmallString(ss);
   6294         ss.data = self->topS;
   6295         l.f->pushSmallString(&l, &ss);
   6296       }
   6297 
   6298       // add arguments to a list
   6299       va_start(pls, self);
   6300       paramTypes = va_arg(pls, char *);
   6301       while (paramTypes) {
   6302         l.f->pushNFreeS(&l, (char *)paramTypes);
   6303         paramTypes = va_arg(pls, char *);
   6304       }
   6305       va_end(pls);
   6306       // join list with empty delimiter
   6307       smallStringt *r = l.f->join(&l, "");
   6308       self->topS = r->data;
   6309       //TODO self->_len = r->_len
   6310       finishO(r);
   6311       freeO(&l);
   6312       break;
   6313     default:;
   6314       // self type doesn't support push, TODO return NULL to signal error
   6315   }
   6316   return(self);
   6317 }
   6318 
   6319 internal baset* popSmallJson(smallJsont *self) {
   6320   size_t len;
   6321   smallt *o = NULL;
   6322 
   6323   if (self->topIsA != TOP_IS_ARRAY) {
   6324     return(NULL);
   6325   }
   6326 
   6327   len = lenSmallJson(self);
   6328   if (!len) {
   6329     return(NULL);
   6330   }
   6331 
   6332   for (size_t i = len ; i != 0 ; i--) {
   6333     o = sArrayPopTiny(self->topA);
   6334     if (o) {
   6335       break;
   6336   }
   6337     }
   6338 
   6339   if (!o) {
   6340     return(NULL);
   6341   }
   6342 
   6343   if (o->type == UNDEFINED) {
   6344     free(o);
   6345     return((baset*) allocUndefined());
   6346   }
   6347   else if (o->type == CONTAINER) {
   6348     cast(sContainert*, sc, o);
   6349     if (sc->dataType == SH_DT_BASET) {
   6350       // baset object in stored in the container, free the container since
   6351       // it was allocated automatically in the toSmallt function in libsheepyObject.c
   6352       baset *r = toBaset(o);
   6353       free(o);
   6354       return(r);
   6355   }
   6356     }
   6357   return(toBaset(o));
   6358 }
   6359 
   6360 internal undefinedt* popUndefinedSmallJson(smallJsont *self) {
   6361   size_t len;
   6362   smallt *o = NULL;
   6363 
   6364   if (self->topIsA != TOP_IS_ARRAY) {
   6365     return(NULL);
   6366   }
   6367 
   6368   len = lenSmallJson(self);
   6369   if (!len) {
   6370     return(NULL);
   6371   }
   6372 
   6373   for (size_t i = len ; i != 0 ; i--) {
   6374     o = sArrayGetTiny(self->topA, self->topA->count -1);
   6375     if (o) {
   6376       break;
   6377     }
   6378     self->topA->count--;
   6379   }
   6380 
   6381   if (!o) {
   6382     return(NULL);
   6383   }
   6384 
   6385   if (o->type != UNDEFINED) {
   6386     return(NULL);
   6387   }
   6388 
   6389   // finish poping
   6390   free(o);
   6391   self->topA->count--;
   6392   return(allocUndefined());
   6393 }
   6394 
   6395 internal bool popBoolSmallJson(smallJsont *self) {
   6396   smallBoolt *e = NULL;
   6397   bool r = false;;
   6398 
   6399   e = popSmallBoolSmallJson(self);
   6400   if (e) {
   6401     r = e->f->get(e);
   6402     terminateO(e);
   6403   }
   6404   return(r);
   6405 }
   6406 
   6407 internal double popDoubleSmallJson(smallJsont *self) {
   6408   smallDoublet *e = NULL;
   6409   double r = 0;;
   6410 
   6411   e = popSmallDoubleSmallJson(self);
   6412   if (e) {
   6413     r = e->f->get(e);
   6414     terminateO(e);
   6415   }
   6416   return(r);
   6417 }
   6418 
   6419 internal int64_t popIntSmallJson(smallJsont *self) {
   6420   smallIntt *e = NULL;
   6421   int64_t r = 0;;
   6422 
   6423   e = popSmallIntSmallJson(self);
   6424   if (e) {
   6425     r = e->f->get(e);
   6426     terminateO(e);
   6427   }
   6428   return(r);
   6429 }
   6430 
   6431 internal int32_t popInt32SmallJson(smallJsont *self) {
   6432   smallIntt *e = NULL;
   6433   int32_t r = 0;;
   6434 
   6435   e = popSmallIntSmallJson(self);
   6436   if (e) {
   6437     r = (int32_t)e->f->get(e);
   6438     terminateO(e);
   6439   }
   6440   return(r);
   6441 }
   6442 
   6443 internal uint64_t popUintSmallJson(smallJsont *self) {
   6444   smallIntt *e = NULL;
   6445   uint64_t r = 0;;
   6446 
   6447   e = popSmallIntSmallJson(self);
   6448   if (e) {
   6449     r = (uint64_t)e->f->get(e);
   6450     terminateO(e);
   6451   }
   6452   return(r);
   6453 }
   6454 
   6455 internal uint32_t popUint32SmallJson(smallJsont *self) {
   6456   smallIntt *e = NULL;
   6457   uint32_t r = 0;;
   6458 
   6459   e = popSmallIntSmallJson(self);
   6460   if (e) {
   6461     r = (uint32_t)e->f->get(e);
   6462     terminateO(e);
   6463   }
   6464   return(r);
   6465 }
   6466 
   6467 internal char* popSSmallJson(smallJsont *self) {
   6468   smallStringt *e = NULL;
   6469   char* r = NULL;
   6470 
   6471   e = popSmallStringSmallJson(self);
   6472   if (e) {
   6473     r = e->f->toString(e);
   6474     terminateO(e);
   6475   }
   6476   return(r);
   6477 }
   6478 
   6479 internal smallDictt* popDictSmallJson(smallJsont *self) {
   6480   size_t len;
   6481   smallt *o = NULL;
   6482 
   6483   if (self->topIsA != TOP_IS_ARRAY) {
   6484     return(NULL);
   6485   }
   6486 
   6487   len = lenSmallJson(self);
   6488   if (!len) {
   6489     return(NULL);
   6490   }
   6491 
   6492   for (size_t i = len ; i != 0 ; i--) {
   6493     o = sArrayGetTiny(self->topA, self->topA->count -1);
   6494     if (o) {
   6495       break;
   6496     }
   6497     self->topA->count--;
   6498   }
   6499 
   6500   if (!o) {
   6501     return(NULL);
   6502   }
   6503 
   6504   if (o->type != DICT) {
   6505     return(NULL);
   6506   }
   6507 
   6508   // finish poping
   6509   self->topA->count--;
   6510   return((smallDictt*)toBaset(o));
   6511 }
   6512 
   6513 internal smallArrayt* popArraySmallJson(smallJsont *self) {
   6514   size_t len;
   6515   smallt *o = NULL;
   6516 
   6517   if (self->topIsA != TOP_IS_ARRAY) {
   6518     return(NULL);
   6519   }
   6520 
   6521   len = lenSmallJson(self);
   6522   if (!len) {
   6523     return(NULL);
   6524   }
   6525 
   6526   for (size_t i = len ; i != 0 ; i--) {
   6527     o = sArrayGetTiny(self->topA, self->topA->count -1);
   6528     if (o) {
   6529       break;
   6530     }
   6531     self->topA->count--;
   6532   }
   6533 
   6534   if (!o) {
   6535     return(NULL);
   6536   }
   6537 
   6538   if (o->type != ARRAY) {
   6539     return(NULL);
   6540   }
   6541 
   6542   // finish poping
   6543   self->topA->count--;
   6544   return((smallArrayt*)toBaset(o));
   6545 }
   6546 
   6547 internal smallBoolt* popSmallBoolSmallJson(smallJsont *self) {
   6548   size_t len;
   6549   smallt *o = NULL;
   6550 
   6551   if (self->topIsA != TOP_IS_ARRAY) {
   6552     return(NULL);
   6553   }
   6554 
   6555   len = lenSmallJson(self);
   6556   if (!len) {
   6557     return(NULL);
   6558   }
   6559 
   6560   for (size_t i = len ; i != 0 ; i--) {
   6561     o = sArrayGetTiny(self->topA, self->topA->count -1);
   6562     if (o) {
   6563       break;
   6564     }
   6565     self->topA->count--;
   6566   }
   6567 
   6568   if (!o) {
   6569     return(NULL);
   6570   }
   6571 
   6572   if (o->type != BOOL) {
   6573     return(NULL);
   6574   }
   6575 
   6576   // finish poping
   6577   self->topA->count--;
   6578   return((smallBoolt*)toBaset(o));
   6579 }
   6580 
   6581 internal smallBytest* popSmallBytesSmallJson(smallJsont *self) {
   6582   size_t len;
   6583   smallt *o = NULL;
   6584 
   6585   if (self->topIsA != TOP_IS_ARRAY) {
   6586     return(NULL);
   6587   }
   6588 
   6589   len = lenSmallJson(self);
   6590   if (!len) {
   6591     return(NULL);
   6592   }
   6593 
   6594   for (size_t i = len ; i != 0 ; i--) {
   6595     o = sArrayGetTiny(self->topA, self->topA->count -1);
   6596     if (o) {
   6597       break;
   6598     }
   6599     self->topA->count--;
   6600   }
   6601 
   6602   if (!o) {
   6603     return(NULL);
   6604   }
   6605 
   6606   if (o->type != BYTES) {
   6607     return(NULL);
   6608   }
   6609 
   6610   // finish poping
   6611   self->topA->count--;
   6612   return((smallBytest*)toBaset(o));
   6613 }
   6614 
   6615 internal smallDoublet* popSmallDoubleSmallJson(smallJsont *self) {
   6616   size_t len;
   6617   smallt *o = NULL;
   6618 
   6619   if (self->topIsA != TOP_IS_ARRAY) {
   6620     return(NULL);
   6621   }
   6622 
   6623   len = lenSmallJson(self);
   6624   if (!len) {
   6625     return(NULL);
   6626   }
   6627 
   6628   for (size_t i = len ; i != 0 ; i--) {
   6629     o = sArrayGetTiny(self->topA, self->topA->count -1);
   6630     if (o) {
   6631       break;
   6632     }
   6633     self->topA->count--;
   6634   }
   6635 
   6636   if (!o) {
   6637     return(NULL);
   6638   }
   6639 
   6640   if (o->type != DOUBLE) {
   6641     return(NULL);
   6642   }
   6643 
   6644   // finish poping
   6645   self->topA->count--;
   6646   return((smallDoublet*)toBaset(o));
   6647 }
   6648 
   6649 internal smallIntt* popSmallIntSmallJson(smallJsont *self) {
   6650   size_t len;
   6651   smallt *o = NULL;
   6652 
   6653   if (self->topIsA != TOP_IS_ARRAY) {
   6654     return(NULL);
   6655   }
   6656 
   6657   len = lenSmallJson(self);
   6658   if (!len) {
   6659     return(NULL);
   6660   }
   6661 
   6662   for (size_t i = len ; i != 0 ; i--) {
   6663     o = sArrayGetTiny(self->topA, self->topA->count -1);
   6664     if (o) {
   6665       break;
   6666     }
   6667     self->topA->count--;
   6668   }
   6669 
   6670   if (!o) {
   6671     return(NULL);
   6672   }
   6673 
   6674   if (o->type != INT) {
   6675     return(NULL);
   6676   }
   6677 
   6678   // finish poping
   6679   self->topA->count--;
   6680   return((smallIntt*)toBaset(o));
   6681 }
   6682 
   6683 internal smallJsont* popSmallJsonSmallJson(smallJsont *self) {
   6684   size_t len;
   6685   smallt *o = NULL;
   6686 
   6687   if (self->topIsA != TOP_IS_ARRAY) {
   6688     return(NULL);
   6689   }
   6690 
   6691   len = lenSmallJson(self);
   6692   if (!len) {
   6693     return(NULL);
   6694   }
   6695 
   6696   for (size_t i = len ; i != 0 ; i--) {
   6697     o = sArrayGetTiny(self->topA, self->topA->count -1);
   6698     if (o) {
   6699       break;
   6700     }
   6701     self->topA->count--;
   6702   }
   6703 
   6704   if (!o) {
   6705     return(NULL);
   6706   }
   6707 
   6708   if ((o->type == BYTES) || (o->type == CONTAINER)) {
   6709     return(NULL);
   6710   }
   6711 
   6712   // finish poping
   6713   self->topA->count--;
   6714 
   6715   baset *e = toBaset(o);
   6716 
   6717   createAllocateSmallJson(r);
   6718   if (!r) {
   6719     finishO(e);
   6720     return(NULL);
   6721   }
   6722   setTopNFreeSmallJson(r, e);
   6723   return(r);
   6724 }
   6725 
   6726 internal smallStringt* popSmallStringSmallJson(smallJsont *self) {
   6727   size_t len;
   6728   smallt *o = NULL;
   6729 
   6730   if (self->topIsA != TOP_IS_ARRAY) {
   6731     return(NULL);
   6732   }
   6733 
   6734   len = lenSmallJson(self);
   6735   if (!len) {
   6736     return(NULL);
   6737   }
   6738 
   6739   for (size_t i = len ; i != 0 ; i--) {
   6740     o = sArrayGetTiny(self->topA, self->topA->count -1);
   6741     if (o) {
   6742       break;
   6743     }
   6744     self->topA->count--;
   6745   }
   6746 
   6747   if (!o) {
   6748     return(NULL);
   6749   }
   6750 
   6751   if (o->type != STRING) {
   6752     return(NULL);
   6753   }
   6754 
   6755   // finish poping
   6756   self->topA->count--;
   6757   return((smallStringt*)toBaset(o));
   6758 }
   6759 
   6760 internal void* popVoidSmallJson(smallJsont *self) {
   6761   smallContainert *e = NULL;
   6762   void* r = NULL;
   6763 
   6764   e = popSmallContainerSmallJson(self);
   6765   if (e) {
   6766     r = e->f->get(e);
   6767     smashO(e);
   6768   }
   6769   return(r);
   6770 }
   6771 
   6772 internal smallContainert* popSmallContainerSmallJson(smallJsont *self) {
   6773   size_t len;
   6774   smallt *o = NULL;
   6775 
   6776   if (self->topIsA != TOP_IS_ARRAY) {
   6777     return(NULL);
   6778   }
   6779 
   6780   len = lenSmallJson(self);
   6781   if (!len) {
   6782     return(NULL);
   6783   }
   6784 
   6785   for (size_t i = len ; i != 0 ; i--) {
   6786     o = sArrayGetTiny(self->topA, self->topA->count -1);
   6787     if (o) {
   6788       break;
   6789     }
   6790     self->topA->count--;
   6791   }
   6792 
   6793   if (!o) {
   6794     return(NULL);
   6795   }
   6796 
   6797   if (o->type != CONTAINER) {
   6798     return(NULL);
   6799   }
   6800 
   6801   if (((sContainert*)o)->dataType == SH_DT_BASET) {
   6802     return(NULL);
   6803   }
   6804 
   6805   // finish poping
   6806   self->topA->count--;
   6807   return((smallContainert*)toBaset(o));
   6808 }
   6809 
   6810 internal double popNumSmallJson(smallJsont *self) {
   6811   size_t len;
   6812   smallt *o = NULL;
   6813 
   6814   if (self->topIsA != TOP_IS_ARRAY) {
   6815     return(0);
   6816   }
   6817 
   6818   len = lenSmallJson(self);
   6819   if (!len) {
   6820     return(0);
   6821   }
   6822 
   6823   for (size_t i = len ; i != 0 ; i--) {
   6824     o = sArrayGetTiny(self->topA, self->topA->count -1);
   6825     if (o) {
   6826       break;
   6827     }
   6828     self->topA->count--;
   6829   }
   6830 
   6831   if (!o) {
   6832     return(0);
   6833   }
   6834 
   6835   if (o->type != INT && o->type != DOUBLE) {
   6836     return(0);
   6837   }
   6838 
   6839   baset *e = toBaset(o);
   6840 
   6841   // finish poping
   6842   self->topA->count--;
   6843 
   6844   double r = 0;
   6845   if (isOSmallDouble(e)) {
   6846     r = getValO((smallDoublet*)e);
   6847   }
   6848   elif (isOSmallInt(e)) {
   6849     r = (double)getValO((smallIntt*)e);
   6850   }
   6851   terminateO(e);
   6852   return(r);
   6853 }
   6854 
   6855 
   6856 internal smallJsont* prependSmallJson(smallJsont *self, baset *value) {
   6857   smallt *o = NULL;
   6858 
   6859   if (!value) {
   6860     return(NULL);
   6861   }
   6862 
   6863   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   6864     return(NULL);
   6865   }
   6866 
   6867   o = toSmallt(value);;
   6868   if (!o) {
   6869     return(NULL);
   6870   }
   6871 
   6872   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   6873     self->topIsA = TOP_IS_ARRAY;
   6874   }
   6875 
   6876   sArrayPrependTiny(&(self->topA), o);
   6877   return(self);
   6878 }
   6879 
   6880 internal smallJsont* prependUndefinedSmallJson(smallJsont *self) {
   6881   smallt *o = NULL;
   6882 
   6883   switch(self->topIsA) {
   6884     case SMALLJSON_IS_EMPTY:
   6885       self->topIsA = TOP_IS_ARRAY;
   6886       FALLTHRU;
   6887     case TOP_IS_ARRAY:
   6888       isError(o, (smallt *) allocSUndefined()) return(NULL);
   6889       sArrayPrependTiny(&(self->topA), o);
   6890       break;
   6891     default:
   6892       return(NULL);
   6893   }
   6894   return(self);
   6895 }
   6896 
   6897 internal smallJsont* prependBoolSmallJson(smallJsont *self, bool value) {
   6898 
   6899   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   6900     return(NULL);
   6901   }
   6902 
   6903   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   6904     self->topIsA = TOP_IS_ARRAY;
   6905   }
   6906 
   6907   smallt *o = (smallt *) allocSBool(value);
   6908   if (!o) {
   6909     return(NULL);
   6910   }
   6911   sArrayPrependTiny(&(self->topA), o);
   6912   return(self);
   6913 }
   6914 
   6915 internal smallJsont* prependDoubleSmallJson(smallJsont *self, double value) {
   6916 
   6917   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   6918     return(NULL);
   6919   }
   6920 
   6921   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   6922     self->topIsA = TOP_IS_ARRAY;
   6923   }
   6924 
   6925   smallt *o = (smallt *) allocSDouble(value);
   6926   if (!o) {
   6927     return(NULL);
   6928   }
   6929   sArrayPrependTiny(&(self->topA), o);
   6930   return(self);
   6931 }
   6932 
   6933 internal smallJsont* prependIntSmallJson(smallJsont *self, int64_t value) {
   6934 
   6935   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   6936     return(NULL);
   6937   }
   6938 
   6939   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   6940     self->topIsA = TOP_IS_ARRAY;
   6941   }
   6942 
   6943   smallt *o = (smallt *) allocSInt(value);
   6944   if (!o) {
   6945     return(NULL);
   6946   }
   6947   sArrayPrependTiny(&(self->topA), o);
   6948   return(self);
   6949 }
   6950 
   6951 internal smallJsont* prependSSmallJson(smallJsont *self, const char *string) {
   6952 
   6953   if (!string) {
   6954     return(NULL);
   6955   }
   6956 
   6957   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY && self->topIsA != TOP_IS_STRING) {
   6958     return(NULL);
   6959   }
   6960 
   6961   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   6962     self->topIsA = TOP_IS_ARRAY;
   6963   }
   6964 
   6965   switch(self->topIsA) {
   6966     case TOP_IS_ARRAY:;
   6967       smallt *o;
   6968       isError(o, (smallt *) allocSStringTiny(string)) return(NULL);
   6969       sArrayPrependTiny(&(self->topA), o);
   6970       break;
   6971     case TOP_IS_STRING:
   6972       ;size_t len = strlen(string);
   6973 
   6974       if (!self->topS) {
   6975         sStringSetTiny(&self->topS, string);
   6976         //TODO self->_len = len
   6977         return(self);
   6978       }
   6979 
   6980       if (!len) {
   6981         // empty string
   6982         return(self);
   6983       }
   6984 
   6985       insertSSmallJson(self, 0, string);
   6986       break;
   6987     default:;
   6988       // not reachable
   6989       logC("Check this function!");
   6990   }
   6991   return(self);
   6992 }
   6993 
   6994 internal smallJsont* prependCharSmallJson(smallJsont *self, char c) {
   6995 
   6996   charToS(s, c);
   6997   return(prependSSmallJson(self, s));
   6998 }
   6999 
   7000 internal smallJsont* prependDictSmallJson(smallJsont *self, smallDictt *dict) {
   7001 
   7002   if (!dict) {
   7003     return(NULL);
   7004   }
   7005 
   7006   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   7007     return(NULL);
   7008   }
   7009 
   7010   if (checkObjectTypes && dict && !isOSmallDict(dict)) {
   7011     return(NULL);
   7012   }
   7013 
   7014   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   7015     self->topIsA = TOP_IS_ARRAY;
   7016   }
   7017 
   7018   if (!dict->d) {
   7019     isError(dict->d, allocSDict()) return(NULL);
   7020   }
   7021 
   7022   sArrayPrependTiny(&(self->topA), (smallt *)dict->d);
   7023   return(self);
   7024 }
   7025 
   7026 
   7027 internal smallJsont* prependArraySmallJson(smallJsont *self, smallArrayt *array) {
   7028 
   7029   if (!array) {
   7030     return(NULL);
   7031   }
   7032 
   7033   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   7034     return(NULL);
   7035   }
   7036 
   7037   if (checkObjectTypes && array && !isOSmallArray(array)) {
   7038     return(NULL);
   7039   }
   7040 
   7041   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   7042     self->topIsA = TOP_IS_ARRAY;
   7043   }
   7044 
   7045   if (!array->a) {
   7046     // allocate empty array
   7047     isError(array->a, allocSArray()) return(NULL);
   7048   }
   7049 
   7050   sArrayPrependTiny(&(self->topA), (smallt *)array->a);
   7051   return(self);
   7052 }
   7053 
   7054 internal smallJsont* prependArraycSmallJson(smallJsont *self, char **array) {
   7055 
   7056   if (!array) {
   7057     return(NULL);
   7058   }
   7059 
   7060   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   7061     return(NULL);
   7062   }
   7063 
   7064   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   7065     self->topIsA = TOP_IS_ARRAY;
   7066   }
   7067 
   7068   sArrayt *a = allocSArray();
   7069   if (!a) {
   7070     return(NULL);
   7071   }
   7072 
   7073   forEachCharP(array, e) {
   7074     sStringt *s = allocSStringTiny(*e);
   7075     if (!s) {
   7076       if ((a)) {
   7077         sArrayFreeTiny(a);
   7078       }
   7079       return(NULL);
   7080     }
   7081     sArrayPushTiny(&a, (smallt *) s);
   7082   }
   7083   sArrayPrependTiny(&(self->topA), (smallt *) a);
   7084   return(self);
   7085 }
   7086 
   7087 internal smallJsont* prependCArraycSmallJson(smallJsont *self, const char **array) {
   7088 
   7089   if (!array) {
   7090     return(NULL);
   7091   }
   7092 
   7093   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   7094     return(NULL);
   7095   }
   7096 
   7097   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   7098     self->topIsA = TOP_IS_ARRAY;
   7099   }
   7100 
   7101   sArrayt *a = allocSArray();
   7102   if (!a) {
   7103     return(NULL);
   7104   }
   7105 
   7106   forEachCCharP(array, e) {
   7107     sStringt *s = allocSStringTiny(*e);
   7108     if (!s) {
   7109       if ((a)) {
   7110         sArrayFreeTiny(a);
   7111       }
   7112       return(NULL);
   7113     }
   7114     sArrayPushTiny(&a, (smallt *) s);
   7115   }
   7116   sArrayPrependTiny(&(self->topA), (smallt *) a);
   7117   return(self);
   7118 }
   7119 
   7120 internal smallJsont* prependSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
   7121 
   7122   if (!value) {
   7123     return(NULL);
   7124   }
   7125 
   7126   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   7127     return(NULL);
   7128   }
   7129 
   7130   if (checkObjectTypes && value && !isOSmallBool(value)) {
   7131     return(NULL);
   7132   }
   7133 
   7134   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   7135     self->topIsA = TOP_IS_ARRAY;
   7136   }
   7137 
   7138   if (!value->value) {
   7139     isError(value->value, allocSBool(false)) return(NULL);
   7140   }
   7141   sArrayPrependTiny(&(self->topA), (smallt *) value->value);
   7142   return(self);
   7143 }
   7144 
   7145 internal smallJsont* prependSmallBytesSmallJson(smallJsont *self, smallBytest *value) {
   7146 
   7147   if (!value) {
   7148     return(NULL);
   7149   }
   7150 
   7151   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   7152     return(NULL);
   7153   }
   7154 
   7155   if (checkObjectTypes && value && !isOSmallBytes(value)) {
   7156     return(NULL);
   7157   }
   7158 
   7159   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   7160     self->topIsA = TOP_IS_ARRAY;
   7161   }
   7162 
   7163   if (!value->B) {
   7164     isError(value->B, allocSBytes()) return(NULL);
   7165   }
   7166   sArrayPrependTiny(&(self->topA), (smallt *) value->B);
   7167   return(self);
   7168 }
   7169 
   7170 internal smallJsont* prependSmallDoubleSmallJson(smallJsont *self, smallDoublet *value) {
   7171 
   7172   if (!value) {
   7173     return(NULL);
   7174   }
   7175 
   7176   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   7177     return(NULL);
   7178   }
   7179 
   7180   if (checkObjectTypes && value && !isOSmallDouble(value)) {
   7181     return(NULL);
   7182   }
   7183 
   7184   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   7185     self->topIsA = TOP_IS_ARRAY;
   7186   }
   7187 
   7188   if (!value->value) {
   7189     isError(value->value, allocSDouble(0)) return(NULL);
   7190   }
   7191   sArrayPrependTiny(&(self->topA), (smallt *) value->value);
   7192   return(self);
   7193 }
   7194 
   7195 internal smallJsont* prependSmallIntSmallJson(smallJsont *self, smallIntt *value) {
   7196 
   7197   if (!value) {
   7198     return(NULL);
   7199   }
   7200 
   7201   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   7202     return(NULL);
   7203   }
   7204 
   7205   if (checkObjectTypes && value && !isOSmallInt(value)) {
   7206     return(NULL);
   7207   }
   7208 
   7209   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   7210     self->topIsA = TOP_IS_ARRAY;
   7211   }
   7212 
   7213   if (!value->value) {
   7214     isError(value->value, allocSInt(0)) return(NULL);
   7215   }
   7216   sArrayPrependTiny(&(self->topA), (smallt *) value->value);
   7217   return(self);
   7218 }
   7219 
   7220 internal smallJsont* prependSmallJsonSmallJson(smallJsont *self, smallJsont *value) {
   7221 
   7222   if (!value) {
   7223     return(NULL);
   7224   }
   7225 
   7226   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   7227     return(NULL);
   7228   }
   7229 
   7230   if (checkObjectTypes && value && !isOSmallJson(value)) {
   7231     return(NULL);
   7232   }
   7233 
   7234   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   7235     self->topIsA = TOP_IS_ARRAY;
   7236   }
   7237 
   7238   smallt *o = getsoO(value);
   7239   if (!o) {
   7240     // smallJson is empty, create an empty dict
   7241     isError(o, (smallt*)allocSDict()) return(NULL);
   7242     setsoO(value, o);
   7243   }
   7244 
   7245   sArrayPrependTiny(&(self->topA), o);
   7246   return(self);
   7247 }
   7248 
   7249 internal smallJsont* prependSmallStringSmallJson(smallJsont *self, smallStringt *string) {
   7250 
   7251   if (!string) {
   7252     return(NULL);
   7253   }
   7254 
   7255   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY && self->topIsA != TOP_IS_STRING) {
   7256     return(NULL);
   7257   }
   7258 
   7259   if (checkObjectTypes && string && !isOSmallString(string)) {
   7260     return(NULL);
   7261   }
   7262 
   7263   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   7264     self->topIsA = TOP_IS_ARRAY;
   7265   }
   7266 
   7267   switch(self->topIsA) {
   7268     case TOP_IS_ARRAY:
   7269       if (!string->data) {
   7270         isError(string->data, allocSStringTiny("")) return(NULL);
   7271       }
   7272       sArrayPrependTiny(&(self->topA), (smallt *) string->data);
   7273       break;
   7274     case TOP_IS_STRING:
   7275       if (!string->data) {
   7276         return(self);
   7277       }
   7278 
   7279       if (!self->topS) {
   7280         self->topS = (sStringt *)strdup((char *)string->data);
   7281         //TODO self->_len = string->_len
   7282         return(self);
   7283       }
   7284 
   7285       if (!string->_len) {
   7286         // empty string
   7287         return(self);
   7288       }
   7289 
   7290       insertStringSmallJson(self, 0, string);
   7291       break;
   7292     default:;
   7293       // not reachable
   7294       logC("Check this function!");
   7295   }
   7296   return(self);
   7297 }
   7298 
   7299 internal smallJsont* prependSmallContainerSmallJson(smallJsont *self, smallContainert *container) {
   7300 
   7301   if (!container) {
   7302     return(NULL);
   7303   }
   7304 
   7305   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   7306     return(NULL);
   7307   }
   7308 
   7309   if (checkObjectTypes && container && !isOSmallContainer(container)) {
   7310     return(NULL);
   7311   }
   7312 
   7313   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   7314     self->topIsA = TOP_IS_ARRAY;
   7315   }
   7316 
   7317   if (!container->data) {
   7318     isError(container->data, allocSContainer(NULL)) return(NULL);
   7319   }
   7320   sArrayPrependTiny(&(self->topA), (smallt *) container->data);
   7321   return(self);
   7322 }
   7323 
   7324 
   7325 internal smallJsont* prependNFreeSmallJson(smallJsont *self, baset *value) {
   7326   smallt *o = NULL;
   7327 
   7328   if (!value) {
   7329     return(NULL);
   7330   }
   7331 
   7332   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   7333     return(NULL);
   7334   }
   7335 
   7336   o = toSmallt(value);;
   7337   if (!o) {
   7338     return(NULL);
   7339   }
   7340 
   7341   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   7342     self->topIsA = TOP_IS_ARRAY;
   7343   }
   7344 
   7345   sArrayPrependTiny(&(self->topA), o);
   7346 
   7347   if (!(o->type == CONTAINER && (((sContainert*)o)->dataType == SH_DT_BASET))) {
   7348     finishO(value);
   7349   }
   7350   return(self);
   7351 }
   7352 
   7353 internal smallJsont* prependNFreeUndefinedSmallJson(smallJsont *self, undefinedt *u) {
   7354 
   7355   smallJsont *r = prependUndefinedSmallJson(self);;
   7356   if (r) {
   7357     terminateO(u);
   7358   }
   7359   return(r);
   7360 }
   7361 
   7362 internal smallJsont* prependNFreeSSmallJson(smallJsont *self, char *string) {
   7363 
   7364   smallJsont *r = prependSSmallJson(self, string);;
   7365   if (r) {
   7366     free(string);
   7367   }
   7368   return(r);
   7369 }
   7370 
   7371 internal smallJsont* prependNFreeDictSmallJson(smallJsont *self, smallDictt *dict) {
   7372 
   7373   smallJsont *r = prependDictSmallJson(self, dict);
   7374   if (r) {
   7375     finishO(dict);
   7376   }
   7377   return(r);
   7378 }
   7379 
   7380 internal smallJsont* prependNFreeArraySmallJson(smallJsont *self, smallArrayt *array) {
   7381 
   7382   smallJsont *r = prependArraySmallJson(self, array);
   7383   if (r) {
   7384     finishO(array);
   7385   }
   7386   return(r);
   7387 }
   7388 
   7389 internal smallJsont* prependNFreeArraycSmallJson(smallJsont *self, char **array) {
   7390 
   7391   smallJsont *r = prependArraycSmallJson(self, array);;
   7392   if (r) {
   7393     listFreeS(array);
   7394   }
   7395   return(r);
   7396 }
   7397 
   7398 internal smallJsont* prependNFreeSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
   7399 
   7400   smallJsont *r = prependSmallBoolSmallJson(self, value);
   7401   if (r) {
   7402     finishO(value);
   7403   }
   7404   return(r);
   7405 }
   7406 
   7407 internal smallJsont* prependNFreeSmallBytesSmallJson(smallJsont *self, smallBytest *value) {
   7408 
   7409   smallJsont *r = prependSmallBytesSmallJson(self, value);
   7410   if (r) {
   7411     finishO(value);
   7412   }
   7413   return(r);
   7414 }
   7415 
   7416 internal smallJsont* prependNFreeSmallDoubleSmallJson(smallJsont *self, smallDoublet *value) {
   7417 
   7418   smallJsont *r = prependSmallDoubleSmallJson(self, value);
   7419   if (r) {
   7420     finishO(value);
   7421   }
   7422   return(r);
   7423 }
   7424 
   7425 internal smallJsont* prependNFreeSmallIntSmallJson(smallJsont *self, smallIntt *value) {
   7426 
   7427   smallJsont *r = prependSmallIntSmallJson(self, value);
   7428   if (r) {
   7429     finishO(value);
   7430   }
   7431   return(r);
   7432 }
   7433 
   7434 internal smallJsont* prependNFreeSmallJsonSmallJson(smallJsont *self, smallJsont *value) {
   7435 
   7436   smallJsont *r = prependSmallJsonSmallJson(self, value);
   7437   if (r) {
   7438     finishO(value);
   7439   }
   7440   return(r);
   7441 }
   7442 
   7443 internal smallJsont* prependNFreeSmallStringSmallJson(smallJsont *self, smallStringt *string) {
   7444 
   7445   smallJsont *r = prependSmallStringSmallJson(self, string);
   7446   if (r) {
   7447     finishO(string);
   7448   }
   7449   return(r);
   7450 }
   7451 
   7452 internal smallJsont* prependNFreeSmallContainerSmallJson(smallJsont *self, smallContainert *container) {
   7453 
   7454   smallJsont *r = prependSmallContainerSmallJson(self, container);
   7455   if (r) {
   7456     finishO(container);
   7457   }
   7458   return(r);
   7459 }
   7460 
   7461 internal baset* dequeueSmallJson(smallJsont *self) {
   7462   size_t len;
   7463   smallt *o = NULL;
   7464 
   7465   if (self->topIsA != TOP_IS_ARRAY) {
   7466     return(NULL);
   7467   }
   7468 
   7469   len = lenSmallJson(self);
   7470   if (!len) {
   7471     return(NULL);
   7472   }
   7473 
   7474   for (size_t i = len ; i != 0 ; i--) {
   7475     o = sArrayDequeueTiny(self->topA);
   7476     if (o) {
   7477       break;
   7478   }
   7479     }
   7480 
   7481   if (!o) {
   7482     return(NULL);
   7483   }
   7484 
   7485   if (o->type == UNDEFINED) {
   7486     free(o);
   7487     return((baset*) allocUndefined());
   7488   }
   7489   else if (o->type == CONTAINER) {
   7490     cast(sContainert*, sc, o);
   7491     if (sc->dataType == SH_DT_BASET) {
   7492       // baset object in stored in the container, free the container since
   7493       // it was allocated automatically in the toSmallt function in libsheepyObject.c
   7494       baset *r = toBaset(o);
   7495       free(o);
   7496       return(r);
   7497   }
   7498     }
   7499   return(toBaset(o));
   7500 }
   7501 
   7502 internal undefinedt* dequeueUndefinedSmallJson(smallJsont *self) {
   7503   size_t len;
   7504   smallt *o = NULL;
   7505 
   7506   if (self->topIsA != TOP_IS_ARRAY) {
   7507     return(NULL);
   7508   }
   7509 
   7510   len = lenSmallJson(self);
   7511   if (!len) {
   7512     return(NULL);
   7513   }
   7514 
   7515   size_t i;
   7516   for (i = 0 ; i < len ; i++) {
   7517     o = sArrayGetTiny(self->topA, (uint32_t)i);
   7518     if (o) {
   7519       break;
   7520   }
   7521     }
   7522 
   7523   if (!o) {
   7524     return(NULL);
   7525   }
   7526 
   7527   if (o->type != UNDEFINED) {
   7528     return(NULL);
   7529   }
   7530 
   7531   // finish dequeuing
   7532   smallt **arr = &(self->topA->data);
   7533   // shift list
   7534   for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
   7535     arr[j-i-1] = arr[j];
   7536   }
   7537   self->topA->count -= (uint32_t)i+1;
   7538 
   7539   free(o);
   7540   return(allocUndefined());
   7541 }
   7542 
   7543 internal bool dequeueBoolSmallJson(smallJsont *self) {
   7544   smallBoolt *e = NULL;
   7545   bool r = false;;
   7546 
   7547   e = dequeueSmallBoolSmallJson(self);
   7548   if (e) {
   7549     r = e->f->get(e);
   7550     terminateO(e);
   7551   }
   7552   return(r);
   7553 }
   7554 
   7555 internal double dequeueDoubleSmallJson(smallJsont *self) {
   7556   smallDoublet *e = NULL;
   7557   double r = 0;;
   7558 
   7559   e = dequeueSmallDoubleSmallJson(self);
   7560   if (e) {
   7561     r = e->f->get(e);
   7562     terminateO(e);
   7563   }
   7564   return(r);
   7565 }
   7566 
   7567 internal int64_t dequeueIntSmallJson(smallJsont *self) {
   7568   smallIntt *e = NULL;
   7569   int64_t r = 0;;
   7570 
   7571   e = dequeueSmallIntSmallJson(self);
   7572   if (e) {
   7573     r = e->f->get(e);
   7574     terminateO(e);
   7575   }
   7576   return(r);
   7577 }
   7578 
   7579 internal int32_t dequeueInt32SmallJson(smallJsont *self) {
   7580   smallIntt *e = NULL;
   7581   int32_t r = 0;;
   7582 
   7583   e = dequeueSmallIntSmallJson(self);
   7584   if (e) {
   7585     r = (int32_t)e->f->get(e);
   7586     terminateO(e);
   7587   }
   7588   return(r);
   7589 }
   7590 
   7591 internal uint64_t dequeueUintSmallJson(smallJsont *self) {
   7592   smallIntt *e = NULL;
   7593   uint64_t r = 0;;
   7594 
   7595   e = dequeueSmallIntSmallJson(self);
   7596   if (e) {
   7597     r = (uint64_t)e->f->get(e);
   7598     terminateO(e);
   7599   }
   7600   return(r);
   7601 }
   7602 
   7603 internal uint32_t dequeueUint32SmallJson(smallJsont *self) {
   7604   smallIntt *e = NULL;
   7605   uint32_t r = 0;;
   7606 
   7607   e = dequeueSmallIntSmallJson(self);
   7608   if (e) {
   7609     r = (uint32_t)e->f->get(e);
   7610     terminateO(e);
   7611   }
   7612   return(r);
   7613 }
   7614 
   7615 internal char* dequeueSSmallJson(smallJsont *self) {
   7616   smallStringt *e = NULL;
   7617   char* r = NULL;
   7618 
   7619   e = dequeueSmallStringSmallJson(self);
   7620   if (e) {
   7621     r = e->f->toString(e);
   7622     terminateO(e);
   7623   }
   7624   return(r);
   7625 }
   7626 
   7627 internal smallDictt* dequeueDictSmallJson(smallJsont *self) {
   7628   size_t len;
   7629   smallt *o = NULL;
   7630 
   7631   if (self->topIsA != TOP_IS_ARRAY) {
   7632     return(NULL);
   7633   }
   7634 
   7635   len = lenSmallJson(self);
   7636   if (!len) {
   7637     return(NULL);
   7638   }
   7639 
   7640   size_t i;
   7641   for (i = 0 ; i < len ; i++) {
   7642     o = sArrayGetTiny(self->topA, (uint32_t)i);
   7643     if (o) {
   7644       break;
   7645   }
   7646     }
   7647 
   7648   if (!o) {
   7649     return(NULL);
   7650   }
   7651 
   7652   if (o->type != DICT) {
   7653     return(NULL);
   7654   }
   7655 
   7656   // finish dequeuing
   7657   smallt **arr = &(self->topA->data);
   7658   // shift list
   7659   for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
   7660     arr[j-i-1] = arr[j];
   7661   }
   7662   self->topA->count -= (uint32_t)i+1;
   7663 
   7664   return((smallDictt*) toBaset(o));
   7665 }
   7666 
   7667 internal smallArrayt* dequeueArraySmallJson(smallJsont *self) {
   7668   size_t len;
   7669   smallt *o = NULL;
   7670 
   7671   if (self->topIsA != TOP_IS_ARRAY) {
   7672     return(NULL);
   7673   }
   7674 
   7675   len = lenSmallJson(self);
   7676   if (!len) {
   7677     return(NULL);
   7678   }
   7679 
   7680   size_t i;
   7681   for (i = 0 ; i < len ; i++) {
   7682     o = sArrayGetTiny(self->topA, (uint32_t)i);
   7683     if (o) {
   7684       break;
   7685   }
   7686     }
   7687 
   7688   if (!o) {
   7689     return(NULL);
   7690   }
   7691 
   7692   if (o->type != ARRAY) {
   7693     return(NULL);
   7694   }
   7695 
   7696   // finish dequeuing
   7697   smallt **arr = &(self->topA->data);
   7698   // shift list
   7699   for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
   7700     arr[j-i-1] = arr[j];
   7701   }
   7702   self->topA->count -= (uint32_t)i+1;
   7703 
   7704   return((smallArrayt*) toBaset(o));
   7705 }
   7706 
   7707 internal smallBoolt* dequeueSmallBoolSmallJson(smallJsont *self) {
   7708   size_t len;
   7709   smallt *o = NULL;
   7710 
   7711   if (self->topIsA != TOP_IS_ARRAY) {
   7712     return(NULL);
   7713   }
   7714 
   7715   len = lenSmallJson(self);
   7716   if (!len) {
   7717     return(NULL);
   7718   }
   7719 
   7720   size_t i;
   7721   for (i = 0 ; i < len ; i++) {
   7722     o = sArrayGetTiny(self->topA, (uint32_t)i);
   7723     if (o) {
   7724       break;
   7725   }
   7726     }
   7727 
   7728   if (!o) {
   7729     return(NULL);
   7730   }
   7731 
   7732   if (o->type != BOOL) {
   7733     return(NULL);
   7734   }
   7735 
   7736   // finish dequeuing
   7737   smallt **arr = &(self->topA->data);
   7738   // shift list
   7739   for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
   7740     arr[j-i-1] = arr[j];
   7741   }
   7742   self->topA->count -= (uint32_t)i+1;
   7743 
   7744   return((smallBoolt*) toBaset(o));
   7745 }
   7746 
   7747 internal smallBytest* dequeueSmallBytesSmallJson(smallJsont *self) {
   7748   size_t len;
   7749   smallt *o = NULL;
   7750 
   7751   if (self->topIsA != TOP_IS_ARRAY) {
   7752     return(NULL);
   7753   }
   7754 
   7755   len = lenSmallJson(self);
   7756   if (!len) {
   7757     return(NULL);
   7758   }
   7759 
   7760   size_t i;
   7761   for (i = 0 ; i < len ; i++) {
   7762     o = sArrayGetTiny(self->topA, (uint32_t)i);
   7763     if (o) {
   7764       break;
   7765   }
   7766     }
   7767 
   7768   if (!o) {
   7769     return(NULL);
   7770   }
   7771 
   7772   if (o->type != BYTES) {
   7773     return(NULL);
   7774   }
   7775 
   7776   // finish dequeuing
   7777   smallt **arr = &(self->topA->data);
   7778   // shift list
   7779   for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
   7780     arr[j-i-1] = arr[j];
   7781   }
   7782   self->topA->count -= (uint32_t)i+1;
   7783 
   7784   return((smallBytest*) toBaset(o));
   7785 }
   7786 
   7787 internal smallDoublet* dequeueSmallDoubleSmallJson(smallJsont *self) {
   7788   size_t len;
   7789   smallt *o = NULL;
   7790 
   7791   if (self->topIsA != TOP_IS_ARRAY) {
   7792     return(NULL);
   7793   }
   7794 
   7795   len = lenSmallJson(self);
   7796   if (!len) {
   7797     return(NULL);
   7798   }
   7799 
   7800   size_t i;
   7801   for (i = 0 ; i < len ; i++) {
   7802     o = sArrayGetTiny(self->topA, (uint32_t)i);
   7803     if (o) {
   7804       break;
   7805   }
   7806     }
   7807 
   7808   if (!o) {
   7809     return(NULL);
   7810   }
   7811 
   7812   if (o->type != DOUBLE) {
   7813     return(NULL);
   7814   }
   7815 
   7816   // finish dequeuing
   7817   smallt **arr = &(self->topA->data);
   7818   // shift list
   7819   for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
   7820     arr[j-i-1] = arr[j];
   7821   }
   7822   self->topA->count -= (uint32_t)i+1;
   7823 
   7824   return((smallDoublet*) toBaset(o));
   7825 }
   7826 
   7827 internal smallIntt* dequeueSmallIntSmallJson(smallJsont *self) {
   7828   size_t len;
   7829   smallt *o = NULL;
   7830 
   7831   if (self->topIsA != TOP_IS_ARRAY) {
   7832     return(NULL);
   7833   }
   7834 
   7835   len = lenSmallJson(self);
   7836   if (!len) {
   7837     return(NULL);
   7838   }
   7839 
   7840   size_t i;
   7841   for (i = 0 ; i < len ; i++) {
   7842     o = sArrayGetTiny(self->topA, (uint32_t)i);
   7843     if (o) {
   7844       break;
   7845   }
   7846     }
   7847 
   7848   if (!o) {
   7849     return(NULL);
   7850   }
   7851 
   7852   if (o->type != INT) {
   7853     return(NULL);
   7854   }
   7855 
   7856   // finish dequeuing
   7857   smallt **arr = &(self->topA->data);
   7858   // shift list
   7859   for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
   7860     arr[j-i-1] = arr[j];
   7861   }
   7862   self->topA->count -= (uint32_t)i+1;
   7863 
   7864   return((smallIntt*) toBaset(o));
   7865 }
   7866 
   7867 internal smallJsont* dequeueSmallJsonSmallJson(smallJsont *self) {
   7868   size_t len;
   7869   smallt *o = NULL;
   7870 
   7871   if (self->topIsA != TOP_IS_ARRAY) {
   7872     return(NULL);
   7873   }
   7874 
   7875   len = lenSmallJson(self);
   7876   if (!len) {
   7877     return(NULL);
   7878   }
   7879 
   7880   size_t i;
   7881   for (i = 0 ; i < len ; i++) {
   7882     o = sArrayGetTiny(self->topA, (uint32_t)i);
   7883     if (o) {
   7884       break;
   7885   }
   7886     }
   7887 
   7888   if (!o) {
   7889     return(NULL);
   7890   }
   7891 
   7892   if ((o->type == BYTES) || (o->type == CONTAINER)) {
   7893     return(NULL);
   7894   }
   7895 
   7896   // finish dequeuing
   7897   smallt **arr = &(self->topA->data);
   7898   // shift list
   7899   for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
   7900     arr[j-i-1] = arr[j];
   7901   }
   7902   self->topA->count -= (uint32_t)i+1;
   7903 
   7904   baset *e = toBaset(o);
   7905 
   7906   createAllocateSmallJson(r);
   7907   if (!r) {
   7908     finishO(e);
   7909     return(NULL);
   7910   }
   7911   setTopNFreeSmallJson(r, e);
   7912   return(r);
   7913 }
   7914 
   7915 internal smallStringt* dequeueSmallStringSmallJson(smallJsont *self) {
   7916   size_t len;
   7917   smallt *o = NULL;
   7918 
   7919   if (self->topIsA != TOP_IS_ARRAY) {
   7920     return(NULL);
   7921   }
   7922 
   7923   len = lenSmallJson(self);
   7924   if (!len) {
   7925     return(NULL);
   7926   }
   7927 
   7928   size_t i;
   7929   for (i = 0 ; i < len ; i++) {
   7930     o = sArrayGetTiny(self->topA, (uint32_t)i);
   7931     if (o) {
   7932       break;
   7933   }
   7934     }
   7935 
   7936   if (!o) {
   7937     return(NULL);
   7938   }
   7939 
   7940   if (o->type != STRING) {
   7941     return(NULL);
   7942   }
   7943 
   7944   // finish dequeuing
   7945   smallt **arr = &(self->topA->data);
   7946   // shift list
   7947   for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
   7948     arr[j-i-1] = arr[j];
   7949   }
   7950   self->topA->count -= (uint32_t)i+1;
   7951 
   7952   return((smallStringt*) toBaset(o));
   7953 }
   7954 
   7955 internal void* dequeueVoidSmallJson(smallJsont *self) {
   7956   smallContainert *e = NULL;
   7957   void* r = NULL;
   7958 
   7959   e = dequeueSmallContainerSmallJson(self);
   7960   if (e) {
   7961     r = e->f->get(e);
   7962     smashO(e);
   7963   }
   7964   return(r);
   7965 }
   7966 
   7967 internal smallContainert* dequeueSmallContainerSmallJson(smallJsont *self) {
   7968   size_t len;
   7969   smallt *o = NULL;
   7970 
   7971   if (self->topIsA != TOP_IS_ARRAY) {
   7972     return(NULL);
   7973   }
   7974 
   7975   len = lenSmallJson(self);
   7976   if (!len) {
   7977     return(NULL);
   7978   }
   7979 
   7980   size_t i;
   7981   for (i = 0 ; i < len ; i++) {
   7982     o = sArrayGetTiny(self->topA, (uint32_t)i);
   7983     if (o) {
   7984       break;
   7985   }
   7986     }
   7987 
   7988   if (!o) {
   7989     return(NULL);
   7990   }
   7991 
   7992   if (o->type != CONTAINER) {
   7993     return(NULL);
   7994   }
   7995 
   7996   if (((sContainert*)o)->dataType == SH_DT_BASET) {
   7997     return(NULL);
   7998   }
   7999 
   8000   // finish dequeuing
   8001   smallt **arr = &(self->topA->data);
   8002   // shift list
   8003   for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
   8004     arr[j-i-1] = arr[j];
   8005   }
   8006   self->topA->count -= (uint32_t)i+1;
   8007 
   8008   return((smallContainert*) toBaset(o));
   8009 }
   8010 
   8011 internal double dequeueNumSmallJson(smallJsont *self) {
   8012   size_t len;
   8013   smallt *o = NULL;
   8014 
   8015   if (self->topIsA != TOP_IS_ARRAY) {
   8016     return(0);
   8017   }
   8018 
   8019   len = lenSmallJson(self);
   8020   if (!len) {
   8021     return(0);
   8022   }
   8023 
   8024   size_t i;
   8025   for (i = 0 ; i < len ; i++) {
   8026     o = sArrayGetTiny(self->topA, (uint32_t)i);
   8027     if (o) {
   8028       break;
   8029   }
   8030     }
   8031 
   8032   if (!o) {
   8033     return(0);
   8034   }
   8035 
   8036   if (o->type != INT && o->type != DOUBLE) {
   8037     return(0);
   8038   }
   8039 
   8040   // finish dequeuing
   8041   smallt **arr = &(self->topA->data);
   8042   // shift list
   8043   for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
   8044     arr[j-i-1] = arr[j];
   8045   }
   8046   self->topA->count -= (uint32_t)i+1;
   8047 
   8048   baset *e = toBaset(o);
   8049 
   8050   double r = 0;
   8051   if (isOSmallDouble(e)) {
   8052     r = getValO((smallDoublet*)e);
   8053   }
   8054   elif (isOSmallInt(e)) {
   8055     r = (double)getValO((smallIntt*)e);
   8056   }
   8057   terminateO(e);
   8058   return(r);
   8059 }
   8060 
   8061 internal smallJsont* reverseSmallJson(smallJsont *self) {
   8062   size_t len;
   8063 
   8064   if (self->topIsA != TOP_IS_ARRAY) {
   8065     return(NULL);
   8066   }
   8067 
   8068   len = lenSmallJson(self);
   8069 
   8070   if (len < 2) {
   8071     // empty or 1 element list
   8072     return(self);
   8073   }
   8074 
   8075   if (!sArrayReverseTiny(self->topA)) {
   8076     return(NULL);
   8077   }
   8078   return(self);
   8079 }
   8080 
   8081 internal smallJsont* catSmallJson(smallJsont *self, ...) {
   8082 
   8083   switch(self->topIsA) {
   8084     case TOP_IS_ARRAY:
   8085       ;va_list pl;
   8086       smallArrayt *paramType;
   8087 
   8088       // add arguments to a list
   8089       va_start(pl, self);
   8090       paramType = va_arg(pl, smallArrayt*);
   8091       while (paramType) {
   8092         smallJsont *r = appendSmallJson(self, paramType);
   8093         if (!r) {
   8094           va_end(pl);
   8095           return(NULL);
   8096         }
   8097         paramType = va_arg(pl, smallArrayt*);
   8098       }
   8099       va_end(pl);
   8100       break;
   8101     case TOP_IS_STRING:
   8102       ;va_list pls;
   8103       smallStringt *paramTypes;
   8104 
   8105       createSmallArray(l);
   8106       if (!l.f) {
   8107         return(NULL);
   8108       }
   8109       if (self->topS) {
   8110         // add self to result
   8111         createSmallString(ss);
   8112         ss.data = self->topS;
   8113         l.f->pushSmallString(&l, &ss);
   8114       }
   8115 
   8116       // add arguments to a list
   8117       va_start(pls, self);
   8118       paramTypes = va_arg(pls, smallStringt*);
   8119       while (paramTypes) {
   8120         if (checkObjectTypes && !isOSmallString(paramTypes)) {
   8121           disposeO(&l);
   8122           va_end(pl);
   8123           return(NULL);
   8124         }
   8125         l.f->pushSmallString(&l, paramTypes);
   8126         paramTypes = va_arg(pls, smallStringt*);
   8127       }
   8128       va_end(pls);
   8129       // join list with empty delimiter
   8130       smallStringt *r = l.f->join(&l, "");
   8131       free(self->topS);
   8132       self->topS = r->data;
   8133       //TODO self->_len = r->_len
   8134       finishO(r);
   8135       disposeO(&l);
   8136       break;
   8137     default:
   8138       return(NULL);
   8139   }
   8140   return(self);
   8141 }
   8142 
   8143 
   8144 internal smallJsont* mergeDictSmallJson(smallJsont *self, smallDictt *smallDict) {
   8145 
   8146   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT) {
   8147     return(NULL);
   8148   }
   8149 
   8150   // sanity checks
   8151   if (!smallDict) {
   8152     return(NULL);
   8153   }
   8154 
   8155   if (checkObjectTypes && !isOSmallDict(smallDict)) {
   8156     return(NULL);
   8157   }
   8158 
   8159   if (!smallDict->f->len(smallDict)) {
   8160     return(self);
   8161   }
   8162 
   8163   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   8164     self->topIsA = TOP_IS_DICT;
   8165   }
   8166 
   8167   if (self->top == smallDict->d) {
   8168     // self and array identical, cancel this operations
   8169     // to avoid double free undefined behavior in free
   8170     return(NULL);
   8171   }
   8172 
   8173   forEachSDict(smallDict->d, e) {
   8174     if (e->key) {
   8175       sDictSetTiny(&(self->top), e->key, e->data);
   8176   }
   8177     }
   8178   return(self);
   8179 }
   8180 
   8181 internal smallJsont* mergeDictNSmashSmallJson(smallJsont *self, smallDictt *smallDict) {
   8182   smallJsont *r = NULL;
   8183 
   8184   r = mergeDictSmallJson(self, smallDict);
   8185   if (r) {
   8186     smashO(smallDict);
   8187   }
   8188   return(r);
   8189 }
   8190 
   8191 internal smallJsont* mergeSmallJson(smallJsont *self, smallJsont *smallJson) {
   8192 
   8193   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
   8194     return(NULL);
   8195   }
   8196 
   8197   // sanity checks
   8198   if (!smallJson) {
   8199     return(NULL);
   8200   }
   8201 
   8202   if (checkObjectTypes && !isOSmallJson(smallJson)) {
   8203     return(NULL);
   8204   }
   8205 
   8206   if (!smallJson->f->len(smallJson)) {
   8207     return(self);
   8208   }
   8209 
   8210   if (smallJson->topIsA != TOP_IS_DICT && smallJson->topIsA != TOP_IS_ARRAY) {
   8211     return(NULL);
   8212   }
   8213 
   8214   switch(self->topIsA) {
   8215     case SMALLJSON_IS_EMPTY:
   8216       if (smallJson->topIsA == TOP_IS_ARRAY) {
   8217         self->topIsA = TOP_IS_ARRAY;
   8218         goto appendToArray;
   8219       }
   8220       self->topIsA = TOP_IS_DICT;
   8221       FALLTHRU;
   8222     case TOP_IS_DICT:;
   8223       if (self->top == smallJson->top) {
   8224         // self and array identical, cancel this operations
   8225         // to avoid double free undefined behavior in free
   8226         return(NULL);
   8227       }
   8228       forEachSDict(smallJson->top, e) {
   8229         if (e->key) {
   8230           sDictSetTiny(&(self->top), e->key, e->data);
   8231       }
   8232         }
   8233       break;
   8234     case TOP_IS_ARRAY:
   8235       appendToArray:;
   8236       if (self->topA == smallJson->topA) {
   8237         // self and array identical, cancel this operations
   8238         // to avoid double free undefined behavior in free
   8239         return(NULL);
   8240       }
   8241       forEachSArray(smallJson->topA, o) {
   8242         sArrayPushTiny(&(self->topA), o);
   8243       }
   8244       break;
   8245     default:;
   8246       // not reachable
   8247       logC("Check this function!");
   8248   }
   8249   return(self);
   8250 }
   8251 
   8252 internal smallJsont* mergeNSmashSmallJson(smallJsont *self, smallJsont *smallJson) {
   8253   smallJsont *r = NULL;
   8254 
   8255   r = mergeSmallJson(self, smallJson);
   8256   if (r) {
   8257     smashO(smallJson);
   8258   }
   8259   return(r);
   8260 }
   8261 
   8262 internal smallJsont* appendSmallJson(smallJsont *self, smallArrayt *array) {
   8263 
   8264   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   8265     return(NULL);
   8266   }
   8267 
   8268   // sanity checks
   8269   if (!array) {
   8270     return(NULL);
   8271   }
   8272 
   8273   if (checkObjectTypes && !isOSmallArray(array)) {
   8274     return(NULL);
   8275   }
   8276 
   8277   if (!array->f->len(array)) {
   8278     // self not modified
   8279     return(self);
   8280   }
   8281 
   8282   if (self->topA == array->a) {
   8283     // self and array identical, cancel this operations
   8284     // to avoid double free undefined behavior in free
   8285     return(NULL);
   8286   }
   8287 
   8288   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   8289     self->topIsA = TOP_IS_ARRAY;
   8290   }
   8291 
   8292   // copy array
   8293   forEachSArray(array->a, o) {
   8294     sArrayPushTiny(&(self->topA), o);
   8295   }
   8296 
   8297   return(self);
   8298 }
   8299 
   8300 internal smallJsont* appendNSmashSmallJson(smallJsont *self, smallArrayt *array) {
   8301   smallJsont *r = NULL;
   8302 
   8303   r = appendSmallJson(self, array);
   8304   if (r) {
   8305     smashO(array);
   8306   }
   8307   return(r);
   8308 }
   8309 
   8310 // not used, included in mergeSmallJson
   8311 /* NOINTERNAL smallJsont* appendSmallJsonSmallJson(smallJsont *self, smallJsont *array) */
   8312 /*  */
   8313 /*   if self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY */
   8314 /*     return NULL */
   8315 /*  */
   8316 /*   // sanity checks */
   8317 /*   if !array */
   8318 /*     return NULL */
   8319 /*  */
   8320 /*   if checkObjectTypes && !isOSmallJson(array) */
   8321 /*     return NULL */
   8322 /*  */
   8323 /*   if array->topIsA != SMALLJSON_IS_EMPTY && array->topIsA != TOP_IS_ARRAY */
   8324 /*     return NULL */
   8325 /*  */
   8326 /*   if !array->f->len(array) */
   8327 /*     // self not modified */
   8328 /*     return self */
   8329 /*  */
   8330 /*   if self->topA = array->topA */
   8331 /*     // self and array identical, cancel this operations */
   8332 /*     // to avoid double free undefined behavior in free */
   8333 /*     return NULL */
   8334 /*  */
   8335 /*   if self->topIsA = SMALLJSON_IS_EMPTY */
   8336 /*     self->topIsA = TOP_IS_ARRAY */
   8337 /*  */
   8338 /*   // copy array */
   8339 /*   forEachSArray(array->topA, o) */
   8340 /*     sArrayPushTiny(&(self->topA), o); */
   8341 /*  */
   8342 /*   return self */
   8343 /*  */
   8344 /* NOINTERNAL smallJsont* NOappendSmallJsonNSmashSmallJson(smallJsont *self, smallJsont *array) */
   8345 /*   smallJsont *r */
   8346 /*  */
   8347 /*   r = appendSmallJsonSmallJson(self, array) */
   8348 /*   if r */
   8349 /*     smashO(array); */
   8350 /*   return r */
   8351 
   8352 internal smallJsont* appendArraySmallJson(smallJsont *self, char **array) {
   8353 
   8354   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   8355     return(NULL);
   8356   }
   8357 
   8358   if (!array) {
   8359     return(NULL);
   8360   }
   8361 
   8362   if (!*array) {
   8363     return(self);
   8364   }
   8365 
   8366   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   8367     self->topIsA = TOP_IS_ARRAY;
   8368   }
   8369 
   8370   forEachCharP(array, e) {
   8371     sStringt *s = allocSStringTiny(*e);
   8372     if (!s) {
   8373       return(NULL);
   8374     }
   8375     sArrayPushTiny(&(self->topA), (smallt *) s);
   8376   }
   8377   return(self);
   8378 }
   8379 
   8380 internal smallJsont* appendCArraySmallJson(smallJsont *self, const char **array) {
   8381 
   8382   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   8383     return(NULL);
   8384   }
   8385 
   8386   if (!array) {
   8387     return(NULL);
   8388   }
   8389 
   8390   if (!*array) {
   8391     return(self);
   8392   }
   8393 
   8394   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   8395     self->topIsA = TOP_IS_ARRAY;
   8396   }
   8397 
   8398   forEachCCharP(array, e) {
   8399     sStringt *s = allocSStringTiny(*e);
   8400     if (!s) {
   8401       return(NULL);
   8402     }
   8403     sArrayPushTiny(&(self->topA), (smallt *) s);
   8404   }
   8405   return(self);
   8406 }
   8407 
   8408 internal smallJsont* appendNSmashArraySmallJson(smallJsont *self, char **array) {
   8409 
   8410   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
   8411     return(NULL);
   8412   }
   8413 
   8414   if (!array) {
   8415     return(NULL);
   8416   }
   8417 
   8418   if (!*array) {
   8419     free(array);
   8420     return(self);
   8421   }
   8422 
   8423   if (self->topIsA == SMALLJSON_IS_EMPTY) {
   8424     self->topIsA = TOP_IS_ARRAY;
   8425   }
   8426 
   8427   forEachCharP(array, e) {
   8428     sStringt *s = allocSStringTiny(*e);
   8429     if (!s) {
   8430       return(NULL);
   8431     }
   8432     sArrayPushTiny(&(self->topA), (smallt *) s);
   8433   }
   8434 
   8435   listFreeS(array);
   8436   return(self);
   8437 }
   8438 
   8439 internal smallJsont* shiftSmallJson(smallJsont *self, smallArrayt *array) {
   8440 
   8441   return(insertSmallJson(self, 0, array));
   8442 }
   8443 
   8444 internal smallJsont* shiftNSmashSmallJson(smallJsont *self, smallArrayt *array) {
   8445 
   8446   return(insertNSmashSmallJson(self, 0, array));
   8447 }
   8448 
   8449 internal smallJsont* shiftSmallJsonSmallJson(smallJsont *self, smallJsont *array) {
   8450 
   8451   return(insertSmallJsonSmallJson(self, 0, array));
   8452 }
   8453 
   8454 internal smallJsont* shiftNSmashSmallJsonSmallJson(smallJsont *self, smallJsont *array) {
   8455 
   8456   return(insertNSmashSmallJsonSmallJson(self, 0, array));
   8457 }
   8458 
   8459 internal smallJsont* addSmallJson(smallJsont *self, smallArrayt *array) {
   8460   smallJsont *r = NULL;
   8461 
   8462   // sanity checks
   8463   if (self->topIsA != TOP_IS_ARRAY) {
   8464     return(NULL);
   8465   }
   8466 
   8467   if (!array) {
   8468     return(NULL);
   8469   }
   8470 
   8471   if (checkObjectTypes && !isOSmallArray(array)) {
   8472     return(NULL);
   8473   }
   8474 
   8475   if (!array->f->len(array)) {
   8476     return(duplicateSmallJson(self));
   8477   }
   8478 
   8479   if (self->topA == array->a) {
   8480     // self and array identical, cancel this operations
   8481     // to avoid double free undefined behavior in free
   8482     return(NULL);
   8483   }
   8484 
   8485   r = duplicateSmallJson(self);
   8486 
   8487   // copy array
   8488   forEachSArray(array->a, o) {
   8489     sArrayPushTiny(&(r->topA), o);
   8490   }
   8491 
   8492   return(r);
   8493 }
   8494 
   8495 internal smallJsont* addJsonSmallJson(smallJsont *self, smallJsont *array) {
   8496   smallJsont *r = NULL;
   8497 
   8498   // sanity checks
   8499   if (self->topIsA != TOP_IS_ARRAY) {
   8500     return(NULL);
   8501   }
   8502 
   8503   if (!array) {
   8504     return(NULL);
   8505   }
   8506 
   8507   if (checkObjectTypes && !isOSmallJson(array)) {
   8508     return(NULL);
   8509   }
   8510 
   8511   if (array->topIsA != TOP_IS_ARRAY) {
   8512     return(NULL);
   8513   }
   8514 
   8515   if (self->topA == array->topA) {
   8516     // self and array identical, cancel this operations
   8517     // to avoid double free undefined behavior in free
   8518     return(NULL);
   8519   }
   8520 
   8521   r = duplicateSmallJson(self);
   8522 
   8523   if (!array->f->len(array)) {
   8524     return(r);
   8525   }
   8526 
   8527   // copy array
   8528   forEachSArray(array->topA, o) {
   8529     sArrayPushTiny(&(r->topA), o);
   8530   }
   8531 
   8532   return(r);
   8533 }
   8534 
   8535 internal smallJsont* sliceSmallJson(smallJsont *self, int64_t start, int64_t end) {
   8536   size_t len;
   8537   char *s = NULL;
   8538   int64_t n;
   8539 
   8540   if (self->topIsA != TOP_IS_ARRAY && self->topIsA != TOP_IS_STRING) {
   8541     return(NULL);
   8542   }
   8543 
   8544   len = lenSmallJson(self);
   8545   // sanity checks
   8546   if (!len) {
   8547     return(NULL);
   8548   }
   8549 
   8550   if (start > (int64_t)len) {
   8551     emptySmallJson(self);
   8552     return(NULL);
   8553   }
   8554   if (end > (int64_t)len) {
   8555     end = (int64_t)len;
   8556   }
   8557   if (start <= -(int64_t)len) {
   8558     start = -(int64_t)len;
   8559   }
   8560   if (end <= -(int64_t)len) {
   8561     emptySmallJson(self);
   8562     return(NULL);
   8563   }
   8564   if (start < 0) {
   8565     start = (int64_t)len + start;
   8566   }
   8567   if (end <= 0) {
   8568     end = (int64_t)len + end;
   8569   }
   8570   if (end < start) {
   8571     emptySmallJson(self);
   8572     return(NULL);
   8573   }
   8574 
   8575   switch(self->topIsA) {
   8576     case TOP_IS_ARRAY:
   8577       if (start == end) {
   8578         // empty list
   8579         emptySmallJson(self);
   8580         return(self);
   8581       }
   8582       else {
   8583         // start < end < len
   8584 
   8585         sArrayDelRangeTiny(self->topA, (uint32_t)end, (uint32_t)len);
   8586         sArrayDelRangeTiny(self->topA, 0, (uint32_t)start);
   8587       }
   8588       break;
   8589     case TOP_IS_STRING:
   8590       if (start == end) {
   8591         emptyS(s);
   8592       }
   8593       else {
   8594         // start < end < len
   8595         // copy range to a new smallString
   8596         n = end - start;
   8597         s = malloc((size_t)n+1);
   8598         if (!s) {
   8599           return(NULL);
   8600         }
   8601         s = strncpy(s, sStringGetTiny(self->topS) + start, (size_t)n);
   8602         s[n] = 0;
   8603       }
   8604 
   8605       freeSmallJson(self);
   8606       setTopNFreeStringSmallJson(self, s);
   8607       break;
   8608     default:
   8609       // not reachable
   8610       logC("Check this function!");
   8611   }
   8612   return(self);
   8613 }
   8614 
   8615 
   8616 internal smallJsont* cropSmallJson(smallJsont *self, int64_t start, int64_t end) {
   8617   int64_t len;
   8618   int64_t n;
   8619   char *l = NULL;
   8620   smallt *o = NULL;
   8621 
   8622   if (self->topIsA != TOP_IS_ARRAY && self->topIsA != TOP_IS_STRING) {
   8623     return(NULL);
   8624   }
   8625 
   8626   len = (int64_t)lenSmallJson(self);
   8627 
   8628   if (!len) {
   8629     return(NULL);
   8630   }
   8631 
   8632   if (start > len) {
   8633     return(NULL);
   8634   }
   8635   if (end > len) {
   8636     end = len;
   8637   }
   8638   if (start <= -len) {
   8639     start = -len;
   8640   }
   8641   if (end <= -len) {
   8642     return(NULL);
   8643   }
   8644   if (start < 0) {
   8645     start = len + start;
   8646   }
   8647   if (end <= 0) {
   8648     end = len + end;
   8649   }
   8650   if (end < start) {
   8651     return(NULL);
   8652   }
   8653 
   8654   createAllocateSmallJson(r);
   8655   if (!r) {
   8656     return(NULL);
   8657   }
   8658   switch(self->topIsA) {
   8659     case TOP_IS_ARRAY:
   8660       setTypeArraySmallJson(r);
   8661       break;
   8662     case TOP_IS_STRING:
   8663       setTypeStringSmallJson(r);
   8664       break;
   8665     default:
   8666       // not reachable
   8667       logC("Check this function!");
   8668   }
   8669 
   8670   if (start < end) {
   8671     n = end - start;
   8672     switch(self->topIsA) {
   8673       case TOP_IS_ARRAY:
   8674         // start < end < len
   8675         for (int64_t i=0;i < n;i++) {
   8676           o = sArrayGetTiny(self->topA, (uint32_t)(start+i));
   8677           sArrayPushTiny(&(r->topA), o);
   8678         }
   8679 
   8680         // copy pointers from range end, array->count to start
   8681         smallt **arr = &(self->topA->data);
   8682 
   8683         for (uint32_t i = 0 ; i < (self->topA->count - end) ; i ++) {
   8684           arr[start+i] = arr[end + i];
   8685         }
   8686 
   8687         self->topA->count -= (uint32_t)(end - start);
   8688         break;
   8689       case TOP_IS_STRING:
   8690         // start < end < len
   8691         l = malloc(((size_t)n+1) * sizeof(char));
   8692         if (!l) {
   8693           terminateO(r);
   8694           return(NULL);
   8695         }
   8696         char *string = sStringGetTiny(self->topS);
   8697         pErrorNULL(strLCpy(l, ((size_t)n+1) * sizeof(char), string+start));
   8698         memmove(string+start, string+end, (size_t)(len-end+1));
   8699         // TODO self->_len -= n
   8700 
   8701         sFree((smallt*)r->topS);
   8702         r->topS = allocSStringTiny(l);;
   8703         free(l);
   8704         break;
   8705       default:
   8706         // not reachable
   8707         logC("Check this function!");
   8708     }
   8709   }
   8710   return(r);
   8711 }
   8712 
   8713 
   8714 internal char* cropSSmallJson(smallJsont *self, int64_t start, int64_t end) {
   8715   char *l = NULL;
   8716   int64_t len;
   8717 
   8718   if (self->topIsA != TOP_IS_STRING) {
   8719     return(NULL);
   8720   }
   8721 
   8722   len = (int64_t)lenSmallJson(self);
   8723 
   8724   if (!len) {
   8725     return(NULL);
   8726   }
   8727 
   8728   if (start > len) {
   8729     return(NULL);
   8730   }
   8731   if (end > len) {
   8732     end = len;
   8733   }
   8734   if (start <= -len) {
   8735     start = -len;
   8736   }
   8737   if (end <= -len) {
   8738     return(NULL);
   8739   }
   8740   if (start < 0) {
   8741     start = len + start;
   8742   }
   8743   if (end <= 0) {
   8744     end = len + end;
   8745   }
   8746   if (end < start) {
   8747     return(NULL);
   8748   }
   8749 
   8750   if (start < end) {
   8751     // start < end < len
   8752     int64_t n;
   8753     n = end - start;
   8754     l = malloc(((size_t)n+1) * sizeof(char));
   8755     if (!l) {
   8756       return(NULL);
   8757     }
   8758     char *string = sStringGetTiny(self->topS);
   8759     pErrorNULL(strLCpy(l, ((size_t)n+1) * sizeof(char), string+start));
   8760     memmove(string+start, string+end, (size_t)(len-end+1));
   8761     // TODO self->_len -= n
   8762   }
   8763   else {
   8764     // start = end, return empty string
   8765     l = strdup("");
   8766   }
   8767 
   8768   return(l);
   8769 }
   8770 
   8771 
   8772 internal smallStringt* cropSmallStringSmallJson(smallJsont *self, int64_t start, int64_t end) {
   8773 
   8774   char *cropped = cropSSmallJson(self, start, end);
   8775 
   8776   if (!cropped) {
   8777     return(NULL);
   8778   }
   8779 
   8780   smallStringt *r = allocSmallString(cropped);
   8781   if (!r) {
   8782     return(NULL);
   8783   }
   8784 
   8785   free(cropped);
   8786   return(r);
   8787 }
   8788 
   8789 
   8790 internal baset* cropElemAtSmallJson(smallJsont *self, int64_t index) {
   8791   baset *r = NULL;
   8792 
   8793   if (self->topIsA != TOP_IS_ARRAY) {
   8794     return(NULL);
   8795   }
   8796 
   8797   if (index >= (int64_t)lenSmallJson(self)) {
   8798     return(NULL);
   8799   }
   8800   if (index < -(int64_t)lenSmallJson(self)) {
   8801     return(NULL);
   8802   }
   8803   if (index < 0) {
   8804     index = (int64_t)lenSmallJson(self) + index;
   8805   }
   8806 
   8807   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
   8808   if (!o) {
   8809     return(NULL);
   8810   }
   8811 
   8812   if (o->type == UNDEFINED) {
   8813     free(o);
   8814     r = (baset*) allocUndefined();
   8815     goto removeElem;
   8816   }
   8817   else if (o->type == CONTAINER) {
   8818     cast(sContainert*, sc, o);
   8819     if (sc->dataType == SH_DT_BASET) {
   8820       // baset object in stored in the container, free the container since
   8821       // it was allocated automatically in the toSmallt function in libsheepyObject.c
   8822       r = toBaset(o);
   8823       free(o);
   8824       goto removeElem;
   8825   }
   8826     }
   8827   r = toBaset(o);;
   8828 
   8829   removeElem:;
   8830 
   8831   // copy pointers from range index+1, array->count to index
   8832   smallt **arr = &(self->topA->data);
   8833 
   8834   for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   8835     arr[index+i] = arr[index+1 + i];
   8836   }
   8837 
   8838   self->topA->count--;
   8839 
   8840   return(r);
   8841 }
   8842 
   8843 
   8844 internal undefinedt* cropElemAtUndefinedSmallJson(smallJsont *self, int64_t index) {
   8845   undefinedt *r = NULL;
   8846 
   8847   if (self->topIsA != TOP_IS_ARRAY) {
   8848     return(NULL);
   8849   }
   8850 
   8851   if (index >= (int64_t)lenSmallJson(self)) {
   8852     return(NULL);
   8853   }
   8854   if (index < -(int64_t)lenSmallJson(self)) {
   8855     return(NULL);
   8856   }
   8857   if (index < 0) {
   8858     index = (int64_t)lenSmallJson(self) + index;
   8859   }
   8860 
   8861   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
   8862   if (!o) {
   8863     return(NULL);
   8864   }
   8865   if (o->type != UNDEFINED) {
   8866     return(NULL);
   8867   }
   8868 
   8869   free(o);
   8870   r = allocUndefined();
   8871 
   8872   // copy pointers from range index+1, array->count to index
   8873   smallt **arr = &(self->topA->data);
   8874 
   8875   for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   8876     arr[index+i] = arr[index+1 + i];
   8877   }
   8878 
   8879   self->topA->count--;
   8880 
   8881   return(r);
   8882 }
   8883 
   8884 internal bool cropElemAtBoolSmallJson(smallJsont *self, int64_t index) {
   8885 
   8886   if (self->topIsA != TOP_IS_ARRAY) {
   8887     return(false);
   8888   }
   8889 
   8890   if (index >= (int64_t)lenSmallJson(self)) {
   8891     return(false);
   8892   }
   8893   if (index < -(int64_t)lenSmallJson(self)) {
   8894     return(false);
   8895   }
   8896   if (index < 0) {
   8897     index = (int64_t)lenSmallJson(self) + index;
   8898   }
   8899 
   8900   bool r        = false;
   8901   smallt *o     = sArrayGetTiny(self->topA, (uint32_t)index);
   8902   if (!o) {
   8903     return(false);
   8904   }
   8905   smallBoolt *e = (smallBoolt*)toBaset(o);
   8906   if (e) {
   8907     if (checkObjectTypes && !isOSmallBool(e)) {
   8908       if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   8909         return(false);
   8910       }
   8911       finishO(e);
   8912       return(false);
   8913     }
   8914     r = e->f->get(e);
   8915     terminateO(e);
   8916 
   8917     // copy pointers from range index+1, array->count to index
   8918     smallt **arr = &(self->topA->data);
   8919 
   8920     for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   8921       arr[index+i] = arr[index+1 + i];
   8922     }
   8923 
   8924     self->topA->count--;
   8925   }
   8926 
   8927   return(r);
   8928 }
   8929 
   8930 
   8931 internal double cropElemAtDoubleSmallJson(smallJsont *self, int64_t index) {
   8932 
   8933   if (self->topIsA != TOP_IS_ARRAY) {
   8934     return(0);
   8935   }
   8936 
   8937   if (index >= (int64_t)lenSmallJson(self)) {
   8938     return(0);
   8939   }
   8940   if (index < -(int64_t)lenSmallJson(self)) {
   8941     return(0);
   8942   }
   8943   if (index < 0) {
   8944     index = (int64_t)lenSmallJson(self) + index;
   8945   }
   8946 
   8947   double r        = 0;
   8948   smallt *o       = sArrayGetTiny(self->topA, (uint32_t)index);
   8949   if (!o) {
   8950     return(0);
   8951   }
   8952   smallDoublet *e = (smallDoublet*)toBaset(o);
   8953   if (e) {
   8954     if (checkObjectTypes && !isOSmallDouble(e)) {
   8955       if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   8956         return(0);
   8957       }
   8958       finishO(e);
   8959       return(0);
   8960     }
   8961     r = e->f->get(e);
   8962     terminateO(e);
   8963 
   8964     // copy pointers from range index+1, array->count to index
   8965     smallt **arr = &(self->topA->data);
   8966 
   8967     for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   8968       arr[index+i] = arr[index+1 + i];
   8969     }
   8970 
   8971     self->topA->count--;
   8972   }
   8973 
   8974   return(r);
   8975 }
   8976 
   8977 
   8978 internal int64_t cropElemAtIntSmallJson(smallJsont *self, int64_t index) {
   8979 
   8980   if (self->topIsA != TOP_IS_ARRAY) {
   8981     return(0);
   8982   }
   8983 
   8984   if (index >= (int64_t)lenSmallJson(self)) {
   8985     return(0);
   8986   }
   8987   if (index < -(int64_t)lenSmallJson(self)) {
   8988     return(0);
   8989   }
   8990   if (index < 0) {
   8991     index = (int64_t)lenSmallJson(self) + index;
   8992   }
   8993 
   8994   int64_t r    = 0;
   8995   smallt *o    = sArrayGetTiny(self->topA, (uint32_t)index);
   8996   if (!o) {
   8997     return(0);
   8998   }
   8999   smallIntt *e = (smallIntt*)toBaset(o);
   9000   if (e) {
   9001     if (checkObjectTypes && !isOSmallInt(e)) {
   9002       if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9003         return(0);
   9004       }
   9005       finishO(e);
   9006       return(0);
   9007     }
   9008     r = e->f->get(e);
   9009     terminateO(e);
   9010 
   9011     // copy pointers from range index+1, array->count to index
   9012     smallt **arr = &(self->topA->data);
   9013 
   9014     for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9015       arr[index+i] = arr[index+1 + i];
   9016     }
   9017 
   9018     self->topA->count--;
   9019   }
   9020 
   9021   return(r);
   9022 }
   9023 
   9024 
   9025 internal int32_t cropElemAtInt32SmallJson(smallJsont *self, int64_t index) {
   9026 
   9027   if (self->topIsA != TOP_IS_ARRAY) {
   9028     return(0);
   9029   }
   9030 
   9031   if (index >= (int64_t)lenSmallJson(self)) {
   9032     return(0);
   9033   }
   9034   if (index < -(int64_t)lenSmallJson(self)) {
   9035     return(0);
   9036   }
   9037   if (index < 0) {
   9038     index = (int64_t)lenSmallJson(self) + index;
   9039   }
   9040 
   9041   int32_t r    = 0;
   9042   smallt *o    = sArrayGetTiny(self->topA, (uint32_t)index);
   9043   if (!o) {
   9044     return(0);
   9045   }
   9046   smallIntt *e = (smallIntt*)toBaset(o);
   9047   if (e) {
   9048     if (checkObjectTypes && !isOSmallInt(e)) {
   9049       if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9050         return(0);
   9051       }
   9052       finishO(e);
   9053       return(0);
   9054     }
   9055     r = (int32_t)e->f->get(e);
   9056     terminateO(e);
   9057 
   9058     // copy pointers from range index+1, array->count to index
   9059     smallt **arr = &(self->topA->data);
   9060 
   9061     for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9062       arr[index+i] = arr[index+1 + i];
   9063     }
   9064 
   9065     self->topA->count--;
   9066   }
   9067 
   9068   return(r);
   9069 }
   9070 
   9071 
   9072 internal uint64_t cropElemAtUintSmallJson(smallJsont *self, int64_t index) {
   9073 
   9074   if (self->topIsA != TOP_IS_ARRAY) {
   9075     return(0);
   9076   }
   9077 
   9078   if (index >= (int64_t)lenSmallJson(self)) {
   9079     return(0);
   9080   }
   9081   if (index < -(int64_t)lenSmallJson(self)) {
   9082     return(0);
   9083   }
   9084   if (index < 0) {
   9085     index = (int64_t)lenSmallJson(self) + index;
   9086   }
   9087 
   9088   uint64_t r   = 0;
   9089   smallt *o    = sArrayGetTiny(self->topA, (uint32_t)index);
   9090   if (!o) {
   9091     return(0);
   9092   }
   9093   smallIntt *e = (smallIntt*)toBaset(o);
   9094   if (e) {
   9095     if (checkObjectTypes && !isOSmallInt(e)) {
   9096       if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9097         return(0);
   9098       }
   9099       finishO(e);
   9100       return(0);
   9101     }
   9102     r = (uint64_t)e->f->get(e);
   9103     terminateO(e);
   9104 
   9105     // copy pointers from range index+1, array->count to index
   9106     smallt **arr = &(self->topA->data);
   9107 
   9108     for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9109       arr[index+i] = arr[index+1 + i];
   9110     }
   9111 
   9112     self->topA->count--;
   9113   }
   9114 
   9115   return(r);
   9116 }
   9117 
   9118 
   9119 internal uint32_t cropElemAtUint32SmallJson(smallJsont *self, int64_t index) {
   9120 
   9121   if (self->topIsA != TOP_IS_ARRAY) {
   9122     return(0);
   9123   }
   9124 
   9125   if (index >= (int64_t)lenSmallJson(self)) {
   9126     return(0);
   9127   }
   9128   if (index < -(int64_t)lenSmallJson(self)) {
   9129     return(0);
   9130   }
   9131   if (index < 0) {
   9132     index = (int64_t)lenSmallJson(self) + index;
   9133   }
   9134 
   9135   uint32_t r   = 0;
   9136   smallt *o    = sArrayGetTiny(self->topA, (uint32_t)index);
   9137   if (!o) {
   9138     return(0);
   9139   }
   9140   smallIntt *e = (smallIntt*)toBaset(o);
   9141   if (e) {
   9142     if (checkObjectTypes && !isOSmallInt(e)) {
   9143       if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9144         return(0);
   9145       }
   9146       finishO(e);
   9147       return(0);
   9148     }
   9149     r = (uint32_t)e->f->get(e);
   9150     terminateO(e);
   9151 
   9152     // copy pointers from range index+1, array->count to index
   9153     smallt **arr = &(self->topA->data);
   9154 
   9155     for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9156       arr[index+i] = arr[index+1 + i];
   9157     }
   9158 
   9159     self->topA->count--;
   9160   }
   9161 
   9162   return(r);
   9163 }
   9164 
   9165 
   9166 internal char* cropElemAtSSmallJson(smallJsont *self, int64_t index) {
   9167 
   9168   if (self->topIsA != TOP_IS_ARRAY) {
   9169     return(NULL);
   9170   }
   9171 
   9172   if (index >= (int64_t)lenSmallJson(self)) {
   9173     return(NULL);
   9174   }
   9175   if (index < -(int64_t)lenSmallJson(self)) {
   9176     return(NULL);
   9177   }
   9178   if (index < 0) {
   9179     index = (int64_t)lenSmallJson(self) + index;
   9180   }
   9181 
   9182   char *r         = NULL;
   9183   smallt *o       = sArrayGetTiny(self->topA, (uint32_t)index);
   9184   if (!o) {
   9185     return(NULL);
   9186   }
   9187   smallStringt *e = (smallStringt*)toBaset(o);
   9188   if (e) {
   9189     if (checkObjectTypes && !isOSmallString(e)) {
   9190       if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9191         return(NULL);
   9192       }
   9193       finishO(e);
   9194       return(NULL);
   9195     }
   9196     r = dupS(e->f->get(e));
   9197     terminateO(e);
   9198 
   9199     // copy pointers from range index+1, array->count to index
   9200     smallt **arr = &(self->topA->data);
   9201 
   9202     for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9203       arr[index+i] = arr[index+1 + i];
   9204     }
   9205 
   9206     self->topA->count--;
   9207   }
   9208 
   9209   return(r);
   9210 }
   9211 
   9212 
   9213 internal char cropElemAtCharSmallJson(smallJsont *self, int64_t index) {
   9214   int64_t len;
   9215 
   9216   if (self->topIsA != TOP_IS_STRING) {
   9217     return(0);
   9218   }
   9219 
   9220   // sanity checks
   9221   if (!self->topS) {
   9222     return(0);
   9223   }
   9224 
   9225   len = (int64_t)lenSmallJson(self);
   9226   if (index >= len) {
   9227     return(0);
   9228   }
   9229   if (index < -len) {
   9230     return(0);
   9231   }
   9232   if (index < 0) {
   9233     index = len + index;
   9234   }
   9235 
   9236   char *string = sStringGetTiny(self->topS);
   9237 
   9238   char r = *(string+index);
   9239 
   9240   if (index == len-1) {
   9241     string[len-1] = 0;
   9242   }
   9243   else {
   9244     memmove(string+index, string+index+1, (size_t)(len - index));
   9245   }
   9246 
   9247   return(r);
   9248 }
   9249 
   9250 
   9251 internal smallDictt* cropElemAtDictSmallJson(smallJsont *self, int64_t index) {
   9252 
   9253   if (self->topIsA != TOP_IS_ARRAY) {
   9254     return(NULL);
   9255   }
   9256 
   9257   if (index >= (int64_t)lenSmallJson(self)) {
   9258     return(NULL);
   9259   }
   9260   if (index < -(int64_t)lenSmallJson(self)) {
   9261     return(NULL);
   9262   }
   9263   if (index < 0) {
   9264     index = (int64_t)lenSmallJson(self) + index;
   9265   }
   9266 
   9267   smallt *o     = sArrayGetTiny(self->topA, (uint32_t)index);
   9268   if (!o) {
   9269     return(NULL);
   9270   }
   9271   smallDictt *r = (smallDictt*)toBaset(o);
   9272   if (checkObjectTypes && r && !isOSmallDict(r)) {
   9273     if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9274       return(NULL);
   9275     }
   9276     finishO(r);
   9277     return(NULL);
   9278   }
   9279 
   9280   // copy pointers from range index+1, array->count to index
   9281   smallt **arr = &(self->topA->data);
   9282 
   9283   for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9284     arr[index+i] = arr[index+1 + i];
   9285   }
   9286 
   9287   self->topA->count--;
   9288 
   9289   return(r);
   9290 }
   9291 
   9292 
   9293 internal smallArrayt* cropElemAtArraySmallJson(smallJsont *self, int64_t index) {
   9294 
   9295   if (self->topIsA != TOP_IS_ARRAY) {
   9296     return(NULL);
   9297   }
   9298 
   9299   if (index >= (int64_t)lenSmallJson(self)) {
   9300     return(NULL);
   9301   }
   9302   if (index < -(int64_t)lenSmallJson(self)) {
   9303     return(NULL);
   9304   }
   9305   if (index < 0) {
   9306     index = (int64_t)lenSmallJson(self) + index;
   9307   }
   9308 
   9309   smallt *o      = sArrayGetTiny(self->topA, (uint32_t)index);
   9310   if (!o) {
   9311     return(NULL);
   9312   }
   9313   smallArrayt *r = (smallArrayt*)toBaset(o);
   9314   if (checkObjectTypes && r && !isOSmallArray(r)) {
   9315     if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9316       return(NULL);
   9317     }
   9318     finishO(r);
   9319     return(NULL);
   9320   }
   9321 
   9322   // copy pointers from range index+1, array->count to index
   9323   smallt **arr = &(self->topA->data);
   9324 
   9325   for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9326     arr[index+i] = arr[index+1 + i];
   9327   }
   9328 
   9329   self->topA->count--;
   9330 
   9331   return(r);
   9332 }
   9333 
   9334 
   9335 internal smallBoolt* cropElemAtSmallBoolSmallJson(smallJsont *self, int64_t index) {
   9336 
   9337   if (self->topIsA != TOP_IS_ARRAY) {
   9338     return(NULL);
   9339   }
   9340 
   9341   if (index >= (int64_t)lenSmallJson(self)) {
   9342     return(NULL);
   9343   }
   9344   if (index < -(int64_t)lenSmallJson(self)) {
   9345     return(NULL);
   9346   }
   9347   if (index < 0) {
   9348     index = (int64_t)lenSmallJson(self) + index;
   9349   }
   9350 
   9351   smallt *o     = sArrayGetTiny(self->topA, (uint32_t)index);
   9352   if (!o) {
   9353     return(NULL);
   9354   }
   9355   smallBoolt *r = (smallBoolt*)toBaset(o);
   9356   if (checkObjectTypes && r && !isOSmallBool(r)) {
   9357     if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9358       return(NULL);
   9359     }
   9360     finishO(r);
   9361     return(NULL);
   9362   }
   9363 
   9364   // copy pointers from range index+1, array->count to index
   9365   smallt **arr = &(self->topA->data);
   9366 
   9367   for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9368     arr[index+i] = arr[index+1 + i];
   9369   }
   9370 
   9371   self->topA->count--;
   9372 
   9373   return(r);
   9374 }
   9375 
   9376 
   9377 internal smallBytest* cropElemAtSmallBytesSmallJson(smallJsont *self, int64_t index) {
   9378 
   9379   if (self->topIsA != TOP_IS_ARRAY) {
   9380     return(NULL);
   9381   }
   9382 
   9383   if (index >= (int64_t)lenSmallJson(self)) {
   9384     return(NULL);
   9385   }
   9386   if (index < -(int64_t)lenSmallJson(self)) {
   9387     return(NULL);
   9388   }
   9389   if (index < 0) {
   9390     index = (int64_t)lenSmallJson(self) + index;
   9391   }
   9392 
   9393   smallt *o      = sArrayGetTiny(self->topA, (uint32_t)index);
   9394   if (!o) {
   9395     return(NULL);
   9396   }
   9397   smallBytest *r = (smallBytest*)toBaset(o);
   9398   if (checkObjectTypes && r && !isOSmallBytes(r)) {
   9399     if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9400       return(NULL);
   9401     }
   9402     finishO(r);
   9403     return(NULL);
   9404   }
   9405 
   9406   // copy pointers from range index+1, array->count to index
   9407   smallt **arr = &(self->topA->data);
   9408 
   9409   for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9410     arr[index+i] = arr[index+1 + i];
   9411   }
   9412 
   9413   self->topA->count--;
   9414 
   9415   return(r);
   9416 }
   9417 
   9418 
   9419 internal smallDoublet* cropElemAtSmallDoubleSmallJson(smallJsont *self, int64_t index) {
   9420 
   9421   if (self->topIsA != TOP_IS_ARRAY) {
   9422     return(NULL);
   9423   }
   9424 
   9425   if (index >= (int64_t)lenSmallJson(self)) {
   9426     return(NULL);
   9427   }
   9428   if (index < -(int64_t)lenSmallJson(self)) {
   9429     return(NULL);
   9430   }
   9431   if (index < 0) {
   9432     index = (int64_t)lenSmallJson(self) + index;
   9433   }
   9434 
   9435   smallt *o       = sArrayGetTiny(self->topA, (uint32_t)index);
   9436   if (!o) {
   9437     return(NULL);
   9438   }
   9439   smallDoublet *r = (smallDoublet*)toBaset(o);
   9440   if (checkObjectTypes && r && !isOSmallDouble(r)) {
   9441     if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9442       return(NULL);
   9443     }
   9444     finishO(r);
   9445     return(NULL);
   9446   }
   9447 
   9448   // copy pointers from range index+1, array->count to index
   9449   smallt **arr = &(self->topA->data);
   9450 
   9451   for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9452     arr[index+i] = arr[index+1 + i];
   9453   }
   9454 
   9455   self->topA->count--;
   9456 
   9457   return(r);
   9458 }
   9459 
   9460 
   9461 internal smallIntt* cropElemAtSmallIntSmallJson(smallJsont *self, int64_t index) {
   9462 
   9463   if (self->topIsA != TOP_IS_ARRAY) {
   9464     return(NULL);
   9465   }
   9466 
   9467   if (index >= (int64_t)lenSmallJson(self)) {
   9468     return(NULL);
   9469   }
   9470   if (index < -(int64_t)lenSmallJson(self)) {
   9471     return(NULL);
   9472   }
   9473   if (index < 0) {
   9474     index = (int64_t)lenSmallJson(self) + index;
   9475   }
   9476 
   9477   smallt *o       = sArrayGetTiny(self->topA, (uint32_t)index);
   9478   if (!o) {
   9479     return(NULL);
   9480   }
   9481   smallIntt *r = (smallIntt*)toBaset(o);
   9482   if (checkObjectTypes && r && !isOSmallInt(r)) {
   9483     if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9484       return(NULL);
   9485     }
   9486     finishO(r);
   9487     return(NULL);
   9488   }
   9489 
   9490   // copy pointers from range index+1, array->count to index
   9491   smallt **arr = &(self->topA->data);
   9492 
   9493   for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9494     arr[index+i] = arr[index+1 + i];
   9495   }
   9496 
   9497   self->topA->count--;
   9498 
   9499   return(r);
   9500 }
   9501 
   9502 
   9503 internal smallJsont* cropElemAtSmallJsonSmallJson(smallJsont *self, int64_t index) {
   9504 
   9505   if (self->topIsA != TOP_IS_ARRAY) {
   9506     return(NULL);
   9507   }
   9508 
   9509   if (index >= (int64_t)lenSmallJson(self)) {
   9510     return(NULL);
   9511   }
   9512   if (index < -(int64_t)lenSmallJson(self)) {
   9513     return(NULL);
   9514   }
   9515   if (index < 0) {
   9516     index = (int64_t)lenSmallJson(self) + index;
   9517   }
   9518 
   9519   smallt *o       = sArrayGetTiny(self->topA, (uint32_t)index);
   9520   if (!o) {
   9521     return(NULL);
   9522   }
   9523   if ((o->type == BYTES) || (o->type == CONTAINER)) {
   9524     return(NULL);
   9525   }
   9526   baset *e = toBaset(o);
   9527   if (!e) {
   9528     finishO(e);
   9529     return(NULL);
   9530   }
   9531   createAllocateSmallJson(r);
   9532   if (!r) {
   9533     finishO(e);
   9534     return(NULL);
   9535   }
   9536   setTopNFreeSmallJson(r, e);
   9537 
   9538   // copy pointers from range index+1, array->count to index
   9539   smallt **arr = &(self->topA->data);
   9540 
   9541   for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9542     arr[index+i] = arr[index+1 + i];
   9543   }
   9544 
   9545   self->topA->count--;
   9546 
   9547   return(r);
   9548 }
   9549 
   9550 
   9551 internal smallStringt* cropElemAtSmallStringSmallJson(smallJsont *self, int64_t index) {
   9552 
   9553   if (self->topIsA != TOP_IS_ARRAY) {
   9554     return(NULL);
   9555   }
   9556 
   9557   if (index >= (int64_t)lenSmallJson(self)) {
   9558     return(NULL);
   9559   }
   9560   if (index < -(int64_t)lenSmallJson(self)) {
   9561     return(NULL);
   9562   }
   9563   if (index < 0) {
   9564     index = (int64_t)lenSmallJson(self) + index;
   9565   }
   9566 
   9567   smallt *o       = sArrayGetTiny(self->topA, (uint32_t)index);
   9568   if (!o) {
   9569     return(NULL);
   9570   }
   9571   smallStringt *r = (smallStringt*)toBaset(o);
   9572   if (checkObjectTypes && r && !isOSmallString(r)) {
   9573     if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9574       return(NULL);
   9575     }
   9576     finishO(r);
   9577     return(NULL);
   9578   }
   9579 
   9580   // copy pointers from range index+1, array->count to index
   9581   smallt **arr = &(self->topA->data);
   9582 
   9583   for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9584     arr[index+i] = arr[index+1 + i];
   9585   }
   9586 
   9587   self->topA->count--;
   9588 
   9589   return(r);
   9590 }
   9591 
   9592 
   9593 internal void* cropElemAtVoidSmallJson(smallJsont *self, int64_t index) {
   9594 
   9595   if (self->topIsA != TOP_IS_ARRAY) {
   9596     return(NULL);
   9597   }
   9598 
   9599   if (index >= (int64_t)lenSmallJson(self)) {
   9600     return(NULL);
   9601   }
   9602   if (index < -(int64_t)lenSmallJson(self)) {
   9603     return(NULL);
   9604   }
   9605   if (index < 0) {
   9606     index = (int64_t)lenSmallJson(self) + index;
   9607   }
   9608 
   9609   void *r            = NULL;
   9610   smallt *o          = sArrayGetTiny(self->topA, (uint32_t)index);
   9611   if (!o) {
   9612     return(NULL);
   9613   }
   9614   smallContainert *e = (smallContainert*)toBaset(o);
   9615   if (e) {
   9616     if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9617       return(NULL);
   9618     }
   9619     if (checkObjectTypes && !isOSmallContainer(e)) {
   9620       finishO(e);
   9621       return(NULL);
   9622     }
   9623     r = e->f->get(e);
   9624     smashO(e);
   9625 
   9626     // copy pointers from range index+1, array->count to index
   9627     smallt **arr = &(self->topA->data);
   9628 
   9629     for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9630       arr[index+i] = arr[index+1 + i];
   9631     }
   9632 
   9633     self->topA->count--;
   9634   }
   9635 
   9636   return(r);
   9637 }
   9638 
   9639 
   9640 internal smallContainert* cropElemAtSmallContainerSmallJson(smallJsont *self, int64_t index) {
   9641 
   9642   if (self->topIsA != TOP_IS_ARRAY) {
   9643     return(NULL);
   9644   }
   9645 
   9646   if (index >= (int64_t)lenSmallJson(self)) {
   9647     return(NULL);
   9648   }
   9649   if (index < -(int64_t)lenSmallJson(self)) {
   9650     return(NULL);
   9651   }
   9652   if (index < 0) {
   9653     index = (int64_t)lenSmallJson(self) + index;
   9654   }
   9655 
   9656   smallt *o          = sArrayGetTiny(self->topA, (uint32_t)index);
   9657   if (!o) {
   9658     return(NULL);
   9659   }
   9660   smallContainert *r = (smallContainert*)toBaset(o);
   9661   if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
   9662     return(NULL);
   9663   }
   9664   if (checkObjectTypes && r && !isOSmallContainer(r)) {
   9665     finishO(r);
   9666     return(NULL);
   9667   }
   9668 
   9669   // copy pointers from range index+1, array->count to index
   9670   smallt **arr = &(self->topA->data);
   9671 
   9672   for (uint32_t i = 0 ; i < (self->topA->count - (index+1)) ; i ++) {
   9673     arr[index+i] = arr[index+1 + i];
   9674   }
   9675 
   9676   self->topA->count--;
   9677 
   9678   return(r);
   9679 }
   9680 
   9681 
   9682 internal baset* cropElemKeySmallJson(smallJsont *self, const char* key) {
   9683 
   9684   if (self->topIsA != TOP_IS_DICT) {
   9685     return(NULL);
   9686   }
   9687 
   9688   if (!key || !self->top) {
   9689     return(NULL);
   9690   }
   9691 
   9692   smallt *sm = NULL;
   9693   forEachSDict(self->top, e) {
   9694     if (e->key && strEq(key, e->key)) {
   9695         sm = e->data;
   9696         free(e->key);
   9697         e->key = NULL;
   9698         break;
   9699   }
   9700     }
   9701 
   9702   if (!sm) {
   9703     return(NULL);
   9704   }
   9705   if (sm->type == UNDEFINED) {
   9706     free(sm);
   9707     return((baset*) allocUndefined());
   9708   }
   9709   else if (sm->type == CONTAINER) {
   9710     cast(sContainert*, sc, sm);
   9711     if (sc->dataType == SH_DT_BASET) {
   9712       // baset object in stored in the container, free the container since
   9713       // it was allocated automatically in the toSmallt function in libsheepyObject.c
   9714       baset *r = toBaset(sm);
   9715       free(sm);
   9716       return(r);
   9717   }
   9718     }
   9719   return(toBaset(sm));
   9720 }
   9721 
   9722 
   9723 internal undefinedt* cropElemKeyUndefinedSmallJson(smallJsont *self, const char* key) {
   9724 
   9725   if (self->topIsA != TOP_IS_DICT) {
   9726     return(NULL);
   9727   }
   9728 
   9729   if (!key || !self->top) {
   9730     return(NULL);
   9731   }
   9732 
   9733   smallt *sm    = NULL;
   9734   undefinedt *r = NULL;
   9735   forEachSDict(self->top, e) {
   9736     if (e->key && eqS(key, e->key)) {
   9737         sm = e->data;
   9738         if (!sm) {
   9739           return(NULL);
   9740         }
   9741         if (sm->type != UNDEFINED) {
   9742           return(NULL);
   9743         }
   9744         free(e->data);
   9745         free(e->key);
   9746         e->key = NULL;
   9747         r  = (undefinedt*) allocUndefined();
   9748         break;
   9749   }
   9750     }
   9751 
   9752   return(r);
   9753 }
   9754 
   9755 
   9756 internal bool cropElemKeyBoolSmallJson(smallJsont *self, const char* key) {
   9757 
   9758   if (self->topIsA != TOP_IS_DICT) {
   9759     return(no);
   9760   }
   9761 
   9762   if (!key || !self->top) {
   9763     return(false);
   9764   }
   9765 
   9766   smallt *sm    = NULL;
   9767   smallBoolt *o = NULL;
   9768   forEachSDict(self->top, e) {
   9769     if (e->key && strEq(key, e->key)) {
   9770         sm = e->data;
   9771         if (!sm) {
   9772           return(no);
   9773         }
   9774         o  = (smallBoolt*)toBaset(sm);
   9775         if (!o) {
   9776           return(no);
   9777         }
   9778         if (checkObjectTypes && o && !isOSmallBool(o)) {
   9779           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
   9780             return(no);
   9781           }
   9782           finishO(o);
   9783           return(false);
   9784         }
   9785         free(e->key);
   9786         e->key = NULL;
   9787 
   9788         bool r = o->f->get(o);
   9789         terminateO(o);
   9790         return(r);
   9791   }
   9792     }
   9793 
   9794   return(false);
   9795 }
   9796 
   9797 
   9798 internal double cropElemKeyDoubleSmallJson(smallJsont *self, const char* key) {
   9799 
   9800   if (self->topIsA != TOP_IS_DICT) {
   9801     return(0);
   9802   }
   9803 
   9804   if (!key || !self->top) {
   9805     return(0);
   9806   }
   9807 
   9808   smallt *sm      = NULL;
   9809   smallDoublet *o = NULL;
   9810   forEachSDict(self->top, e) {
   9811     if (e->key && strEq(key, e->key)) {
   9812         sm = e->data;
   9813         if (!sm) {
   9814           return(0);
   9815         }
   9816         o  = (smallDoublet*)toBaset(sm);
   9817         if (!o) {
   9818           return(0);
   9819         }
   9820         if (checkObjectTypes && o && !isOSmallDouble(o)) {
   9821           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
   9822             return(0);
   9823           }
   9824           finishO(o);
   9825           return(0);
   9826         }
   9827         free(e->key);
   9828         e->key = NULL;
   9829 
   9830         double r = o->f->get(o);
   9831         terminateO(o);
   9832         return(r);
   9833   }
   9834     }
   9835 
   9836   return(0);
   9837 }
   9838 
   9839 
   9840 internal int64_t cropElemKeyIntSmallJson(smallJsont *self, const char* key) {
   9841 
   9842   if (self->topIsA != TOP_IS_DICT) {
   9843     return(0);
   9844   }
   9845 
   9846   if (!key || !self->top) {
   9847     return(0);
   9848   }
   9849 
   9850   smallt *sm   = NULL;
   9851   smallIntt *o = NULL;
   9852   forEachSDict(self->top, e) {
   9853     if (e->key && strEq(key, e->key)) {
   9854         sm = e->data;
   9855         if (!sm) {
   9856           return(0);
   9857         }
   9858         o  = (smallIntt*)toBaset(sm);
   9859         if (!o) {
   9860           return(0);
   9861         }
   9862         if (checkObjectTypes && o && !isOSmallInt(o)) {
   9863           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
   9864             return(0);
   9865           }
   9866           finishO(o);
   9867           return(0);
   9868         }
   9869         free(e->key);
   9870         e->key = NULL;
   9871 
   9872         int64_t r = o->f->get(o);
   9873         terminateO(o);
   9874         return(r);
   9875   }
   9876     }
   9877 
   9878   return(0);
   9879 }
   9880 
   9881 
   9882 internal int32_t cropElemKeyInt32SmallJson(smallJsont *self, const char* key) {
   9883 
   9884   if (self->topIsA != TOP_IS_DICT) {
   9885     return(0);
   9886   }
   9887 
   9888   if (!key || !self->top) {
   9889     return(0);
   9890   }
   9891 
   9892   smallt *sm   = NULL;
   9893   smallIntt *o = NULL;
   9894   forEachSDict(self->top, e) {
   9895     if (e->key && strEq(key, e->key)) {
   9896         sm = e->data;
   9897         if (!sm) {
   9898           return(0);
   9899         }
   9900         o  = (smallIntt*)toBaset(sm);
   9901         if (!o) {
   9902           return(0);
   9903         }
   9904         if (checkObjectTypes && o && !isOSmallInt(o)) {
   9905           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
   9906             return(0);
   9907           }
   9908           finishO(o);
   9909           return(0);
   9910         }
   9911         free(e->key);
   9912         e->key = NULL;
   9913 
   9914         int32_t r = (int32_t)o->f->get(o);
   9915         terminateO(o);
   9916         return(r);
   9917   }
   9918     }
   9919 
   9920   return(0);
   9921 }
   9922 
   9923 
   9924 internal uint64_t cropElemKeyUintSmallJson(smallJsont *self, const char* key) {
   9925 
   9926   if (self->topIsA != TOP_IS_DICT) {
   9927     return(0);
   9928   }
   9929 
   9930   if (!key || !self->top) {
   9931     return(0);
   9932   }
   9933 
   9934   smallt *sm   = NULL;
   9935   smallIntt *o = NULL;
   9936   forEachSDict(self->top, e) {
   9937     if (e->key && strEq(key, e->key)) {
   9938         sm = e->data;
   9939         if (!sm) {
   9940           return(0);
   9941         }
   9942         o  = (smallIntt*)toBaset(sm);
   9943         if (!o) {
   9944           return(0);
   9945         }
   9946         if (checkObjectTypes && o && !isOSmallInt(o)) {
   9947           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
   9948             return(0);
   9949           }
   9950           finishO(o);
   9951           return(0);
   9952         }
   9953         free(e->key);
   9954         e->key = NULL;
   9955 
   9956         uint64_t r = (uint64_t)o->f->get(o);
   9957         terminateO(o);
   9958         return(r);
   9959   }
   9960     }
   9961 
   9962   return(0);
   9963 }
   9964 
   9965 
   9966 internal uint32_t cropElemKeyUint32SmallJson(smallJsont *self, const char* key) {
   9967 
   9968   if (self->topIsA != TOP_IS_DICT) {
   9969     return(0);
   9970   }
   9971 
   9972   if (!key || !self->top) {
   9973     return(0);
   9974   }
   9975 
   9976   smallt *sm   = NULL;
   9977   smallIntt *o = NULL;
   9978   forEachSDict(self->top, e) {
   9979     if (e->key && strEq(key, e->key)) {
   9980         sm = e->data;
   9981         if (!sm) {
   9982           return(0);
   9983         }
   9984         o  = (smallIntt*)toBaset(sm);
   9985         if (!o) {
   9986           return(0);
   9987         }
   9988         if (checkObjectTypes && o && !isOSmallInt(o)) {
   9989           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
   9990             return(0);
   9991           }
   9992           finishO(o);
   9993           return(0);
   9994         }
   9995         free(e->key);
   9996         e->key = NULL;
   9997 
   9998         uint32_t r = (uint32_t)o->f->get(o);
   9999         terminateO(o);
  10000         return(r);
  10001   }
  10002     }
  10003 
  10004   return(0);
  10005 }
  10006 
  10007 
  10008 internal char* cropElemKeySSmallJson(smallJsont *self, const char* key) {
  10009 
  10010   if (self->topIsA != TOP_IS_DICT) {
  10011     return(NULL);
  10012   }
  10013 
  10014   if (!key || !self->top) {
  10015     return(NULL);
  10016   }
  10017 
  10018   smallt *sm      = NULL;
  10019   smallStringt *o = NULL;
  10020   forEachSDict(self->top, e) {
  10021     if (e->key && strEq(key, e->key)) {
  10022         sm = e->data;
  10023         if (!sm) {
  10024           return(NULL);
  10025         }
  10026         o  = (smallStringt*)toBaset(sm);
  10027         if (!o) {
  10028           return(NULL);
  10029         }
  10030         if (checkObjectTypes && o && !isOSmallString(o)) {
  10031           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
  10032             return(NULL);
  10033           }
  10034           finishO(o);
  10035           return(NULL);
  10036         }
  10037         free(e->key);
  10038         e->key = NULL;
  10039 
  10040         char *r = dupS(o->f->get(o));
  10041         terminateO(o);
  10042         return(r);
  10043   }
  10044     }
  10045 
  10046   return(NULL);
  10047 }
  10048 
  10049 
  10050 internal smallDictt* cropElemKeyDictSmallJson(smallJsont *self, const char* key) {
  10051 
  10052   if (self->topIsA != TOP_IS_DICT) {
  10053     return(NULL);
  10054   }
  10055 
  10056   if (!key || !self->top) {
  10057     return(NULL);
  10058   }
  10059 
  10060   smallt *sm    = NULL;
  10061   smallDictt *r = NULL;
  10062   forEachSDict(self->top, e) {
  10063     if (e->key && strEq(key, e->key)) {
  10064         sm = e->data;
  10065         if (!sm) {
  10066           return(NULL);
  10067         }
  10068         r  = (smallDictt*)toBaset(sm);
  10069         if (checkObjectTypes && r && !isOSmallDict(r)) {
  10070           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
  10071             return(NULL);
  10072           }
  10073           finishO(r);
  10074           return(NULL);
  10075         }
  10076         free(e->key);
  10077         e->key = NULL;
  10078         break;
  10079   }
  10080     }
  10081 
  10082   return(r);
  10083 }
  10084 
  10085 
  10086 internal smallArrayt* cropElemKeyArraySmallJson(smallJsont *self, const char* key) {
  10087 
  10088   if (self->topIsA != TOP_IS_DICT) {
  10089     return(NULL);
  10090   }
  10091 
  10092   if (!key || !self->top) {
  10093     return(NULL);
  10094   }
  10095 
  10096   smallt *sm     = NULL;
  10097   smallArrayt *r = NULL;
  10098   forEachSDict(self->top, e) {
  10099     if (e->key && strEq(key, e->key)) {
  10100         sm = e->data;
  10101         if (!sm) {
  10102           return(NULL);
  10103         }
  10104         r  = (smallArrayt*)toBaset(sm);
  10105         if (checkObjectTypes && r && !isOSmallArray(r)) {
  10106           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
  10107             return(NULL);
  10108           }
  10109           finishO(r);
  10110           return(NULL);
  10111         }
  10112         free(e->key);
  10113         e->key = NULL;
  10114         break;
  10115   }
  10116     }
  10117 
  10118   return(r);
  10119 }
  10120 
  10121 
  10122 internal smallBoolt* cropElemKeySmallBoolSmallJson(smallJsont *self, const char* key) {
  10123 
  10124   if (self->topIsA != TOP_IS_DICT) {
  10125     return(NULL);
  10126   }
  10127 
  10128   if (!key || !self->top) {
  10129     return(NULL);
  10130   }
  10131 
  10132   smallt *sm    = NULL;
  10133   smallBoolt *r = NULL;
  10134   forEachSDict(self->top, e) {
  10135     if (e->key && strEq(key, e->key)) {
  10136         sm = e->data;
  10137         if (!sm) {
  10138           return(NULL);
  10139         }
  10140         r  = (smallBoolt*)toBaset(sm);
  10141         if (checkObjectTypes && r && !isOSmallBool(r)) {
  10142           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
  10143             return(NULL);
  10144           }
  10145           finishO(r);
  10146           return(NULL);
  10147         }
  10148         free(e->key);
  10149         e->key = NULL;
  10150         break;
  10151   }
  10152     }
  10153 
  10154   return(r);
  10155 }
  10156 
  10157 
  10158 internal smallBytest* cropElemKeySmallBytesSmallJson(smallJsont *self, const char* key) {
  10159 
  10160   if (self->topIsA != TOP_IS_DICT) {
  10161     return(NULL);
  10162   }
  10163 
  10164   if (!key || !self->top) {
  10165     return(NULL);
  10166   }
  10167 
  10168   smallt *sm     = NULL;
  10169   smallBytest *r = NULL;
  10170   forEachSDict(self->top, e) {
  10171     if (e->key && strEq(key, e->key)) {
  10172         sm = e->data;
  10173         if (!sm) {
  10174           return(NULL);
  10175         }
  10176         r  = (smallBytest*)toBaset(sm);
  10177         if (checkObjectTypes && r && !isOSmallBytes(r)) {
  10178           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
  10179             return(NULL);
  10180           }
  10181           finishO(r);
  10182           return(NULL);
  10183         }
  10184         free(e->key);
  10185         e->key = NULL;
  10186         break;
  10187   }
  10188     }
  10189 
  10190   return(r);
  10191 }
  10192 
  10193 
  10194 internal smallDoublet* cropElemKeySmallDoubleSmallJson(smallJsont *self, const char* key) {
  10195 
  10196   if (self->topIsA != TOP_IS_DICT) {
  10197     return(NULL);
  10198   }
  10199 
  10200   if (!key || !self->top) {
  10201     return(NULL);
  10202   }
  10203 
  10204   smallt *sm      = NULL;
  10205   smallDoublet *r = NULL;
  10206   forEachSDict(self->top, e) {
  10207     if (e->key && strEq(key, e->key)) {
  10208         sm = e->data;
  10209         if (!sm) {
  10210           return(NULL);
  10211         }
  10212         r  = (smallDoublet*)toBaset(sm);
  10213         if (checkObjectTypes && r && !isOSmallDouble(r)) {
  10214           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
  10215             return(NULL);
  10216           }
  10217           finishO(r);
  10218           return(NULL);
  10219         }
  10220         free(e->key);
  10221         e->key = NULL;
  10222         break;
  10223   }
  10224     }
  10225 
  10226   return(r);
  10227 }
  10228 
  10229 
  10230 internal smallIntt* cropElemKeySmallIntSmallJson(smallJsont *self, const char* key) {
  10231 
  10232   if (self->topIsA != TOP_IS_DICT) {
  10233     return(NULL);
  10234   }
  10235 
  10236   if (!key || !self->top) {
  10237     return(NULL);
  10238   }
  10239 
  10240   smallt *sm   = NULL;
  10241   smallIntt *r = NULL;
  10242   forEachSDict(self->top, e) {
  10243     if (e->key && strEq(key, e->key)) {
  10244         sm = e->data;
  10245         if (!sm) {
  10246           return(NULL);
  10247         }
  10248         r  = (smallIntt*)toBaset(sm);
  10249         if (checkObjectTypes && r && !isOSmallInt(r)) {
  10250           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
  10251             return(NULL);
  10252           }
  10253           finishO(r);
  10254           return(NULL);
  10255         }
  10256         free(e->key);
  10257         e->key = NULL;
  10258         break;
  10259   }
  10260     }
  10261 
  10262   return(r);
  10263 }
  10264 
  10265 
  10266 internal smallJsont* cropElemKeySmallJsonSmallJson(smallJsont *self, const char* key) {
  10267 
  10268   if (self->topIsA != TOP_IS_DICT) {
  10269     return(NULL);
  10270   }
  10271 
  10272   if (!key || !self->top) {
  10273     return(NULL);
  10274   }
  10275 
  10276   smallt *sm    = NULL;
  10277   forEachSDict(self->top, e) {
  10278     if (e->key && strEq(key, e->key)) {
  10279         sm       = e->data;
  10280         if (!sm) {
  10281           return(NULL);
  10282         }
  10283         if ((sm->type == BYTES) || (sm->type == CONTAINER)) {
  10284           return(NULL);
  10285         }
  10286         baset *o = toBaset(sm);
  10287         if (!o) {
  10288           finishO(o);
  10289           return(NULL);
  10290         }
  10291         free(e->key);
  10292         e->key = NULL;
  10293         createAllocateSmallJson(r);
  10294         if (!r) {
  10295           finishO(o);
  10296           return(NULL);
  10297         }
  10298         setTopNFreeO(r, o);
  10299         return(r);
  10300   }
  10301     }
  10302 
  10303   return(NULL);
  10304 }
  10305 
  10306 
  10307 internal smallStringt* cropElemKeySmallStringSmallJson(smallJsont *self, const char* key) {
  10308 
  10309   if (self->topIsA != TOP_IS_DICT) {
  10310     return(NULL);
  10311   }
  10312 
  10313   if (!key || !self->top) {
  10314     return(NULL);
  10315   }
  10316 
  10317   smallt *sm      = NULL;
  10318   smallStringt *r = NULL;
  10319   forEachSDict(self->top, e) {
  10320     if (e->key && strEq(key, e->key)) {
  10321         sm = e->data;
  10322         if (!sm) {
  10323           return(NULL);
  10324         }
  10325         r  = (smallStringt*)toBaset(sm);
  10326         if (checkObjectTypes && r && !isOSmallString(r)) {
  10327           if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
  10328             return(NULL);
  10329           }
  10330           finishO(r);
  10331           return(NULL);
  10332         }
  10333         free(e->key);
  10334         e->key = NULL;
  10335         break;
  10336   }
  10337     }
  10338 
  10339   return(r);
  10340 }
  10341 
  10342 
  10343 internal void* cropElemKeyVoidSmallJson(smallJsont *self, const char* key) {
  10344 
  10345   if (self->topIsA != TOP_IS_DICT) {
  10346     return(NULL);
  10347   }
  10348 
  10349   if (!key || !self->top) {
  10350     return(NULL);
  10351   }
  10352 
  10353   smallt *sm         = NULL;
  10354   smallContainert *o = NULL;
  10355   forEachSDict(self->top, e) {
  10356     if (e->key && strEq(key, e->key)) {
  10357         sm = e->data;
  10358         if (!sm) {
  10359           return(NULL);
  10360         }
  10361         if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
  10362           return(NULL);
  10363         }
  10364         o  = (smallContainert*)toBaset(sm);
  10365         if (!o) {
  10366           return(NULL);
  10367         }
  10368         if (checkObjectTypes && o && !isOSmallContainer(o)) {
  10369           finishO(o);
  10370           return(NULL);
  10371         }
  10372         free(e->key);
  10373         e->key = NULL;
  10374 
  10375         void *r = o->f->get(o);
  10376         terminateO(o);
  10377         return(r);
  10378   }
  10379     }
  10380 
  10381   return(NULL);
  10382 }
  10383 
  10384 
  10385 internal smallContainert* cropElemKeySmallContainerSmallJson(smallJsont *self, const char* key) {
  10386 
  10387   if (self->topIsA != TOP_IS_DICT) {
  10388     return(NULL);
  10389   }
  10390 
  10391   if (!key || !self->top) {
  10392     return(NULL);
  10393   }
  10394 
  10395   smallt *sm         = NULL;
  10396   smallContainert *r = NULL;
  10397   forEachSDict(self->top, e) {
  10398     if (e->key && strEq(key, e->key)) {
  10399         sm = e->data;
  10400         if (!sm) {
  10401           return(NULL);
  10402         }
  10403         if ((sm->type == CONTAINER) && (((sContainert*)sm)->dataType == SH_DT_BASET)) {
  10404           return(NULL);
  10405         }
  10406         r  = (smallContainert*)toBaset(sm);
  10407         if (checkObjectTypes && r && !isOSmallContainer(r)) {
  10408           finishO(r);
  10409           return(NULL);
  10410         }
  10411         free(e->key);
  10412         e->key = NULL;
  10413         break;
  10414   }
  10415     }
  10416 
  10417   return(r);
  10418 }
  10419 
  10420 
  10421 
  10422 internal smallJsont* copySmallJson(smallJsont *self, int64_t start, int64_t end) {
  10423   size_t len;
  10424   smallt *o = NULL;
  10425   char *s = NULL;
  10426 
  10427   if (self->topIsA != TOP_IS_ARRAY && self->topIsA != TOP_IS_STRING) {
  10428     return(NULL);
  10429   }
  10430 
  10431   len = lenSmallJson(self);
  10432   // sanity checks
  10433   if (!len) {
  10434     return(NULL);
  10435   }
  10436 
  10437   if (start >= (int64_t)len) {
  10438     return(NULL);
  10439   }
  10440   if (end > (int64_t)len) {
  10441     end = (int64_t)len;
  10442   }
  10443   if (start <= -(int64_t)len) {
  10444     start = -(int64_t)len;
  10445   }
  10446   if (end <= -(int64_t)len) {
  10447     return(NULL);
  10448   }
  10449   if (start < 0) {
  10450     start = (int64_t)len + start;
  10451   }
  10452   if (end <= 0) {
  10453     end = (int64_t)len + end;
  10454   }
  10455   if (end < start) {
  10456     return(NULL);
  10457   }
  10458 
  10459   createAllocateSmallJson(r);
  10460   if (!r) {
  10461     return(NULL);
  10462   }
  10463   switch(self->topIsA) {
  10464     case TOP_IS_ARRAY:
  10465       r->f->setTypeArray(r);
  10466 
  10467       if (start == end) {
  10468         // empty list
  10469         return(r);
  10470       }
  10471       else {
  10472         // start < end < len
  10473         int64_t n;
  10474         n = end - start;
  10475 
  10476         for (int64_t i=0;i < n;i++) {
  10477           o = sArrayGetTiny(self->topA, (uint32_t)(start+i));
  10478           sArrayPushTiny(&(r->topA), sDuplicate(o));
  10479       }
  10480         }
  10481       break;
  10482     case TOP_IS_STRING:;
  10483 
  10484       int64_t n;
  10485       if (start == end) {
  10486         emptyS(s);
  10487       }
  10488       else {
  10489         // start < end < len
  10490         // copy range to a new smallString
  10491         n = end - start;
  10492         s = malloc((size_t)n+1);
  10493         if (!s) {
  10494           return(NULL);
  10495         }
  10496         s = strncpy(s, sStringGetTiny(self->topS) + start, (size_t)n);
  10497         s[n] = 0;
  10498       }
  10499 
  10500       r->f->setTopNFreeString(r, s);
  10501       break;
  10502     default:
  10503       // not reachable
  10504       logC("Check this function!");
  10505   }
  10506 
  10507   return(r);
  10508 }
  10509 
  10510 internal smallJsont* insertSmallJson(smallJsont *self, int64_t index, smallArrayt *toInsert) {
  10511   size_t len;
  10512 
  10513   //sanity checks
  10514   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  10515     return(NULL);
  10516   }
  10517 
  10518   if (!toInsert) {
  10519     return(NULL);
  10520   }
  10521 
  10522   if (checkObjectTypes && toInsert && !isOSmallArray(toInsert)) {
  10523     return(NULL);
  10524   }
  10525 
  10526   if (self->topA == toInsert->a) {
  10527     return(NULL);
  10528   }
  10529 
  10530   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  10531     self->topIsA = TOP_IS_ARRAY;
  10532   }
  10533 
  10534   len = lenSmallJson(self);
  10535 
  10536   if (!len && index == -1) {
  10537     // empty string, index -1 is equal to 0
  10538     index = 0;
  10539   }
  10540   bool neg = false;
  10541   if (index < 0) {
  10542     neg = true;
  10543   }
  10544 
  10545   if (index > (int64_t)len) {
  10546     return(NULL);
  10547   }
  10548   if (neg) {
  10549     index++;
  10550   }
  10551   if (index < -(int64_t)len) {
  10552     return(NULL);
  10553   }
  10554   if (neg) {
  10555     index = (int64_t)len + index;
  10556   }
  10557 
  10558   if (!toInsert->f->len(toInsert)) {
  10559     return(self);
  10560   }
  10561 
  10562 
  10563   sArrayt *a = allocSArray();;
  10564   if (!a) {
  10565     return(NULL);
  10566   }
  10567 
  10568   smallt *o;
  10569   if (index == 0) {
  10570     // insert at beginning
  10571     for (int64_t i=0;i < (int64_t)toInsert->f->len(toInsert);i++) {
  10572       o = sArrayGetTiny(toInsert->a, (uint32_t)i);
  10573       sArrayPushTiny(&a, o);
  10574     }
  10575     for (int64_t i=0;i < (int64_t)len;i++) {
  10576       o = sArrayGetTiny(self->topA, (uint32_t)i);
  10577       sArrayPushTiny(&a, o);
  10578   }
  10579     }
  10580   else {
  10581 
  10582     for (int64_t i=0;i < index;i++) {
  10583       o = sArrayGetTiny(self->topA, (uint32_t)i);
  10584       sArrayPushTiny(&a, o);
  10585     }
  10586     for (int64_t i=0;i < (int64_t)toInsert->f->len(toInsert);i++) {
  10587       o = sArrayGetTiny(toInsert->a, (uint32_t)i);
  10588       sArrayPushTiny(&a, o);
  10589     }
  10590     for (int64_t i=index;i < (int64_t)len;i++) {
  10591       o = sArrayGetTiny(self->topA, (uint32_t)i);
  10592       sArrayPushTiny(&a, o);
  10593   }
  10594     }
  10595 
  10596   free(self->topA);
  10597   self->topA = a;
  10598   return(self);
  10599 }
  10600 
  10601 internal smallJsont* insertNSmashSmallJson(smallJsont *self, int64_t index, smallArrayt *toInsert) {
  10602   smallJsont *r = NULL;
  10603 
  10604   r = insertSmallJson(self, index, toInsert);
  10605   if (r) {
  10606     smashO(toInsert);
  10607   }
  10608   return(r);
  10609 }
  10610 
  10611 internal smallJsont* insertSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *toInsert) {
  10612   size_t len;
  10613 
  10614   //sanity checks
  10615   if (self->topIsA != TOP_IS_ARRAY || !toInsert) {
  10616     return(NULL);
  10617   }
  10618 
  10619   if (checkObjectTypes && toInsert && !isOSmallJson(toInsert)) {
  10620     return(NULL);
  10621   }
  10622 
  10623   if (self->topA == toInsert->topA) {
  10624     return(NULL);
  10625   }
  10626 
  10627   len = lenSmallJson(self);
  10628 
  10629   if (!len && index == -1) {
  10630     // empty string, index -1 is equal to 0
  10631     index = 0;
  10632   }
  10633   bool neg = false;
  10634   if (index < 0) {
  10635     neg = true;
  10636   }
  10637 
  10638   if (index > (int64_t)len) {
  10639     return(NULL);
  10640   }
  10641   if (neg) {
  10642     index++;
  10643   }
  10644   if (index < -(int64_t)len) {
  10645     return(NULL);
  10646   }
  10647   if (neg) {
  10648     index = (int64_t)len + index;
  10649   }
  10650 
  10651   if (toInsert->topIsA != TOP_IS_ARRAY) {
  10652     return(NULL);
  10653   }
  10654 
  10655   if (!toInsert->f->len(toInsert)) {
  10656     return(self);
  10657   }
  10658 
  10659 
  10660   sArrayt *a = allocSArray();;
  10661   if (!a) {
  10662     return(NULL);
  10663   }
  10664 
  10665   smallt *o;
  10666   if (index == 0) {
  10667     // insert at beginning
  10668     for (int64_t i=0;i < (int64_t)toInsert->f->len(toInsert);i++) {
  10669       o = sArrayGetTiny(toInsert->topA, (uint32_t)i);
  10670       sArrayPushTiny(&a, o);
  10671     }
  10672     for (int64_t i=0;i < (int64_t)len;i++) {
  10673       o = sArrayGetTiny(self->topA, (uint32_t)i);
  10674       sArrayPushTiny(&a, o);
  10675   }
  10676     }
  10677   else {
  10678 
  10679     for (int64_t i=0;i < index;i++) {
  10680       o = sArrayGetTiny(self->topA, (uint32_t)i);
  10681       sArrayPushTiny(&a, o);
  10682     }
  10683     for (int64_t i=0;i < (int64_t)toInsert->f->len(toInsert);i++) {
  10684       o = sArrayGetTiny(toInsert->topA, (uint32_t)i);
  10685       sArrayPushTiny(&a, o);
  10686     }
  10687     for (int64_t i=index;i < (int64_t)len;i++) {
  10688       o = sArrayGetTiny(self->topA, (uint32_t)i);
  10689       sArrayPushTiny(&a, o);
  10690   }
  10691     }
  10692 
  10693   free(self->topA);
  10694   self->topA = a;
  10695   return(self);
  10696 }
  10697 
  10698 internal smallJsont* insertNSmashSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *toInsert) {
  10699   smallJsont *r = NULL;
  10700 
  10701   r = insertSmallJsonSmallJson(self, index, toInsert);
  10702   if (r) {
  10703     smashO(toInsert);
  10704   }
  10705   return(r);
  10706 }
  10707 
  10708 internal smallJsont* insertStringSmallJson(smallJsont *self, int64_t index, smallStringt *toInsert) {
  10709   char *r = NULL;
  10710 
  10711   // sanity checks
  10712   if (checkObjectTypes && toInsert && !isOSmallString(toInsert)) {
  10713     return(NULL);
  10714   }
  10715   if (!toInsert) {
  10716     return(NULL);
  10717   }
  10718   if (self->topIsA == SMALLJSON_IS_EMPTY && !index) {
  10719     if (toInsert->data) {
  10720       self->topS   = (sStringt*)sDuplicateTiny((smallt*)toInsert->data);
  10721       self->topIsA = TOP_IS_STRING;
  10722     }
  10723     // TODO self->_len = toInsert->_len
  10724     return(self);
  10725   }
  10726   else if (self->topIsA != TOP_IS_STRING) {
  10727     return(NULL);
  10728   }
  10729 
  10730   if (!self->topS) {
  10731     if (index) {
  10732       return(NULL);
  10733     }
  10734     if (toInsert->data) {
  10735       self->topS = (sStringt*)sDuplicateTiny((smallt*)toInsert->data);
  10736     }
  10737     // TODO self->_len = toInsert->_len
  10738     return(self);
  10739   }
  10740 
  10741   if (!lenSmallJson(self) && index == -1) {
  10742     // empty string, index -1 is equal to 0
  10743     index = 0;
  10744   }
  10745   bool neg = false;
  10746   if (index < 0) {
  10747     neg = true;
  10748   }
  10749 
  10750   if (index > (int64_t)lenSmallJson(self)) {
  10751     return(NULL);
  10752   }
  10753   if (neg) {
  10754     index++;
  10755   }
  10756   if (index < -(int64_t)lenSmallJson(self)) {
  10757     return(NULL);
  10758   }
  10759   if (neg) {
  10760     index = (int64_t)lenSmallJson(self) + index;
  10761   }
  10762 
  10763   if (!toInsert->data || !toInsert->_len) {
  10764     return(self);
  10765   }
  10766 
  10767   if (index == 0) {
  10768     // insert at beginning
  10769     r = catS(toInsert->data, sStringGetTiny(self->topS));
  10770   }
  10771   else {
  10772     // include sType in s1 (index+1)
  10773     char *s1 = sliceS((char *)self->topS, 0, index+1);
  10774     char *s2 = sliceS((char *)self->topS, index+1, 0);
  10775     r        = catS(s1, sStringGetTiny(toInsert->data), s2);
  10776     freeManyS(s1,s2);
  10777   }
  10778 
  10779   free(self->topS);
  10780   self->topS = (sStringt *)r;
  10781   //TODO self->_len += toInsert->_len
  10782   return(self);
  10783 }
  10784 
  10785 internal smallJsont* insertSSmallJson(smallJsont *self, int64_t index, const char *toInsert) {
  10786   char *r = NULL;
  10787 
  10788   // sanity checks
  10789   if (!toInsert) {
  10790     return(self);
  10791   }
  10792   if (self->topIsA == SMALLJSON_IS_EMPTY && !index) {
  10793     char header[2] = {STRING ,0};
  10794     self->topS = (sStringt*) catS(header, toInsert);
  10795     self->topIsA = TOP_IS_STRING;
  10796     // TODO self->_len = toInsert->_len
  10797     return(self);
  10798   }
  10799   if (self->topIsA != TOP_IS_STRING) {
  10800     return(NULL);
  10801   }
  10802   if (!self->topS) {
  10803     if (index) {
  10804       return(NULL);
  10805     }
  10806     char header[2] = {STRING ,0};
  10807     self->topS = (sStringt*) catS(header, toInsert);
  10808     // TODO self->_len = strlen(toInsert)
  10809     return(self);
  10810   }
  10811 
  10812   if (!lenSmallJson(self) && index == -1) {
  10813     // empty string, index -1 is equal to 0
  10814     index = 0;
  10815   }
  10816   bool neg = false;
  10817   if (index < 0) {
  10818     neg = true;
  10819   }
  10820 
  10821   if (index > (int64_t)lenSmallJson(self)) {
  10822     return(NULL);
  10823   }
  10824   if (neg) {
  10825     index++;
  10826   }
  10827   if (index < -(int64_t)lenSmallJson(self)) {
  10828     return(NULL);
  10829   }
  10830   if (neg) {
  10831     index = (int64_t)lenSmallJson(self) + index;
  10832   }
  10833 
  10834   if (!*toInsert) {
  10835     return(self);
  10836   }
  10837 
  10838   if (index == 0) {
  10839     // insert at beginning
  10840     char header[2] = {STRING ,0};
  10841     r = catS(header, toInsert, sStringGetTiny(self->topS));
  10842   }
  10843   else {
  10844     // include sType in s1 (index+1)
  10845     char *s1 = sliceS((char *)self->topS, 0, index+1);
  10846     char *s2 = sliceS((char *)self->topS, index+1, 0);
  10847     r        = catS(s1, toInsert, s2);
  10848     freeManyS(s1,s2);
  10849   }
  10850 
  10851   free(self->topS);
  10852   self->topS = (sStringt *)r;
  10853   //TODO self->_len += strlen(toInsert)
  10854   return(self);
  10855 }
  10856 
  10857 internal smallJsont* insertNFreeStringSmallJson(smallJsont *self, int64_t index, smallStringt *toInsert) {
  10858 
  10859   smallJsont *r = insertStringSmallJson(self, index, toInsert);
  10860   if (r) {
  10861     terminateO(toInsert);
  10862   }
  10863   return(r);
  10864 }
  10865 
  10866 internal smallJsont* insertSNFreeSmallJson(smallJsont *self, int64_t index, char *toInsert) {
  10867 
  10868   smallJsont *r = insertSSmallJson(self, index, toInsert);
  10869   if (r) {
  10870     free(toInsert);
  10871   }
  10872   return(r);
  10873 }
  10874 
  10875 internal smallJsont* injectSmallJson(smallJsont *self, int64_t index, baset *toInject) {
  10876   size_t len;
  10877 
  10878   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  10879     return(NULL);
  10880   }
  10881 
  10882   if (!toInject) {
  10883     return(NULL);
  10884   }
  10885 
  10886   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  10887     self->topIsA = TOP_IS_ARRAY;
  10888   }
  10889 
  10890   len = lenSmallJson(self);
  10891 
  10892   if (!len && index == -1) {
  10893     // empty string, index -1 is equal to 0
  10894     index = 0;
  10895   }
  10896   bool neg = false;
  10897   if (index < 0) {
  10898     neg = true;
  10899   }
  10900 
  10901   if (index > (int64_t)len) {
  10902     return(NULL);
  10903   }
  10904   if (neg) {
  10905     index++;
  10906   }
  10907   if (index < -(int64_t)len) {
  10908     return(NULL);
  10909   }
  10910   if (neg) {
  10911     index = (int64_t)len + index;
  10912   }
  10913 
  10914 
  10915   sArrayt *a = allocSArray();
  10916   if (!a) {
  10917     return(NULL);
  10918   }
  10919 
  10920   smallt *o = toSmallt(toInject);
  10921   if (!o) {
  10922     sArrayFreeTiny(a);
  10923     return(NULL);
  10924   }
  10925 
  10926   if (index == 0) {
  10927     // inject at beginning
  10928     sArrayPushTiny(&a, o);
  10929     for (int64_t i=0;i < (int64_t)len;i++) {
  10930       o = sArrayGetTiny(self->topA, (uint32_t)i);
  10931       sArrayPushTiny(&a, o);
  10932   }
  10933     }
  10934   else {
  10935 
  10936     smallt *o2;
  10937     for (int64_t i=0;i < index;i++) {
  10938       o2 = sArrayGetTiny(self->topA, (uint32_t)i);
  10939       sArrayPushTiny(&a, o2);
  10940     }
  10941     sArrayPushTiny(&a, o);
  10942     for (int64_t i=index;i < (int64_t)len;i++) {
  10943       o = sArrayGetTiny(self->topA, (uint32_t)i);
  10944       sArrayPushTiny(&a, o);
  10945   }
  10946     }
  10947 
  10948   free(self->topA);
  10949   self->topA = a;
  10950   return(self);
  10951 }
  10952 
  10953 internal smallJsont* injectUndefinedSmallJson(smallJsont *self, int64_t index) {
  10954   size_t len;
  10955 
  10956   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  10957     return(NULL);
  10958   }
  10959 
  10960   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  10961     self->topIsA = TOP_IS_ARRAY;
  10962   }
  10963 
  10964   len = lenSmallJson(self);
  10965 
  10966   if (!len && index == -1) {
  10967     // empty string, index -1 is equal to 0
  10968     index = 0;
  10969   }
  10970   bool neg = false;
  10971   if (index < 0) {
  10972     neg = true;
  10973   }
  10974 
  10975   if (index > (int64_t)len) {
  10976     return(NULL);
  10977   }
  10978   if (neg) {
  10979     index++;
  10980   }
  10981   if (index < -(int64_t)len) {
  10982     return(NULL);
  10983   }
  10984   if (neg) {
  10985     index = (int64_t)len + index;
  10986   }
  10987 
  10988 
  10989   sArrayt *a = allocSArray();
  10990   if (!a) {
  10991     return(NULL);
  10992   }
  10993 
  10994   smallt *o  = (smallt *) allocSUndefined();
  10995   if (!o) {
  10996     sArrayFreeTiny(a);
  10997     return(NULL);
  10998   }
  10999 
  11000   if (index == 0) {
  11001     // inject at beginning
  11002     sArrayPushTiny(&a, o);
  11003     for (int64_t i=0;i < (int64_t)len;i++) {
  11004       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11005       sArrayPushTiny(&a, o);
  11006   }
  11007     }
  11008   else {
  11009 
  11010     smallt *o2;
  11011     for (int64_t i=0;i < index;i++) {
  11012       o2 = sArrayGetTiny(self->topA, (uint32_t)i);
  11013       sArrayPushTiny(&a, o2);
  11014     }
  11015     sArrayPushTiny(&a, o);
  11016     for (int64_t i=index;i < (int64_t)len;i++) {
  11017       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11018       sArrayPushTiny(&a, o);
  11019   }
  11020     }
  11021 
  11022   free(self->topA);
  11023   self->topA = a;
  11024   return(self);
  11025 }
  11026 
  11027 internal smallJsont* injectBoolSmallJson(smallJsont *self, int64_t index, bool toInject) {
  11028   size_t len;
  11029 
  11030   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  11031     return(NULL);
  11032   }
  11033 
  11034   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  11035     self->topIsA = TOP_IS_ARRAY;
  11036   }
  11037 
  11038   len = lenSmallJson(self);
  11039 
  11040   if (!len && index == -1) {
  11041     // empty string, index -1 is equal to 0
  11042     index = 0;
  11043   }
  11044   bool neg = false;
  11045   if (index < 0) {
  11046     neg = true;
  11047   }
  11048 
  11049   if (index > (int64_t)len) {
  11050     return(NULL);
  11051   }
  11052   if (neg) {
  11053     index++;
  11054   }
  11055   if (index < -(int64_t)len) {
  11056     return(NULL);
  11057   }
  11058   if (neg) {
  11059     index = (int64_t)len + index;
  11060   }
  11061 
  11062 
  11063   sArrayt *a = allocSArray();
  11064   if (!a) {
  11065     return(NULL);
  11066   }
  11067 
  11068   smallt *o = NULL;
  11069   o = (smallt *) allocSBool(toInject);
  11070   if (!o) {
  11071     sArrayFreeTiny(a);
  11072     return(NULL);
  11073   }
  11074 
  11075   if (index == 0) {
  11076     // inject at beginning
  11077     sArrayPushTiny(&a, o);
  11078     for (int64_t i=0;i < (int64_t)len;i++) {
  11079       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11080       sArrayPushTiny(&a, o);
  11081   }
  11082     }
  11083   else {
  11084 
  11085     smallt *o2;
  11086     for (int64_t i=0;i < index;i++) {
  11087       o2 = sArrayGetTiny(self->topA, (uint32_t)i);
  11088       sArrayPushTiny(&a, o2);
  11089     }
  11090     sArrayPushTiny(&a, o);
  11091     for (int64_t i=index;i < (int64_t)len;i++) {
  11092       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11093       sArrayPushTiny(&a, o);
  11094   }
  11095     }
  11096 
  11097   free(self->topA);
  11098   self->topA = a;
  11099   return(self);
  11100 }
  11101 
  11102 internal smallJsont* injectDoubleSmallJson(smallJsont *self, int64_t index, double toInject) {
  11103   size_t len;
  11104 
  11105   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  11106     return(NULL);
  11107   }
  11108 
  11109   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  11110     self->topIsA = TOP_IS_ARRAY;
  11111   }
  11112 
  11113   len = lenSmallJson(self);
  11114 
  11115   if (!len && index == -1) {
  11116     // empty string, index -1 is equal to 0
  11117     index = 0;
  11118   }
  11119   bool neg = false;
  11120   if (index < 0) {
  11121     neg = true;
  11122   }
  11123 
  11124   if (index > (int64_t)len) {
  11125     return(NULL);
  11126   }
  11127   if (neg) {
  11128     index++;
  11129   }
  11130   if (index < -(int64_t)len) {
  11131     return(NULL);
  11132   }
  11133   if (neg) {
  11134     index = (int64_t)len + index;
  11135   }
  11136 
  11137 
  11138   sArrayt *a = allocSArray();
  11139   if (!a) {
  11140     return(NULL);
  11141   }
  11142 
  11143   smallt *o = NULL;
  11144   o         = (smallt *) allocSDouble(toInject);
  11145   if (!o) {
  11146     sArrayFreeTiny(a);
  11147     return(NULL);
  11148   }
  11149 
  11150   if (index == 0) {
  11151     // inject at beginning
  11152     sArrayPushTiny(&a, o);
  11153     for (int64_t i=0;i < (int64_t)len;i++) {
  11154       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11155       sArrayPushTiny(&a, o);
  11156   }
  11157     }
  11158   else {
  11159 
  11160     smallt *o2;
  11161     for (int64_t i=0;i < index;i++) {
  11162       o2 = sArrayGetTiny(self->topA, (uint32_t)i);
  11163       sArrayPushTiny(&a, o2);
  11164     }
  11165     sArrayPushTiny(&a, o);
  11166     for (int64_t i=index;i < (int64_t)len;i++) {
  11167       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11168       sArrayPushTiny(&a, o);
  11169   }
  11170     }
  11171 
  11172   free(self->topA);
  11173   self->topA = a;
  11174   return(self);
  11175 }
  11176 
  11177 internal smallJsont* injectIntSmallJson(smallJsont *self, int64_t index, int64_t toInject) {
  11178   size_t len;
  11179 
  11180   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  11181     return(NULL);
  11182   }
  11183 
  11184   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  11185     self->topIsA = TOP_IS_ARRAY;
  11186   }
  11187 
  11188   len = lenSmallJson(self);
  11189 
  11190   if (!len && index == -1) {
  11191     // empty string, index -1 is equal to 0
  11192     index = 0;
  11193   }
  11194   bool neg = false;
  11195   if (index < 0) {
  11196     neg = true;
  11197   }
  11198 
  11199   if (index > (int64_t)len) {
  11200     return(NULL);
  11201   }
  11202   if (neg) {
  11203     index++;
  11204   }
  11205   if (index < -(int64_t)len) {
  11206     return(NULL);
  11207   }
  11208   if (neg) {
  11209     index = (int64_t)len + index;
  11210   }
  11211 
  11212 
  11213   sArrayt *a = allocSArray();
  11214   if (!a) {
  11215     return(NULL);
  11216   }
  11217 
  11218   smallt *o = NULL;
  11219   o         = (smallt *) allocSInt(toInject);
  11220   if (!o) {
  11221     sArrayFreeTiny(a);
  11222     return(NULL);
  11223   }
  11224 
  11225   if (index == 0) {
  11226     // inject at beginning
  11227     sArrayPushTiny(&a, o);
  11228     for (int64_t i=0;i < (int64_t)len;i++) {
  11229       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11230       sArrayPushTiny(&a, o);
  11231   }
  11232     }
  11233   else {
  11234 
  11235     smallt *o2;
  11236     for (int64_t i=0;i < index;i++) {
  11237       o2 = sArrayGetTiny(self->topA, (uint32_t)i);
  11238       sArrayPushTiny(&a, o2);
  11239     }
  11240     sArrayPushTiny(&a, o);
  11241     for (int64_t i=index;i < (int64_t)len;i++) {
  11242       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11243       sArrayPushTiny(&a, o);
  11244   }
  11245     }
  11246 
  11247   free(self->topA);
  11248   self->topA = a;
  11249   return(self);
  11250 }
  11251 
  11252 internal smallJsont* injectSSmallJson(smallJsont *self, int64_t index, const char *toInject) {
  11253   size_t len;
  11254 
  11255   if (!toInject) {
  11256     return(NULL);
  11257   }
  11258 
  11259   if (self->topIsA == TOP_IS_STRING) {
  11260     return(insertSSmallJson(self, index, toInject));
  11261   }
  11262 
  11263   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  11264     self->topIsA = TOP_IS_ARRAY;
  11265   }
  11266 
  11267   if (self->topIsA != TOP_IS_ARRAY) {
  11268     return(NULL);
  11269   }
  11270 
  11271   len = lenSmallJson(self);
  11272 
  11273   if (!len && index == -1) {
  11274     // empty string, index -1 is equal to 0
  11275     index = 0;
  11276   }
  11277   bool neg = false;
  11278   if (index < 0) {
  11279     neg = true;
  11280   }
  11281 
  11282   if (index > (int64_t)len) {
  11283     return(NULL);
  11284   }
  11285   if (neg) {
  11286     index++;
  11287   }
  11288   if (index < -(int64_t)len) {
  11289     return(NULL);
  11290   }
  11291   if (neg) {
  11292     index = (int64_t)len + index;
  11293   }
  11294 
  11295 
  11296   sArrayt *a = allocSArray();
  11297   if (!a) {
  11298     return(NULL);
  11299   }
  11300 
  11301   smallt *o = (smallt *) allocSStringTiny(toInject);
  11302   if (!o) {
  11303     sArrayFreeTiny(a);
  11304     return(NULL);
  11305   }
  11306 
  11307   if (index == 0) {
  11308     // inject at beginning
  11309     sArrayPushTiny(&a, o);
  11310     for (int64_t i=0;i < (int64_t)len;i++) {
  11311       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11312       sArrayPushTiny(&a, o);
  11313   }
  11314     }
  11315   else {
  11316 
  11317     smallt *o2;
  11318     for (int64_t i=0;i < index;i++) {
  11319       o2 = sArrayGetTiny(self->topA, (uint32_t)i);
  11320       sArrayPushTiny(&a, o2);
  11321     }
  11322     sArrayPushTiny(&a, o);
  11323     for (int64_t i=index;i < (int64_t)len;i++) {
  11324       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11325       sArrayPushTiny(&a, o);
  11326   }
  11327     }
  11328 
  11329   free(self->topA);
  11330   self->topA = a;
  11331   return(self);
  11332 }
  11333 
  11334 internal smallJsont* injectCharSmallJson(smallJsont *self, int64_t index, char c) {
  11335 
  11336   charToS(s, c);
  11337   return(injectSSmallJson(self, index, s));
  11338 }
  11339 
  11340 internal smallJsont* injectDictSmallJson(smallJsont *self, int64_t index, smallDictt *toInject) {
  11341   size_t len;
  11342 
  11343   if (!toInject) {
  11344     return(NULL);
  11345   }
  11346 
  11347   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  11348     return(NULL);
  11349   }
  11350 
  11351   if (checkObjectTypes && toInject && !isOSmallDict(toInject)) {
  11352     return(NULL);
  11353   }
  11354 
  11355   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  11356     self->topIsA = TOP_IS_ARRAY;
  11357   }
  11358 
  11359   len = lenSmallJson(self);
  11360 
  11361   if (!len && index == -1) {
  11362     // empty string, index -1 is equal to 0
  11363     index = 0;
  11364   }
  11365   bool neg = false;
  11366   if (index < 0) {
  11367     neg = true;
  11368   }
  11369 
  11370   if (index > (int64_t)len) {
  11371     return(NULL);
  11372   }
  11373   if (neg) {
  11374     index++;
  11375   }
  11376   if (index < -(int64_t)len) {
  11377     return(NULL);
  11378   }
  11379   if (neg) {
  11380     index = (int64_t)len + index;
  11381   }
  11382 
  11383 
  11384   sArrayt *a = allocSArray();;
  11385   if (!a) {
  11386     return(NULL);
  11387   }
  11388 
  11389   if (!toInject->d) {
  11390     isError(toInject->d, allocSDict()) return(NULL);
  11391   }
  11392 
  11393   smallt *o = (smallt *) toInject->d;
  11394 
  11395   if (index == 0) {
  11396     // inject at beginning
  11397     sArrayPushTiny(&a, o);
  11398     for (int64_t i=0;i < (int64_t)len;i++) {
  11399       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11400       sArrayPushTiny(&a, o);
  11401   }
  11402     }
  11403   else {
  11404 
  11405     smallt *o2;
  11406     for (int64_t i=0;i < index;i++) {
  11407       o2 = sArrayGetTiny(self->topA, (uint32_t)i);
  11408       sArrayPushTiny(&a, o2);
  11409     }
  11410     sArrayPushTiny(&a, o);
  11411     for (int64_t i=index;i < (int64_t)len;i++) {
  11412       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11413       sArrayPushTiny(&a, o);
  11414   }
  11415     }
  11416 
  11417   free(self->topA);
  11418   self->topA = a;
  11419   return(self);
  11420 }
  11421 
  11422 internal smallJsont* injectArraySmallJson(smallJsont *self, int64_t index, smallArrayt *toInject) {
  11423   size_t len;
  11424 
  11425   if (!toInject) {
  11426     return(NULL);
  11427   }
  11428 
  11429   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  11430     return(NULL);
  11431   }
  11432 
  11433   if (checkObjectTypes && toInject && !isOSmallArray(toInject)) {
  11434     return(NULL);
  11435   }
  11436 
  11437   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  11438     self->topIsA = TOP_IS_ARRAY;
  11439   }
  11440 
  11441   len = lenSmallJson(self);
  11442 
  11443   if (!len && index == -1) {
  11444     // empty string, index -1 is equal to 0
  11445     index = 0;
  11446   }
  11447   bool neg = false;
  11448   if (index < 0) {
  11449     neg = true;
  11450   }
  11451 
  11452   if (index > (int64_t)len) {
  11453     return(NULL);
  11454   }
  11455   if (neg) {
  11456     index++;
  11457   }
  11458   if (index < -(int64_t)len) {
  11459     return(NULL);
  11460   }
  11461   if (neg) {
  11462     index = (int64_t)len + index;
  11463   }
  11464 
  11465 
  11466   sArrayt *a = allocSArray();;
  11467   if (!a) {
  11468     return(NULL);
  11469   }
  11470 
  11471   if (!toInject->a) {
  11472     isError(toInject->a, allocSArray()) return(NULL);
  11473   }
  11474 
  11475   smallt *o = (smallt *) toInject->a;
  11476 
  11477   if (index == 0) {
  11478     // inject at beginning
  11479     sArrayPushTiny(&a, o);
  11480     for (int64_t i=0;i < (int64_t)len;i++) {
  11481       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11482       sArrayPushTiny(&a, o);
  11483   }
  11484     }
  11485   else {
  11486 
  11487     smallt *o2;
  11488     for (int64_t i=0;i < index;i++) {
  11489       o2 = sArrayGetTiny(self->topA, (uint32_t)i);
  11490       sArrayPushTiny(&a, o2);
  11491     }
  11492     sArrayPushTiny(&a, o);
  11493     for (int64_t i=index;i < (int64_t)len;i++) {
  11494       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11495       sArrayPushTiny(&a, o);
  11496   }
  11497     }
  11498 
  11499   free(self->topA);
  11500   self->topA = a;
  11501   return(self);
  11502 }
  11503 
  11504 internal smallJsont* injectArraycSmallJson(smallJsont *self, int64_t index, char **toInject) {
  11505   size_t len;
  11506 
  11507   if (!toInject) {
  11508     return(NULL);
  11509   }
  11510 
  11511   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  11512     return(NULL);
  11513   }
  11514 
  11515   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  11516     self->topIsA = TOP_IS_ARRAY;
  11517   }
  11518 
  11519   len = lenSmallJson(self);
  11520 
  11521   if (!len && index == -1) {
  11522     // empty string, index -1 is equal to 0
  11523     index = 0;
  11524   }
  11525   bool neg = false;
  11526   if (index < 0) {
  11527     neg = true;
  11528   }
  11529 
  11530   if (index > (int64_t)len) {
  11531     return(NULL);
  11532   }
  11533   if (neg) {
  11534     index++;
  11535   }
  11536   if (index < -(int64_t)len) {
  11537     return(NULL);
  11538   }
  11539   if (neg) {
  11540     index = (int64_t)len + index;
  11541   }
  11542 
  11543 
  11544   sArrayt *a = allocSArray();;
  11545   if (!a) {
  11546     return(NULL);
  11547   }
  11548 
  11549   smallt *o = NULL;
  11550   sArrayt *aa = allocSArray();
  11551   if (!aa) {
  11552     sArrayFreeTiny(a);
  11553     return(NULL);
  11554   }
  11555 
  11556   forEachCharP(toInject, e) {
  11557     sStringt *s = allocSStringTiny(*e);
  11558     if (!s) {
  11559       sArrayFreeTiny(a);
  11560       if (aa) {
  11561         sArrayFreeTiny(aa);
  11562       }
  11563       return(NULL);
  11564     }
  11565     sArrayPushTiny(&aa, (smallt *) s);
  11566   }
  11567   o = (smallt *) aa;
  11568 
  11569   if (index == 0) {
  11570     // inject at beginning
  11571     sArrayPushTiny(&a, o);
  11572     for (int64_t i=0;i < (int64_t)len;i++) {
  11573       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11574       sArrayPushTiny(&a, o);
  11575   }
  11576     }
  11577   else {
  11578 
  11579     smallt *o2;
  11580     for (int64_t i=0;i < index;i++) {
  11581       o2 = sArrayGetTiny(self->topA, (uint32_t)i);
  11582       sArrayPushTiny(&a, o2);
  11583     }
  11584     sArrayPushTiny(&a, o);
  11585     for (int64_t i=index;i < (int64_t)len;i++) {
  11586       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11587       sArrayPushTiny(&a, o);
  11588   }
  11589     }
  11590 
  11591   free(self->topA);
  11592   self->topA = a;
  11593   return(self);
  11594 }
  11595 
  11596 internal smallJsont* injectCArraycSmallJson(smallJsont *self, int64_t index, const char **toInject) {
  11597   size_t len;
  11598 
  11599   if (!toInject) {
  11600     return(NULL);
  11601   }
  11602 
  11603   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  11604     return(NULL);
  11605   }
  11606 
  11607   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  11608     self->topIsA = TOP_IS_ARRAY;
  11609   }
  11610 
  11611   len = lenSmallJson(self);
  11612 
  11613   if (!len && index == -1) {
  11614     // empty string, index -1 is equal to 0
  11615     index = 0;
  11616   }
  11617   bool neg = false;
  11618   if (index < 0) {
  11619     neg = true;
  11620   }
  11621 
  11622   if (index > (int64_t)len) {
  11623     return(NULL);
  11624   }
  11625   if (neg) {
  11626     index++;
  11627   }
  11628   if (index < -(int64_t)len) {
  11629     return(NULL);
  11630   }
  11631   if (neg) {
  11632     index = (int64_t)len + index;
  11633   }
  11634 
  11635 
  11636   sArrayt *a = allocSArray();;
  11637   if (!a) {
  11638     return(NULL);
  11639   }
  11640 
  11641   smallt *o = NULL;
  11642   sArrayt *aa = allocSArray();
  11643   if (!aa) {
  11644     sArrayFreeTiny(a);
  11645     return(NULL);
  11646   }
  11647 
  11648   forEachCCharP(toInject, e) {
  11649     sStringt *s = allocSStringTiny(*e);
  11650     if (!s) {
  11651       sArrayFreeTiny(a);
  11652       if (aa) {
  11653         sArrayFreeTiny(aa);
  11654       }
  11655       return(NULL);
  11656     }
  11657     sArrayPushTiny(&aa, (smallt *) s);
  11658   }
  11659   o = (smallt *) aa;
  11660 
  11661   if (index == 0) {
  11662     // inject at beginning
  11663     sArrayPushTiny(&a, o);
  11664     for (int64_t i=0;i < (int64_t)len;i++) {
  11665       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11666       sArrayPushTiny(&a, o);
  11667   }
  11668     }
  11669   else {
  11670 
  11671     smallt *o2;
  11672     for (int64_t i=0;i < index;i++) {
  11673       o2 = sArrayGetTiny(self->topA, (uint32_t)i);
  11674       sArrayPushTiny(&a, o2);
  11675     }
  11676     sArrayPushTiny(&a, o);
  11677     for (int64_t i=index;i < (int64_t)len;i++) {
  11678       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11679       sArrayPushTiny(&a, o);
  11680   }
  11681     }
  11682 
  11683   free(self->topA);
  11684   self->topA = a;
  11685   return(self);
  11686 }
  11687 
  11688 internal smallJsont* injectSmallBoolSmallJson(smallJsont *self, int64_t index, smallBoolt *toInject) {
  11689 
  11690   if (!toInject) {
  11691     return(NULL);
  11692   }
  11693 
  11694   if (checkObjectTypes && toInject && !isOSmallBool(toInject)) {
  11695     return(NULL);
  11696   }
  11697 
  11698   if (!toInject->value) {
  11699     isError(toInject->value, allocSBool(false)) return(NULL);
  11700   }
  11701 
  11702   return(injectSmallJson(self, index, (baset*)toInject));
  11703 }
  11704 
  11705 internal smallJsont* injectSmallBytesSmallJson(smallJsont *self, int64_t index, smallBytest *toInject) {
  11706 
  11707   if (!toInject) {
  11708     return(NULL);
  11709   }
  11710 
  11711   if (checkObjectTypes && toInject && !isOSmallBytes(toInject)) {
  11712     return(NULL);
  11713   }
  11714 
  11715   if (!toInject->B) {
  11716     isError(toInject->B, allocSBytes()) return(NULL);
  11717   }
  11718 
  11719   return(injectSmallJson(self, index, (baset*)toInject));
  11720 }
  11721 
  11722 internal smallJsont* injectSmallDoubleSmallJson(smallJsont *self, int64_t index, smallDoublet *toInject) {
  11723 
  11724   if (!toInject) {
  11725     return(NULL);
  11726   }
  11727 
  11728   if (checkObjectTypes && toInject && !isOSmallDouble(toInject)) {
  11729     return(NULL);
  11730   }
  11731 
  11732   if (!toInject->value) {
  11733     isError(toInject->value, allocSDouble(0)) return(NULL);
  11734   }
  11735 
  11736   return(injectSmallJson(self, index, (baset*)toInject));
  11737 }
  11738 
  11739 internal smallJsont* injectSmallIntSmallJson(smallJsont *self, int64_t index, smallIntt *toInject) {
  11740 
  11741   if (!toInject) {
  11742     return(NULL);
  11743   }
  11744 
  11745   if (checkObjectTypes && toInject && !isOSmallInt(toInject)) {
  11746     return(NULL);
  11747   }
  11748 
  11749   if (!toInject->value) {
  11750     isError(toInject->value, allocSInt(0)) return(NULL);
  11751   }
  11752 
  11753   return(injectSmallJson(self, index, (baset*)toInject));
  11754 }
  11755 
  11756 internal smallJsont* injectSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *toInject) {
  11757 
  11758   if (!toInject) {
  11759     return(NULL);
  11760   }
  11761 
  11762   if (checkObjectTypes && toInject && !isOSmallJson(toInject)) {
  11763     return(NULL);
  11764   }
  11765 
  11766   smallt *o = getsoO(toInject);
  11767   if (!o) {
  11768     // smallJson is empty, create an empty dict
  11769     isError(o, (smallt*)allocSDict()) return(NULL);
  11770     setsoO(toInject, o);
  11771   }
  11772 
  11773   baset *O = getTopO(toInject);
  11774 
  11775   smallJsont *r = injectSmallJson(self, index, O);
  11776   finishO(O);
  11777   return(r);
  11778 }
  11779 
  11780 internal smallJsont* injectSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *toInject) {
  11781 
  11782   if (!toInject) {
  11783     return(NULL);
  11784   }
  11785 
  11786   if (checkObjectTypes && toInject && !isOSmallString(toInject)) {
  11787     return(NULL);
  11788   }
  11789 
  11790   if (self->topIsA == TOP_IS_STRING) {
  11791     return(insertStringSmallJson(self, index, toInject));
  11792   }
  11793 
  11794   if (!toInject->data) {
  11795     isError(toInject->data, allocSStringTiny("")) return(NULL);
  11796   }
  11797 
  11798   return(injectSmallJson(self, index, (baset*)toInject));
  11799 }
  11800 
  11801 internal smallJsont* injectSmallContainerSmallJson(smallJsont *self, int64_t index, smallContainert *toInject) {
  11802 
  11803   if (!toInject) {
  11804     return(NULL);
  11805   }
  11806 
  11807   if (checkObjectTypes && toInject && !isOSmallContainer(toInject)) {
  11808     return(NULL);
  11809   }
  11810 
  11811   if (!toInject->data) {
  11812     isError(toInject->data, allocSContainer(NULL)) return(NULL);
  11813   }
  11814 
  11815   return(injectSmallJson(self, index, (baset*)toInject));
  11816 }
  11817 
  11818 internal smallJsont* injectNFreeSmallJson(smallJsont *self, int64_t index, baset *toInject) {
  11819   size_t len;
  11820 
  11821   if (!toInject) {
  11822     return(NULL);
  11823   }
  11824 
  11825   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  11826     return(NULL);
  11827   }
  11828 
  11829   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  11830     self->topIsA = TOP_IS_ARRAY;
  11831   }
  11832 
  11833   len = lenSmallJson(self);
  11834 
  11835   if (!len && index == -1) {
  11836     // empty string, index -1 is equal to 0
  11837     index = 0;
  11838   }
  11839   bool neg = false;
  11840   if (index < 0) {
  11841     neg = true;
  11842   }
  11843 
  11844   if (index > (int64_t)len) {
  11845     return(NULL);
  11846   }
  11847   if (neg) {
  11848     index++;
  11849   }
  11850   if (index < -(int64_t)len) {
  11851     return(NULL);
  11852   }
  11853   if (neg) {
  11854     index = (int64_t)len + index;
  11855   }
  11856 
  11857 
  11858   sArrayt *a = allocSArray();
  11859   if (!a) {
  11860     return(NULL);
  11861   }
  11862 
  11863   smallt *o = toSmallt(toInject);
  11864   if (!o) {
  11865     sArrayFreeTiny(a);
  11866     return(NULL);
  11867   }
  11868 
  11869   if (!(o->type == CONTAINER && (((sContainert*)o)->dataType == SH_DT_BASET))) {
  11870     finishO(toInject);
  11871   }
  11872 
  11873   if (index == 0) {
  11874     // inject at beginning
  11875     sArrayPushTiny(&a, o);
  11876     for (int64_t i=0;i < (int64_t)len;i++) {
  11877       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11878       sArrayPushTiny(&a, o);
  11879   }
  11880     }
  11881   else {
  11882 
  11883     smallt *o2;
  11884     for (int64_t i=0;i < index;i++) {
  11885       o2 = sArrayGetTiny(self->topA, (uint32_t)i);
  11886       sArrayPushTiny(&a, o2);
  11887     }
  11888     sArrayPushTiny(&a, o);
  11889     for (int64_t i=index;i < (int64_t)len;i++) {
  11890       o = sArrayGetTiny(self->topA, (uint32_t)i);
  11891       sArrayPushTiny(&a, o);
  11892   }
  11893     }
  11894 
  11895   free(self->topA);
  11896   self->topA = a;
  11897   return(self);
  11898 }
  11899 
  11900 internal smallJsont* injectNFreeUndefinedSmallJson(smallJsont *self, int64_t index, undefinedt *u) {
  11901 
  11902   smallJsont *r = injectUndefinedSmallJson(self, index);;
  11903   if (r) {
  11904     terminateO(u);
  11905   }
  11906   return(r);
  11907 }
  11908 
  11909 internal smallJsont* injectNFreeSSmallJson(smallJsont *self, int64_t index, char *toInject) {
  11910 
  11911   if (!toInject) {
  11912     return(NULL);
  11913   }
  11914 
  11915   smallJsont *r = injectSSmallJson(self, index, toInject);;
  11916   if (r) {
  11917     free(toInject);
  11918   }
  11919   return(r);
  11920 }
  11921 
  11922 internal smallJsont* injectNFreeDictSmallJson(smallJsont *self, int64_t index, smallDictt *toInject) {
  11923 
  11924   if (!toInject) {
  11925     return(NULL);
  11926   }
  11927 
  11928   smallJsont *r = injectDictSmallJson(self, index, toInject);
  11929   if (r) {
  11930     finishO(toInject);
  11931   }
  11932   return(r);
  11933 }
  11934 
  11935 internal smallJsont* injectNFreeArraySmallJson(smallJsont *self, int64_t index, smallArrayt *toInject) {
  11936 
  11937   if (!toInject) {
  11938     return(NULL);
  11939   }
  11940 
  11941   smallJsont *r = injectArraySmallJson(self, index, toInject);
  11942   if (r) {
  11943     finishO(toInject);
  11944   }
  11945   return(r);
  11946 }
  11947 
  11948 internal smallJsont* injectNFreeArraycSmallJson(smallJsont *self, int64_t index, char **toInject) {
  11949 
  11950   if (!toInject) {
  11951     return(NULL);
  11952   }
  11953 
  11954   smallJsont *r = injectArraycSmallJson(self, index, toInject);;
  11955   if (r) {
  11956     listFreeS(toInject);
  11957   }
  11958   return(r);
  11959 }
  11960 
  11961 internal smallJsont* injectNFreeSmallBoolSmallJson(smallJsont *self, int64_t index, smallBoolt *toInject) {
  11962 
  11963   if (!toInject) {
  11964     return(NULL);
  11965   }
  11966 
  11967   smallJsont *r = injectSmallBoolSmallJson(self, index, toInject);
  11968   if (r) {
  11969     finishO(toInject);
  11970   }
  11971   return(r);
  11972 }
  11973 
  11974 internal smallJsont* injectNFreeSmallBytesSmallJson(smallJsont *self, int64_t index, smallBytest *toInject) {
  11975 
  11976   if (!toInject) {
  11977     return(NULL);
  11978   }
  11979 
  11980   smallJsont *r = injectSmallBytesSmallJson(self, index, toInject);
  11981   if (r) {
  11982     finishO(toInject);
  11983   }
  11984   return(r);
  11985 }
  11986 
  11987 internal smallJsont* injectNFreeSmallDoubleSmallJson(smallJsont *self, int64_t index, smallDoublet *toInject) {
  11988 
  11989   if (!toInject) {
  11990     return(NULL);
  11991   }
  11992 
  11993   smallJsont *r = injectSmallDoubleSmallJson(self, index, toInject);
  11994   if (r) {
  11995     finishO(toInject);
  11996   }
  11997   return(r);
  11998 }
  11999 
  12000 internal smallJsont* injectNFreeSmallIntSmallJson(smallJsont *self, int64_t index, smallIntt *toInject) {
  12001 
  12002   if (!toInject) {
  12003     return(NULL);
  12004   }
  12005 
  12006   smallJsont *r = injectSmallIntSmallJson(self, index, toInject);
  12007   if (r) {
  12008     finishO(toInject);
  12009   }
  12010   return(r);
  12011 }
  12012 
  12013 internal smallJsont* injectNFreeSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *toInject) {
  12014 
  12015   if (!toInject) {
  12016     return(NULL);
  12017   }
  12018 
  12019   smallJsont *r = injectSmallJsonSmallJson(self, index, toInject);
  12020   if (r) {
  12021     finishO(toInject);
  12022   }
  12023   return(r);
  12024 }
  12025 
  12026 internal smallJsont* injectNFreeSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *toInject) {
  12027 
  12028   if (!toInject) {
  12029     return(NULL);
  12030   }
  12031 
  12032   smallJsont *r = injectSmallStringSmallJson(self, index, toInject);
  12033   if (r) {
  12034     finishO(toInject);
  12035   }
  12036   return(r);
  12037 }
  12038 
  12039 internal smallJsont* injectNFreeSmallContainerSmallJson(smallJsont *self, int64_t index, smallContainert *toInject) {
  12040 
  12041   if (!toInject) {
  12042     return(NULL);
  12043   }
  12044 
  12045   smallJsont *r = injectSmallContainerSmallJson(self, index, toInject);
  12046   if (r) {
  12047     finishO(toInject);
  12048   }
  12049   return(r);
  12050 }
  12051 
  12052 
  12053 internal smallJsont* uniqSmallJson(smallJsont *self) {
  12054 
  12055   // sanity checks
  12056   if (self->topIsA != TOP_IS_ARRAY) {
  12057     return(NULL);
  12058   }
  12059 
  12060   if (!lenSmallJson(self)) {
  12061     return(NULL);
  12062   }
  12063 
  12064   if (lenSmallJson(self) == 1) {
  12065     return(self);
  12066   }
  12067 
  12068   createAllocateSmallArray(r);
  12069   if (!r) {
  12070     return(NULL);
  12071   }
  12072   createAllocateSmallArray(a);
  12073   if (!a) {
  12074     terminateO(r);
  12075     return(NULL);
  12076   }
  12077   createAllocateSmallDict(d);
  12078   if (!d) {
  12079     terminateO(r);
  12080     terminateO(a);
  12081     return(NULL);
  12082   }
  12083   createAllocateSmallBytes(B);
  12084   if (!B) {
  12085     terminateO(r);
  12086     terminateO(a);
  12087     terminateO(B);
  12088     return(NULL);
  12089   }
  12090 
  12091 
  12092   // push element to new list if it is not already in new list
  12093   bool pushE          = false;
  12094   bool foundUndefined = false;
  12095   forEachSArray(self->topA, e) {
  12096     if (e) {
  12097       switch (e->type) {
  12098       case UNDEFINED:
  12099         if (!foundUndefined) {
  12100           pushE = true;
  12101           foundUndefined = true;
  12102         }
  12103         else {
  12104           free(e);
  12105         }
  12106         break;
  12107       case BOOL:
  12108         if (r->f->indexOfBool(r, ((sBoolt*)e)->value) == -1) {
  12109           pushE = true;
  12110         }
  12111         else {
  12112           free(e);
  12113         }
  12114         break;
  12115       // TODO case CONTAINER:
  12116       case DICT:
  12117         d->d = (sDictt*)e;
  12118         if (r->f->indexOfDict(r, d) == -1) {
  12119           pushE = true;
  12120         }
  12121         else {
  12122           freeO(d);
  12123         }
  12124         break;
  12125       case DOUBLE:
  12126         if (r->f->indexOfDouble(r, ((sDoublet*)e)->value) == -1) {
  12127           pushE = true;
  12128         }
  12129         else {
  12130           free(e);
  12131         }
  12132         break;
  12133       case INT:
  12134         if (r->f->indexOfInt(r, ((sIntt*)e)->value) == -1) {
  12135           pushE = true;
  12136         }
  12137         else {
  12138           free(e);
  12139         }
  12140         break;
  12141       case STRING:
  12142         if (r->f->indexOfS(r, sStringGetTiny((sStringt*)e)) == -1) {
  12143           pushE = true;
  12144         }
  12145         else {
  12146           free(e);
  12147         }
  12148         break;
  12149       case ARRAY:
  12150         a->a = (sArrayt*)e;
  12151         if (r->f->indexOfArray(r, a) == -1) {
  12152           pushE = true;
  12153         }
  12154         else {
  12155           freeO(a);
  12156         }
  12157         break;
  12158       case BYTES:
  12159         B->B = (sBytest*)e;
  12160         if (r->f->indexOfSmallBytes(r, B) == -1) {
  12161           pushE = true;
  12162         }
  12163         else {
  12164           freeO(B);
  12165         }
  12166         break;
  12167       default:
  12168         logC("Unsupported object type!");
  12169       }
  12170     }
  12171     if (pushE) {
  12172       sArrayPushTiny(&(r->a), e);
  12173       pushE = false;
  12174   }
  12175     }
  12176 
  12177   finishManyG(a, d, B);
  12178 
  12179   free(self->topA);
  12180   self->topA = r->a;
  12181   finishO(r);
  12182   return(self);
  12183 }
  12184 
  12185 internal int sortSCmp(const void * a, const void * b) {
  12186 
  12187   // sanity checks
  12188   smallt *A = (*((smallt *const*)a));
  12189   smallt *B = (*((smallt *const*)b));
  12190   if (!A && !B) {
  12191     return(0);
  12192   }
  12193   if (!A && B) {
  12194     return(-1);
  12195   }
  12196   if (A && !B) {
  12197     return(1);
  12198   }
  12199   char *As, *Bs;
  12200   int r;
  12201   if (A->type != B->type) {
  12202     return(A->type - B->type);
  12203   }
  12204   else {
  12205     switch (A->type){
  12206     case UNDEFINED:
  12207       return(0);
  12208     case BOOL:
  12209       return(((sBoolt*)A)->value < ((sBoolt*)B)->value * -1);
  12210     case CONTAINER:
  12211       return(0);
  12212     case DICT:
  12213       if (((sDictt*)A)->count < ((sDictt*)B)->count) {
  12214         return(-1);
  12215       }
  12216       else if (((sDictt*)A)->count == ((sDictt*)B)->count) {
  12217         As = sToString(A);
  12218         Bs = sToString(B);
  12219         // TODO compare recursively
  12220         r = strcmp(As,Bs);;
  12221         freeManyS(As,Bs);
  12222         return(r);
  12223       }
  12224       else {
  12225         return(1);
  12226       }
  12227     case DOUBLE:
  12228       if (((sDoublet*)A)->value < ((sDoublet*)B)->value) {
  12229         return(-1);
  12230       }
  12231       else if (((sDoublet*)A)->value == ((sDoublet*)B)->value) {
  12232         return(0);
  12233       }
  12234       else {
  12235         return(1);
  12236       }
  12237     case INT:
  12238       if (((sIntt*)A)->value < ((sIntt*)B)->value) {
  12239         return(-1);
  12240       }
  12241       else if (((sIntt*)A)->value == ((sIntt*)B)->value) {
  12242         return(0);
  12243       }
  12244       else {
  12245         return(1);
  12246       }
  12247     case STRING:
  12248       return(strcmp(sStringGetTiny((sStringt*)A), sStringGetTiny((sStringt*)B)));
  12249     case ARRAY:
  12250       if (((sArrayt*)A)->count < ((sArrayt*)B)->count) {
  12251         return(-1);
  12252       }
  12253       else if (((sArrayt*)A)->count == ((sArrayt*)B)->count) {
  12254         As = sToString(A);
  12255         Bs = sToString(B);
  12256         // TODO compare recursively
  12257         r = strcmp(As,Bs);;
  12258         freeManyS(As,Bs);
  12259         return(r);
  12260       }
  12261       else {
  12262         return(1);
  12263       }
  12264     case BYTES:
  12265       if (((sBytest*)A)->count < ((sBytest*)B)->count) {
  12266         return(-1);
  12267       }
  12268       else if (((sBytest*)A)->count == ((sBytest*)B)->count) {
  12269         As = sToString(A);
  12270         Bs = sToString(B);
  12271         // TODO compare recursively
  12272         r = strcmp(As,Bs);;
  12273         freeManyS(As,Bs);
  12274         return(r);
  12275       }
  12276       else {
  12277         return(1);
  12278       }
  12279     default:
  12280       return(0);
  12281     }
  12282 }
  12283   }
  12284 
  12285 internal smallJsont* sortSmallJson(smallJsont *self) {
  12286   size_t len;
  12287 
  12288   // sanity checks
  12289   if (self->topIsA != TOP_IS_ARRAY) {
  12290     return(NULL);
  12291   }
  12292 
  12293   len = lenSmallJson(self);
  12294   if (!len) {
  12295     return(NULL);
  12296   }
  12297   // sort
  12298   smallt **arr = &(self->topA->data);
  12299   qsort(arr, lenSmallJson(self), sizeof(smallt *), sortSCmp);
  12300   return(self);
  12301 }
  12302 
  12303 #if (__APPLE__ || __FreeBSD__ || __DragonFly__)
  12304 internal int sortFCmp(void *func, const void *a, const void *b) {
  12305   shCmpt cmp;
  12306 
  12307   smallt *A = (*((smallt *const*)a));
  12308   smallt *B = (*((smallt *const*)b));
  12309 
  12310   baset *aO = toBaset(A);;
  12311   baset *bO = toBaset(B);;
  12312 
  12313   cmp   = (shCmpt) func;
  12314   int r = cmp(aO, bO);
  12315 
  12316   if ((A->type != CONTAINER) || (A->type == CONTAINER && ((sContainert*)A)->dataType != SH_DT_BASET)) {
  12317     finishO(aO);
  12318   }
  12319   if ((A->type != CONTAINER) || (A->type == CONTAINER && ((sContainert*)A)->dataType != SH_DT_BASET)) {
  12320     finishO(bO);
  12321   }
  12322   return(r);
  12323 }
  12324 #else
  12325 internal int sortFCmp(const void *a, const void *b, void *func) {
  12326   shCmpt cmp;
  12327 
  12328   smallt *A = (*((smallt *const*)a));
  12329   smallt *B = (*((smallt *const*)b));
  12330 
  12331   baset *aO = toBaset(A);;
  12332   baset *bO = toBaset(B);;
  12333 
  12334   cmp   = (shCmpt) func;
  12335   int r = cmp(aO, bO);
  12336 
  12337   if ((A->type != CONTAINER) || (A->type == CONTAINER && ((sContainert*)A)->dataType != SH_DT_BASET)) {
  12338     finishO(aO);
  12339   }
  12340   if ((A->type != CONTAINER) || (A->type == CONTAINER && ((sContainert*)A)->dataType != SH_DT_BASET)) {
  12341     finishO(bO);
  12342   }
  12343   return(r);
  12344 }
  12345 #endif
  12346 
  12347 internal int icSortSCmp(const void * a, const void * b) {
  12348 
  12349   // sanity checks
  12350   smallt *A = (*((smallt *const*)a));
  12351   smallt *B = (*((smallt *const*)b));
  12352   if (!A && !B) {
  12353     return(0);
  12354   }
  12355   if (!A && B) {
  12356     return(-1);
  12357   }
  12358   if (A && !B) {
  12359     return(1);
  12360   }
  12361   char *As, *Bs;
  12362   int r;
  12363   if (A->type != B->type) {
  12364     return(A->type - B->type);
  12365   }
  12366   else {
  12367     switch (A->type){
  12368     case UNDEFINED:
  12369       return(0);
  12370     case BOOL:
  12371       return(((sBoolt*)A)->value < ((sBoolt*)B)->value * -1);
  12372     case CONTAINER:
  12373       return(0);
  12374     case DICT:
  12375       if (((sDictt*)A)->count < ((sDictt*)B)->count) {
  12376         return(-1);
  12377       }
  12378       else if (((sDictt*)A)->count == ((sDictt*)B)->count) {
  12379         As = sToString(A);
  12380         Bs = sToString(B);
  12381         // TODO compare recursively
  12382         r = strcasecmp(As,Bs);;
  12383         freeManyS(As,Bs);
  12384         return(r);
  12385       }
  12386       else {
  12387         return(1);
  12388       }
  12389     case DOUBLE:
  12390       if (((sDoublet*)A)->value < ((sDoublet*)B)->value) {
  12391         return(-1);
  12392       }
  12393       else if (((sDoublet*)A)->value == ((sDoublet*)B)->value) {
  12394         return(0);
  12395       }
  12396       else {
  12397         return(1);
  12398       }
  12399     case INT:
  12400       if (((sIntt*)A)->value < ((sIntt*)B)->value) {
  12401         return(-1);
  12402       }
  12403       else if (((sIntt*)A)->value == ((sIntt*)B)->value) {
  12404         return(0);
  12405       }
  12406       else {
  12407         return(1);
  12408       }
  12409     case STRING:
  12410       return(strcasecmp(sStringGetTiny((sStringt*)A), sStringGetTiny((sStringt*)B)));
  12411     case ARRAY:
  12412       if (((sArrayt*)A)->count < ((sArrayt*)B)->count) {
  12413         return(-1);
  12414       }
  12415       else if (((sArrayt*)A)->count == ((sArrayt*)B)->count) {
  12416         As = sToString(A);
  12417         Bs = sToString(B);
  12418         // TODO compare recursively
  12419         r = strcasecmp(As,Bs);;
  12420         freeManyS(As,Bs);
  12421         return(r);
  12422       }
  12423       else {
  12424         return(1);
  12425       }
  12426     case BYTES:
  12427       if (((sBytest*)A)->count < ((sBytest*)B)->count) {
  12428         return(-1);
  12429       }
  12430       else if (((sBytest*)A)->count == ((sBytest*)B)->count) {
  12431         As = sToString(A);
  12432         Bs = sToString(B);
  12433         // TODO compare recursively
  12434         r = strcasecmp(As,Bs);;
  12435         freeManyS(As,Bs);
  12436         return(r);
  12437       }
  12438       else {
  12439         return(1);
  12440       }
  12441     default:
  12442       return(0);
  12443     }
  12444 }
  12445   }
  12446 
  12447 internal smallJsont* icSortSmallJson(smallJsont *self) {
  12448   size_t len;
  12449 
  12450   // sanity checks
  12451   if (self->topIsA != TOP_IS_ARRAY) {
  12452     return(NULL);
  12453   }
  12454 
  12455   len = lenSmallJson(self);
  12456   if (!len) {
  12457     return(NULL);
  12458   }
  12459   // sort
  12460   smallt **arr = &(self->topA->data);
  12461   qsort(arr, lenSmallJson(self), sizeof(smallt *), icSortSCmp);
  12462   return(self);
  12463 }
  12464 
  12465 #if (__APPLE__ || __FreeBSD__ || __DragonFly__)
  12466 // qsort_r has the parameters in a different order
  12467 internal smallJsont* sortFSmallJson(smallJsont *self, shCmpt compareFunction) {
  12468   size_t len;
  12469 
  12470   // sanity checks
  12471   if (self->topIsA != TOP_IS_ARRAY) {
  12472     return(NULL);
  12473   }
  12474 
  12475   len = lenSmallJson(self);
  12476   if (!len || !compareFunction) {
  12477     return(NULL);
  12478   }
  12479   // sort
  12480   smallt **arr = &(self->topA->data);
  12481   qsort_r(arr, lenSmallJson(self), sizeof(smallt *), compareFunction, sortFCmp);
  12482   return(self);
  12483 }
  12484 #else
  12485 internal smallJsont* sortFSmallJson(smallJsont *self, shCmpt compareFunction) {
  12486   size_t len;
  12487 
  12488   // sanity checks
  12489   if (self->topIsA != TOP_IS_ARRAY) {
  12490     return(NULL);
  12491   }
  12492 
  12493   len = lenSmallJson(self);
  12494   if (!len || !compareFunction) {
  12495     return(NULL);
  12496   }
  12497   // sort
  12498   smallt **arr = &(self->topA->data);
  12499   #if (__TERMUX__ || __OpenBSD__ || MUSL_LIBC || __sun__ || __HAIKU__)
  12500   // qsort_r is missing in Termux
  12501   smallt *tmp;
  12502   QSORT(lenSmallJson(self), LESSsa, SWAPsa);
  12503   #else
  12504   qsort_r(arr, lenSmallJson(self), sizeof(smallt *), sortFCmp, compareFunction);
  12505   #endif
  12506   return(self);
  12507 }
  12508 #endif
  12509 
  12510 internal smallJsont* icUniqSmallJson(smallJsont *self) {
  12511 
  12512   // sanity checks
  12513   if (self->topIsA != TOP_IS_ARRAY) {
  12514     return(NULL);
  12515   }
  12516 
  12517   if (!lenSmallJson(self)) {
  12518     return(NULL);
  12519   }
  12520 
  12521   if (lenSmallJson(self) == 1) {
  12522     return(self);
  12523   }
  12524 
  12525   createAllocateSmallArray(r);
  12526   if (!r) {
  12527     return(NULL);
  12528   }
  12529   createAllocateSmallArray(a);
  12530   if (!a) {
  12531     terminateO(r);
  12532     return(NULL);
  12533   }
  12534   createAllocateSmallDict(d);
  12535   if (!d) {
  12536     terminateO(r);
  12537     terminateO(a);
  12538     return(NULL);
  12539   }
  12540   createAllocateSmallBytes(B);
  12541   if (!B) {
  12542     terminateO(r);
  12543     terminateO(a);
  12544     terminateO(B);
  12545     return(NULL);
  12546   }
  12547 
  12548 
  12549   // push element to new list if it is not already in new list
  12550   bool pushE          = false;
  12551   bool foundUndefined = false;
  12552   forEachSArray(self->topA, e) {
  12553     if (e) {
  12554       switch (e->type) {
  12555       case UNDEFINED:
  12556         if (!foundUndefined) {
  12557           pushE = true;
  12558           foundUndefined = true;
  12559         }
  12560         else {
  12561           free(e);
  12562         }
  12563         break;
  12564       case BOOL:
  12565         if (r->f->indexOfBool(r, ((sBoolt*)e)->value) == -1) {
  12566           pushE = true;
  12567         }
  12568         else {
  12569           free(e);
  12570         }
  12571         break;
  12572       // TODO case CONTAINER:
  12573       case DICT:
  12574         d->d = (sDictt*)e;
  12575         if (r->f->icIndexOfDict(r, d) == -1) {
  12576           pushE = true;
  12577         }
  12578         else {
  12579           freeO(d);
  12580         }
  12581         break;
  12582       case DOUBLE:
  12583         if (r->f->indexOfDouble(r, ((sDoublet*)e)->value) == -1) {
  12584           pushE = true;
  12585         }
  12586         else {
  12587           free(e);
  12588         }
  12589         break;
  12590       case INT:
  12591         if (r->f->indexOfInt(r, ((sIntt*)e)->value) == -1) {
  12592           pushE = true;
  12593         }
  12594         else {
  12595           free(e);
  12596         }
  12597         break;
  12598       case STRING:
  12599         if (r->f->icIndexOfS(r, sStringGetTiny((sStringt*)e)) == -1) {
  12600           pushE = true;
  12601         }
  12602         else {
  12603           free(e);
  12604         }
  12605         break;
  12606       case ARRAY:
  12607         a->a = (sArrayt*)e;
  12608         if (r->f->icIndexOfArray(r, a) == -1) {
  12609           pushE = true;
  12610         }
  12611         else {
  12612           freeO(a);
  12613         }
  12614         break;
  12615       case BYTES:
  12616         B->B = (sBytest*)e;
  12617         if (r->f->indexOfSmallBytes(r, B) == -1) {
  12618           pushE = true;
  12619         }
  12620         else {
  12621           freeO(B);
  12622         }
  12623         break;
  12624       default:
  12625         logC("Unsupported object type!");
  12626       }
  12627     }
  12628     if (pushE) {
  12629       sArrayPushTiny(&(r->a), e);
  12630       pushE = false;
  12631   }
  12632     }
  12633 
  12634   finishManyG(a, d, B);
  12635 
  12636   free(self->topA);
  12637   self->topA = r->a;
  12638   finishO(r);
  12639   return(self);
  12640 }
  12641 
  12642 internal smallJsont* uniqCharSmallJson(smallJsont *self, char c) {
  12643 
  12644   // sanity checks
  12645   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  12646     return(NULL);
  12647   }
  12648 
  12649   if (lenSmallJson(self) < 2) {
  12650     // string is too short to have repetitions
  12651     return(self);
  12652   }
  12653 
  12654   char *string = sStringGetTiny(self->topS);
  12655   // index in r
  12656   size_t j = 1;;
  12657   rangeFrom(i, 1, lenSmallJson(self))
  12658     if (string[i-1] == c && string[i] == c) {
  12659       // skip
  12660       continue;
  12661     }
  12662     else {
  12663       string[j] = string[i];
  12664       j++;
  12665     }
  12666 
  12667   string[j] = 0;
  12668 
  12669   return(self);
  12670 }
  12671 
  12672 internal smallJsont* icUniqCharSmallJson(smallJsont *self, char c) {
  12673 
  12674   // sanity checks
  12675   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  12676     return(NULL);
  12677   }
  12678 
  12679   if (lenSmallJson(self) < 2) {
  12680     // string is too short to have repetitions
  12681     return(self);
  12682   }
  12683 
  12684   char *string = sStringGetTiny(self->topS);
  12685   // index in r
  12686   size_t j = 1;;
  12687   rangeFrom(i, 1, lenSmallJson(self))
  12688     if (tolower(string[i-1]) == c && tolower(string[i]) == c) {
  12689       // skip
  12690       continue;
  12691     }
  12692     else {
  12693       string[j] = string[i];
  12694       j++;
  12695     }
  12696 
  12697   string[j] = 0;
  12698 
  12699   return(self);
  12700 }
  12701 
  12702 internal bool hasSmallJson(smallJsont *self, baset *value) {
  12703 
  12704   if (!value) {
  12705     return(false);
  12706   }
  12707 
  12708   if (indexOfSmallJson(self, value) == -1) {
  12709     return(false);
  12710   }
  12711 
  12712   return(true);
  12713 }
  12714 
  12715 internal bool hasUndefinedSmallJson(smallJsont *self, undefinedt *u) {
  12716 
  12717   if (!u) {
  12718     return(false);
  12719   }
  12720 
  12721   if (checkObjectTypes && !isOUndefined(u)) {
  12722     return(false);
  12723   }
  12724 
  12725   if (indexOfUndefinedSmallJson(self, u) == -1) {
  12726     return(false);
  12727   }
  12728 
  12729   return(true);
  12730 }
  12731 
  12732 internal bool hasBoolSmallJson(smallJsont *self, bool value) {
  12733 
  12734   if (indexOfBoolSmallJson(self, value) == -1) {
  12735     return(false);
  12736   }
  12737 
  12738   return(true);
  12739 }
  12740 
  12741 internal bool hasDoubleSmallJson(smallJsont *self, double value) {
  12742 
  12743   if (indexOfDoubleSmallJson(self, value) == -1) {
  12744     return(false);
  12745   }
  12746 
  12747   return(true);
  12748 }
  12749 
  12750 internal bool hasIntSmallJson(smallJsont *self, int64_t value) {
  12751 
  12752   if (indexOfIntSmallJson(self, value) == -1) {
  12753     return(false);
  12754   }
  12755 
  12756   return(true);
  12757 }
  12758 
  12759 internal bool hasSSmallJson(smallJsont *self, const char *string) {
  12760 
  12761   if (!string) {
  12762     return(false);
  12763   }
  12764 
  12765   if (self->topIsA == TOP_IS_DICT) {
  12766     if (!self->top) {
  12767       return(false);
  12768     }
  12769     smallt *o = sDictGetTiny(self->top, string);;
  12770     if (!o) {
  12771       return(false);
  12772   }
  12773     }
  12774   else if (indexOfSSmallJson(self, string) == -1) {
  12775     return(false);
  12776   }
  12777 
  12778   return(true);
  12779 }
  12780 
  12781 internal bool hasCharSmallJson(smallJsont *self, char c) {
  12782 
  12783   charToS(s, c);
  12784   return(hasSSmallJson(self, s));
  12785 }
  12786 
  12787 internal bool hasDictSmallJson(smallJsont *self, smallDictt *dict) {
  12788 
  12789   if (!dict) {
  12790     return(false);
  12791   }
  12792 
  12793   if (checkObjectTypes && !isOSmallDict(dict)) {
  12794     return(false);
  12795   }
  12796 
  12797   if (indexOfDictSmallJson(self, dict) == -1) {
  12798     return(false);
  12799   }
  12800 
  12801   return(true);
  12802 }
  12803 
  12804 internal bool hasArraySmallJson(smallJsont *self, smallArrayt *array) {
  12805 
  12806   if (!array) {
  12807     return(false);
  12808   }
  12809 
  12810   if (checkObjectTypes && !isOSmallArray(array)) {
  12811     return(false);
  12812   }
  12813 
  12814   if (indexOfArraySmallJson(self, array) == -1) {
  12815     return(false);
  12816   }
  12817 
  12818   return(true);
  12819 }
  12820 
  12821 internal bool hasArraycSmallJson(smallJsont *self, char **array) {
  12822 
  12823   if (!array) {
  12824     return(false);
  12825   }
  12826 
  12827   if (indexOfArraycSmallJson(self, array) == -1) {
  12828     return(false);
  12829   }
  12830 
  12831   return(true);
  12832 }
  12833 
  12834 internal bool hasCArraycSmallJson(smallJsont *self, const char **array) {
  12835 
  12836   if (!array) {
  12837     return(false);
  12838   }
  12839 
  12840   if (indexOfCArraycSmallJson(self, array) == -1) {
  12841     return(false);
  12842   }
  12843 
  12844   return(true);
  12845 }
  12846 
  12847 internal bool hasSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
  12848 
  12849   if (!value) {
  12850     return(false);
  12851   }
  12852 
  12853   if (checkObjectTypes && !isOSmallBool(value)) {
  12854     return(false);
  12855   }
  12856 
  12857   if (indexOfSmallBoolSmallJson(self, value) == -1) {
  12858     return(false);
  12859   }
  12860 
  12861   return(true);
  12862 }
  12863 
  12864 internal bool hasSmallBytesSmallJson(smallJsont *self, smallBytest *value) {
  12865 
  12866   if (!value) {
  12867     return(false);
  12868   }
  12869 
  12870   if (checkObjectTypes && !isOSmallBytes(value)) {
  12871     return(false);
  12872   }
  12873 
  12874   if (indexOfSmallBytesSmallJson(self, value) == -1) {
  12875     return(false);
  12876   }
  12877 
  12878   return(true);
  12879 }
  12880 
  12881 internal bool hasSmallDoubleSmallJson(smallJsont *self, smallDoublet *value) {
  12882 
  12883   if (!value) {
  12884     return(false);
  12885   }
  12886 
  12887   if (checkObjectTypes && !isOSmallDouble(value)) {
  12888     return(false);
  12889   }
  12890 
  12891   if (indexOfSmallDoubleSmallJson(self, value) == -1) {
  12892     return(false);
  12893   }
  12894 
  12895   return(true);
  12896 }
  12897 
  12898 internal bool hasSmallIntSmallJson(smallJsont *self, smallIntt *value) {
  12899 
  12900   if (!value) {
  12901     return(false);
  12902   }
  12903 
  12904   if (checkObjectTypes && !isOSmallInt(value)) {
  12905     return(false);
  12906   }
  12907 
  12908   if (indexOfSmallIntSmallJson(self, value) == -1) {
  12909     return(false);
  12910   }
  12911 
  12912   return(true);
  12913 }
  12914 
  12915 internal bool hasSmallJsonSmallJson(smallJsont *self, smallJsont *value) {
  12916 
  12917   if (!value) {
  12918     return(false);
  12919   }
  12920 
  12921   if (checkObjectTypes && !isOSmallJson(value)) {
  12922     return(false);
  12923   }
  12924 
  12925   if (indexOfSmallJsonSmallJson(self, value) == -1) {
  12926     return(false);
  12927   }
  12928 
  12929   return(true);
  12930 }
  12931 
  12932 internal bool hasSmallStringSmallJson(smallJsont *self, smallStringt *string) {
  12933 
  12934   if (!string) {
  12935     return(false);
  12936   }
  12937 
  12938   if (checkObjectTypes && !isOSmallString(string)) {
  12939     return(false);
  12940   }
  12941 
  12942   if (indexOfSmallStringSmallJson(self, string) == -1) {
  12943     return(false);
  12944   }
  12945 
  12946   return(true);
  12947 }
  12948 
  12949 internal bool hasSmallContainerSmallJson(smallJsont *self, smallContainert *container) {
  12950 
  12951   if (!container) {
  12952     return(false);
  12953   }
  12954 
  12955   if (checkObjectTypes && !isOSmallContainer(container)) {
  12956     return(NULL);
  12957   }
  12958 
  12959   if (indexOfSmallContainerSmallJson(self, container) == -1) {
  12960     return(false);
  12961   }
  12962 
  12963   return(true);
  12964 }
  12965 
  12966 internal smallJsont* findSmallJson(smallJsont *self, const char *needle) {
  12967 
  12968   // sanity checks
  12969   if (self->topIsA != TOP_IS_STRING || !self->topS || !needle || !lenSmallJson(self)) {
  12970     return(NULL);
  12971   }
  12972 
  12973   char *s = strstr(sStringGetTiny(self->topS), needle);
  12974   if (!s) {
  12975     return(NULL);
  12976   }
  12977   createAllocateSmallJson(r);
  12978   if (!r) {
  12979     return(NULL);
  12980   }
  12981   r->f->setTopString(r, s);
  12982   return(r);
  12983 }
  12984 
  12985 internal smallJsont* findCharSmallJson(smallJsont *self, char c) {
  12986 
  12987   // sanity checks
  12988   if (self->topIsA != TOP_IS_STRING || !self->topS || !lenSmallJson(self)) {
  12989     return(NULL);
  12990   }
  12991 
  12992   char *s = strchr(sStringGetTiny(self->topS), c);
  12993   if (!s) {
  12994     return(NULL);
  12995   }
  12996   createAllocateSmallJson(r);
  12997   if (!r) {
  12998     return(NULL);
  12999   }
  13000   r->f->setTopString(r, s);
  13001   return(r);
  13002 }
  13003 
  13004 internal smallJsont* findSmallStringSmallJson(smallJsont *self, smallStringt *needle) {
  13005 
  13006   if (!needle) {
  13007     return(NULL);
  13008   }
  13009   if (checkObjectTypes && !isOSmallString(needle)) {
  13010     return(NULL);
  13011   }
  13012 
  13013   return(findSmallJson(self, ssGet(needle)));
  13014 }
  13015 
  13016 internal smallJsont* findJsonSmallJson(smallJsont *self, smallJsont *needle) {
  13017 
  13018   if (!needle) {
  13019     return(NULL);
  13020   }
  13021   if (checkObjectTypes && !isOSmallJson(needle)) {
  13022     return(NULL);
  13023   }
  13024 
  13025   return(findSmallJson(self, sjGet(needle)));
  13026 }
  13027 
  13028 internal ssize_t indexOfSmallJson(smallJsont *self, baset *value) {
  13029 
  13030   // sanity checks
  13031   if (self->topIsA != TOP_IS_ARRAY) {
  13032     return(-1);
  13033   }
  13034 
  13035   if (!lenSmallJson(self) || !value) {
  13036     return(-1);
  13037   }
  13038 
  13039   // search string in elements
  13040   char *s = toStringO(value);
  13041   char *es = NULL;
  13042 
  13043   enumerateSArray(self->topA, e, i) {
  13044     if (not e) {
  13045       continue;
  13046     }
  13047     es = sToString(e);
  13048     if (strEq(es, s)) {
  13049       free(es);
  13050       free(s);
  13051       return((ssize_t)i);
  13052     }
  13053     free(es);
  13054   }
  13055   free(s);
  13056   return(-1);
  13057 }
  13058 
  13059 internal ssize_t indexOfUndefinedSmallJson(smallJsont *self, undefinedt *u) {
  13060 
  13061   // sanity checks
  13062   if (self->topIsA != TOP_IS_ARRAY) {
  13063     return(-1);
  13064   }
  13065 
  13066   if (!lenSmallJson(self) || !u) {
  13067     return(-1);
  13068   }
  13069 
  13070   if (checkObjectTypes && !isOUndefined(u)) {
  13071     return(-1);
  13072   }
  13073 
  13074   // search string in elements
  13075   enumerateSArray(self->topA, e, i) {
  13076     if (not e) {
  13077       continue;
  13078     }
  13079     if (e->type == UNDEFINED) {
  13080       return((ssize_t)i);
  13081   }
  13082     }
  13083   return(-1);
  13084 }
  13085 
  13086 internal ssize_t indexOfBoolSmallJson(smallJsont *self, bool value) {
  13087 
  13088   // sanity checks
  13089   if (self->topIsA != TOP_IS_ARRAY) {
  13090     return(-1);
  13091   }
  13092 
  13093   if (!lenSmallJson(self)) {
  13094     return(-1);
  13095   }
  13096 
  13097   // search value in elements
  13098   enumerateSArray(self->topA, e, i) {
  13099     if (not e) {
  13100       continue;
  13101     }
  13102     if (e->type == BOOL && ((sBoolt*)e)->value == value) {
  13103       return((ssize_t)i);
  13104   }
  13105     }
  13106   return(-1);
  13107 }
  13108 
  13109 internal ssize_t indexOfDoubleSmallJson(smallJsont *self, double value) {
  13110 
  13111   // sanity checks
  13112   if (self->topIsA != TOP_IS_ARRAY) {
  13113     return(-1);
  13114   }
  13115 
  13116   if (!lenSmallJson(self)) {
  13117     return(-1);
  13118   }
  13119 
  13120   // search value in elements
  13121   enumerateSArray(self->topA, e, i) {
  13122     if (not e) {
  13123       continue;
  13124     }
  13125     if (e->type == DOUBLE && ((sDoublet*)e)->value == value) {
  13126       return((ssize_t)i);
  13127   }
  13128     }
  13129   return(-1);
  13130 }
  13131 
  13132 internal ssize_t indexOfIntSmallJson(smallJsont *self, int64_t value) {
  13133 
  13134   // sanity checks
  13135   if (self->topIsA != TOP_IS_ARRAY) {
  13136     return(-1);
  13137   }
  13138 
  13139   if (!lenSmallJson(self)) {
  13140     return(-1);
  13141   }
  13142 
  13143   // search value in elements
  13144   enumerateSArray(self->topA, e, i) {
  13145     if (not e) {
  13146       continue;
  13147     }
  13148     if (e->type == INT && ((sIntt*)e)->value == value) {
  13149       return((ssize_t)i);
  13150   }
  13151     }
  13152   return(-1);
  13153 }
  13154 
  13155 internal ssize_t indexOfSSmallJson(smallJsont *self, const char *string) {
  13156 
  13157   // sanity checks
  13158   if (self->topIsA != TOP_IS_ARRAY && self->topIsA != TOP_IS_STRING) {
  13159     return(-1);
  13160   }
  13161 
  13162   if (!string) {
  13163     return(-1);
  13164   }
  13165 
  13166   switch(self->topIsA) {
  13167     case TOP_IS_ARRAY:
  13168       if (!lenSmallJson(self)) {
  13169         return(-1);
  13170       }
  13171       // search string in elements
  13172       enumerateSArray(self->topA, e, i) {
  13173         if (not e) {
  13174           continue;
  13175         }
  13176         if (e->type == STRING && strEq(sStringGetTiny((sStringt*)e), string)) {
  13177           return((ssize_t)i);
  13178       }
  13179         }
  13180       break;
  13181     case TOP_IS_STRING:
  13182       return((ssize_t)indexOfS(sStringGetTiny((sStringt*)self->topS), string));
  13183     default:;
  13184       // not reachable
  13185       logC("Check this function!");
  13186   }
  13187   return(-1);
  13188 }
  13189 
  13190 internal ssize_t indexOfCharSmallJson(smallJsont *self, char c) {
  13191 
  13192   charToS(s, c);
  13193   return((ssize_t)indexOfSSmallJson(self, s));
  13194 }
  13195 
  13196 internal ssize_t indexOfDictSmallJson(smallJsont *self, smallDictt *dict) {
  13197 
  13198   // sanity checks
  13199   if (self->topIsA != TOP_IS_ARRAY) {
  13200     return(-1);
  13201   }
  13202 
  13203   if (!lenSmallJson(self) || !dict) {
  13204     return(-1);
  13205   }
  13206 
  13207   if (checkObjectTypes && !isOSmallDict(dict)) {
  13208     return(-1);
  13209   }
  13210 
  13211   // search object in elements
  13212   char *s = toStringO(dict);
  13213   char *es = NULL;;
  13214 
  13215   enumerateSArray(self->topA, e, i) {
  13216     if (not e) {
  13217       continue;
  13218     }
  13219     if (e->type == DICT) {
  13220       es = sToString(e);
  13221       if (strEq(es, s)) {
  13222         free(es);
  13223         free(s);
  13224         return((ssize_t)i);
  13225       }
  13226       free(es);
  13227   }
  13228     }
  13229   free(s);
  13230   return(-1);
  13231 }
  13232 
  13233 internal ssize_t indexOfArraySmallJson(smallJsont *self, smallArrayt *array) {
  13234 
  13235   // sanity checks
  13236   if (self->topIsA != TOP_IS_ARRAY) {
  13237     return(-1);
  13238   }
  13239 
  13240   if (!lenSmallJson(self) || !array) {
  13241     return(-1);
  13242   }
  13243 
  13244   if (checkObjectTypes && !isOSmallArray(array)) {
  13245     return(-1);
  13246   }
  13247 
  13248   // search object in elements
  13249   char *s = toStringO(array);
  13250   char *es = NULL;;
  13251 
  13252   enumerateSArray(self->topA, e, i) {
  13253     if (not e) {
  13254       continue;
  13255     }
  13256     if (e->type == ARRAY) {
  13257       es = sToString(e);
  13258       if (strEq(es, s)) {
  13259         free(es);
  13260         free(s);
  13261         return((ssize_t)i);
  13262       }
  13263       free(es);
  13264   }
  13265     }
  13266   free(s);
  13267   return(-1);
  13268 }
  13269 
  13270 internal ssize_t indexOfArraycSmallJson(smallJsont *self, char **array) {
  13271 
  13272   // sanity checks
  13273   if (self->topIsA != TOP_IS_ARRAY) {
  13274     return(-1);
  13275   }
  13276 
  13277   if (!lenSmallJson(self) || !array) {
  13278     return(-1);
  13279   }
  13280 
  13281   // search object in elements
  13282   char *s = toStringListSGF(array);
  13283   char *es = NULL;;
  13284 
  13285   enumerateSArray(self->topA, e, i) {
  13286     if (not e) {
  13287       continue;
  13288     }
  13289     if (e->type == ARRAY) {
  13290       es = sToString(e);
  13291       if (strEq(es, s)) {
  13292         free(es);
  13293         free(s);
  13294         return((ssize_t)i);
  13295       }
  13296       free(es);
  13297   }
  13298     }
  13299   free(s);
  13300   return(-1);
  13301 }
  13302 
  13303 internal ssize_t indexOfCArraycSmallJson(smallJsont *self, const char **array) {
  13304 
  13305   // sanity checks
  13306   if (self->topIsA != TOP_IS_ARRAY) {
  13307     return(-1);
  13308   }
  13309 
  13310   if (!lenSmallJson(self) || !array) {
  13311     return(-1);
  13312   }
  13313 
  13314   // search object in elements
  13315   char *s = toStringListCSGF(array);
  13316   char *es = NULL;;
  13317 
  13318   enumerateSArray(self->topA, e, i) {
  13319     if (not e) {
  13320       continue;
  13321     }
  13322     if (e->type == ARRAY) {
  13323       es = sToString(e);
  13324       if (strEq(es, s)) {
  13325         free(es);
  13326         free(s);
  13327         return((ssize_t)i);
  13328       }
  13329       free(es);
  13330   }
  13331     }
  13332   free(s);
  13333   return(-1);
  13334 }
  13335 
  13336 internal ssize_t indexOfSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
  13337 
  13338   // sanity checks
  13339   if (self->topIsA != TOP_IS_ARRAY) {
  13340     return(-1);
  13341   }
  13342 
  13343   if (!lenSmallJson(self) || !value) {
  13344     return(-1);
  13345   }
  13346 
  13347   if (checkObjectTypes && !isOSmallBool(value)) {
  13348     return(-1);
  13349   }
  13350 
  13351   // search object in elements
  13352   bool b = value->f->get(value);
  13353 
  13354   enumerateSArray(self->topA, e, i) {
  13355     if (not e) {
  13356       continue;
  13357     }
  13358     if (e->type == BOOL && ((sBoolt*)e)->value == b) {
  13359       return((ssize_t)i);
  13360   }
  13361     }
  13362   return(-1);
  13363 }
  13364 
  13365 internal ssize_t indexOfSmallBytesSmallJson(smallJsont *self, smallBytest *value) {
  13366 
  13367   // sanity checks
  13368   if (self->topIsA != TOP_IS_ARRAY) {
  13369     return(-1);
  13370   }
  13371 
  13372   if (!lenSmallJson(self) || !value || !value->B) {
  13373     return(-1);
  13374   }
  13375 
  13376   if (checkObjectTypes && !isOSmallBytes(value)) {
  13377     return(-1);
  13378   }
  13379 
  13380   // search object in elements
  13381   void *b        = sBytesGet(value->B);
  13382   uint32_t count = value->B->count;
  13383 
  13384   enumerateSArray(self->topA, e, i) {
  13385     if (not e) {
  13386       continue;
  13387     }
  13388     if (e->type == BYTES && ((sBytest*)e)->count == count && !memcmp(&(((sBytest*)e)->data), b, count)) {
  13389       return((ssize_t)i);
  13390   }
  13391     }
  13392   return(-1);
  13393 }
  13394 
  13395 internal ssize_t indexOfSmallDoubleSmallJson(smallJsont *self, smallDoublet *value) {
  13396 
  13397   // sanity checks
  13398   if (self->topIsA != TOP_IS_ARRAY) {
  13399     return(-1);
  13400   }
  13401 
  13402   if (!lenSmallJson(self) || !value) {
  13403     return(-1);
  13404   }
  13405 
  13406   if (checkObjectTypes && !isOSmallDouble(value)) {
  13407     return(-1);
  13408   }
  13409 
  13410   // search object in elements
  13411   double v = value->f->get(value);
  13412 
  13413   enumerateSArray(self->topA, e, i) {
  13414     if (not e) {
  13415       continue;
  13416     }
  13417     if (e->type == DOUBLE && ((sDoublet*)e)->value == v) {
  13418       return((ssize_t)i);
  13419   }
  13420     }
  13421   return(-1);
  13422 }
  13423 
  13424 internal ssize_t indexOfSmallIntSmallJson(smallJsont *self, smallIntt *value) {
  13425 
  13426   // sanity checks
  13427   if (self->topIsA != TOP_IS_ARRAY) {
  13428     return(-1);
  13429   }
  13430 
  13431   if (!lenSmallJson(self) || !value) {
  13432     return(-1);
  13433   }
  13434 
  13435   if (checkObjectTypes && !isOSmallInt(value)) {
  13436     return(-1);
  13437   }
  13438 
  13439   // search object in elements
  13440   int64_t v = value->f->get(value);
  13441 
  13442   enumerateSArray(self->topA, e, i) {
  13443     if (not e) {
  13444       continue;
  13445     }
  13446     if (e->type == INT && ((sIntt*)e)->value == v) {
  13447       return((ssize_t)i);
  13448   }
  13449     }
  13450   return(-1);
  13451 }
  13452 
  13453 internal ssize_t indexOfSmallJsonSmallJson(smallJsont *self, smallJsont *value) {
  13454 
  13455   // sanity checks
  13456   if (self->topIsA != TOP_IS_ARRAY) {
  13457     return(-1);
  13458   }
  13459 
  13460   if (!lenSmallJson(self) || !value) {
  13461     return(-1);
  13462   }
  13463 
  13464   if (checkObjectTypes && !isOSmallJson(value)) {
  13465     return(-1);
  13466   }
  13467 
  13468   baset *O = NULL;
  13469   ssize_t r = -1;
  13470   switch(value->topIsA){
  13471     case SMALLJSON_IS_EMPTY:
  13472       return(-1);
  13473     case TOP_IS_UNDEFINED:
  13474       O = getTopSmallJson(value);
  13475       r = indexOfUndefinedSmallJson(self, (undefinedt*)O);;
  13476       finishO(O);
  13477       break;
  13478     case TOP_IS_BOOL:
  13479       O = getTopSmallJson(value);
  13480       r = indexOfSmallBoolSmallJson(self, (smallBoolt*)O);;
  13481       finishO(O);
  13482       break;
  13483     case TOP_IS_DOUBLE:
  13484       O = getTopSmallJson(value);
  13485       r = indexOfSmallDoubleSmallJson(self, (smallDoublet*)O);;
  13486       finishO(O);
  13487       break;
  13488     case TOP_IS_INT:
  13489       O = getTopSmallJson(value);
  13490       r = indexOfSmallIntSmallJson(self, (smallIntt*)O);;
  13491       finishO(O);
  13492       break;
  13493     case TOP_IS_STRING:
  13494       O = getTopSmallJson(value);
  13495       r = indexOfSmallStringSmallJson(self, (smallStringt*)O);;
  13496       finishO(O);
  13497       break;
  13498     case TOP_IS_DICT:
  13499       O = getTopSmallJson(value);
  13500       r = indexOfDictSmallJson(self, (smallDictt*)O);;
  13501       finishO(O);
  13502       break;
  13503     case TOP_IS_ARRAY:
  13504       O = getTopSmallJson(value);
  13505       r = indexOfArraySmallJson(self, (smallArrayt*)O);;
  13506       finishO(O);
  13507       break;
  13508     default:
  13509       logC("Unsupported smallJson type!");
  13510   }
  13511   return(r);
  13512 }
  13513 
  13514 internal ssize_t indexOfSmallStringSmallJson(smallJsont *self, smallStringt *string) {
  13515 
  13516   // sanity checks
  13517   if (self->topIsA != TOP_IS_ARRAY && self->topIsA != TOP_IS_STRING) {
  13518     return(-1);
  13519   }
  13520 
  13521   if (!string) {
  13522     return(-1);
  13523   }
  13524 
  13525   if (checkObjectTypes && !isOSmallString(string)) {
  13526     return(-1);
  13527   }
  13528 
  13529   if (!string->data) {
  13530     return(-1);
  13531   }
  13532 
  13533   // search string in elements
  13534   char *s = sStringGetTiny(string->data);
  13535 
  13536   switch(self->topIsA) {
  13537     case TOP_IS_ARRAY:
  13538       if (!lenSmallJson(self)) {
  13539         return(-1);
  13540       }
  13541 
  13542       enumerateSArray(self->topA, e, i) {
  13543         if (not e) {
  13544           continue;
  13545         }
  13546         if (e->type == STRING && strEq(sStringGetTiny((sStringt*)e), s)) {
  13547           return((ssize_t)i);
  13548       }
  13549         }
  13550       break;
  13551     case TOP_IS_STRING:
  13552       return(indexOfS(sStringGetTiny((sStringt*)self->topS), s));
  13553     default:
  13554       // not reachable
  13555       logC("Check this function!");
  13556   }
  13557   return(-1);
  13558 }
  13559 
  13560 internal ssize_t indexOfSmallContainerSmallJson(smallJsont *self UNUSED, smallContainert *container UNUSED) {
  13561 
  13562   return(-1);
  13563 }
  13564 
  13565 internal ssize_t binarySearchSmallJson(smallJsont *self, baset *value) {
  13566   ssize_t first = 0, middle, last;;
  13567 
  13568   if (self->topIsA != TOP_IS_ARRAY) {
  13569     return(-1);
  13570   }
  13571 
  13572   if (!lenSmallJson(self) || !value) {
  13573     return(-1);
  13574   }
  13575 
  13576   char *s = toStringO(value);
  13577   char *m = NULL;
  13578 
  13579   ssize_t r = -1;
  13580   last   = (ssize_t)lenSmallJson(self) - 1;
  13581   while (first <= last) {
  13582     middle = (first+last)/2;
  13583     m      = sToString(sArrayGetTiny(self->topA, (uint32_t)middle));
  13584     if (!m) {
  13585       // there are null element in the array
  13586       // the array needs to be trimmed or compacted
  13587       goto finish;
  13588     }
  13589     if (strcmp(m, s) < 0) {
  13590       first = middle + 1;
  13591     }
  13592     else if (strcmp(m, s) == 0) {
  13593       r = middle;
  13594       free(m);
  13595       goto finish;
  13596     }
  13597     else {
  13598       last = middle -1;
  13599     }
  13600     free(m);
  13601   }
  13602   finish:
  13603   free(s);
  13604   return(r);
  13605 }
  13606 
  13607 internal ssize_t binarySearchUndefinedSmallJson(smallJsont *self UNUSED, undefinedt *u UNUSED) {
  13608   // ssize_t first = 0, middle, last
  13609 
  13610   // it doesn't make sense to search for undefined
  13611   // the array has to be sorted
  13612   // so undefined is always at postion 0
  13613   return(-1);
  13614 }
  13615 
  13616   /* if self->topIsA != TOP_IS_ARRAY */
  13617   /*   return -1 */
  13618   /*  */
  13619   /* if !lenSmallJson(self) || !undefined */
  13620   /*   return -1 */
  13621   /*  */
  13622   /* if checkObjectTypes && !isOUndefined(undefined) */
  13623   /*   return -1 */
  13624   /*  */
  13625   /* smallt *m = NULL */
  13626   /*  */
  13627   /* ssize_t r = -1 */
  13628   /* last   = lenSmallJson(self) - 1 */
  13629   /* while first <= last */
  13630   /*   middle = (first+last)/2 */
  13631   /*   m      = sArrayGetTiny(self->topA, middle) */
  13632   /*   if m->type < UNDEFINED */
  13633   /*     first = middle + 1 */
  13634   /*   else if m->type = UNDEFINED */
  13635   /*     r = middle */
  13636   /*     goto finish; */
  13637   /*   else */
  13638   /*     last = middle -1 */
  13639   /* finish: */
  13640   /* return r */
  13641 
  13642 internal ssize_t binarySearchBoolSmallJson(smallJsont *self, bool value) {
  13643   ssize_t first = 0, middle, last;;
  13644 
  13645   if (self->topIsA != TOP_IS_ARRAY) {
  13646     return(-1);
  13647   }
  13648 
  13649   if (!lenSmallJson(self)) {
  13650     return(-1);
  13651   }
  13652 
  13653   sBoolt *m = NULL;
  13654 
  13655   ssize_t r = -1;
  13656   last   = (ssize_t)lenSmallJson(self) - 1;
  13657   while (first <= last) {
  13658     middle = (first+last)/2;
  13659     m      = (sBoolt*)(sArrayGetTiny(self->topA, (uint32_t)middle));
  13660     if (!m) {
  13661       // there are null element in the array
  13662       // the array needs to be trimmed or compacted
  13663       goto finish;
  13664     }
  13665     if (m->type < BOOL || ((m->type == BOOL) && (m->value < value))) {
  13666       first = middle + 1;
  13667     }
  13668     else if ((m->type == BOOL) && (m->value == value)) {
  13669       r = middle;
  13670       goto finish;
  13671     }
  13672     else {
  13673       last = middle -1;
  13674   }
  13675     }
  13676   finish:
  13677   return(r);
  13678 }
  13679 
  13680 
  13681 internal ssize_t binarySearchDoubleSmallJson(smallJsont *self, double value) {
  13682   ssize_t first = 0, middle, last;;
  13683 
  13684   if (self->topIsA != TOP_IS_ARRAY) {
  13685     return(-1);
  13686   }
  13687 
  13688   if (!lenSmallJson(self)) {
  13689     return(-1);
  13690   }
  13691 
  13692   sDoublet *m = NULL;
  13693 
  13694   ssize_t r = -1;
  13695   last   = (ssize_t)lenSmallJson(self) - 1;
  13696   while (first <= last) {
  13697     middle = (first+last)/2;
  13698     m      = (sDoublet*)(sArrayGetTiny(self->topA, (uint32_t)middle));
  13699     if (!m) {
  13700       // there are null element in the array
  13701       // the array needs to be trimmed or compacted
  13702       goto finish;
  13703     }
  13704     if (m->type < DOUBLE || ((m->type == DOUBLE) && (m->value < value))) {
  13705       first = middle + 1;
  13706     }
  13707     else if ((m->type == DOUBLE) && (m->value == value)) {
  13708       r = middle;
  13709       goto finish;
  13710     }
  13711     else {
  13712       last = middle -1;
  13713   }
  13714     }
  13715   finish:
  13716   return(r);
  13717 }
  13718 
  13719 internal ssize_t binarySearchIntSmallJson(smallJsont *self, int64_t value) {
  13720   ssize_t first = 0, middle, last;;
  13721 
  13722   if (self->topIsA != TOP_IS_ARRAY) {
  13723     return(-1);
  13724   }
  13725 
  13726   if (!lenSmallJson(self)) {
  13727     return(-1);
  13728   }
  13729 
  13730   sIntt *m = NULL;
  13731 
  13732   ssize_t r = -1;
  13733   last   = (ssize_t)lenSmallJson(self) - 1;
  13734   while (first <= last) {
  13735     middle = (first+last)/2;
  13736     m      = (sIntt*)(sArrayGetTiny(self->topA, (uint32_t)middle));
  13737     if (!m) {
  13738       // there are null element in the array
  13739       // the array needs to be trimmed or compacted
  13740       goto finish;
  13741     }
  13742     if (m->type < INT || ((m->type == INT) && (m->value < value))) {
  13743       first = middle + 1;
  13744     }
  13745     else if ((m->type == INT) && (m->value == value)) {
  13746       r = middle;
  13747       goto finish;
  13748     }
  13749     else {
  13750       last = middle -1;
  13751   }
  13752     }
  13753   finish:
  13754   return(r);
  13755 }
  13756 
  13757 internal ssize_t binarySearchSSmallJson(smallJsont *self, const char *string) {
  13758   ssize_t first = 0, middle, last;;
  13759 
  13760   if (self->topIsA != TOP_IS_ARRAY) {
  13761     return(-1);
  13762   }
  13763 
  13764   if (!lenSmallJson(self) || !string) {
  13765     return(-1);
  13766   }
  13767 
  13768   smallt *e = NULL;
  13769 
  13770   last   = (ssize_t)lenSmallJson(self) - 1;
  13771   while (first <= last) {
  13772     middle  = (first+last)/2;
  13773     e       = sArrayGetTiny(self->topA, (uint32_t)middle);
  13774     if (!e) {
  13775       // there are null element in the array
  13776       // the array needs to be trimmed or compacted
  13777       return(-1);
  13778     }
  13779     char *m = sStringGetTiny((sStringt*)(e));
  13780     if (e->type < STRING || ((e->type == STRING) && (strcmp(m, string) < 0))) {
  13781       first = middle + 1;
  13782     }
  13783     else if ((e->type == STRING) && (strcmp(m, string) == 0)) {
  13784       return(middle);
  13785     }
  13786     else {
  13787       last = middle -1;
  13788   }
  13789     }
  13790   return(-1);
  13791 }
  13792 
  13793 internal ssize_t binarySearchCharSmallJson(smallJsont *self, char c) {
  13794 
  13795   charToS(s, c);
  13796   return(binarySearchSSmallJson(self, s));
  13797 }
  13798 
  13799 internal ssize_t binarySearchDictSmallJson(smallJsont *self, smallDictt *dict) {
  13800   ssize_t first = 0, middle, last;;
  13801 
  13802   if (self->topIsA != TOP_IS_ARRAY) {
  13803     return(-1);
  13804   }
  13805 
  13806   if (!lenSmallJson(self) || !dict) {
  13807     return(-1);
  13808   }
  13809 
  13810   if (checkObjectTypes && !isOSmallDict(dict)) {
  13811     return(-1);
  13812   }
  13813 
  13814   char *s   = toStringO(dict);
  13815   smallt *e = NULL;
  13816   char *m   = NULL;
  13817 
  13818   ssize_t r = -1;
  13819   last   = (ssize_t)lenSmallJson(self) - 1;
  13820   while (first <= last) {
  13821     middle = (first+last)/2;
  13822     e      = sArrayGetTiny(self->topA, (uint32_t)middle);
  13823     if (!e) {
  13824       // there are null element in the array
  13825       // the array needs to be trimmed or compacted
  13826       goto finish;
  13827     }
  13828     // cg_c bug, can't use comma operator, extra code
  13829     if (e->type == DICT) {
  13830       m = sToString(e);
  13831     }
  13832     // cg_c bug, can't use comma operator
  13833     /* if e->type < DICT || ((e->type = DICT) && strcmp((m=sToString(e),m), s) < 0) */
  13834     if (e->type < DICT || ((e->type == DICT) && strcmp(m, s) < 0)) {
  13835       first = middle + 1;
  13836     }
  13837     else if ((e->type == DICT) && strcmp(m, s) == 0) {
  13838       r = middle;
  13839       free(m);
  13840       goto finish;
  13841     }
  13842     else {
  13843       last = middle -1;
  13844     }
  13845     if (e->type == DICT) {
  13846       free(m);
  13847   }
  13848     }
  13849   finish:
  13850   free(s);
  13851   return(r);
  13852 }
  13853 
  13854 internal ssize_t binarySearchArraySmallJson(smallJsont *self, smallArrayt *array) {
  13855   ssize_t first = 0, middle, last;;
  13856 
  13857   if (self->topIsA != TOP_IS_ARRAY) {
  13858     return(-1);
  13859   }
  13860 
  13861   if (!lenSmallJson(self) || !array) {
  13862     return(-1);
  13863   }
  13864 
  13865   if (checkObjectTypes && !isOSmallArray(array)) {
  13866     return(-1);
  13867   }
  13868 
  13869   char *s   = toStringO(array);
  13870   smallt *e = NULL;
  13871   char *m   = NULL;
  13872 
  13873   ssize_t r = -1;
  13874   last   = (ssize_t)lenSmallJson(self) - 1;
  13875   while (first <= last) {
  13876     middle = (first+last)/2;
  13877     e      = sArrayGetTiny(self->topA, (uint32_t)middle);
  13878     if (!e) {
  13879       // there are null element in the array
  13880       // the array needs to be trimmed or compacted
  13881       goto finish;
  13882     }
  13883     // cg_c bug, can't use comma operator, extra code
  13884     if (e->type == ARRAY) {
  13885       m = sToString(e);
  13886     }
  13887     // cg_c bug, can't use comma operator
  13888     /* if e->type < ARRAY || ((e->type = ARRAY) && strcmp((m=sToString(e),m), s) < 0) */
  13889     if (e->type < ARRAY || ((e->type == ARRAY) && strcmp(m, s) < 0)) {
  13890       first = middle + 1;
  13891     }
  13892     else if ((e->type == ARRAY) && strcmp(m, s) == 0) {
  13893       r = middle;
  13894       free(m);
  13895       goto finish;
  13896     }
  13897     else {
  13898       last = middle -1;
  13899     }
  13900     if (e->type == ARRAY) {
  13901       free(m);
  13902   }
  13903     }
  13904   finish:
  13905   free(s);
  13906   return(r);
  13907 }
  13908 
  13909 internal ssize_t binarySearchArraycSmallJson(smallJsont *self, char **array) {
  13910   ssize_t first = 0, middle, last;;
  13911 
  13912   if (self->topIsA != TOP_IS_ARRAY) {
  13913     return(-1);
  13914   }
  13915 
  13916   if (!lenSmallJson(self) || !array) {
  13917     return(-1);
  13918   }
  13919 
  13920   char *s   = toStringListSGF(array);
  13921   smallt *e = NULL;
  13922   char *m   = NULL;
  13923 
  13924   ssize_t r = -1;
  13925   last   = (ssize_t)lenSmallJson(self) - 1;
  13926   while (first <= last) {
  13927     middle = (first+last)/2;
  13928     e      = sArrayGetTiny(self->topA, (uint32_t)middle);
  13929     if (!e) {
  13930       // there are null element in the array
  13931       // the array needs to be trimmed or compacted
  13932       goto finish;
  13933     }
  13934     // cg_c bug, can't use comma operator, extra code
  13935     if (e->type == ARRAY) {
  13936       m = sToString(e);
  13937     }
  13938     // cg_c bug, can't use comma operator
  13939     /* if e->type < ARRAY || ((e->type = ARRAY) && strcmp((m=sToString(e),m), s) < 0) */
  13940     if (e->type < ARRAY || ((e->type == ARRAY) && strcmp(m, s) < 0)) {
  13941       first = middle + 1;
  13942     }
  13943     else if ((e->type == ARRAY) && strcmp(m, s) == 0) {
  13944       r = middle;
  13945       free(m);
  13946       goto finish;
  13947     }
  13948     else {
  13949       last = middle -1;
  13950     }
  13951     if (e->type == ARRAY) {
  13952       free(m);
  13953   }
  13954     }
  13955   finish:
  13956   free(s);
  13957   return(r);
  13958 }
  13959 
  13960 internal ssize_t binarySearchCArraycSmallJson(smallJsont *self, const char **array) {
  13961   ssize_t first = 0, middle, last;;
  13962 
  13963   if (self->topIsA != TOP_IS_ARRAY) {
  13964     return(-1);
  13965   }
  13966 
  13967   if (!lenSmallJson(self) || !array) {
  13968     return(-1);
  13969   }
  13970 
  13971   char *s   = toStringListCSGF(array);
  13972   smallt *e = NULL;
  13973   char *m   = NULL;
  13974 
  13975   ssize_t r = -1;
  13976   last   = (ssize_t)lenSmallJson(self) - 1;
  13977   while (first <= last) {
  13978     middle = (first+last)/2;
  13979     e      = sArrayGetTiny(self->topA, (uint32_t)middle);
  13980     if (!e) {
  13981       // there are null element in the array
  13982       // the array needs to be trimmed or compacted
  13983       goto finish;
  13984     }
  13985     // cg_c bug, can't use comma operator, extra code
  13986     if (e->type == ARRAY) {
  13987       m = sToString(e);
  13988     }
  13989     // cg_c bug, can't use comma operator
  13990     /* if e->type < ARRAY || ((e->type = ARRAY) && strcmp((m=sToString(e),m), s) < 0) */
  13991     if (e->type < ARRAY || ((e->type == ARRAY) && strcmp(m, s) < 0)) {
  13992       first = middle + 1;
  13993     }
  13994     else if ((e->type == ARRAY) && strcmp(m, s) == 0) {
  13995       r = middle;
  13996       free(m);
  13997       goto finish;
  13998     }
  13999     else {
  14000       last = middle -1;
  14001     }
  14002     if (e->type == ARRAY) {
  14003       free(m);
  14004   }
  14005     }
  14006   finish:
  14007   free(s);
  14008   return(r);
  14009 }
  14010 
  14011 internal ssize_t binarySearchSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
  14012   ssize_t first = 0, middle, last;;
  14013 
  14014   if (self->topIsA != TOP_IS_ARRAY) {
  14015     return(-1);
  14016   }
  14017 
  14018   if (!lenSmallJson(self) || !value) {
  14019     return(-1);
  14020   }
  14021 
  14022   if (checkObjectTypes && !isOSmallBool(value)) {
  14023     return(-1);
  14024   }
  14025 
  14026   bool b    = value->f->get(value);
  14027   sBoolt *m = NULL;
  14028 
  14029   ssize_t r = -1;
  14030   last   = (ssize_t)lenSmallJson(self) - 1;
  14031   while (first <= last) {
  14032     middle = (first+last)/2;
  14033     m      = (sBoolt*)(sArrayGetTiny(self->topA, (uint32_t)middle));
  14034     if (!m) {
  14035       // there are null element in the array
  14036       // the array needs to be trimmed or compacted
  14037       goto finish;
  14038     }
  14039     if (m->type < BOOL || ((m->type == BOOL) && (m->value < b))) {
  14040       first = middle + 1;
  14041     }
  14042     else if ((m->type == BOOL) && (m->value == b)) {
  14043       r = middle;
  14044       goto finish;
  14045     }
  14046     else {
  14047       last = middle -1;
  14048   }
  14049     }
  14050   finish:
  14051   return(r);
  14052 }
  14053 
  14054 internal ssize_t binarySearchSmallBytesSmallJson(smallJsont *self, smallBytest *value) {
  14055   ssize_t first = 0, middle, last;;
  14056 
  14057   if (self->topIsA != TOP_IS_ARRAY) {
  14058     return(-1);
  14059   }
  14060 
  14061   if (!lenSmallJson(self) || !value || !value->B) {
  14062     return(-1);
  14063   }
  14064 
  14065   if (checkObjectTypes && !isOSmallBytes(value)) {
  14066     return(-1);
  14067   }
  14068 
  14069   void *b        = sBytesGet(value->B);
  14070   uint32_t count = value->B->count;
  14071   sBytest *m     = NULL;
  14072 
  14073   ssize_t r = -1;
  14074   last   = (ssize_t)lenSmallJson(self) - 1;
  14075   while (first <= last) {
  14076     middle = (first+last)/2;
  14077     m      = (sBytest*)(sArrayGetTiny(self->topA, (uint32_t)middle));
  14078     if (!m) {
  14079       // there are null element in the array
  14080       // the array needs to be trimmed or compacted
  14081       goto finish;
  14082     }
  14083     if (m->type < BYTES || ((m->type == BYTES) && ((m->count < count) || (memcmp(&m->data, b, count) < 0)))) {
  14084       first = middle + 1;
  14085     }
  14086     else if ((m->type == BYTES) && (m->count == count) && !memcmp(&m->data, b, count)) {
  14087       r = middle;
  14088       goto finish;
  14089     }
  14090     else {
  14091       last = middle -1;
  14092   }
  14093     }
  14094   finish:
  14095   return(r);
  14096 }
  14097 
  14098 internal ssize_t binarySearchSmallDoubleSmallJson(smallJsont *self, smallDoublet *value) {
  14099   ssize_t first = 0, middle, last;;
  14100 
  14101   if (self->topIsA != TOP_IS_ARRAY) {
  14102     return(-1);
  14103   }
  14104 
  14105   if (!lenSmallJson(self) || !value) {
  14106     return(-1);
  14107   }
  14108 
  14109   if (checkObjectTypes && !isOSmallDouble(value)) {
  14110     return(-1);
  14111   }
  14112 
  14113   double v    = value->f->get(value);
  14114   sDoublet *m = NULL;
  14115 
  14116   ssize_t r = -1;
  14117   last   = (ssize_t)lenSmallJson(self) - 1;
  14118   while (first <= last) {
  14119     middle = (first+last)/2;
  14120     m      = (sDoublet*)(sArrayGetTiny(self->topA, (uint32_t)middle));
  14121     if (!m) {
  14122       // there are null element in the array
  14123       // the array needs to be trimmed or compacted
  14124       goto finish;
  14125     }
  14126     if (m->type < DOUBLE || ((m->type == DOUBLE) && (m->value < v))) {
  14127       first = middle + 1;
  14128     }
  14129     else if ((m->type == DOUBLE) && (m->value == v)) {
  14130       r = middle;
  14131       goto finish;
  14132     }
  14133     else {
  14134       last = middle -1;
  14135   }
  14136     }
  14137   finish:
  14138   return(r);
  14139 }
  14140 
  14141 internal ssize_t binarySearchSmallIntSmallJson(smallJsont *self, smallIntt *value) {
  14142   ssize_t first = 0, middle, last;;
  14143 
  14144   if (self->topIsA != TOP_IS_ARRAY) {
  14145     return(-1);
  14146   }
  14147 
  14148   if (!lenSmallJson(self) || !value) {
  14149     return(-1);
  14150   }
  14151 
  14152   if (checkObjectTypes && !isOSmallInt(value)) {
  14153     return(-1);
  14154   }
  14155 
  14156   int64_t v   = value->f->get(value);
  14157   sIntt *m = NULL;
  14158 
  14159   ssize_t r = -1;
  14160   last   = (ssize_t)lenSmallJson(self) - 1;
  14161   while (first <= last) {
  14162     middle = (first+last)/2;
  14163     m      = (sIntt*)(sArrayGetTiny(self->topA, (uint32_t)middle));
  14164     if (!m) {
  14165       // there are null element in the array
  14166       // the array needs to be trimmed or compacted
  14167       goto finish;
  14168     }
  14169     if (m->type < INT || ((m->type == INT) && (m->value < v))) {
  14170       first = middle + 1;
  14171     }
  14172     else if ((m->type == INT) && (m->value == v)) {
  14173       r = middle;
  14174       goto finish;
  14175     }
  14176     else {
  14177       last = middle -1;
  14178   }
  14179     }
  14180   finish:
  14181   return(r);
  14182 }
  14183 
  14184 internal ssize_t binarySearchSmallJsonSmallJson(smallJsont *self, smallJsont *value) {
  14185 
  14186   if (self->topIsA != TOP_IS_ARRAY) {
  14187     return(-1);
  14188   }
  14189 
  14190   if (!lenSmallJson(self) || !value) {
  14191     return(-1);
  14192   }
  14193 
  14194   if (checkObjectTypes && !isOSmallJson(value)) {
  14195     return(-1);
  14196   }
  14197 
  14198   baset *O = NULL;
  14199   ssize_t r = -1;
  14200   switch(value->topIsA){
  14201     case SMALLJSON_IS_EMPTY:
  14202       return(-1);
  14203     case TOP_IS_UNDEFINED:
  14204       // it doesn't make sense to search for undefined
  14205       // the array has to be sorted
  14206       // so undefined is always at postion 0
  14207       return(-1);
  14208     case TOP_IS_BOOL:
  14209       O = getTopSmallJson(value);
  14210       r = binarySearchSmallBoolSmallJson(self, (smallBoolt*)O);;
  14211       finishO(O);
  14212       break;
  14213     case TOP_IS_DOUBLE:
  14214       O = getTopSmallJson(value);
  14215       r = binarySearchSmallDoubleSmallJson(self, (smallDoublet*)O);;
  14216       finishO(O);
  14217       break;
  14218     case TOP_IS_INT:
  14219       O = getTopSmallJson(value);
  14220       r = binarySearchSmallIntSmallJson(self, (smallIntt*)O);;
  14221       finishO(O);
  14222       break;
  14223     case TOP_IS_STRING:
  14224       O = getTopSmallJson(value);
  14225       r = binarySearchSmallStringSmallJson(self, (smallStringt*)O);;
  14226       finishO(O);
  14227       break;
  14228     case TOP_IS_DICT:
  14229       O = getTopSmallJson(value);
  14230       r = binarySearchDictSmallJson(self, (smallDictt*)O);;
  14231       finishO(O);
  14232       break;
  14233     case TOP_IS_ARRAY:
  14234       O = getTopSmallJson(value);
  14235       r = binarySearchArraySmallJson(self, (smallArrayt*)O);;
  14236       finishO(O);
  14237       break;
  14238     default:
  14239       logC("Unsupported object type!");
  14240   }
  14241   return(r);
  14242 }
  14243 
  14244 internal ssize_t binarySearchSmallStringSmallJson(smallJsont *self, smallStringt *string) {
  14245   ssize_t first = 0, middle, last;;
  14246 
  14247   if (self->topIsA != TOP_IS_ARRAY) {
  14248     return(-1);
  14249   }
  14250 
  14251   if (!lenSmallJson(self) || !string) {
  14252     return(-1);
  14253   }
  14254 
  14255   if (checkObjectTypes && !isOSmallString(string)) {
  14256     return(-1);
  14257   }
  14258 
  14259   if (!string->data) {
  14260     return(-1);
  14261   }
  14262 
  14263   char *s   = sStringGetTiny(string->data);
  14264   smallt *e = NULL;
  14265 
  14266   last   = (ssize_t)lenSmallJson(self) - 1;
  14267   while (first <= last) {
  14268     middle  = (first+last)/2;
  14269     e       = sArrayGetTiny(self->topA, (uint32_t)middle);
  14270     if (!e) {
  14271       // there are null element in the array
  14272       // the array needs to be trimmed or compacted
  14273       return(-1);
  14274     }
  14275     char *m = sStringGetTiny((sStringt*)(e));
  14276     if (e->type < STRING || ((e->type == STRING) && (strcmp(m, s) < 0))) {
  14277       first = middle + 1;
  14278     }
  14279     else if ((e->type == STRING) && (strcmp(m, s) == 0)) {
  14280       return(middle);
  14281     }
  14282     else {
  14283       last = middle -1;
  14284   }
  14285     }
  14286   return(-1);
  14287 }
  14288 
  14289 internal ssize_t binarySearchSmallContainerSmallJson(smallJsont *self UNUSED, smallContainert *container UNUSED) {
  14290 
  14291   return(-1);
  14292 }
  14293 
  14294 
  14295 
  14296 
  14297 
  14298 internal bool icHasSmallJson(smallJsont *self, baset *value) {
  14299 
  14300   if (!value) {
  14301     return(false);
  14302   }
  14303 
  14304   if (icIndexOfSmallJson(self, value) == -1) {
  14305     return(false);
  14306   }
  14307 
  14308   return(true);
  14309 }
  14310 
  14311 internal bool icHasSSmallJson(smallJsont *self, const char *string) {
  14312 
  14313   if (!string) {
  14314     return(false);
  14315   }
  14316 
  14317   if (self->topIsA == TOP_IS_DICT) {
  14318     if (!self->top) {
  14319       return(false);
  14320     }
  14321     smallt *o = sDictGetTiny(self->top, string);;
  14322     if (!o) {
  14323       return(false);
  14324   }
  14325     }
  14326   else if (icIndexOfSSmallJson(self, string) == -1) {
  14327     return(false);
  14328   }
  14329 
  14330   return(true);
  14331 }
  14332 
  14333 internal bool icHasCharSmallJson(smallJsont *self, char c) {
  14334 
  14335   charToS(s, c);
  14336   return(icHasSSmallJson(self, s));
  14337 }
  14338 
  14339 internal bool icHasDictSmallJson(smallJsont *self, smallDictt *dict) {
  14340 
  14341   if (!dict) {
  14342     return(false);
  14343   }
  14344 
  14345   if (icIndexOfDictSmallJson(self, dict) == -1) {
  14346     return(false);
  14347   }
  14348 
  14349   return(true);
  14350 }
  14351 
  14352 internal bool icHasArraySmallJson(smallJsont *self, smallArrayt *array) {
  14353 
  14354   if (!array) {
  14355     return(false);
  14356   }
  14357 
  14358   if (icIndexOfArraySmallJson(self, array) == -1) {
  14359     return(false);
  14360   }
  14361 
  14362   return(true);
  14363 }
  14364 
  14365 internal bool icHasArraycSmallJson(smallJsont *self, char **array) {
  14366 
  14367   if (!array) {
  14368     return(false);
  14369   }
  14370 
  14371   if (icIndexOfArraycSmallJson(self, array) == -1) {
  14372     return(false);
  14373   }
  14374 
  14375   return(true);
  14376 }
  14377 
  14378 internal bool icHasCArraycSmallJson(smallJsont *self, const char **array) {
  14379 
  14380   if (!array) {
  14381     return(false);
  14382   }
  14383 
  14384   if (icIndexOfCArraycSmallJson(self, array) == -1) {
  14385     return(false);
  14386   }
  14387 
  14388   return(true);
  14389 }
  14390 
  14391 internal bool icHasSmallStringSmallJson(smallJsont *self, smallStringt *string) {
  14392 
  14393   if (!string) {
  14394     return(false);
  14395   }
  14396 
  14397   if (icIndexOfSmallStringSmallJson(self, string) == -1) {
  14398     return(false);
  14399   }
  14400 
  14401   return(true);
  14402 }
  14403 
  14404 internal smallJsont* icFindSmallJson(smallJsont *self, const char *needle) {
  14405 
  14406   // sanity checks
  14407   if (self->topIsA != TOP_IS_STRING || !self->topS || !needle || !lenSmallJson(self)) {
  14408     return(NULL);
  14409   }
  14410 
  14411   char *s = strcasestr(sStringGetTiny(self->topS), needle);
  14412   if (!s) {
  14413     return(NULL);
  14414   }
  14415   createAllocateSmallJson(r);
  14416   if (!r) {
  14417     return(NULL);
  14418   }
  14419   r->f->setTopString(r, s);
  14420   return(r);
  14421 }
  14422 
  14423 internal smallJsont* icFindCharSmallJson(smallJsont *self, char c) {
  14424 
  14425   if (c == 0) {
  14426     // include terminating '\0' in comparison
  14427     // like findCharS
  14428     // sanity checks
  14429     if (self->topIsA != TOP_IS_STRING || !self->topS || !lenSmallJson(self)) {
  14430       return(NULL);
  14431     }
  14432     char *s = strchr(sStringGetTiny(self->topS), c);
  14433     if (!s) {
  14434       // this should not happen because strings end with 0
  14435       // if there is no 0 at the end of the string, strchr will stop when it finds a 0 or crash the program
  14436       // anyway, it is wrong
  14437       return(NULL);
  14438     }
  14439     createAllocateSmallJson(r);
  14440     if (!r) {
  14441       return(NULL);
  14442     }
  14443     r->f->setTopString(r, s);
  14444     return(r);
  14445   }
  14446   charToS(s, c);
  14447   return(icFindSmallJson(self, s));
  14448 }
  14449 
  14450 internal smallJsont* icFindSmallStringSmallJson(smallJsont *self, smallStringt *needle) {
  14451 
  14452   if (!needle) {
  14453     return(NULL);
  14454   }
  14455   if (checkObjectTypes && !isOSmallString(needle)) {
  14456     return(NULL);
  14457   }
  14458 
  14459   return(icFindSmallJson(self, ssGet(needle)));
  14460 }
  14461 
  14462 internal smallJsont* icFindJsonSmallJson(smallJsont *self, smallJsont *needle) {
  14463 
  14464   if (!needle) {
  14465     return(NULL);
  14466   }
  14467   if (checkObjectTypes && !isOSmallJson(needle)) {
  14468     return(NULL);
  14469   }
  14470 
  14471   return(icFindSmallJson(self, sjGet(needle)));
  14472 }
  14473 
  14474 internal ssize_t icIndexOfSmallJson(smallJsont *self, baset *value) {
  14475 
  14476   // sanity checks
  14477   if (self->topIsA != TOP_IS_ARRAY) {
  14478     return(-1);
  14479   }
  14480 
  14481   if (!lenSmallJson(self) || !value) {
  14482     return(-1);
  14483   }
  14484 
  14485   // search string in elements
  14486   char *s = toStringO(value);
  14487   char *es = NULL;
  14488 
  14489   enumerateSArray(self->topA, e, i) {
  14490     if (not e) {
  14491       continue;
  14492     }
  14493     es = sToString(e);
  14494     if (icEqS(es, s)) {
  14495       free(es);
  14496       free(s);
  14497       return((ssize_t)i);
  14498     }
  14499     free(es);
  14500   }
  14501   free(s);
  14502   return(-1);
  14503 }
  14504 
  14505 internal ssize_t icIndexOfSSmallJson(smallJsont *self, const char *string) {
  14506 
  14507   // sanity checks
  14508   if (self->topIsA != TOP_IS_ARRAY && self->topIsA != TOP_IS_STRING) {
  14509     return(-1);
  14510   }
  14511 
  14512   if (!string) {
  14513     return(-1);
  14514   }
  14515 
  14516   switch(self->topIsA) {
  14517     case TOP_IS_ARRAY:
  14518       if (!lenSmallJson(self)) {
  14519         return(-1);
  14520       }
  14521       // search string in elements
  14522       enumerateSArray(self->topA, e, i) {
  14523         if (not e) {
  14524           continue;
  14525         }
  14526         if (e->type == STRING && icEqS(sStringGetTiny((sStringt*)e), string)) {
  14527           return((ssize_t)i);
  14528       }
  14529         }
  14530       break;
  14531     case TOP_IS_STRING:
  14532       return((ssize_t)icIndexOfS(sStringGetTiny((sStringt*)self->topS), string));
  14533     default:;
  14534       // not reachable
  14535       logC("Check this function!");
  14536   }
  14537   return(-1);
  14538 }
  14539 
  14540 internal ssize_t icIndexOfCharSmallJson(smallJsont *self, char c) {
  14541 
  14542   charToS(s, c);
  14543   return((ssize_t)icIndexOfSSmallJson(self, s));
  14544 }
  14545 
  14546 internal ssize_t icIndexOfDictSmallJson(smallJsont *self, smallDictt *dict) {
  14547 
  14548   // sanity checks
  14549   if (self->topIsA != TOP_IS_ARRAY) {
  14550     return(-1);
  14551   }
  14552 
  14553   if (!lenSmallJson(self) || !dict) {
  14554     return(-1);
  14555   }
  14556 
  14557   if (checkObjectTypes && !isOSmallDict(dict)) {
  14558     return(-1);
  14559   }
  14560 
  14561   // search object in elements
  14562   char *s = toStringO(dict);
  14563   char *es = NULL;;
  14564 
  14565   enumerateSArray(self->topA, e, i) {
  14566     if (not e) {
  14567       continue;
  14568     }
  14569     if (e->type == DICT) {
  14570       es = sToString(e);
  14571       if (icEqS(es, s)) {
  14572         free(es);
  14573         free(s);
  14574         return((ssize_t)i);
  14575       }
  14576       free(es);
  14577   }
  14578     }
  14579   free(s);
  14580   return(-1);
  14581 }
  14582 
  14583 internal ssize_t icIndexOfArraySmallJson(smallJsont *self, smallArrayt *array) {
  14584 
  14585   // sanity checks
  14586   if (self->topIsA != TOP_IS_ARRAY) {
  14587     return(-1);
  14588   }
  14589 
  14590   if (!lenSmallJson(self) || !array) {
  14591     return(-1);
  14592   }
  14593 
  14594   if (checkObjectTypes && !isOSmallArray(array)) {
  14595     return(-1);
  14596   }
  14597 
  14598   // search object in elements
  14599   char *s = toStringO(array);
  14600   char *es = NULL;;
  14601 
  14602   enumerateSArray(self->topA, e, i) {
  14603     if (not e) {
  14604       continue;
  14605     }
  14606     if (e->type == ARRAY) {
  14607       es = sToString(e);
  14608       if (icEqS(es, s)) {
  14609         free(es);
  14610         free(s);
  14611         return((ssize_t)i);
  14612       }
  14613       free(es);
  14614   }
  14615     }
  14616   free(s);
  14617   return(-1);
  14618 }
  14619 
  14620 internal ssize_t icIndexOfArraycSmallJson(smallJsont *self, char **array) {
  14621 
  14622   // sanity checks
  14623   if (self->topIsA != TOP_IS_ARRAY) {
  14624     return(-1);
  14625   }
  14626 
  14627   if (!lenSmallJson(self) || !array) {
  14628     return(-1);
  14629   }
  14630 
  14631   // search object in elements
  14632   char *s = toStringListSGF(array);
  14633   char *es = NULL;;
  14634 
  14635   enumerateSArray(self->topA, e, i) {
  14636     if (not e) {
  14637       continue;
  14638     }
  14639     if (e->type == ARRAY) {
  14640       es = sToString(e);
  14641       if (icEqS(es, s)) {
  14642         free(es);
  14643         free(s);
  14644         return((ssize_t)i);
  14645       }
  14646       free(es);
  14647   }
  14648     }
  14649   free(s);
  14650   return(-1);
  14651 }
  14652 
  14653 internal ssize_t icIndexOfCArraycSmallJson(smallJsont *self, const char **array) {
  14654 
  14655   // sanity checks
  14656   if (self->topIsA != TOP_IS_ARRAY) {
  14657     return(-1);
  14658   }
  14659 
  14660   if (!lenSmallJson(self) || !array) {
  14661     return(-1);
  14662   }
  14663 
  14664   // search object in elements
  14665   char *s = toStringListCSGF(array);
  14666   char *es = NULL;;
  14667 
  14668   enumerateSArray(self->topA, e, i) {
  14669     if (not e) {
  14670       continue;
  14671     }
  14672     if (e->type == ARRAY) {
  14673       es = sToString(e);
  14674       if (icEqS(es, s)) {
  14675         free(es);
  14676         free(s);
  14677         return((ssize_t)i);
  14678       }
  14679       free(es);
  14680   }
  14681     }
  14682   free(s);
  14683   return(-1);
  14684 }
  14685 
  14686 internal ssize_t icIndexOfSmallStringSmallJson(smallJsont *self, smallStringt *string) {
  14687 
  14688   // sanity checks
  14689   if (self->topIsA != TOP_IS_ARRAY && self->topIsA != TOP_IS_STRING) {
  14690     return(-1);
  14691   }
  14692 
  14693   if (!string) {
  14694     return(-1);
  14695   }
  14696 
  14697   if (checkObjectTypes && !isOSmallString(string)) {
  14698     return(-1);
  14699   }
  14700 
  14701   if (!string->data) {
  14702     return(-1);
  14703   }
  14704 
  14705   // search string in elements
  14706   char *s = sStringGetTiny(string->data);
  14707 
  14708   switch(self->topIsA) {
  14709     case TOP_IS_ARRAY:
  14710       if (!lenSmallJson(self)) {
  14711         return(-1);
  14712       }
  14713 
  14714       enumerateSArray(self->topA, e, i) {
  14715         if (not e) {
  14716           continue;
  14717         }
  14718         if (e->type == STRING && icEqS(sStringGetTiny((sStringt*)e), s)) {
  14719           return((ssize_t)i);
  14720       }
  14721         }
  14722       break;
  14723     case TOP_IS_STRING:
  14724       return(icIndexOfS(sStringGetTiny((sStringt*)self->topS), s));
  14725     default:
  14726       // not reachable
  14727       logC("Check this function!");
  14728   }
  14729   return(-1);
  14730 }
  14731 
  14732 internal ssize_t icBinarySearchSmallJson(smallJsont *self, baset *value) {
  14733   ssize_t first = 0, middle, last;;
  14734 
  14735   if (self->topIsA != TOP_IS_ARRAY) {
  14736     return(-1);
  14737   }
  14738 
  14739   if (!lenSmallJson(self) || !value) {
  14740     return(-1);
  14741   }
  14742 
  14743   char *s = toStringO(value);
  14744   char *m = NULL;
  14745 
  14746   ssize_t r = -1;
  14747   last   = (ssize_t)lenSmallJson(self) - 1;
  14748   while (first <= last) {
  14749     middle = (first+last)/2;
  14750     m      = sToString(sArrayGetTiny(self->topA, (uint32_t)middle));
  14751     if (!m) {
  14752       // there are null element in the array
  14753       // the array needs to be trimmed or compacted
  14754       goto finish;
  14755     }
  14756     if (strcasecmp(m, s) < 0) {
  14757       first = middle + 1;
  14758     }
  14759     else if (strcasecmp(m, s) == 0) {
  14760       r = middle;
  14761       free(m);
  14762       goto finish;
  14763     }
  14764     else {
  14765       last = middle -1;
  14766     }
  14767     free(m);
  14768   }
  14769   finish:
  14770   free(s);
  14771   return(r);
  14772 }
  14773 
  14774 internal ssize_t icBinarySearchSSmallJson(smallJsont *self, const char *string) {
  14775   ssize_t first = 0, middle, last;;
  14776 
  14777   if (self->topIsA != TOP_IS_ARRAY) {
  14778     return(-1);
  14779   }
  14780 
  14781   if (!lenSmallJson(self) || !string) {
  14782     return(-1);
  14783   }
  14784 
  14785   smallt *e = NULL;
  14786 
  14787   last   = (ssize_t)lenSmallJson(self) - 1;
  14788   while (first <= last) {
  14789     middle  = (first+last)/2;
  14790     e       = sArrayGetTiny(self->topA, (uint32_t)middle);
  14791     if (!e) {
  14792       // there are null element in the array
  14793       // the array needs to be trimmed or compacted
  14794       return(-1);
  14795     }
  14796     char *m = sStringGetTiny((sStringt*)(e));
  14797     if (e->type < STRING || ((e->type == STRING) && (strcasecmp(m, string) < 0))) {
  14798       first = middle + 1;
  14799     }
  14800     else if ((e->type == STRING) && (strcasecmp(m, string) == 0)) {
  14801       return(middle);
  14802     }
  14803     else {
  14804       last = middle -1;
  14805   }
  14806     }
  14807   return(-1);
  14808 }
  14809 
  14810 internal ssize_t icBinarySearchCharSmallJson(smallJsont *self, char c) {
  14811 
  14812   charToS(s, c);
  14813   return(icBinarySearchSSmallJson(self, s));
  14814 }
  14815 
  14816 internal ssize_t icBinarySearchDictSmallJson(smallJsont *self, smallDictt *dict) {
  14817   ssize_t first = 0, middle, last;;
  14818 
  14819   if (self->topIsA != TOP_IS_ARRAY) {
  14820     return(-1);
  14821   }
  14822 
  14823   if (!lenSmallJson(self) || !dict) {
  14824     return(-1);
  14825   }
  14826 
  14827   if (checkObjectTypes && !isOSmallDict(dict)) {
  14828     return(-1);
  14829   }
  14830 
  14831   char *s   = toStringO(dict);
  14832   smallt *e = NULL;
  14833   char *m   = NULL;
  14834 
  14835   ssize_t r = -1;
  14836   last   = (ssize_t)lenSmallJson(self) - 1;
  14837   while (first <= last) {
  14838     middle = (first+last)/2;
  14839     e      = sArrayGetTiny(self->topA, (uint32_t)middle);
  14840     if (!e) {
  14841       // there are null element in the array
  14842       // the array needs to be trimmed or compacted
  14843       goto finish;
  14844     }
  14845     // cg_c bug, can't use comma operator, extra code
  14846     if (e->type == DICT) {
  14847       m = sToString(e);
  14848     }
  14849     // cg_c bug, can't use comma operator
  14850     /* if e->type < DICT || ((e->type = DICT) && strcmp((m=sToString(e),m), s) < 0) */
  14851     if (e->type < DICT || ((e->type == DICT) && strcasecmp(m, s) < 0)) {
  14852       first = middle + 1;
  14853     }
  14854     else if ((e->type == DICT) && strcasecmp(m, s) == 0) {
  14855       r = middle;
  14856       free(m);
  14857       goto finish;
  14858     }
  14859     else {
  14860       last = middle -1;
  14861     }
  14862     if (e->type == DICT) {
  14863       free(m);
  14864   }
  14865     }
  14866   finish:
  14867   free(s);
  14868   return(r);
  14869 }
  14870 
  14871 internal ssize_t icBinarySearchArraySmallJson(smallJsont *self, smallArrayt *array) {
  14872   ssize_t first = 0, middle, last;;
  14873 
  14874   if (self->topIsA != TOP_IS_ARRAY) {
  14875     return(-1);
  14876   }
  14877 
  14878   if (!lenSmallJson(self) || !array) {
  14879     return(-1);
  14880   }
  14881 
  14882   if (checkObjectTypes && !isOSmallArray(array)) {
  14883     return(-1);
  14884   }
  14885 
  14886   char *s   = toStringO(array);
  14887   smallt *e = NULL;
  14888   char *m   = NULL;
  14889 
  14890   ssize_t r = -1;
  14891   last   = (ssize_t)lenSmallJson(self) - 1;
  14892   while (first <= last) {
  14893     middle = (first+last)/2;
  14894     e      = sArrayGetTiny(self->topA, (uint32_t)middle);
  14895     if (!e) {
  14896       // there are null element in the array
  14897       // the array needs to be trimmed or compacted
  14898       goto finish;
  14899     }
  14900     // cg_c bug, can't use comma operator, extra code
  14901     if (e->type == ARRAY) {
  14902       m = sToString(e);
  14903     }
  14904     // cg_c bug, can't use comma operator
  14905     /* if e->type < ARRAY || ((e->type = ARRAY) && strcmp((m=sToString(e),m), s) < 0) */
  14906     if (e->type < ARRAY || ((e->type == ARRAY) && strcasecmp(m, s) < 0)) {
  14907       first = middle + 1;
  14908     }
  14909     else if ((e->type == ARRAY) && strcasecmp(m, s) == 0) {
  14910       r = middle;
  14911       free(m);
  14912       goto finish;
  14913     }
  14914     else {
  14915       last = middle -1;
  14916     }
  14917     if (e->type == ARRAY) {
  14918       free(m);
  14919   }
  14920     }
  14921   finish:
  14922   free(s);
  14923   return(r);
  14924 }
  14925 
  14926 internal ssize_t icBinarySearchArraycSmallJson(smallJsont *self, char **array) {
  14927   ssize_t first = 0, middle, last;;
  14928 
  14929   if (self->topIsA != TOP_IS_ARRAY) {
  14930     return(-1);
  14931   }
  14932 
  14933   if (!lenSmallJson(self) || !array) {
  14934     return(-1);
  14935   }
  14936 
  14937   char *s   = toStringListSGF(array);
  14938   smallt *e = NULL;
  14939   char *m   = NULL;
  14940 
  14941   ssize_t r = -1;
  14942   last   = (ssize_t)lenSmallJson(self) - 1;
  14943   while (first <= last) {
  14944     middle = (first+last)/2;
  14945     e      = sArrayGetTiny(self->topA, (uint32_t)middle);
  14946     if (!e) {
  14947       // there are null element in the array
  14948       // the array needs to be trimmed or compacted
  14949       goto finish;
  14950     }
  14951     // cg_c bug, can't use comma operator, extra code
  14952     if (e->type == ARRAY) {
  14953       m = sToString(e);
  14954     }
  14955     // cg_c bug, can't use comma operator
  14956     /* if e->type < ARRAY || ((e->type = ARRAY) && strcmp((m=sToString(e),m), s) < 0) */
  14957     if (e->type < ARRAY || ((e->type == ARRAY) && strcasecmp(m, s) < 0)) {
  14958       first = middle + 1;
  14959     }
  14960     else if ((e->type == ARRAY) && strcasecmp(m, s) == 0) {
  14961       r = middle;
  14962       free(m);
  14963       goto finish;
  14964     }
  14965     else {
  14966       last = middle -1;
  14967     }
  14968     if (e->type == ARRAY) {
  14969       free(m);
  14970   }
  14971     }
  14972   finish:
  14973   free(s);
  14974   return(r);
  14975 }
  14976 
  14977 internal ssize_t icBinarySearchCArraycSmallJson(smallJsont *self, const char **array) {
  14978   ssize_t first = 0, middle, last;;
  14979 
  14980   if (self->topIsA != TOP_IS_ARRAY) {
  14981     return(-1);
  14982   }
  14983 
  14984   if (!lenSmallJson(self) || !array) {
  14985     return(-1);
  14986   }
  14987 
  14988   char *s   = toStringListCSGF(array);
  14989   smallt *e = NULL;
  14990   char *m   = NULL;
  14991 
  14992   ssize_t r = -1;
  14993   last   = (ssize_t)lenSmallJson(self) - 1;
  14994   while (first <= last) {
  14995     middle = (first+last)/2;
  14996     e      = sArrayGetTiny(self->topA, (uint32_t)middle);
  14997     if (!e) {
  14998       // there are null element in the array
  14999       // the array needs to be trimmed or compacted
  15000       goto finish;
  15001     }
  15002     // cg_c bug, can't use comma operator, extra code
  15003     if (e->type == ARRAY) {
  15004       m = sToString(e);
  15005     }
  15006     // cg_c bug, can't use comma operator
  15007     /* if e->type < ARRAY || ((e->type = ARRAY) && strcmp((m=sToString(e),m), s) < 0) */
  15008     if (e->type < ARRAY || ((e->type == ARRAY) && strcasecmp(m, s) < 0)) {
  15009       first = middle + 1;
  15010     }
  15011     else if ((e->type == ARRAY) && strcasecmp(m, s) == 0) {
  15012       r = middle;
  15013       free(m);
  15014       goto finish;
  15015     }
  15016     else {
  15017       last = middle -1;
  15018     }
  15019     if (e->type == ARRAY) {
  15020       free(m);
  15021   }
  15022     }
  15023   finish:
  15024   free(s);
  15025   return(r);
  15026 }
  15027 
  15028 internal ssize_t icBinarySearchSmallStringSmallJson(smallJsont *self, smallStringt *string) {
  15029   ssize_t first = 0, middle, last;;
  15030 
  15031   if (self->topIsA != TOP_IS_ARRAY) {
  15032     return(-1);
  15033   }
  15034 
  15035   if (!lenSmallJson(self) || !string) {
  15036     return(-1);
  15037   }
  15038 
  15039   if (checkObjectTypes && !isOSmallString(string)) {
  15040     return(-1);
  15041   }
  15042 
  15043   if (!string->data) {
  15044     return(-1);
  15045   }
  15046 
  15047   char *s   = sStringGetTiny(string->data);
  15048   smallt *e = NULL;
  15049 
  15050   last   = (ssize_t)lenSmallJson(self) - 1;
  15051   while (first <= last) {
  15052     middle  = (first+last)/2;
  15053     e       = sArrayGetTiny(self->topA, (uint32_t)middle);
  15054     if (!e) {
  15055       // there are null element in the array
  15056       // the array needs to be trimmed or compacted
  15057       return(-1);
  15058     }
  15059     char *m = sStringGetTiny((sStringt*)(e));
  15060     if (e->type < STRING || ((e->type == STRING) && (strcasecmp(m, s) < 0))) {
  15061       first = middle + 1;
  15062     }
  15063     else if ((e->type == STRING) && (strcasecmp(m, s) == 0)) {
  15064       return(middle);
  15065     }
  15066     else {
  15067       last = middle -1;
  15068   }
  15069     }
  15070   return(-1);
  15071 }
  15072 
  15073 internal char* keyBySmallJson(smallJsont *self, baset *value) {
  15074 
  15075   // sanity checks
  15076   if (self->topIsA != TOP_IS_DICT) {
  15077     return(NULL);
  15078   }
  15079 
  15080   if (!lenSmallJson(self) || !value) {
  15081     return(NULL);
  15082   }
  15083 
  15084   // search string in elements
  15085   char *s  = toStringO(value);
  15086   char *es = NULL;
  15087 
  15088   forEachSDict(self->top, e) {
  15089     if (e->key) {
  15090       es = sToString(e->data);
  15091       if (strEq(es, s)) {
  15092         free(es);
  15093         free(s);
  15094         return(e->key);
  15095       }
  15096       free(es);
  15097   }
  15098     }
  15099   free(s);
  15100   return(NULL);
  15101 }
  15102 
  15103 internal char* keyByUndefinedSmallJson(smallJsont *self, undefinedt *u) {
  15104 
  15105   // sanity checks
  15106   if (self->topIsA != TOP_IS_DICT) {
  15107     return(NULL);
  15108   }
  15109 
  15110   if (!lenSmallJson(self) || !u) {
  15111     return(NULL);
  15112   }
  15113 
  15114   if (checkObjectTypes && !isOUndefined(u)) {
  15115     return(NULL);
  15116   }
  15117 
  15118   // search string in elements
  15119   forEachSDict(self->top, e) {
  15120     if (e->key && e->data->type == UNDEFINED) {
  15121       return(e->key);
  15122   }
  15123     }
  15124   return(NULL);
  15125 }
  15126 
  15127 internal char* keyByBoolSmallJson(smallJsont *self, bool value) {
  15128 
  15129   // sanity checks
  15130   if (self->topIsA != TOP_IS_DICT) {
  15131     return(NULL);
  15132   }
  15133 
  15134   if (!lenSmallJson(self)) {
  15135     return(NULL);
  15136   }
  15137 
  15138   // search value in elements
  15139   forEachSDict(self->top, e) {
  15140     if (e->key && e->data->type == BOOL && ((sBoolt*)(e->data))->value == value) {
  15141       return(e->key);
  15142   }
  15143     }
  15144   return(NULL);
  15145 }
  15146 
  15147 internal char* keyByDoubleSmallJson(smallJsont *self, double value) {
  15148 
  15149   // sanity checks
  15150   if (self->topIsA != TOP_IS_DICT) {
  15151     return(NULL);
  15152   }
  15153 
  15154   if (!lenSmallJson(self)) {
  15155     return(NULL);
  15156   }
  15157 
  15158   // search value in elements
  15159   forEachSDict(self->top, e) {
  15160     if (e->key && e->data->type == DOUBLE && ((sDoublet*)(e->data))->value == value) {
  15161       return(e->key);
  15162   }
  15163     }
  15164   return(NULL);
  15165 }
  15166 
  15167 internal char* keyByIntSmallJson(smallJsont *self, int64_t value) {
  15168 
  15169   // sanity checks
  15170   if (self->topIsA != TOP_IS_DICT) {
  15171     return(NULL);
  15172   }
  15173 
  15174   if (!lenSmallJson(self)) {
  15175     return(NULL);
  15176   }
  15177 
  15178   // search value in elements
  15179   forEachSDict(self->top, e) {
  15180     if (e->key && e->data->type == INT && ((sIntt*)(e->data))->value == value) {
  15181       return(e->key);
  15182   }
  15183     }
  15184   return(NULL);
  15185 }
  15186 
  15187 internal char* keyBySSmallJson(smallJsont *self, const char *string) {
  15188 
  15189   // sanity checks
  15190   if (self->topIsA != TOP_IS_DICT) {
  15191     return(NULL);
  15192   }
  15193 
  15194   if (!lenSmallJson(self) || !string) {
  15195     return(NULL);
  15196   }
  15197   // search string in elements
  15198   forEachSDict(self->top, e) {
  15199     if (e->key && e->data->type == STRING && eqS(sStringGetTiny((sStringt*)(e->data)), string)) {
  15200       return(e->key);
  15201   }
  15202     }
  15203   return(NULL);
  15204 }
  15205 
  15206 internal char* keyByCharSmallJson(smallJsont *self, char c) {
  15207 
  15208   charToS(s, c);
  15209   return(keyBySSmallJson(self, s));
  15210 }
  15211 
  15212 internal char* keyByDictSmallJson(smallJsont *self, smallDictt *dict) {
  15213 
  15214   // sanity checks
  15215   if (self->topIsA != TOP_IS_DICT) {
  15216     return(NULL);
  15217   }
  15218 
  15219   if (!lenSmallJson(self) || !dict) {
  15220     return(NULL);
  15221   }
  15222 
  15223   if (checkObjectTypes && !isOSmallDict(dict)) {
  15224     return(NULL);
  15225   }
  15226 
  15227   // search object in elements
  15228   char *s = toStringO(dict);
  15229   char *es = NULL;;
  15230 
  15231   forEachSDict(self->top, e) {
  15232     if (e->key && e->data->type == DICT) {
  15233       es = sToString(e->data);
  15234       if (eqS(es, s)) {
  15235         free(es);
  15236         free(s);
  15237         return(e->key);
  15238       }
  15239       free(es);
  15240   }
  15241     }
  15242   free(s);
  15243   return(NULL);
  15244 }
  15245 
  15246 internal char* keyByArraySmallJson(smallJsont *self, smallArrayt *array) {
  15247 
  15248   // sanity checks
  15249   if (self->topIsA != TOP_IS_DICT) {
  15250     return(NULL);
  15251   }
  15252 
  15253   if (!lenSmallJson(self) || !array) {
  15254     return(NULL);
  15255   }
  15256 
  15257   if (checkObjectTypes && !isOSmallArray(array)) {
  15258     return(NULL);
  15259   }
  15260 
  15261   // search object in elements
  15262   char *s = toStringO(array);
  15263   char *es = NULL;;
  15264 
  15265   forEachSDict(self->top, e) {
  15266     if (e->key && e->data->type == ARRAY) {
  15267       es = sToString(e->data);
  15268       if (eqS(es, s)) {
  15269         free(es);
  15270         free(s);
  15271         return(e->key);
  15272       }
  15273       free(es);
  15274   }
  15275     }
  15276   free(s);
  15277   return(NULL);
  15278 }
  15279 
  15280 internal char* keyByArraycSmallJson(smallJsont *self, char **array) {
  15281 
  15282   // sanity checks
  15283   if (self->topIsA != TOP_IS_DICT) {
  15284     return(NULL);
  15285   }
  15286 
  15287   if (!lenSmallJson(self) || !array) {
  15288     return(NULL);
  15289   }
  15290 
  15291   // search object in elements
  15292   char *s = toStringListSGF(array);
  15293   char *es = NULL;;
  15294 
  15295   forEachSDict(self->top, e) {
  15296     if (e->key && e->data->type == ARRAY) {
  15297       es = sToString(e->data);
  15298       if (eqS(es, s)) {
  15299         free(es);
  15300         free(s);
  15301         return(e->key);
  15302       }
  15303       free(es);
  15304   }
  15305     }
  15306   free(s);
  15307   return(NULL);
  15308 }
  15309 
  15310 internal char* keyByCArraycSmallJson(smallJsont *self, const char **array) {
  15311 
  15312   // sanity checks
  15313   if (self->topIsA != TOP_IS_DICT) {
  15314     return(NULL);
  15315   }
  15316 
  15317   if (!lenSmallJson(self) || !array) {
  15318     return(NULL);
  15319   }
  15320 
  15321   // search object in elements
  15322   char *s = toStringListCSGF(array);
  15323   char *es = NULL;;
  15324 
  15325   forEachSDict(self->top, e) {
  15326     if (e->key && e->data->type == ARRAY) {
  15327       es = sToString(e->data);
  15328       if (eqS(es, s)) {
  15329         free(es);
  15330         free(s);
  15331         return(e->key);
  15332       }
  15333       free(es);
  15334   }
  15335     }
  15336   free(s);
  15337   return(NULL);
  15338 }
  15339 
  15340 internal char* keyBySmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
  15341 
  15342   // sanity checks
  15343   if (self->topIsA != TOP_IS_DICT) {
  15344     return(NULL);
  15345   }
  15346 
  15347   if (!lenSmallJson(self) || !value) {
  15348     return(NULL);
  15349   }
  15350 
  15351   if (checkObjectTypes && !isOSmallBool(value)) {
  15352     return(NULL);
  15353   }
  15354 
  15355   // search object in elements
  15356   bool b = value->f->get(value);
  15357 
  15358   forEachSDict(self->top, e) {
  15359     if (e->key && e->data->type == BOOL && ((sBoolt*)(e->data))->value == b) {
  15360       return(e->key);
  15361   }
  15362     }
  15363   return(NULL);
  15364 }
  15365 
  15366 internal char* keyBySmallBytesSmallJson(smallJsont *self, smallBytest *value) {
  15367 
  15368   // sanity checks
  15369   if (self->topIsA != TOP_IS_DICT) {
  15370     return(NULL);
  15371   }
  15372 
  15373   if (!lenSmallJson(self) || !value || !value->B) {
  15374     return(NULL);
  15375   }
  15376 
  15377   if (checkObjectTypes && !isOSmallBytes(value)) {
  15378     return(NULL);
  15379   }
  15380 
  15381   // search object in elements
  15382   void *b        = sBytesGet(value->B);
  15383   uint32_t count = value->B->count;
  15384 
  15385   forEachSDict(self->top, e) {
  15386     if (e->key && e->data->type == BYTES && ((sBytest*)e->data)->count == count && !memcmp(&(((sBytest*)e->data)->data), b, count)) {
  15387       return(e->key);
  15388   }
  15389     }
  15390   return(NULL);
  15391 }
  15392 
  15393 internal char* keyBySmallDoubleSmallJson(smallJsont *self, smallDoublet *value) {
  15394 
  15395   // sanity checks
  15396   if (self->topIsA != TOP_IS_DICT) {
  15397     return(NULL);
  15398   }
  15399 
  15400   if (!lenSmallJson(self) || !value) {
  15401     return(NULL);
  15402   }
  15403 
  15404   if (checkObjectTypes && !isOSmallDouble(value)) {
  15405     return(NULL);
  15406   }
  15407 
  15408   // search object in elements
  15409   double v = value->f->get(value);
  15410 
  15411   forEachSDict(self->top, e) {
  15412     if (e->key && e->data->type == DOUBLE && ((sDoublet*)(e->data))->value == v) {
  15413       return(e->key);
  15414   }
  15415     }
  15416   return(NULL);
  15417 }
  15418 
  15419 internal char* keyBySmallIntSmallJson(smallJsont *self, smallIntt *value) {
  15420 
  15421   // sanity checks
  15422   if (self->topIsA != TOP_IS_DICT) {
  15423     return(NULL);
  15424   }
  15425 
  15426   if (!lenSmallJson(self) || !value) {
  15427     return(NULL);
  15428   }
  15429 
  15430   if (checkObjectTypes && !isOSmallInt(value)) {
  15431     return(NULL);
  15432   }
  15433 
  15434   // search object in elements
  15435   int64_t v = value->f->get(value);
  15436 
  15437   forEachSDict(self->top, e) {
  15438     if (e->key && e->data->type == INT && ((sIntt*)(e->data))->value == v) {
  15439       return(e->key);
  15440   }
  15441     }
  15442   return(NULL);
  15443 }
  15444 
  15445 internal char* keyBySmallJsonSmallJson(smallJsont *self, smallJsont *value) {
  15446 
  15447   // sanity checks
  15448   if (self->topIsA != TOP_IS_DICT) {
  15449     return(NULL);
  15450   }
  15451 
  15452   if (!lenSmallJson(self) || !value) {
  15453     return(NULL);
  15454   }
  15455 
  15456   if (checkObjectTypes && !isOSmallJson(value)) {
  15457     return(NULL);
  15458   }
  15459 
  15460   baset *O = NULL;
  15461   char *r  = NULL;
  15462   switch(value->topIsA){
  15463     case SMALLJSON_IS_EMPTY:
  15464       return(NULL);
  15465     case TOP_IS_UNDEFINED:
  15466       O = getTopSmallJson(value);
  15467       r = keyByUndefinedSmallJson(self, (undefinedt*)O);;
  15468       finishO(O);
  15469       break;
  15470     case TOP_IS_BOOL:
  15471       O = getTopSmallJson(value);
  15472       r = keyBySmallBoolSmallJson(self, (smallBoolt*)O);;
  15473       finishO(O);
  15474       break;
  15475     case TOP_IS_DOUBLE:
  15476       O = getTopSmallJson(value);
  15477       r = keyBySmallDoubleSmallJson(self, (smallDoublet*)O);;
  15478       finishO(O);
  15479       break;
  15480     case TOP_IS_INT:
  15481       O = getTopSmallJson(value);
  15482       r = keyBySmallIntSmallJson(self, (smallIntt*)O);;
  15483       finishO(O);
  15484       break;
  15485     case TOP_IS_STRING:
  15486       O = getTopSmallJson(value);
  15487       r = keyBySmallStringSmallJson(self, (smallStringt*)O);;
  15488       finishO(O);
  15489       break;
  15490     case TOP_IS_DICT:
  15491       O = getTopSmallJson(value);
  15492       r = keyByDictSmallJson(self, (smallDictt*)O);;
  15493       finishO(O);
  15494       break;
  15495     case TOP_IS_ARRAY:
  15496       O = getTopSmallJson(value);
  15497       r = keyByArraySmallJson(self, (smallArrayt*)O);;
  15498       finishO(O);
  15499       break;
  15500     default:
  15501       logC("Unsupported smallJson type!");
  15502   }
  15503   return(r);
  15504 }
  15505 
  15506 internal char* keyBySmallStringSmallJson(smallJsont *self, smallStringt *string) {
  15507 
  15508   // sanity checks
  15509   if (self->topIsA != TOP_IS_DICT) {
  15510     return(NULL);
  15511   }
  15512 
  15513   if (!lenSmallJson(self)) {
  15514     return(NULL);
  15515   }
  15516 
  15517   if (!string) {
  15518     return(NULL);
  15519   }
  15520 
  15521   if (checkObjectTypes && !isOSmallString(string)) {
  15522     return(NULL);
  15523   }
  15524 
  15525   if (!string->data) {
  15526     return(NULL);
  15527   }
  15528 
  15529   // search string in elements
  15530   char *s = sStringGetTiny(string->data);
  15531 
  15532   forEachSDict(self->top, e) {
  15533     if (e->key && e->data->type == STRING && strEq(sStringGetTiny((sStringt*)(e->data)), s)) {
  15534       return(e->key);
  15535   }
  15536     }
  15537   return(NULL);
  15538 }
  15539 
  15540 internal char* keyBySmallContainerSmallJson(smallJsont *self, smallContainert *container) {
  15541 
  15542   if (self->topIsA != TOP_IS_DICT) {
  15543     return(NULL);
  15544   }
  15545 
  15546   if (!container) {
  15547     return(NULL);
  15548   }
  15549 
  15550   if (checkObjectTypes && !isOSmallContainer(container)) {
  15551     return(NULL);
  15552   }
  15553 
  15554   return(NULL);
  15555 }
  15556 
  15557 internal char* icKeyBySmallJson(smallJsont *self, baset *value) {
  15558 
  15559   // sanity checks
  15560   if (self->topIsA != TOP_IS_DICT) {
  15561     return(NULL);
  15562   }
  15563 
  15564   if (!lenSmallJson(self) || !value) {
  15565     return(NULL);
  15566   }
  15567 
  15568   // search string in elements
  15569   char *s  = toStringO(value);
  15570   char *es = NULL;
  15571 
  15572   forEachSDict(self->top, e) {
  15573     if (e->key) {
  15574       es = sToString(e->data);
  15575       if (icEqS(es, s)) {
  15576         free(es);
  15577         free(s);
  15578         return(e->key);
  15579       }
  15580       free(es);
  15581   }
  15582     }
  15583   free(s);
  15584   return(NULL);
  15585 }
  15586 
  15587 internal char* icKeyBySSmallJson(smallJsont *self, const char *string) {
  15588 
  15589   // sanity checks
  15590   if (self->topIsA != TOP_IS_DICT) {
  15591     return(NULL);
  15592   }
  15593 
  15594   if (!lenSmallJson(self) || !string) {
  15595     return(NULL);
  15596   }
  15597   // search string in elements
  15598   forEachSDict(self->top, e) {
  15599     if (e->key && e->data->type == STRING && icEqS(sStringGetTiny((sStringt*)(e->data)), string)) {
  15600       return(e->key);
  15601   }
  15602     }
  15603   return(NULL);
  15604 }
  15605 
  15606 internal char* icKeyByCharSmallJson(smallJsont *self, char c) {
  15607 
  15608   charToS(s, c);
  15609   return(icKeyBySSmallJson(self, s));
  15610 }
  15611 
  15612 internal char* icKeyByDictSmallJson(smallJsont *self, smallDictt *dict) {
  15613 
  15614   // sanity checks
  15615   if (self->topIsA != TOP_IS_DICT) {
  15616     return(NULL);
  15617   }
  15618 
  15619   if (!lenSmallJson(self) || !dict) {
  15620     return(NULL);
  15621   }
  15622 
  15623   if (checkObjectTypes && !isOSmallDict(dict)) {
  15624     return(NULL);
  15625   }
  15626 
  15627   // search object in elements
  15628   char *s = toStringO(dict);
  15629   char *es = NULL;;
  15630 
  15631   forEachSDict(self->top, e) {
  15632     if (e->key && e->data->type == DICT) {
  15633       es = sToString(e->data);
  15634       if (icEqS(es, s)) {
  15635         free(es);
  15636         free(s);
  15637         return(e->key);
  15638       }
  15639       free(es);
  15640   }
  15641     }
  15642   free(s);
  15643   return(NULL);
  15644 }
  15645 
  15646 internal char* icKeyByArraySmallJson(smallJsont *self, smallArrayt *array) {
  15647 
  15648   // sanity checks
  15649   if (self->topIsA != TOP_IS_DICT) {
  15650     return(NULL);
  15651   }
  15652 
  15653   if (!lenSmallJson(self) || !array) {
  15654     return(NULL);
  15655   }
  15656 
  15657   if (checkObjectTypes && !isOSmallArray(array)) {
  15658     return(NULL);
  15659   }
  15660 
  15661   // search object in elements
  15662   char *s = toStringO(array);
  15663   char *es = NULL;;
  15664 
  15665   forEachSDict(self->top, e) {
  15666     if (e->key && e->data->type == ARRAY) {
  15667       es = sToString(e->data);
  15668       if (icEqS(es, s)) {
  15669         free(es);
  15670         free(s);
  15671         return(e->key);
  15672       }
  15673       free(es);
  15674   }
  15675     }
  15676   free(s);
  15677   return(NULL);
  15678 }
  15679 
  15680 internal char* icKeyByArraycSmallJson(smallJsont *self, char **array) {
  15681 
  15682   // sanity checks
  15683   if (self->topIsA != TOP_IS_DICT) {
  15684     return(NULL);
  15685   }
  15686 
  15687   if (!lenSmallJson(self) || !array) {
  15688     return(NULL);
  15689   }
  15690 
  15691   // search object in elements
  15692   char *s = toStringListSGF(array);
  15693   char *es = NULL;;
  15694 
  15695   forEachSDict(self->top, e) {
  15696     if (e->key && e->data->type == ARRAY) {
  15697       es = sToString(e->data);
  15698       if (icEqS(es, s)) {
  15699         free(es);
  15700         free(s);
  15701         return(e->key);
  15702       }
  15703       free(es);
  15704   }
  15705     }
  15706   free(s);
  15707   return(NULL);
  15708 }
  15709 
  15710 internal char* icKeyByCArraycSmallJson(smallJsont *self, const char **array) {
  15711 
  15712   // sanity checks
  15713   if (self->topIsA != TOP_IS_DICT) {
  15714     return(NULL);
  15715   }
  15716 
  15717   if (!lenSmallJson(self) || !array) {
  15718     return(NULL);
  15719   }
  15720 
  15721   // search object in elements
  15722   char *s = toStringListCSGF(array);
  15723   char *es = NULL;;
  15724 
  15725   forEachSDict(self->top, e) {
  15726     if (e->key && e->data->type == ARRAY) {
  15727       es = sToString(e->data);
  15728       if (icEqS(es, s)) {
  15729         free(es);
  15730         free(s);
  15731         return(e->key);
  15732       }
  15733       free(es);
  15734   }
  15735     }
  15736   free(s);
  15737   return(NULL);
  15738 }
  15739 
  15740 internal char* icKeyBySmallStringSmallJson(smallJsont *self, smallStringt *string) {
  15741 
  15742   // sanity checks
  15743   if (self->topIsA != TOP_IS_DICT) {
  15744     return(NULL);
  15745   }
  15746 
  15747   if (!lenSmallJson(self)) {
  15748     return(NULL);
  15749   }
  15750 
  15751   if (!string) {
  15752     return(NULL);
  15753   }
  15754 
  15755   if (checkObjectTypes && !isOSmallString(string)) {
  15756     return(NULL);
  15757   }
  15758 
  15759   if (!string->data) {
  15760     return(NULL);
  15761   }
  15762 
  15763   // search string in elements
  15764   char *s = sStringGetTiny(string->data);
  15765 
  15766   forEachSDict(self->top, e) {
  15767     if (e->key && e->data->type == STRING && icEqS(sStringGetTiny((sStringt*)(e->data)), s)) {
  15768       return(e->key);
  15769   }
  15770     }
  15771   return(NULL);
  15772 }
  15773 
  15774 internal smallJsont* replaceSmallJson(smallJsont *self, const char *olds, const char *news, size_t max) {
  15775   char *r = NULL;
  15776   char *tmp = NULL;
  15777   char *workingS = NULL;
  15778   // ins is next insert point
  15779   char *ins = NULL;
  15780   size_t count;
  15781   size_t lfront;
  15782 
  15783   // sanity checks and initialization
  15784   // count the number of replacements needed
  15785   // allocate result
  15786   // replace olds with news
  15787   // copy end of smallString
  15788 
  15789   // sanity checks and initialization
  15790   if (self->topIsA != TOP_IS_STRING) {
  15791     return(NULL);
  15792   }
  15793 
  15794   if (!self->topS) {
  15795     return(NULL);
  15796   }
  15797   if (!lenSmallJson(self)) {
  15798     // s is empty, do nothing
  15799     return(self);
  15800   }
  15801   if (!olds) {
  15802     return(NULL);
  15803   }
  15804   size_t lolds;
  15805   lolds = strlen(olds);
  15806   if (!lolds) {
  15807     // empty olds causes infinite loop
  15808     return(NULL);
  15809   }
  15810   if (!news) {
  15811     // empty smallString for NULL
  15812     news = "";
  15813   }
  15814 
  15815   // count the number of replacements needed
  15816   ins = sStringGetTiny(self->topS);
  15817   for (count = 0 ; (tmp = strstr(ins, olds)) ; ++count) {
  15818      ins = tmp + lolds;
  15819      if (max && (count == max)) {
  15820        // the maximum number is replacements is reached, stop
  15821        break;
  15822   }
  15823      }
  15824 
  15825 
  15826   size_t lnews;
  15827   lnews       = strlen(news);
  15828 
  15829   // allocate result
  15830   // +1 for 0 at the end +1 for sType at the start
  15831   size_t rLen = lenSmallJson(self) + (lnews - lolds) * count + 2;;
  15832   tmp = r     = malloc(rLen);
  15833   if (!r) {
  15834     return(NULL);
  15835   }
  15836 
  15837   // include sType in workingS
  15838   workingS = (char *)self->topS;
  15839   // replace olds with news
  15840   // ins points to the start of olds in s
  15841   // tmp is the front of s, tmp points the end of s front in r
  15842   // copy news to tmp, tmp points the end of news in r
  15843   // s is the remainder of s after end of olds
  15844   while (count--) {
  15845     ins       = strstr(workingS, olds);
  15846     lfront    = (size_t)(ins - workingS);
  15847     tmp       = strncpy(tmp, workingS, lfront) + lfront;
  15848     tmp       = strcpy(tmp, news) + lnews;
  15849     workingS += lfront + lolds;
  15850   }
  15851 
  15852   // copy end of smallString
  15853   strcpy(tmp, workingS);
  15854 
  15855   free(self->topS);
  15856   self->topS = (sStringt *)r;
  15857   //TODO self->_len = strlen(r)-1
  15858   return(self);
  15859 }
  15860 
  15861 internal smallJsont* replaceCharSSmallJson(smallJsont *self, char olds, const char *news, size_t max) {
  15862 
  15863   charToS(s, olds);
  15864   return(replaceSmallJson(self, s, news, max));
  15865 }
  15866 
  15867 internal smallJsont* replaceSCharSmallJson(smallJsont *self, const char *olds, char news, size_t max) {
  15868 
  15869   charToS(s, news);
  15870   return(replaceSmallJson(self, olds, s, max));
  15871 }
  15872 
  15873 internal smallJsont* replaceCharCharSmallJson(smallJsont *self, char olds, char news, size_t max) {
  15874 
  15875   charToS(s, olds);
  15876   charToS(t, news);
  15877   return(replaceSmallJson(self, s, t , max));
  15878 }
  15879 
  15880 internal smallJsont* replaceSmallStringSmallStringSmallJson(smallJsont *self, smallStringt *olds, smallStringt *news, size_t max) {
  15881 
  15882   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  15883     return(NULL);
  15884   }
  15885   if (!lenSmallJson(self)) {
  15886     // s is empty, do nothing
  15887     return(self);
  15888   }
  15889 
  15890   if (!olds) {
  15891     return(NULL);
  15892   }
  15893   if (checkObjectTypes && !isOSmallString(olds)) {
  15894     return(NULL);
  15895   }
  15896 
  15897   if (!news) {
  15898     return(replaceSmallStringSSmallJson(self, olds, "", max));
  15899   }
  15900 
  15901   if (checkObjectTypes && !isOSmallString(news)) {
  15902     return(NULL);
  15903   }
  15904 
  15905   return(replaceSmallJson(self, ssGet(olds), ssGet(news), max));
  15906 }
  15907 
  15908 internal smallJsont* replaceSmallStringSSmallJson(smallJsont *self, smallStringt *olds, const char *news, size_t max) {
  15909 
  15910   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  15911     return(NULL);
  15912   }
  15913   if (!lenSmallJson(self)) {
  15914     // s is empty, do nothing
  15915     return(self);
  15916   }
  15917 
  15918   if (!olds) {
  15919     return(NULL);
  15920   }
  15921   if (checkObjectTypes && !isOSmallString(olds)) {
  15922     return(NULL);
  15923   }
  15924 
  15925   return(replaceSmallJson(self, ssGet(olds), news, max));
  15926 }
  15927 
  15928 internal smallJsont* replaceSmallStringCharSmallJson(smallJsont *self, smallStringt *olds, char news, size_t max) {
  15929 
  15930   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  15931     return(NULL);
  15932   }
  15933   if (!lenSmallJson(self)) {
  15934     // s is empty, do nothing
  15935     return(self);
  15936   }
  15937 
  15938   if (!olds) {
  15939     return(NULL);
  15940   }
  15941   if (checkObjectTypes && !isOSmallString(olds)) {
  15942     return(NULL);
  15943   }
  15944 
  15945   charToS(s, news);
  15946   return(replaceSmallJson(self, ssGet(olds), s, max));
  15947 }
  15948 
  15949 internal smallJsont* replaceSSmallStringSmallJson(smallJsont *self, const char *olds, smallStringt *news, size_t max) {
  15950 
  15951   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  15952     return(NULL);
  15953   }
  15954   if (!lenSmallJson(self)) {
  15955     // s is empty, do nothing
  15956     return(self);
  15957   }
  15958 
  15959   if (!news) {
  15960     return(replaceSmallJson(self, olds, "", max));
  15961   }
  15962 
  15963   if (checkObjectTypes && !isOSmallString(news)) {
  15964     return(NULL);
  15965   }
  15966 
  15967   return(replaceSmallJson(self, olds, ssGet(news), max));
  15968 }
  15969 
  15970 internal smallJsont* replaceCharSmallStringSmallJson(smallJsont *self, char olds, smallStringt *news, size_t max) {
  15971 
  15972   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  15973     return(NULL);
  15974   }
  15975   if (!lenSmallJson(self)) {
  15976     // s is empty, do nothing
  15977     return(self);
  15978   }
  15979 
  15980   if (!news) {
  15981     charToS(s, olds);
  15982     return(replaceSmallJson(self, s, "", max));
  15983   }
  15984   if (checkObjectTypes && !isOSmallString(news)) {
  15985     return(NULL);
  15986   }
  15987 
  15988   charToS(s, olds);
  15989   return(replaceSmallJson(self, s, ssGet(news), max));
  15990 }
  15991 
  15992 internal smallJsont* replaceJsonJsonSmallJson(smallJsont *self, smallJsont *olds, smallJsont *news, size_t max) {
  15993 
  15994   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  15995     return(NULL);
  15996   }
  15997   if (!lenSmallJson(self)) {
  15998     // s is empty, do nothing
  15999     return(self);
  16000   }
  16001 
  16002   if (!olds) {
  16003     return(NULL);
  16004   }
  16005 
  16006   if (checkObjectTypes && !isOSmallJson(olds)) {
  16007     return(NULL);
  16008   }
  16009 
  16010   if (!news) {
  16011     return(replaceJsonSSmallJson(self, olds, "", max));
  16012   }
  16013 
  16014   if (checkObjectTypes && !isOSmallJson(news)) {
  16015     return(NULL);
  16016   }
  16017 
  16018   if (olds->topIsA != TOP_IS_STRING || news->topIsA != TOP_IS_STRING) {
  16019     return(NULL);
  16020   }
  16021 
  16022   return(replaceSmallJson(self, sjGet(olds), sjGet(news), max));
  16023 }
  16024 
  16025 internal smallJsont* replaceJsonSmallStringSmallJson(smallJsont *self, smallJsont *olds, smallStringt *news, size_t max) {
  16026 
  16027   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16028     return(NULL);
  16029   }
  16030   if (!lenSmallJson(self)) {
  16031     // s is empty, do nothing
  16032     return(self);
  16033   }
  16034 
  16035   if (!olds) {
  16036     return(NULL);
  16037   }
  16038 
  16039   if (checkObjectTypes && !isOSmallJson(olds)) {
  16040     return(NULL);
  16041   }
  16042 
  16043   if (!news) {
  16044     return(replaceJsonSSmallJson(self, olds, "", max));
  16045   }
  16046 
  16047   if (checkObjectTypes && !isOSmallString(news)) {
  16048     return(NULL);
  16049   }
  16050 
  16051   if (olds->topIsA != TOP_IS_STRING) {
  16052     return(NULL);
  16053   }
  16054 
  16055   return(replaceSmallJson(self, sjGet(olds), ssGet(news), max));
  16056 }
  16057 
  16058 internal smallJsont* replaceJsonSSmallJson(smallJsont *self, smallJsont *olds, const char *news, size_t max) {
  16059 
  16060   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16061     return(NULL);
  16062   }
  16063   if (!lenSmallJson(self)) {
  16064     // s is empty, do nothing
  16065     return(self);
  16066   }
  16067 
  16068   if (!olds) {
  16069     return(NULL);
  16070   }
  16071   if (checkObjectTypes && !isOSmallJson(olds)) {
  16072     return(NULL);
  16073   }
  16074 
  16075   if (olds->topIsA != TOP_IS_STRING) {
  16076     return(NULL);
  16077   }
  16078 
  16079   return(replaceSmallJson(self, sjGet(olds), news, max));
  16080 }
  16081 
  16082 internal smallJsont* replaceJsonCharSmallJson(smallJsont *self, smallJsont *olds, char news, size_t max) {
  16083 
  16084   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16085     return(NULL);
  16086   }
  16087   if (!lenSmallJson(self)) {
  16088     // s is empty, do nothing
  16089     return(self);
  16090   }
  16091 
  16092   if (!olds) {
  16093     return(NULL);
  16094   }
  16095 
  16096   if (checkObjectTypes && !isOSmallJson(olds)) {
  16097     return(NULL);
  16098   }
  16099 
  16100   if (olds->topIsA != TOP_IS_STRING) {
  16101     return(NULL);
  16102   }
  16103 
  16104   charToS(s, news);
  16105   return(replaceSmallJson(self, sjGet(olds), s, max));
  16106 }
  16107 
  16108 internal smallJsont* replaceSmallStringJsonSmallJson(smallJsont *self, smallStringt *olds, smallJsont *news, size_t max) {
  16109 
  16110   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16111     return(NULL);
  16112   }
  16113   if (!lenSmallJson(self)) {
  16114     // s is empty, do nothing
  16115     return(self);
  16116   }
  16117 
  16118   if (!olds) {
  16119     return(NULL);
  16120   }
  16121 
  16122   if (checkObjectTypes && !isOSmallString(olds)) {
  16123     return(NULL);
  16124   }
  16125 
  16126   if (!news) {
  16127     return(replaceSmallStringSSmallJson(self, olds, "", max));
  16128   }
  16129 
  16130   if (checkObjectTypes && !isOSmallJson(news)) {
  16131     return(NULL);
  16132   }
  16133 
  16134   if (news->topIsA != TOP_IS_STRING) {
  16135     return(NULL);
  16136   }
  16137 
  16138   return(replaceSmallJson(self, ssGet(olds), sjGet(news), max));
  16139 }
  16140 
  16141 internal smallJsont* replaceSJsonSmallJson(smallJsont *self, const char *olds, smallJsont *news, size_t max) {
  16142 
  16143   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16144     return(NULL);
  16145   }
  16146   if (!lenSmallJson(self)) {
  16147     // s is empty, do nothing
  16148     return(self);
  16149   }
  16150 
  16151   if (!news) {
  16152     return(replaceSmallJson(self, olds, "", max));
  16153   }
  16154 
  16155   if (checkObjectTypes && !isOSmallJson(news)) {
  16156     return(NULL);
  16157   }
  16158 
  16159   if (news->topIsA != TOP_IS_STRING) {
  16160     return(NULL);
  16161   }
  16162 
  16163   return(replaceSmallJson(self, olds, sjGet(news), max));
  16164 }
  16165 
  16166 internal smallJsont* replaceCharJsonSmallJson(smallJsont *self, char olds, smallJsont *news, size_t max) {
  16167 
  16168   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16169     return(NULL);
  16170   }
  16171   if (!lenSmallJson(self)) {
  16172     // s is empty, do nothing
  16173     return(self);
  16174   }
  16175 
  16176   if (!news) {
  16177     charToS(s, olds);
  16178     return(replaceSmallJson(self, s, "", max));
  16179   }
  16180 
  16181   if (checkObjectTypes && !isOSmallJson(news)) {
  16182     return(NULL);
  16183   }
  16184 
  16185   if (news->topIsA != TOP_IS_STRING) {
  16186     return(NULL);
  16187   }
  16188 
  16189   charToS(s, olds);
  16190   return(replaceSmallJson(self, s, sjGet(news), max));
  16191 }
  16192 
  16193 
  16194 internal smallJsont* replaceManySmallJson(smallJsont *self, const char *paramType, ...) {
  16195   va_list pl;
  16196   const char *olds = NULL;
  16197   const char *news = NULL;
  16198 
  16199   // sanity checks
  16200   if (self->topIsA != TOP_IS_STRING) {
  16201     return(NULL);
  16202   }
  16203 
  16204   if (!lenSmallJson(self)) {
  16205     return(self);
  16206   }
  16207 
  16208   olds = paramType;
  16209 
  16210   // add arguments to a list
  16211   va_start(pl, paramType);
  16212   paramType = va_arg(pl, const char *);
  16213   if (!paramType) {
  16214     // missing news
  16215     va_end(pl);
  16216     return(NULL);
  16217   }
  16218   while (paramType) {
  16219     if (!olds) {
  16220       olds = paramType;
  16221     }
  16222     else if (!news) {
  16223       news = paramType;
  16224       smallJsont *r = replaceSmallJson(self, olds, news, 0);
  16225       if (!r) {
  16226         // replace error
  16227         va_end(pl);
  16228         return(NULL);
  16229       }
  16230       olds = NULL;
  16231       news = NULL;
  16232     }
  16233 
  16234     paramType = va_arg(pl, const char *);
  16235   }
  16236   va_end(pl);
  16237   return(self);
  16238 }
  16239 
  16240 internal smallJsont* icReplaceSmallJson(smallJsont *self, const char *olds, const char *news, size_t max) {
  16241   char *r = NULL;
  16242   char *tmp = NULL;
  16243   char *workingS = NULL;
  16244   // ins is next insert point
  16245   char *ins = NULL;
  16246   size_t count;
  16247   size_t lfront;
  16248 
  16249   // sanity checks and initialization
  16250   // count the number of replacements needed
  16251   // allocate result
  16252   // replace olds with news
  16253   // copy end of smallString
  16254 
  16255   // sanity checks and initialization
  16256   if (self->topIsA != TOP_IS_STRING) {
  16257     return(NULL);
  16258   }
  16259 
  16260   if (!self->topS) {
  16261     return(NULL);
  16262   }
  16263   if (!lenSmallJson(self)) {
  16264     // s is empty, do nothing
  16265     return(self);
  16266   }
  16267   if (!olds) {
  16268     return(NULL);
  16269   }
  16270   size_t lolds;
  16271   lolds = strlen(olds);
  16272   if (!lolds) {
  16273     // empty olds causes infinite loop
  16274     return(NULL);
  16275   }
  16276   if (!news) {
  16277     // empty smallString for NULL
  16278     news = "";
  16279   }
  16280 
  16281   // count the number of replacements needed
  16282   ins = sStringGetTiny(self->topS);
  16283   for (count = 0 ; (tmp = strcasestr(ins, olds)) ; ++count) {
  16284      ins = tmp + lolds;
  16285      if (max && (count == max)) {
  16286        // the maximum number is replacements is reached, stop
  16287        break;
  16288   }
  16289      }
  16290 
  16291 
  16292   size_t lnews;
  16293   lnews       = strlen(news);
  16294 
  16295   // allocate result
  16296   // +1 for 0 at the end +1 for sType at the start
  16297   size_t rLen = lenSmallJson(self) + (lnews - lolds) * count + 2;;
  16298   tmp = r     = malloc(rLen);
  16299   if (!r) {
  16300     return(NULL);
  16301   }
  16302 
  16303   // include sType in workingS
  16304   workingS = (char *)self->topS;
  16305   // replace olds with news
  16306   // ins points to the start of olds in s
  16307   // tmp is the front of s, tmp points the end of s front in r
  16308   // copy news to tmp, tmp points the end of news in r
  16309   // s is the remainder of s after end of olds
  16310   while (count--) {
  16311     ins       = strcasestr(workingS, olds);
  16312     lfront    = (size_t)(ins - workingS);
  16313     tmp       = strncpy(tmp, workingS, lfront) + lfront;
  16314     tmp       = strcpy(tmp, news) + lnews;
  16315     workingS += lfront + lolds;
  16316   }
  16317 
  16318   // copy end of smallString
  16319   strcpy(tmp, workingS);
  16320 
  16321   free(self->topS);
  16322   self->topS = (sStringt *)r;
  16323   //TODO self->_len = strlen(r)-1
  16324   return(self);
  16325 }
  16326 
  16327 internal smallJsont* icReplaceCharSSmallJson(smallJsont *self, char olds, const char *news, size_t max) {
  16328 
  16329   charToS(s, olds);
  16330   return(icReplaceSmallJson(self, s, news, max));
  16331 }
  16332 
  16333 internal smallJsont* icReplaceSCharSmallJson(smallJsont *self, const char *olds, char news, size_t max) {
  16334 
  16335   charToS(s, news);
  16336   return(icReplaceSmallJson(self, olds, s, max));
  16337 }
  16338 
  16339 internal smallJsont* icReplaceCharCharSmallJson(smallJsont *self, char olds, char news, size_t max) {
  16340 
  16341   charToS(s, olds);
  16342   charToS(t, news);
  16343   return(icReplaceSmallJson(self, s, t , max));
  16344 }
  16345 
  16346 internal smallJsont* icReplaceSmallStringSmallStringSmallJson(smallJsont *self, smallStringt *olds, smallStringt *news, size_t max) {
  16347 
  16348   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16349     return(NULL);
  16350   }
  16351   if (!lenSmallJson(self)) {
  16352     // s is empty, do nothing
  16353     return(self);
  16354   }
  16355 
  16356   if (!olds) {
  16357     return(NULL);
  16358   }
  16359 
  16360   if (checkObjectTypes && !isOSmallString(olds)) {
  16361     return(NULL);
  16362   }
  16363 
  16364   if (!news) {
  16365     return(icReplaceSmallStringSSmallJson(self, olds, "", max));
  16366   }
  16367 
  16368   if (checkObjectTypes && !isOSmallString(news)) {
  16369     return(NULL);
  16370   }
  16371 
  16372   return(icReplaceSmallJson(self, ssGet(olds), ssGet(news), max));
  16373 }
  16374 
  16375 internal smallJsont* icReplaceSmallStringSSmallJson(smallJsont *self, smallStringt *olds, const char *news, size_t max) {
  16376 
  16377   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16378     return(NULL);
  16379   }
  16380   if (!lenSmallJson(self)) {
  16381     // s is empty, do nothing
  16382     return(self);
  16383   }
  16384 
  16385   if (!olds) {
  16386     return(NULL);
  16387   }
  16388 
  16389   if (checkObjectTypes && !isOSmallString(olds)) {
  16390     return(NULL);
  16391   }
  16392 
  16393   return(icReplaceSmallJson(self, ssGet(olds), news, max));
  16394 }
  16395 
  16396 internal smallJsont* icReplaceSmallStringCharSmallJson(smallJsont *self, smallStringt *olds, char news, size_t max) {
  16397 
  16398   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16399     return(NULL);
  16400   }
  16401   if (!lenSmallJson(self)) {
  16402     // s is empty, do nothing
  16403     return(self);
  16404   }
  16405 
  16406   if (!olds) {
  16407     return(NULL);
  16408   }
  16409 
  16410   if (checkObjectTypes && !isOSmallString(olds)) {
  16411     return(NULL);
  16412   }
  16413 
  16414   charToS(s, news);
  16415   return(icReplaceSmallJson(self, ssGet(olds), s, max));
  16416 }
  16417 
  16418 internal smallJsont* icReplaceSSmallStringSmallJson(smallJsont *self, const char *olds, smallStringt *news, size_t max) {
  16419 
  16420   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16421     return(NULL);
  16422   }
  16423   if (!lenSmallJson(self)) {
  16424     // s is empty, do nothing
  16425     return(self);
  16426   }
  16427 
  16428   if (!news) {
  16429     return(icReplaceSmallJson(self, olds, "", max));
  16430   }
  16431 
  16432   if (checkObjectTypes && !isOSmallString(news)) {
  16433     return(NULL);
  16434   }
  16435 
  16436   return(icReplaceSmallJson(self, olds, ssGet(news), max));
  16437 }
  16438 
  16439 internal smallJsont* icReplaceCharSmallStringSmallJson(smallJsont *self, char olds, smallStringt *news, size_t max) {
  16440 
  16441   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16442     return(NULL);
  16443   }
  16444   if (!lenSmallJson(self)) {
  16445     // s is empty, do nothing
  16446     return(self);
  16447   }
  16448 
  16449   if (!news) {
  16450     charToS(s, olds);
  16451     return(icReplaceSmallJson(self, s, "", max));
  16452   }
  16453 
  16454   if (checkObjectTypes && !isOSmallString(news)) {
  16455     return(NULL);
  16456   }
  16457 
  16458   charToS(s, olds);
  16459   return(icReplaceSmallJson(self, s, ssGet(news), max));
  16460 }
  16461 
  16462 internal smallJsont* icReplaceJsonJsonSmallJson(smallJsont *self, smallJsont *olds, smallJsont *news, size_t max) {
  16463 
  16464   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16465     return(NULL);
  16466   }
  16467   if (!lenSmallJson(self)) {
  16468     // s is empty, do nothing
  16469     return(self);
  16470   }
  16471 
  16472   if (!olds) {
  16473     return(NULL);
  16474   }
  16475 
  16476   if (checkObjectTypes && !isOSmallJson(olds)) {
  16477     return(NULL);
  16478   }
  16479 
  16480   if (!news) {
  16481     return(icReplaceJsonSSmallJson(self, olds, "", max));
  16482   }
  16483 
  16484   if (checkObjectTypes && !isOSmallJson(news)) {
  16485     return(NULL);
  16486   }
  16487 
  16488   if (olds->topIsA != TOP_IS_STRING || news->topIsA != TOP_IS_STRING) {
  16489     return(NULL);
  16490   }
  16491 
  16492   return(icReplaceSmallJson(self, sjGet(olds), sjGet(news), max));
  16493 }
  16494 
  16495 internal smallJsont* icReplaceJsonSmallStringSmallJson(smallJsont *self, smallJsont *olds, smallStringt *news, size_t max) {
  16496 
  16497   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16498     return(NULL);
  16499   }
  16500   if (!lenSmallJson(self)) {
  16501     // s is empty, do nothing
  16502     return(self);
  16503   }
  16504 
  16505   if (!olds) {
  16506     return(NULL);
  16507   }
  16508 
  16509   if (checkObjectTypes && !isOSmallJson(olds)) {
  16510     return(NULL);
  16511   }
  16512 
  16513   if (!news) {
  16514     return(icReplaceJsonSSmallJson(self, olds, "", max));
  16515   }
  16516 
  16517   if (checkObjectTypes && !isOSmallString(news)) {
  16518     return(NULL);
  16519   }
  16520 
  16521   if (olds->topIsA != TOP_IS_STRING) {
  16522     return(NULL);
  16523   }
  16524 
  16525   return(icReplaceSmallJson(self, sjGet(olds), ssGet(news), max));
  16526 }
  16527 
  16528 internal smallJsont* icReplaceJsonSSmallJson(smallJsont *self, smallJsont *olds, const char *news, size_t max) {
  16529 
  16530   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16531     return(NULL);
  16532   }
  16533   if (!lenSmallJson(self)) {
  16534     // s is empty, do nothing
  16535     return(self);
  16536   }
  16537 
  16538   if (!olds) {
  16539     return(NULL);
  16540   }
  16541 
  16542   if (checkObjectTypes && !isOSmallJson(olds)) {
  16543     return(NULL);
  16544   }
  16545 
  16546   if (olds->topIsA != TOP_IS_STRING) {
  16547     return(NULL);
  16548   }
  16549 
  16550   return(icReplaceSmallJson(self, sjGet(olds), news, max));
  16551 }
  16552 
  16553 internal smallJsont* icReplaceJsonCharSmallJson(smallJsont *self, smallJsont *olds, char news, size_t max) {
  16554 
  16555   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16556     return(NULL);
  16557   }
  16558   if (!lenSmallJson(self)) {
  16559     // s is empty, do nothing
  16560     return(self);
  16561   }
  16562 
  16563   if (!olds) {
  16564     return(NULL);
  16565   }
  16566 
  16567   if (checkObjectTypes && !isOSmallJson(olds)) {
  16568     return(NULL);
  16569   }
  16570 
  16571   if (olds->topIsA != TOP_IS_STRING) {
  16572     return(NULL);
  16573   }
  16574 
  16575   charToS(s, news);
  16576   return(icReplaceSmallJson(self, sjGet(olds), s, max));
  16577 }
  16578 
  16579 internal smallJsont* icReplaceSmallStringJsonSmallJson(smallJsont *self, smallStringt *olds, smallJsont *news, size_t max) {
  16580 
  16581   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16582     return(NULL);
  16583   }
  16584   if (!lenSmallJson(self)) {
  16585     // s is empty, do nothing
  16586     return(self);
  16587   }
  16588 
  16589   if (!olds) {
  16590     return(NULL);
  16591   }
  16592 
  16593   if (checkObjectTypes && !isOSmallString(olds)) {
  16594     return(NULL);
  16595   }
  16596 
  16597   if (!news) {
  16598     return(icReplaceSmallStringSSmallJson(self, olds, "", max));
  16599   }
  16600 
  16601   if (checkObjectTypes && !isOSmallJson(news)) {
  16602     return(NULL);
  16603   }
  16604 
  16605   if (news->topIsA != TOP_IS_STRING) {
  16606     return(NULL);
  16607   }
  16608 
  16609   return(icReplaceSmallJson(self, ssGet(olds), sjGet(news), max));
  16610 }
  16611 
  16612 internal smallJsont* icReplaceSJsonSmallJson(smallJsont *self, const char *olds, smallJsont *news, size_t max) {
  16613 
  16614   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16615     return(NULL);
  16616   }
  16617   if (!lenSmallJson(self)) {
  16618     // s is empty, do nothing
  16619     return(self);
  16620   }
  16621 
  16622   if (!news) {
  16623     return(icReplaceSmallJson(self, olds, "", max));
  16624   }
  16625 
  16626   if (checkObjectTypes && !isOSmallJson(news)) {
  16627     return(NULL);
  16628   }
  16629 
  16630   if (news->topIsA != TOP_IS_STRING) {
  16631     return(NULL);
  16632   }
  16633 
  16634   return(icReplaceSmallJson(self, olds, sjGet(news), max));
  16635 }
  16636 
  16637 internal smallJsont* icReplaceCharJsonSmallJson(smallJsont *self, char olds, smallJsont *news, size_t max) {
  16638 
  16639   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  16640     return(NULL);
  16641   }
  16642   if (!lenSmallJson(self)) {
  16643     // s is empty, do nothing
  16644     return(self);
  16645   }
  16646 
  16647   if (!news) {
  16648     charToS(s, olds);
  16649     return(icReplaceSmallJson(self, s, "", max));
  16650   }
  16651 
  16652   if (checkObjectTypes && !isOSmallJson(news)) {
  16653     return(NULL);
  16654   }
  16655 
  16656   if (news->topIsA != TOP_IS_STRING) {
  16657     return(NULL);
  16658   }
  16659 
  16660   charToS(s, olds);
  16661   return(icReplaceSmallJson(self, s, sjGet(news), max));
  16662 }
  16663 
  16664 internal smallJsont* icReplaceManySmallJson(smallJsont *self, const char *paramType, ...) {
  16665   va_list pl;
  16666   const char *olds = NULL;
  16667   const char *news = NULL;
  16668 
  16669   // sanity checks
  16670   if (self->topIsA != TOP_IS_STRING) {
  16671     return(NULL);
  16672   }
  16673 
  16674   if (!lenSmallJson(self)) {
  16675     return(self);
  16676   }
  16677 
  16678   olds = paramType;
  16679 
  16680   // add arguments to a list
  16681   va_start(pl, paramType);
  16682   paramType = va_arg(pl, const char *);
  16683   if (!paramType) {
  16684     // missing news
  16685     va_end(pl);
  16686     return(NULL);
  16687   }
  16688   while (paramType) {
  16689     if (!olds) {
  16690       olds = paramType;
  16691     }
  16692     else if (!news) {
  16693       news = paramType;
  16694       smallJsont *r = icReplaceSmallJson(self, olds, news, 0);
  16695       if (!r) {
  16696         // replace error
  16697         va_end(pl);
  16698         return(NULL);
  16699       }
  16700       olds = NULL;
  16701       news = NULL;
  16702     }
  16703 
  16704     paramType = va_arg(pl, const char *);
  16705   }
  16706   va_end(pl);
  16707   return(self);
  16708 }
  16709 
  16710 
  16711 internal bool equalSmallJsonSmallArray(smallJsont *self, smallArrayt *array) {
  16712 
  16713   // sanity checks
  16714   if (self->topIsA != TOP_IS_ARRAY || !array) {
  16715     return(false);
  16716   }
  16717 
  16718   if (checkObjectTypes && array && !isOSmallArray(array)) {
  16719     return(false);
  16720   }
  16721 
  16722   if (!lenSmallJson(self) && !lenO(array)) {
  16723     return(true);
  16724   }
  16725   if (!lenSmallJson(self) || !lenO(array)) {
  16726     return(false);
  16727   }
  16728   if (lenSmallJson(self) != lenO(array)) {
  16729     return(false);
  16730   }
  16731 
  16732   // compare elements
  16733   char *es = NULL;
  16734   char *as = NULL;
  16735   enumerateSArray(self->topA, e, i) {
  16736     if (not e) {
  16737       if (not sArrayGetTiny(array->a, (uint32_t)i)) {
  16738         continue;
  16739       }
  16740       else {
  16741         return(false);
  16742     }
  16743       }
  16744     if ((e->type != sArrayGetTiny(array->a, (uint32_t)i)->type)) {
  16745       return(false);
  16746     }
  16747     else {
  16748       switch (e->type) {
  16749       // not needed always equal - case UNDEFINED:
  16750       case BOOL:
  16751         if (((sBoolt*)e)->value != ((sBoolt*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
  16752           return(false);
  16753         }
  16754         break;
  16755       // TODO case CONTAINER:
  16756       case DICT:
  16757         es = sToString(e);
  16758         as = sToString(sArrayGetTiny(array->a, (uint32_t)i));
  16759         if (!strEq(es, as)) {
  16760           free(es);
  16761           free(as);
  16762           return(false);
  16763         }
  16764         free(es);
  16765         free(as);
  16766         break;
  16767       case DOUBLE:
  16768         if (((sDoublet*)e)->value != ((sDoublet*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
  16769           return(false);
  16770         }
  16771         break;
  16772       case INT:
  16773         if (((sIntt*)e)->value != ((sIntt*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
  16774           return(false);
  16775         }
  16776         break;
  16777       case STRING:
  16778         if (!strEq(sStringGetTiny((sStringt*)e), sStringGetTiny((sStringt*)sArrayGetTiny(array->a, (uint32_t)i)))) {
  16779           return(false);
  16780         }
  16781         break;
  16782       case ARRAY:
  16783         es = sToString(e);
  16784         as = sToString(sArrayGetTiny(array->a, (uint32_t)i));
  16785         if (!strEq(es, as)) {
  16786           free(es);
  16787           free(as);
  16788           return(false);
  16789         }
  16790         free(es);
  16791         free(as);
  16792         break;
  16793       case BYTES:
  16794         if (((sBytest*)e)->count != ((sBytest*)sArrayGetTiny(array->a, (uint32_t)i))->count) {
  16795           return(false);
  16796         }
  16797         if (memcmp(&((sBytest*)e)->data, &((sBytest*)sArrayGetTiny(array->a, (uint32_t)i))->data, ((sBytest*)e)->count)) {
  16798           return(false);
  16799         }
  16800         break;
  16801       default:
  16802         logC("Unsupported object type!");
  16803       }
  16804   }
  16805     }
  16806 
  16807   return(true);
  16808 }
  16809 
  16810 bool equalSmallJsonArray(smallJsont *self, char ** p2) {
  16811 
  16812   // sanity checks
  16813   if (!lenSmallJson(self) && !listLengthS(p2)) {
  16814     // both arrays are empty
  16815     return(true);
  16816   }
  16817   if (self->topIsA != TOP_IS_ARRAY) {
  16818     return(false);
  16819   }
  16820 
  16821   if (!lenSmallJson(self) || !listLengthS(p2)) {
  16822     return(false);
  16823   }
  16824   if (lenSmallJson(self) != listLengthS(p2)) {
  16825     return(false);
  16826   }
  16827 
  16828   // compare elements
  16829   enumerateSArray(self->topA, e, i) {
  16830     if (not e) {
  16831       return(false);
  16832     }
  16833     if (e->type != STRING) {
  16834       return(false);
  16835     }
  16836     if (!strEq(sStringGetTiny((sStringt*)e), p2[i])) {
  16837       return(false);
  16838   }
  16839     }
  16840 
  16841   return(true);
  16842 }
  16843 
  16844 bool equalSmallJsonCArray(smallJsont *self, const char ** p2) {
  16845 
  16846   // sanity checks
  16847   if (!lenSmallJson(self) && !listLengthCS(p2)) {
  16848     // both arrays are empty
  16849     return(true);
  16850   }
  16851   if (self->topIsA != TOP_IS_ARRAY) {
  16852     return(false);
  16853   }
  16854 
  16855   if (!lenSmallJson(self) || !listLengthCS(p2)) {
  16856     return(false);
  16857   }
  16858   if (lenSmallJson(self) != listLengthCS(p2)) {
  16859     return(false);
  16860   }
  16861 
  16862   // compare elements
  16863   enumerateSArray(self->topA, e, i) {
  16864     if (not e) {
  16865       return(false);
  16866     }
  16867     if (e->type != STRING) {
  16868       return(false);
  16869     }
  16870     if (!strEq(sStringGetTiny((sStringt*)e), p2[i])) {
  16871       return(false);
  16872   }
  16873     }
  16874 
  16875   return(true);
  16876 }
  16877 
  16878 bool equalSmallJsonBase(smallJsont *self, baset* p2) {
  16879   char *s = NULL;
  16880   bool r;
  16881 
  16882   if (self->topIsA == SMALLJSON_IS_EMPTY || !p2) {
  16883     return(false);
  16884   }
  16885 
  16886   switch(self->topIsA) {
  16887     case TOP_IS_BOOL:
  16888       s = toStringO(p2);
  16889 
  16890       if (eqS(s, "true") || eqS(s, "TRUE")) {
  16891         free(s);
  16892         return(self->topB->value);
  16893       }
  16894       else if (eqS(s, "false") || eqS(s, "FALSE")) {
  16895         free(s);
  16896         return(!self->topB->value);
  16897       }
  16898       free(s);
  16899       break;
  16900     case TOP_IS_DOUBLE:
  16901       s = toStringO(p2);
  16902       if (isInt(s) || !isNumber(s)) {
  16903         free(s);
  16904         return(false);
  16905       }
  16906       double value = parseDouble(s);
  16907       if (self->topD->value == value) {
  16908         r = true;
  16909       }
  16910       else {
  16911         r = false;
  16912       }
  16913       free(s);
  16914       return(r);
  16915     case TOP_IS_INT:
  16916       s = toStringO(p2);
  16917       if (!isInt(s)) {
  16918         free(s);
  16919         return(false);
  16920       }
  16921       int64_t ivalue = parseInt(s);
  16922       if (self->topI->value == ivalue) {
  16923         r = true;
  16924       }
  16925       else {
  16926         r = false;
  16927       }
  16928       free(s);
  16929       return(r);
  16930     case TOP_IS_STRING:
  16931       s         = sStringGetTiny(self->topS);
  16932       char *p2s = toStringO(p2);
  16933 
  16934       r         = eqS(s, p2s);
  16935       free(p2s);
  16936       return(r);
  16937     case TOP_IS_DICT:
  16938       if (!isOType(p2, "smallDict")) {
  16939         return(false);
  16940       }
  16941       return(equalSmallJsonSmallDict(self, (smallDictt *) p2));
  16942     case TOP_IS_ARRAY:
  16943       if (!lenSmallJson(self)) {
  16944         return(false);
  16945       }
  16946 
  16947       if (!isOType(p2, "smallArray")) {
  16948         return(false);
  16949       }
  16950 
  16951       cast(smallArrayt *, arr, p2);
  16952 
  16953       return(equalSmallJsonSmallArray(self, arr));
  16954     default:
  16955       logC("Unsupported object type!");
  16956   }
  16957   return(false);
  16958 }
  16959 
  16960 internal bool equalSmallJsonCha(smallJsont* self, char p2) {
  16961 
  16962   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  16963     return(false);
  16964   }
  16965 
  16966   charToS(s, p2);
  16967 
  16968   switch(self->topIsA) {
  16969     case TOP_IS_INT:
  16970       if (!isInt(s)) {
  16971         return(false);
  16972       }
  16973       int64_t ivalue = parseInt(s);
  16974       return(self->topI->value == ivalue);;
  16975       break;
  16976     case TOP_IS_STRING:
  16977       if (lenSmallJson(self) != 1) {
  16978         return(false);
  16979       }
  16980       return(sStringGetTiny(self->topS)[0] == p2);;
  16981       break;
  16982     default:;
  16983       // return false
  16984   }
  16985   return(false);
  16986 }
  16987 
  16988 internal bool equalSmallJsonChar(smallJsont* self, const char * p2) {
  16989 
  16990   if (self->topIsA == SMALLJSON_IS_EMPTY || !p2) {
  16991     return(false);
  16992   }
  16993 
  16994   switch(self->topIsA) {
  16995     case TOP_IS_BOOL:
  16996       if (eqS(p2, "true") || eqS(p2, "TRUE")) {
  16997         return(self->topB->value);
  16998       }
  16999       else if (eqS(p2, "false") || eqS(p2, "FALSE")) {
  17000         return(!self->topB->value);
  17001       }
  17002       break;
  17003     case TOP_IS_DOUBLE:
  17004       if (isInt(p2) || !isNumber(p2)) {
  17005         return(false);
  17006       }
  17007       double value = parseDouble(p2);
  17008       return(self->topD->value == value);;
  17009     case TOP_IS_INT:
  17010       if (!isInt(p2)) {
  17011         return(false);
  17012       }
  17013       int64_t ivalue = parseInt(p2);
  17014       return(self->topI->value == ivalue);;
  17015     case TOP_IS_STRING:
  17016       if (lenSmallJson(self) != strlen(p2)) {
  17017         return(false);
  17018       }
  17019       return(strcmp(sStringGetTiny(self->topS),p2) == 0);;
  17020     default:;
  17021       // return false
  17022   }
  17023   return(false);
  17024 }
  17025 
  17026 internal bool equalSmallJsonBool(smallJsont* self, bool p2) {
  17027 
  17028   switch(self->topIsA) {
  17029     case TOP_IS_BOOL:
  17030       return(self->topB->value == p2);;
  17031     case TOP_IS_DOUBLE:
  17032       return(self->topD->value == p2);;
  17033     case TOP_IS_INT:
  17034       return(self->topI->value == p2);;
  17035     case TOP_IS_STRING:
  17036       ;char *s = sStringGetTiny(self->topS);
  17037       if (eqS(s, "true") || eqS(s, "TRUE")) {
  17038         return(p2);
  17039       }
  17040       else if (eqS(s, "false") || eqS(s, "FALSE")) {
  17041         return(!p2);
  17042       }
  17043       break;
  17044     default:;
  17045       // return false
  17046   }
  17047   return(false);
  17048 }
  17049 
  17050 internal bool equalSmallJsonDouble(smallJsont* self, double p2) {
  17051 
  17052   switch(self->topIsA) {
  17053     case TOP_IS_BOOL:
  17054       return(self->topB->value == p2);;
  17055     case TOP_IS_DOUBLE:
  17056       return(self->topD->value == p2);;
  17057     case TOP_IS_INT:
  17058       return(self->topI->value == p2);;
  17059     case TOP_IS_STRING:
  17060       ;char *s = sStringGetTiny(self->topS);
  17061       if (isInt(s) || !isNumber(s)) {
  17062         return(false);
  17063       }
  17064       double selfValue = parseDoubleSmallJson(self);
  17065       return(selfValue == p2);;
  17066     default:;
  17067       // return false
  17068   }
  17069   return(false);
  17070 }
  17071 
  17072 internal bool equalSmallJsonInt64(smallJsont* self, int64_t p2) {
  17073 
  17074   switch(self->topIsA) {
  17075     case TOP_IS_BOOL:
  17076       return(self->topB->value == p2);;
  17077     case TOP_IS_DOUBLE:
  17078       return(self->topD->value == p2);;
  17079     case TOP_IS_INT:
  17080       return(self->topI->value == p2);;
  17081     case TOP_IS_STRING:
  17082       ;char *s = sStringGetTiny(self->topS);
  17083       if (!isInt(s)) {
  17084         return(false);
  17085       }
  17086       int64_t selfValue = parseIntSmallJson(self);
  17087       return(selfValue == p2);;
  17088     default:;
  17089       // return false
  17090   }
  17091   return(false);
  17092 }
  17093 
  17094 internal bool equalSmallJsonInt32(smallJsont* self, int32_t p2) {
  17095 
  17096   switch(self->topIsA) {
  17097     case TOP_IS_BOOL:
  17098       return(self->topB->value == p2);;
  17099     case TOP_IS_DOUBLE:
  17100       return(self->topD->value == p2);;
  17101     case TOP_IS_INT:
  17102       return(self->topI->value == p2);;
  17103     case TOP_IS_STRING:
  17104       ;char *s = sStringGetTiny(self->topS);
  17105       if (!isInt(s)) {
  17106         return(false);
  17107       }
  17108       int64_t selfValue = parseIntSmallJson(self);
  17109       return(selfValue == p2);;
  17110     default:;
  17111       // return false
  17112   }
  17113   return(false);
  17114 }
  17115 
  17116 internal bool equalSmallJsonUint32(smallJsont* self, uint32_t p2) {
  17117 
  17118   switch(self->topIsA) {
  17119     case TOP_IS_BOOL:
  17120       return(self->topB->value == p2);;
  17121     case TOP_IS_DOUBLE:
  17122       return(self->topD->value == p2);;
  17123     case TOP_IS_INT:
  17124       return(self->topI->value == p2);;
  17125     case TOP_IS_STRING:
  17126       ;char *s = sStringGetTiny(self->topS);
  17127       if (!isInt(s)) {
  17128         return(false);
  17129       }
  17130       uint32_t selfValue = (uint32_t)parseIntSmallJson(self);
  17131       return(selfValue == p2);;
  17132     default:;
  17133       // return false
  17134   }
  17135   return(false);
  17136 }
  17137 
  17138 internal bool equalSmallJsonUint64(smallJsont* self, uint64_t p2) {
  17139 
  17140   switch(self->topIsA) {
  17141     case TOP_IS_BOOL:
  17142       return(self->topB->value == p2);;
  17143     case TOP_IS_DOUBLE:
  17144       return(self->topD->value == p2);;
  17145     case TOP_IS_INT:
  17146       return((uint64_t)self->topI->value == p2);;
  17147     case TOP_IS_STRING:
  17148       ;char *s = sStringGetTiny(self->topS);
  17149       if (!isInt(s)) {
  17150         return(false);
  17151       }
  17152       uint64_t selfValue = (uint64_t)parseIntSmallJson(self);
  17153       return(selfValue == p2);;
  17154     default:;
  17155       // return false
  17156   }
  17157   return(false);
  17158 }
  17159 
  17160 internal bool equalSmallJsonSmallBool(smallJsont* self, smallBoolt* p2) {
  17161 
  17162   if (checkObjectTypes && p2 && !isOSmallBool(p2)) {
  17163     return(false);
  17164   }
  17165 
  17166   if (!p2 || !p2->value) {
  17167     return(false);
  17168   }
  17169 
  17170   return(equalSmallJsonBool(self, p2->value->value));
  17171 }
  17172 
  17173 internal bool equalSmallJsonSmallBytes(smallJsont* self, smallBytest* p2) {
  17174   char *s = NULL;
  17175   bool has0;
  17176 
  17177   if (checkObjectTypes && p2 && !isOSmallBytes(p2)) {
  17178     return(false);
  17179   }
  17180 
  17181   if (self->topIsA == SMALLJSON_IS_EMPTY || !p2 || !p2->B) {
  17182     return(false);
  17183   }
  17184 
  17185   switch(self->topIsA) {
  17186     case TOP_IS_BOOL:
  17187       if (equalSO(p2, "true") || equalSO(p2, "TRUE")) {
  17188         return(self->topB->value);
  17189       }
  17190       else if (equalSO(p2, "false") || equalSO(p2, "FALSE")) {
  17191         return(!self->topB->value);
  17192       }
  17193       break;
  17194     case TOP_IS_DOUBLE:
  17195       s = sBytesGet(p2->B);
  17196       has0 = false;
  17197       rangeDown(i, p2->B->count) {
  17198         if (s[i] == 0) {
  17199           has0 = true;
  17200           break;
  17201         }
  17202       }
  17203       if (!has0) {
  17204         return(false);
  17205       }
  17206       if (isInt(s) || !isNumber(s)) {
  17207         return(false);
  17208       }
  17209       double p2Value = parseDouble(s);
  17210       return(p2Value == self->topD->value);;
  17211     case TOP_IS_INT:
  17212       s = sBytesGet(p2->B);
  17213       has0 = false;
  17214       rangeDown(i, p2->B->count) {
  17215         if (s[i] == 0) {
  17216           has0 = true;
  17217           break;
  17218         }
  17219       }
  17220       if (!has0) {
  17221         return(false);
  17222       }
  17223       if (!isInt(s)) {
  17224         return(false);
  17225       }
  17226       int64_t ivalue = parseInt(s);
  17227       return(self->topI->value == ivalue);;
  17228     case TOP_IS_STRING:
  17229       if ((lenSmallJson(self)+1) != p2->B->count) {
  17230         return(false);
  17231       }
  17232       return(equalSO(p2, sStringGetTiny(self->topS)));
  17233       break;
  17234     default:;
  17235       // return false
  17236   }
  17237   return(false);
  17238 }
  17239 
  17240 internal bool equalSmallJsonSmallDouble(smallJsont* self, smallDoublet* p2) {
  17241 
  17242   if (checkObjectTypes && p2 && !isOSmallDouble(p2)) {
  17243     return(false);
  17244   }
  17245 
  17246   if (!p2 || !p2->value) {
  17247     return(false);
  17248   }
  17249 
  17250   switch(self->topIsA) {
  17251     case TOP_IS_BOOL:
  17252       return(self->topB->value == p2->value->value);;
  17253     case TOP_IS_DOUBLE:
  17254       return(self->topD->value == p2->value->value);;
  17255     case TOP_IS_INT:
  17256       return(self->topI->value == p2->value->value);;
  17257     case TOP_IS_STRING:
  17258       ;char *s = sStringGetTiny(self->topS);
  17259       if (isInt(s) || !isNumber(s)) {
  17260         return(false);
  17261       }
  17262       double selfValue = parseDoubleSmallJson(self);
  17263       return(selfValue == p2->value->value);;
  17264     default:;
  17265       // return false
  17266   }
  17267   return(false);
  17268 }
  17269 
  17270 internal bool equalSmallJsonSmallInt(smallJsont* self, smallIntt* p2) {
  17271 
  17272   if (checkObjectTypes && p2 && !isOSmallInt(p2)) {
  17273     return(false);
  17274   }
  17275 
  17276   if (!p2 || !p2->value) {
  17277     return(false);
  17278   }
  17279 
  17280   switch(self->topIsA) {
  17281     case TOP_IS_BOOL:
  17282       return(self->topB->value == p2->value->value);;
  17283     case TOP_IS_DOUBLE:
  17284       return(self->topD->value == p2->value->value);;
  17285     case TOP_IS_INT:
  17286       return(self->topI->value == p2->value->value);;
  17287     case TOP_IS_STRING:
  17288       ;char *s = sStringGetTiny(self->topS);
  17289       if (!isInt(s)) {
  17290         return(false);
  17291       }
  17292       int64_t selfValue = parseIntSmallJson(self);
  17293       return(selfValue == p2->value->value);;
  17294     default:;
  17295       // return false
  17296   }
  17297   return(false);
  17298 }
  17299 
  17300 internal bool equalSmallJsonSmallJson(smallJsont* self, smallJsont* p2) {
  17301 
  17302   if (checkObjectTypes && p2 && !isOSmallJson(p2)) {
  17303     return(false);
  17304   }
  17305 
  17306   if (!p2) {
  17307     return(false);
  17308   }
  17309 
  17310   baset *O = NULL;
  17311   bool   r = false;
  17312   switch(p2->topIsA){
  17313     case SMALLJSON_IS_EMPTY:
  17314       return(false);
  17315     case TOP_IS_UNDEFINED:
  17316       return(self->topIsA == TOP_IS_UNDEFINED);;
  17317     case TOP_IS_BOOL:
  17318       O = getTopSmallJson(p2);
  17319       r = equalSmallJsonSmallBool(self, (smallBoolt*)O);;
  17320       finishO(O);
  17321       break;
  17322     case TOP_IS_DOUBLE:
  17323       O = getTopSmallJson(p2);
  17324       r = equalSmallJsonSmallDouble(self, (smallDoublet*)O);;
  17325       finishO(O);
  17326       break;
  17327     case TOP_IS_INT:
  17328       O = getTopSmallJson(p2);
  17329       r = equalSmallJsonSmallInt(self, (smallIntt*)O);;
  17330       finishO(O);
  17331       break;
  17332     case TOP_IS_STRING:
  17333       O = getTopSmallJson(p2);
  17334       r = equalSmallJsonSmallString(self, (smallStringt*)O);;
  17335       finishO(O);
  17336       break;
  17337     case TOP_IS_DICT:
  17338       O = getTopSmallJson(p2);
  17339       r = equalSmallJsonSmallDict(self, (smallDictt*)O);;
  17340       finishO(O);
  17341       break;
  17342     case TOP_IS_ARRAY:
  17343       O = getTopSmallJson(p2);
  17344       r = equalSmallJsonSmallArray(self, (smallArrayt*)O);;
  17345       finishO(O);
  17346       break;
  17347     default:;
  17348       // return false
  17349   }
  17350   return(r);
  17351 }
  17352 
  17353 internal bool equalSmallJsonSmallString(smallJsont* self, smallStringt* p2) {
  17354   char *s = NULL;
  17355 
  17356   if (!p2) {
  17357     return(false);
  17358   }
  17359 
  17360   if (checkObjectTypes && p2 && !isOSmallString(p2)) {
  17361     return(false);
  17362   }
  17363 
  17364   if (self->topIsA == SMALLJSON_IS_EMPTY || !p2->data) {
  17365     return(false);
  17366   }
  17367 
  17368   switch(self->topIsA) {
  17369     case TOP_IS_BOOL:
  17370       s = sStringGetTiny(p2->data);
  17371       if (strEq(s, "true") || strEq(s, "TRUE")) {
  17372         return(self->topB->value);
  17373       }
  17374       else if (strEq(s, "false") || strEq(s, "FALSE")) {
  17375         return(!self->topB->value);
  17376       }
  17377       break;
  17378     case TOP_IS_DOUBLE:
  17379       if (isIntO(p2) || !isNumberO(p2)) {
  17380         return(false);
  17381       }
  17382       double value = parseDoubleO(p2);
  17383       return(self->topD->value == value);;
  17384     case TOP_IS_INT:
  17385       if (!isIntO(p2)) {
  17386         return(false);
  17387       }
  17388       int64_t ivalue = parseIntO(p2);
  17389       return(self->topI->value == ivalue);;
  17390     case TOP_IS_STRING:
  17391       if (lenSmallJson(self) != p2->_len) {
  17392         return(false);
  17393       }
  17394       return(strcmp(sStringGetTiny(self->topS),sStringGetTiny(p2->data)) == 0);;
  17395       break;
  17396     default:;
  17397       // return false
  17398   }
  17399   return(false);
  17400 }
  17401 
  17402 internal bool equalSmallJsonSmallDict(smallJsont* self, smallDictt* p2) {
  17403 
  17404   if (self->topIsA != TOP_IS_DICT || !self->top || !p2 || !p2->d) {
  17405     return(false);
  17406   }
  17407 
  17408   if (checkObjectTypes && !isOSmallDict(p2)) {
  17409     return(false);
  17410   }
  17411 
  17412   //TODO - sort keys, use binary search
  17413   forEachSDict(self->top, e) {
  17414     if (e->key) {
  17415       bool foundK = false;
  17416       forEachSDict(p2->d, E) {
  17417         if (E->key) {
  17418           if (eqS(e->key, E->key)) {
  17419             foundK = true;
  17420             char *s = sToString(e->data);
  17421             char *S = sToString(E->data);
  17422             if (!eqS(s, S)) {
  17423               freeManyS(s, S);
  17424               return(false);
  17425             }
  17426             freeManyS(s, S);
  17427             break;
  17428       }
  17429         }
  17430           }
  17431       if (!foundK) {
  17432         return(false);
  17433   }
  17434     }
  17435       }
  17436   return(true);
  17437 }
  17438 
  17439 
  17440 internal bool icEqualSmallJsonSmallArray(smallJsont *self, smallArrayt *array) {
  17441 
  17442   // sanity checks
  17443   if (self->topIsA != TOP_IS_ARRAY || !array) {
  17444     return(false);
  17445   }
  17446 
  17447   if (checkObjectTypes && array && !isOSmallArray(array)) {
  17448     return(false);
  17449   }
  17450 
  17451   if (!lenSmallJson(self) && !lenO(array)) {
  17452     return(true);
  17453   }
  17454   if (!lenSmallJson(self) || !lenO(array)) {
  17455     return(false);
  17456   }
  17457   if (lenSmallJson(self) != lenO(array)) {
  17458     return(false);
  17459   }
  17460 
  17461   // compare elements
  17462   char *es = NULL;
  17463   char *as = NULL;
  17464   enumerateSArray(self->topA, e, i) {
  17465     if (not e) {
  17466       if (not sArrayGetTiny(array->a, (uint32_t)i)) {
  17467         continue;
  17468       }
  17469       else {
  17470         return(false);
  17471     }
  17472       }
  17473     if ((e->type != sArrayGetTiny(array->a, (uint32_t)i)->type)) {
  17474       return(false);
  17475     }
  17476     else {
  17477       switch (e->type) {
  17478       // not needed always equal - case UNDEFINED:
  17479       case BOOL:
  17480         if (((sBoolt*)e)->value != ((sBoolt*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
  17481           return(false);
  17482         }
  17483         break;
  17484       // TODO case CONTAINER:
  17485       case DICT:
  17486         es = sToString(e);
  17487         as = sToString(sArrayGetTiny(array->a, (uint32_t)i));
  17488         if (!icEqS(es, as)) {
  17489           free(es);
  17490           free(as);
  17491           return(false);
  17492         }
  17493         free(es);
  17494         free(as);
  17495         break;
  17496       case DOUBLE:
  17497         if (((sDoublet*)e)->value != ((sDoublet*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
  17498           return(false);
  17499         }
  17500         break;
  17501       case INT:
  17502         if (((sIntt*)e)->value != ((sIntt*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
  17503           return(false);
  17504         }
  17505         break;
  17506       case STRING:
  17507         if (!icEqS(sStringGetTiny((sStringt*)e), sStringGetTiny((sStringt*)sArrayGetTiny(array->a, (uint32_t)i)))) {
  17508           return(false);
  17509         }
  17510         break;
  17511       case ARRAY:
  17512         es = sToString(e);
  17513         as = sToString(sArrayGetTiny(array->a, (uint32_t)i));
  17514         if (!icEqS(es, as)) {
  17515           free(es);
  17516           free(as);
  17517           return(false);
  17518         }
  17519         free(es);
  17520         free(as);
  17521         break;
  17522       case BYTES:
  17523         if (((sBytest*)e)->count != ((sBytest*)sArrayGetTiny(array->a, (uint32_t)i))->count) {
  17524           return(false);
  17525         }
  17526         if (memcmp(&((sBytest*)e)->data, &((sBytest*)sArrayGetTiny(array->a, (uint32_t)i))->data, ((sBytest*)e)->count)) {
  17527           return(false);
  17528         }
  17529         break;
  17530       default:
  17531         logC("Unsupported object type!");
  17532       }
  17533   }
  17534     }
  17535 
  17536   return(true);
  17537 }
  17538 
  17539 bool icEqualSmallJsonArray(smallJsont *self, char ** p2) {
  17540 
  17541   // sanity checks
  17542   if (self->topIsA != TOP_IS_ARRAY) {
  17543     return(false);
  17544   }
  17545   if (!lenSmallJson(self) && !listLengthS(p2)) {
  17546     // both arrays are empty
  17547     return(true);
  17548   }
  17549   if (!lenSmallJson(self) || !listLengthS(p2)) {
  17550     return(false);
  17551   }
  17552   if (lenSmallJson(self) != listLengthS(p2)) {
  17553     return(false);
  17554   }
  17555 
  17556   // compare elements
  17557   enumerateSArray(self->topA, e, i) {
  17558     if (not e) {
  17559       return(false);
  17560     }
  17561     if (e->type != STRING) {
  17562       return(false);
  17563     }
  17564     if (!icEqS(sStringGetTiny((sStringt*)e), p2[i])) {
  17565       return(false);
  17566   }
  17567     }
  17568 
  17569   return(true);
  17570 }
  17571 
  17572 bool icEqualSmallJsonCArray(smallJsont *self, const char ** p2) {
  17573 
  17574   // sanity checks
  17575   if (self->topIsA != TOP_IS_ARRAY) {
  17576     return(false);
  17577   }
  17578   if (!lenSmallJson(self) && !listLengthCS(p2)) {
  17579     // both arrays are empty
  17580     return(true);
  17581   }
  17582   if (!lenSmallJson(self) || !listLengthCS(p2)) {
  17583     return(false);
  17584   }
  17585   if (lenSmallJson(self) != listLengthCS(p2)) {
  17586     return(false);
  17587   }
  17588 
  17589   // compare elements
  17590   enumerateSArray(self->topA, e, i) {
  17591     if (not e) {
  17592       return(false);
  17593     }
  17594     if (e->type != STRING) {
  17595       return(false);
  17596     }
  17597     if (!icEqS(sStringGetTiny((sStringt*)e), p2[i])) {
  17598       return(false);
  17599   }
  17600     }
  17601 
  17602   return(true);
  17603 }
  17604 
  17605 bool icEqualSmallJsonBase(smallJsont *self, baset* p2) {
  17606 
  17607   if (!lenSmallJson(self) || !p2) {
  17608     return(false);
  17609   }
  17610 
  17611   switch(self->topIsA) {
  17612     case TOP_IS_DICT:
  17613       if (!isOType(p2, "smallDict")) {
  17614         return(false);
  17615       }
  17616       return(icEqualSmallJsonSmallDict(self, (smallDictt *) p2));
  17617     case TOP_IS_ARRAY:
  17618       if (!isOType(p2, "smallArray")) {
  17619         return(false);
  17620       }
  17621       cast(smallArrayt *, arr, p2);
  17622       return(icEqualSmallJsonSmallArray(self, arr));
  17623     case TOP_IS_STRING:
  17624       if (!isOType(p2, "smallString")) {
  17625         return(false);
  17626       }
  17627       cast(smallStringt *, so, p2);
  17628       return(icEqualSmallJsonSmallString(self, so));
  17629     default:
  17630       return(equalSmallJsonBase(self, p2));
  17631   }
  17632 }
  17633 
  17634 
  17635 internal bool icEqualSmallJsonSmallDict(smallJsont* self, smallDictt* p2) {
  17636 
  17637   if (self->topIsA != TOP_IS_DICT || !self->top || !p2 || !p2->d) {
  17638     return(false);
  17639   }
  17640 
  17641   if (checkObjectTypes && !isOSmallDict(p2)) {
  17642     return(false);
  17643   }
  17644 
  17645   //TODO - sort keys, use binary search
  17646   forEachSDict(self->top, e) {
  17647     if (e->key) {
  17648       bool foundK = false;
  17649       forEachSDict(p2->d, E) {
  17650         if (E->key) {
  17651           if (eqS(e->key, E->key)) {
  17652             foundK = true;
  17653             char *s = sToString(e->data);
  17654             char *S = sToString(E->data);
  17655             if (!icEqS(s, S)) {
  17656               freeManyS(s, S);
  17657               return(false);
  17658             }
  17659             freeManyS(s, S);
  17660             break;
  17661       }
  17662         }
  17663           }
  17664       if (!foundK) {
  17665         return(false);
  17666   }
  17667     }
  17668       }
  17669   return(true);
  17670 }
  17671 
  17672 internal bool icEqualSmallJsonSmallJson(smallJsont *self, smallJsont *string) {
  17673 
  17674   if (self->topIsA != TOP_IS_STRING || !string) {
  17675     return(false);
  17676   }
  17677 
  17678   if (checkObjectTypes && !isOSmallJson(string)) {
  17679     return(false);
  17680   }
  17681 
  17682   if (string->topIsA != TOP_IS_STRING || lenSmallJson(self) != lenO(string)) {
  17683     return(false);
  17684   }
  17685 
  17686   return(strcasecmp(sStringGetTiny(self->topS),sStringGetTiny(string->topS)) == 0);;
  17687 }
  17688 
  17689 internal bool icEqualSmallJsonSmallString(smallJsont *self, smallStringt *string) {
  17690 
  17691   if (self->topIsA != TOP_IS_STRING || !string) {
  17692     return(false);
  17693   }
  17694 
  17695   if (checkObjectTypes && !isOSmallString(string)) {
  17696     return(false);
  17697   }
  17698 
  17699   if (!string->data) {
  17700     return(false);
  17701   }
  17702 
  17703   if (lenSmallJson(self) != string->_len) {
  17704     return(false);
  17705   }
  17706 
  17707   return(strcasecmp(sStringGetTiny(self->topS),sStringGetTiny(string->data)) == 0);;
  17708 }
  17709 
  17710 internal bool icEqualSSmallJson(smallJsont *self, const char *string) {
  17711 
  17712   if (self->topIsA != TOP_IS_STRING || !string) {
  17713     return(false);
  17714   }
  17715 
  17716   if (lenSmallJson(self) != strlen(string)) {
  17717     return(false);
  17718   }
  17719 
  17720   return(strcasecmp(sStringGetTiny(self->topS),string) == 0);;
  17721 }
  17722 
  17723 internal bool icEqualCharSmallJson(smallJsont *self, char c) {
  17724 
  17725   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  17726     return(false);
  17727   }
  17728 
  17729   charToS(s, c);
  17730 
  17731   switch(self->topIsA) {
  17732     case TOP_IS_INT:
  17733       if (!isInt(s)) {
  17734         return(false);
  17735       }
  17736       int64_t ivalue = parseInt(s);
  17737       return(self->topI->value == ivalue);;
  17738       break;
  17739     case TOP_IS_STRING:
  17740       return(icEqualSSmallJson(self, s));
  17741     default:;
  17742       // return false
  17743   }
  17744   return(false);
  17745 }
  17746 
  17747 internal bool equalISSmallJson(smallJsont *self, const char *string, int64_t index) {
  17748 
  17749   if (self->topIsA != TOP_IS_STRING || !self->topS || !string) {
  17750     return(false);
  17751   }
  17752 
  17753   if (index >= (int64_t)lenSmallJson(self) && lenSmallJson(self)) {
  17754     return(false);
  17755   }
  17756   if (index < -(int64_t)lenSmallJson(self)) {
  17757     return(false);
  17758   }
  17759   if (index < 0) {
  17760     index = (int64_t)lenSmallJson(self) + index;
  17761   }
  17762 
  17763   if (index > (int64_t)(lenSmallJson(self) - strlen(string))) {
  17764     return(false);
  17765   }
  17766 
  17767   if (!string[0] && !lenSmallJson(self)) {
  17768     return(true);
  17769   }
  17770 
  17771   if (!string[0]) {
  17772     return(false);
  17773   }
  17774 
  17775   return(strncmp(sStringGetTiny(self->topS) + index, string, strlen(string)) == 0);;
  17776 }
  17777 
  17778 internal bool equalICharSmallJson(smallJsont *self, char c, int64_t index) {
  17779 
  17780   charToS(s, c);
  17781   return(equalISSmallJson(self, s, index));
  17782 }
  17783 
  17784 internal bool equalIJsonSmallJson(smallJsont *self, smallJsont *string, int64_t index) {
  17785 
  17786   if (!string) {
  17787     return(false);
  17788   }
  17789 
  17790   if (checkObjectTypes && !isOSmallJson(string)) {
  17791     return(false);
  17792   }
  17793 
  17794   if (string->topIsA != TOP_IS_STRING) {
  17795     return(false);
  17796   }
  17797 
  17798   return(equalISSmallJson(self, sjGet(string), index));
  17799 }
  17800 
  17801 internal bool equalISmallStringSmallJson(smallJsont *self, smallStringt *string, int64_t index) {
  17802 
  17803   if (!string) {
  17804     return(false);
  17805   }
  17806 
  17807   if (checkObjectTypes && !isOSmallString(string)) {
  17808     return(false);
  17809   }
  17810 
  17811   return(equalISSmallJson(self, ssGet(string), index));
  17812 }
  17813 
  17814 internal bool startsWithSSmallJson(smallJsont *self, const char *string) {
  17815 
  17816   if (!self->topS || !string) {
  17817     return(false);
  17818   }
  17819 
  17820   return(strncmp(sStringGetTiny(self->topS), string, strlen(string)) == 0);;
  17821 }
  17822 
  17823 internal bool startsWithCharSmallJson(smallJsont *self, char c) {
  17824 
  17825   if (!self->topS) {
  17826     return(false);
  17827   }
  17828 
  17829   return(sStringGetTiny(self->topS)[0] == c);;
  17830 }
  17831 
  17832 internal bool startsWithSmallStringSmallJson(smallJsont *self, smallStringt *string) {
  17833 
  17834   if (!string) {
  17835     return(false);
  17836   }
  17837 
  17838   if (checkObjectTypes && !isOSmallString(string)) {
  17839     return(false);
  17840   }
  17841 
  17842   return(startsWithSSmallJson(self, ssGet(string)));
  17843 }
  17844 
  17845 internal bool startsWithJsonSmallJson(smallJsont *self, smallJsont *string) {
  17846 
  17847   if (!string) {
  17848     return(false);
  17849   }
  17850 
  17851   if (checkObjectTypes && !isOSmallJson(string)) {
  17852     return(false);
  17853   }
  17854 
  17855   if (string->topIsA != TOP_IS_STRING) {
  17856     return(false);
  17857   }
  17858 
  17859   return(startsWithSSmallJson(self, sjGet(string)));
  17860 }
  17861 
  17862 internal bool endsWithSSmallJson(smallJsont *self, const char *string) {
  17863 
  17864   if (self->topIsA != TOP_IS_STRING || !self->topS || !string) {
  17865     return(false);
  17866   }
  17867 
  17868   if (lenSmallJson(self) < strlen(string)) {
  17869     return(false);
  17870   }
  17871   return(strcmp(sStringGetTiny(self->topS) + lenSmallJson(self) - strlen(string), string) == 0);;
  17872 }
  17873 
  17874 internal bool endsWithCharSmallJson(smallJsont *self, char c) {
  17875 
  17876   if (!self->topS) {
  17877     return(false);
  17878   }
  17879 
  17880   if (!lenSmallJson(self) && !c) {
  17881     // self is empty and c is 0
  17882     return(true);
  17883   }
  17884   if (!lenSmallJson(self)) {
  17885     return(false);
  17886   }
  17887 
  17888   return(*(sStringGetTiny(self->topS) + lenSmallJson(self)-1) == c);;
  17889 }
  17890 
  17891 internal bool endsWithSmallStringSmallJson(smallJsont *self, smallStringt *string) {
  17892 
  17893   if (!string) {
  17894     return(false);
  17895   }
  17896 
  17897   if (checkObjectTypes && !isOSmallString(string)) {
  17898     return(false);
  17899   }
  17900 
  17901   return(endsWithSSmallJson(self, ssGet(string)));
  17902 }
  17903 
  17904 internal bool endsWithJsonSmallJson(smallJsont *self, smallJsont *string) {
  17905 
  17906   if (!string) {
  17907     return(false);
  17908   }
  17909 
  17910   if (checkObjectTypes && !isOSmallJson(string)) {
  17911     return(false);
  17912   }
  17913 
  17914   if (string->topIsA != TOP_IS_STRING) {
  17915     return(false);
  17916   }
  17917 
  17918   return(endsWithSSmallJson(self, sjGet(string)));
  17919 }
  17920 
  17921 internal ssize_t countSSmallJson(smallJsont *self, const char *string) {
  17922 
  17923   if (self->topIsA != TOP_IS_STRING || !self->topS || !string || !string[0]) {
  17924     return(-1);
  17925   }
  17926 
  17927   ssize_t r  = 0;
  17928   size_t len = strlen(string);
  17929   char *s    = sStringGetTiny(self->topS);
  17930 
  17931   while (s != NULL) {
  17932     s = strstr(s, string);
  17933     if (s != NULL) {
  17934       r++;
  17935       s += len;
  17936     }
  17937     else {
  17938       break;
  17939   }
  17940     }
  17941 
  17942   return(r);
  17943 }
  17944 
  17945 internal ssize_t countCharSmallJson(smallJsont *self, char c) {
  17946 
  17947   charToS(s, c);
  17948   return(countSSmallJson(self, s));
  17949 }
  17950 
  17951 internal ssize_t countSmallStringSmallJson(smallJsont *self, smallStringt *string) {
  17952 
  17953   if (!string) {
  17954     return(-1);
  17955   }
  17956 
  17957   if (checkObjectTypes && !isOSmallString(string)) {
  17958     return(-1);
  17959   }
  17960 
  17961   return(countSSmallJson(self, ssGet(string)));
  17962 }
  17963 
  17964 internal ssize_t countJsonSmallJson(smallJsont *self, smallJsont *string) {
  17965 
  17966   if (!string) {
  17967     return(-1);
  17968   }
  17969 
  17970   if (checkObjectTypes && !isOSmallJson(string)) {
  17971     return(-1);
  17972   }
  17973 
  17974   if (string->topIsA != TOP_IS_STRING) {
  17975     return(-1);
  17976   }
  17977 
  17978   return(countSSmallJson(self, sjGet(string)));
  17979 }
  17980 
  17981 internal bool icStartsWithSSmallJson(smallJsont *self, const char *string) {
  17982 
  17983   if (self->topIsA != TOP_IS_STRING || !self->topS || !string) {
  17984     return(false);
  17985   }
  17986 
  17987   return(strncasecmp(sStringGetTiny(self->topS), string, strlen(string)) == 0);;
  17988 }
  17989 
  17990 internal bool icStartsWithCharSmallJson(smallJsont *self, char c) {
  17991 
  17992   if (!self->topS) {
  17993     return(false);
  17994   }
  17995 
  17996   return(toupper(sStringGetTiny(self->topS)[0]) == toupper(c));;
  17997 }
  17998 
  17999 internal bool icStartsWithSmallStringSmallJson(smallJsont *self, smallStringt *string) {
  18000 
  18001   if (!string) {
  18002     return(false);
  18003   }
  18004 
  18005   if (checkObjectTypes && !isOSmallString(string)) {
  18006     return(false);
  18007   }
  18008 
  18009   return(icStartsWithSSmallJson(self, ssGet(string)));
  18010 }
  18011 
  18012 internal bool icStartsWithJsonSmallJson(smallJsont *self, smallJsont *string) {
  18013 
  18014   if (!string) {
  18015     return(false);
  18016   }
  18017 
  18018   if (checkObjectTypes && !isOSmallJson(string)) {
  18019     return(false);
  18020   }
  18021 
  18022   if (string->topIsA != TOP_IS_STRING) {
  18023     return(false);
  18024   }
  18025 
  18026   return(icStartsWithSSmallJson(self, sjGet(string)));
  18027 }
  18028 
  18029 internal bool icEndsWithSSmallJson(smallJsont *self, const char *string) {
  18030 
  18031   if (self->topIsA != TOP_IS_STRING || !self->topS || !string) {
  18032     return(false);
  18033   }
  18034 
  18035   if (lenSmallJson(self) < strlen(string)) {
  18036     return(false);
  18037   }
  18038   return(strcasecmp(sStringGetTiny(self->topS) + lenSmallJson(self) - strlen(string), string) == 0);;
  18039 }
  18040 
  18041 internal bool icEndsWithCharSmallJson(smallJsont *self, char c) {
  18042 
  18043   if (!self->topS) {
  18044     return(false);
  18045   }
  18046 
  18047   if (!lenSmallJson(self) && !c) {
  18048     // self is empty and c is 0
  18049     return(true);
  18050   }
  18051   if (!lenSmallJson(self)) {
  18052     return(false);
  18053   }
  18054 
  18055   return(toupper(*(sStringGetTiny(self->topS) + lenSmallJson(self)-1)) == toupper(c));;
  18056 }
  18057 
  18058 internal bool icEndsWithSmallStringSmallJson(smallJsont *self, smallStringt *string) {
  18059 
  18060   if (!string) {
  18061     return(false);
  18062   }
  18063 
  18064   if (checkObjectTypes && !isOSmallString(string)) {
  18065     return(false);
  18066   }
  18067 
  18068   return(icEndsWithSSmallJson(self, ssGet(string)));
  18069 }
  18070 
  18071 internal bool icEndsWithJsonSmallJson(smallJsont *self, smallJsont *string) {
  18072 
  18073   if (!string) {
  18074     return(false);
  18075   }
  18076 
  18077   if (checkObjectTypes && !isOSmallJson(string)) {
  18078     return(false);
  18079   }
  18080 
  18081   if (string->topIsA != TOP_IS_STRING) {
  18082     return(false);
  18083   }
  18084 
  18085   return(icEndsWithSSmallJson(self, sjGet(string)));
  18086 }
  18087 
  18088 internal ssize_t icCountSSmallJson(smallJsont *self, const char *string) {
  18089 
  18090   if (self->topIsA != TOP_IS_STRING || !self->topS || !string || !string[0]) {
  18091     return(-1);
  18092   }
  18093 
  18094   ssize_t r  = 0;
  18095   size_t len = strlen(string);
  18096   char *s    = sStringGetTiny(self->topS);
  18097 
  18098   while (s != NULL) {
  18099     s = strcasestr(s, string);
  18100     if (s != NULL) {
  18101       r++;
  18102       s += len;
  18103     }
  18104     else {
  18105       break;
  18106   }
  18107     }
  18108 
  18109   return(r);
  18110 }
  18111 
  18112 internal ssize_t icCountCharSmallJson(smallJsont *self, char c) {
  18113 
  18114   charToS(s, c);
  18115   return(icCountSSmallJson(self, s));
  18116 }
  18117 
  18118 internal ssize_t icCountSmallStringSmallJson(smallJsont *self, smallStringt *string) {
  18119 
  18120   if (!string) {
  18121     return(-1);
  18122   }
  18123 
  18124   if (checkObjectTypes && !isOSmallString(string)) {
  18125     return(-1);
  18126   }
  18127 
  18128   return(icCountSSmallJson(self, ssGet(string)));
  18129 }
  18130 
  18131 internal ssize_t icCountJsonSmallJson(smallJsont *self, smallJsont *string) {
  18132 
  18133   if (!string) {
  18134     return(-1);
  18135   }
  18136 
  18137   if (checkObjectTypes && !isOSmallJson(string)) {
  18138     return(-1);
  18139   }
  18140 
  18141   if (string->topIsA != TOP_IS_STRING) {
  18142     return(-1);
  18143   }
  18144 
  18145   return(icCountSSmallJson(self, sjGet(string)));
  18146 }
  18147 
  18148 internal bool isNumberSmallJson(smallJsont *self) {
  18149 
  18150   if (self->topIsA != TOP_IS_STRING || !self->topS || !lenSmallJson(self)) {
  18151     return(false);
  18152   }
  18153 
  18154   char *string = sStringGetTiny(self->topS);
  18155   // . not allowed in first position
  18156   // first position can be digit, '.' or '-' but not "-" and not "."
  18157   if (!isdigit(*string) && (*string != '-') && (*string != '.')) {
  18158     return(false);
  18159   }
  18160 
  18161   // save pointer to first char to verify if there is a leader . and an exponent
  18162   const char *firstChar = string;
  18163   string++;
  18164 
  18165   bool r        = false;
  18166   int dots      = 0;
  18167   int exponents = 0;
  18168   if (*(string-1) == '.') {
  18169     // count first '.'
  18170     dots++;
  18171   }
  18172   while ((isdigit(*string) || (*string == '.') || (*string == 'e') || (*string == 'E') || (((*string == '-') || (*string == '+')) && ((*(string-1) == 'E') || (*(string-1) == 'e')))) && *string != 0) {
  18173     if (*string == '.') {
  18174       dots++;
  18175       if (*firstChar == '-') {
  18176         // -.234 allowed
  18177         firstChar = string;
  18178       }
  18179       if ((dots > 1) || (exponents > 0)) {
  18180         // only one '.' allowed but not after exponent
  18181         break;
  18182     }
  18183       }
  18184     if ((*string == 'e') || (*string == 'E')) {
  18185       exponents++;
  18186       if ((exponents > 1) || (*firstChar == '.')) {
  18187         // only one 'e' or 'E' allowed
  18188         break;
  18189     }
  18190       }
  18191     string++;
  18192   }
  18193 
  18194   // strings ending with '.', '-', 'e' and 'E' are not numbers
  18195   if ((*string == 0) && (*(string-1) != '.') && (*(string-1) != '-') && (*(string-1) != 'e') && (*(string-1) != 'E')) {
  18196     r = true;
  18197   }
  18198   return(r);
  18199 }
  18200 
  18201 internal bool isIntSmallJson(smallJsont *self) {
  18202 
  18203   if (self->topIsA != TOP_IS_STRING || !self->topS || !lenSmallJson(self)) {
  18204     return(false);
  18205   }
  18206 
  18207   char *string = sStringGetTiny(self->topS);
  18208 
  18209   // . not allowed in first position
  18210   // first position can be digit or - but not "-"
  18211   if (!isdigit(*string) && (*string != '-')) {
  18212     return(false);
  18213   }
  18214   string++;
  18215 
  18216   bool r        = false;
  18217   while (isdigit(*string) && *string != 0) {
  18218     string++;
  18219   }
  18220 
  18221   // strings ending with '-' are not integers
  18222   if ((*string == 0) && (*(string-1) != '-')) {
  18223     r = true;
  18224   }
  18225   return(r);
  18226 }
  18227 
  18228 
  18229 internal int64_t parseIntSmallJson(smallJsont *self) {
  18230 
  18231   if (self->topIsA != TOP_IS_STRING || !lenSmallJson(self)) {
  18232     return(0);
  18233   }
  18234 
  18235   char *string = sStringGetTiny(self->topS);
  18236   while (!isdigit(*string) && *string != '-' && *string != 0) {
  18237     string++;
  18238   }
  18239   int64_t r = strtoll(string, NULL, 10);
  18240   if (r == INT64_MAX || r == INT64_MIN) {
  18241     pStrError("parseInt error");
  18242   }
  18243   return(r);
  18244 }
  18245 
  18246 internal double parseDoubleSmallJson(smallJsont *self) {
  18247 
  18248   if (self->topIsA != TOP_IS_STRING || !lenSmallJson(self)) {
  18249     return(0);
  18250   }
  18251 
  18252   char *string = sStringGetTiny(self->topS);
  18253   while (!isdigit(*string) && *string != '-' && *string != 0) {
  18254     string++;
  18255   }
  18256   double r = strtod(string, NULL);
  18257   return(r);
  18258 }
  18259 
  18260 internal smallJsont* intToSmallJson(smallJsont *self, int64_t n) {
  18261   char s[50];
  18262 
  18263   sprintf(s, "%" PRIiMAX, n);
  18264   freeSmallJson(self);
  18265   setTopStringSmallJson(self, s);
  18266   return(self);
  18267 }
  18268 
  18269 internal smallJsont* doubleToSmallJson(smallJsont *self, double n) {
  18270   char s[256];
  18271 
  18272   sprintf(s, "%e", n);
  18273   freeSmallJson(self);
  18274   setTopStringSmallJson(self, s);
  18275   return(self);
  18276 }
  18277 
  18278 internal size_t lenSmallJson(smallJsont *self) {
  18279 
  18280   switch(self->topIsA) {
  18281     case SMALLJSON_IS_EMPTY:
  18282       return(0);
  18283     case TOP_IS_STRING:
  18284       if (!self->topS) {
  18285         return(0);
  18286       }
  18287       else {
  18288         return(strlen(sStringGetTiny(self->topS)));
  18289       }
  18290     case TOP_IS_DICT:
  18291       if (!self->top) {
  18292         return(0);
  18293       }
  18294       else {
  18295         return(self->top->count);
  18296       }
  18297     case TOP_IS_ARRAY:
  18298       if (!self->topA) {
  18299         return(0);
  18300       }
  18301       else {
  18302         return(self->topA->count);
  18303       }
  18304     default:
  18305       return(1);
  18306   }
  18307 }
  18308 
  18309 internal smallJsont* upperSmallJson(smallJsont *self) {
  18310 
  18311   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  18312     return(NULL);
  18313   }
  18314 
  18315   char *string = sStringGetTiny(self->topS);
  18316   while (*string != 0) {
  18317     *string = (char)toupper(*string);
  18318     string++;
  18319   }
  18320   return(self);
  18321 }
  18322 
  18323 internal smallJsont* lowerSmallJson(smallJsont *self) {
  18324 
  18325   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  18326     return(NULL);
  18327   }
  18328 
  18329   char *string = sStringGetTiny(self->topS);
  18330   while (*string != 0) {
  18331     *string = (char)tolower(*string);
  18332     string++;
  18333   }
  18334   return(self);
  18335 }
  18336 
  18337 internal smallJsont* trimSmallJson(smallJsont *self) {
  18338   smallt *o = NULL;
  18339   sArrayt *a = NULL;
  18340   sDictt *d = NULL;
  18341 
  18342   // sanity checks
  18343   if (self->topIsA != TOP_IS_ARRAY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_STRING) {
  18344     return(NULL);
  18345   }
  18346 
  18347   switch(self->topIsA) {
  18348     case TOP_IS_ARRAY:
  18349       a = allocSArray();
  18350       if (!a) {
  18351         return(NULL);
  18352       }
  18353 
  18354       for (size_t i = 0 ; i < lenSmallJson(self); i++) {
  18355         o = sArrayGetTiny(self->topA, (uint32_t)i);
  18356         if (o) {
  18357           sArrayPushTiny(&a, o);
  18358       }
  18359         }
  18360 
  18361       free(self->topA);
  18362       self->topA = a;
  18363       break;
  18364     case TOP_IS_DICT:
  18365       if (!lenSmallJson(self)) {
  18366         return(self);
  18367       }
  18368 
  18369       isError(d, allocSDict()) return(NULL);
  18370 
  18371       forEachSDict(self->top, e) {
  18372         if (e->key) {
  18373           sDictSetTiny(&d, e->key, e->data);
  18374           free(e->key);
  18375       }
  18376         }
  18377 
  18378       free(self->top);
  18379       self->top = d;
  18380       break;
  18381     case TOP_IS_STRING:
  18382       ;char *workingS;
  18383       char *r;
  18384       char *end;
  18385       size_t len;
  18386 
  18387       // sanity checks
  18388       if (!self->topS) {
  18389         return(NULL);
  18390       }
  18391 
  18392       if (!lenSmallJson(self)) {
  18393         return(self);
  18394       }
  18395 
  18396       workingS = sStringGetTiny(self->topS);
  18397 
  18398       // remove heading spaces
  18399       while (isspace(*workingS)) {
  18400         workingS++;
  18401       }
  18402 
  18403       if (!*workingS) {
  18404         // all spaces
  18405         freeSmallJson(self);
  18406         setTopStringSmallJson(self, "");
  18407         return(self);
  18408       }
  18409 
  18410       // remove trailing spaces
  18411       end = workingS + strlen(workingS) - 1;
  18412       while (isspace(*end)) {
  18413         end--;
  18414       }
  18415 
  18416       // copy range to new smallString
  18417       len             = (size_t)(end - workingS + 2);
  18418       isError(r, malloc(len)) return(NULL);
  18419       r               = strncpy(r, workingS, len - 1);
  18420       r[len - 1]      = 0;
  18421 
  18422       freeSmallJson(self);
  18423       if (!setTopNFreeStringSmallJson(self, r)) {
  18424         free(r);
  18425         return(NULL);
  18426       }
  18427       break;
  18428     default:
  18429       // not reachable
  18430       logC("Check this function!");
  18431   }
  18432   return(self);
  18433 }
  18434 
  18435 internal smallJsont* lTrimSmallJson(smallJsont *self) {
  18436   char *workingS = NULL;
  18437   char *r = NULL;
  18438 
  18439   // sanity checks
  18440   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  18441     return(NULL);
  18442   }
  18443 
  18444   if (!lenSmallJson(self)) {
  18445     return(self);
  18446   }
  18447 
  18448   workingS = sStringGetTiny(self->topS);
  18449 
  18450   // remove heading spaces
  18451   while (isspace(*workingS)) {
  18452     workingS++;
  18453   }
  18454 
  18455   r = strdup(workingS);;
  18456 
  18457   freeSmallJson(self);
  18458   if (!setTopNFreeStringSmallJson(self, r)) {
  18459     free(r);
  18460     return(NULL);
  18461   }
  18462   return(self);
  18463 }
  18464 
  18465 internal smallJsont* rTrimSmallJson(smallJsont *self) {
  18466   char *workingS = NULL;
  18467   char *end = NULL;
  18468 
  18469   // sanity checks
  18470   if (self->topIsA != TOP_IS_STRING || !self->topS) {
  18471     return(NULL);
  18472   }
  18473 
  18474   if (!lenSmallJson(self)) {
  18475     return(self);
  18476   }
  18477 
  18478   workingS = sStringGetTiny(self->topS);
  18479 
  18480   // remove trailing spaces
  18481   end = workingS + strlen(workingS) - 1;
  18482   while ((end >= workingS) && isspace(*end)) {
  18483     end--;
  18484   }
  18485 
  18486   *(end+1) = 0;;
  18487   return(self);
  18488 }
  18489 
  18490 
  18491 internal char** keysSmallJson(smallJsont *self) {
  18492   char **r = NULL;
  18493 
  18494   if (self->topIsA != TOP_IS_DICT) {
  18495     return(NULL);
  18496   }
  18497 
  18498   if (!lenSmallJson(self)) {
  18499     // empty
  18500     return(NULL);
  18501   }
  18502 
  18503   forEachSDict(self->top, e) {
  18504     if (e->key) {
  18505       pErrorNULL(listPushS(&r, e->key));
  18506   }
  18507     }
  18508   return(r);
  18509 }
  18510 
  18511 internal smallArrayt* keysSmallStringSmallJson(smallJsont *self) {
  18512 
  18513   char** r = keysSmallJson(self);
  18514   createAllocateSmallArray(a);
  18515   if (!a) {
  18516     listFreeS(r);
  18517     return(NULL);
  18518   }
  18519   fromArrayNFreeO(a, r, 0);
  18520   return(a);
  18521 }
  18522 
  18523 internal smallArrayt* valuesSmallJson(smallJsont *self) {
  18524 
  18525   if (self->topIsA != TOP_IS_DICT) {
  18526     return(NULL);
  18527   }
  18528 
  18529   if (!lenSmallJson(self)) {
  18530     // empty
  18531     return(NULL);
  18532   }
  18533 
  18534   createAllocateSmallArray(a);
  18535   if (!a) {
  18536     return(NULL);
  18537   }
  18538 
  18539   forEachSDict(self->top, e) {
  18540     if (e->key) {
  18541       sArrayPushTiny(&(a->a), e->data);
  18542   }
  18543     }
  18544 
  18545   return(a);
  18546 }
  18547 
  18548 
  18549 internal smallJsont* compactSmallJson(smallJsont *self) {
  18550 
  18551   // sanity checks
  18552   if (self->topIsA != TOP_IS_ARRAY) {
  18553     return(NULL);
  18554   }
  18555 
  18556   if (!lenSmallJson(self)) {
  18557     return(NULL);
  18558   }
  18559 
  18560   createAllocateSmallJson(r);
  18561   if (!r) {
  18562     return(NULL);
  18563   }
  18564 
  18565   char *trim = NULL;
  18566 
  18567   // keep non empty elements
  18568   forEachSArray(self->topA, e) {
  18569     if (e) {
  18570       switch (e->type) {
  18571       case UNDEFINED:
  18572         free(e);
  18573         break;
  18574       case BOOL:
  18575         sArrayPushTiny(&(r->topA), e);
  18576         break;
  18577       case CONTAINER:
  18578         sArrayPushTiny(&(r->topA), e);
  18579         break;
  18580       case DICT:
  18581         if (((sDictt*)e)->count > 0) {
  18582           sArrayPushTiny(&(r->topA), e);
  18583         }
  18584         else {
  18585           sFree(e);
  18586         }
  18587         break;
  18588       case DOUBLE:
  18589         sArrayPushTiny(&(r->topA), e);
  18590         break;
  18591       case INT:
  18592         sArrayPushTiny(&(r->topA), e);
  18593         break;
  18594       case STRING:
  18595         trim = trimS(sStringGetTiny((sStringt*)e));
  18596         if (*trim != 0) {
  18597           sArrayPushTiny(&(r->topA), e);
  18598         }
  18599         else {
  18600           free(e);
  18601         }
  18602         free(trim);
  18603         break;
  18604       case ARRAY:
  18605         if (((sArrayt*)e)->count > 0) {
  18606           sArrayPushTiny(&(r->topA), e);
  18607         }
  18608         else {
  18609           sFree(e);
  18610         }
  18611         break;
  18612       case BYTES:
  18613         if (((sBytest*)e)->count > 0) {
  18614           sArrayPushTiny(&(r->topA), e);
  18615         }
  18616         else {
  18617           sFree(e);
  18618         }
  18619         break;
  18620       default:
  18621         logC("Unsupported object type!");
  18622       }
  18623   }
  18624     }
  18625 
  18626   free(self->topA);
  18627   self->topA = r->topA;
  18628   if ((r->topA)) {
  18629     self->topA = r->topA;
  18630   }
  18631   else {
  18632     // r->topA is null and has no elements, allocate an empty sArray
  18633     // to make setP work correctly after a call to compact.
  18634     // For example:
  18635     // smallJsont *a = getG(dict, rtSmallJsont, "key");
  18636     // compactG(a);
  18637     // setNFreePG(dict, "key", a);
  18638     // if self->topA is null then setNFreePG returns an error and the "key" array pointer
  18639     // is not updated causing memory errors
  18640     self->topA = allocSArray();;
  18641   }
  18642   finishO(r);
  18643   return(self);
  18644 }
  18645 
  18646 internal smallJsont* emptySmallJson(smallJsont *self) {
  18647 
  18648   if (self->iterIndex != -1) {
  18649     if (self->iterElementDataType != SH_DT_BASET) {
  18650       finishO(self->iterElement);
  18651     }
  18652     self->iterElement = NULL;
  18653     self->iterIndex   = -1;
  18654   }
  18655 
  18656   switch(self->topIsA) {
  18657     case TOP_IS_STRING:
  18658       sFree((smallt *)self->topS);
  18659       isError(self->topS, allocSStringTiny("")) return(NULL);
  18660       return(self);
  18661     case TOP_IS_DICT:
  18662       sFree((smallt *)self->top);
  18663       isError(self->top, allocSDict()) return(NULL);
  18664       return(self);
  18665     case TOP_IS_ARRAY:
  18666       sFree((smallt *)self->topA);
  18667       isError(self->topA, allocSArray()) return(NULL);
  18668       return(self);
  18669     default:
  18670       return(self);
  18671   }
  18672 }
  18673 
  18674 internal bool isEmptySmallJson(smallJsont *self) {
  18675 
  18676   if (lenSmallJson(self) == 0) {
  18677     return(true);
  18678   }
  18679 
  18680   // check if all elements are null
  18681   switch(self->topIsA) {
  18682     case TOP_IS_DICT:
  18683       {forEachSDict(self->top, e)
  18684         if (e->key)
  18685           return(false);
  18686       }
  18687       break;
  18688     case TOP_IS_ARRAY:;
  18689       {forEachSArray(self->topA, e)
  18690         if (e)
  18691           return(false);
  18692       }
  18693       break;
  18694     case TOP_IS_STRING:
  18695       return(false);
  18696     default:;
  18697       // do nothing for other types
  18698   }
  18699   return(true);
  18700 }
  18701 
  18702 
  18703 internal bool isBlankSmallJson(smallJsont *self) {
  18704 
  18705   if (self->topIsA == TOP_IS_DICT) {
  18706     return(isEmptySmallJson(self));
  18707   }
  18708 
  18709   if (self->topIsA == TOP_IS_STRING) {
  18710     return(isBlankS(sStringGetTiny((sStringt*)self->topS)));
  18711   }
  18712 
  18713   if (self->topIsA != TOP_IS_ARRAY) {
  18714     return(true);
  18715   }
  18716 
  18717   if (!lenSmallJson(self)) {
  18718     return(true);
  18719   }
  18720 
  18721   forEachSArray(self->topA, e) {
  18722     if (e) {
  18723       switch (e->type) {
  18724       // skip undefined - case UNDEFINED:
  18725       case BOOL:
  18726         return(false);
  18727       case CONTAINER:
  18728         return(false);
  18729       case DICT:
  18730         if (((sDictt*)e)->count > 0) {
  18731           return(false);
  18732         }
  18733         break;
  18734       case DOUBLE:
  18735         return(false);
  18736       case INT:
  18737         return(false);
  18738       case STRING:
  18739         if (!isBlankS(sStringGetTiny((sStringt*)e))) {
  18740           return(false);
  18741         }
  18742         break;
  18743       case ARRAY:
  18744         if (((sArrayt*)e)->count > 0) {
  18745           return(false);
  18746         }
  18747         break;
  18748       case BYTES:
  18749         if (((sBytest*)e)->count > 0) {
  18750           return(false);
  18751         }
  18752         break;
  18753       default:
  18754         logC("Unsupported object type!");
  18755       }
  18756   }
  18757     }
  18758   return(true);
  18759 }
  18760 
  18761 internal void forEachSmallJsonF(smallJsont *self, void *closure, forEachElementSmallArrayFt funcElem) {
  18762 
  18763   // sanity checks
  18764   if (self->topIsA != TOP_IS_ARRAY || !lenSmallJson(self)) {
  18765     return;
  18766   }
  18767 
  18768   forEachSArray(self->topA, e) {
  18769     if (not e) {
  18770       continue;
  18771     }
  18772     baset *E = toBaset(e);
  18773     if (!funcElem(closure, E)) {
  18774       if (e->type == CONTAINER && ((sContainert*)e)->dataType == SH_DT_BASET) {
  18775         break;
  18776       }
  18777       finishO(E);
  18778       break;
  18779     }
  18780     if (e->type == CONTAINER && ((sContainert*)e)->dataType == SH_DT_BASET) {
  18781       continue;
  18782     }
  18783     finishO(E);
  18784   }
  18785   return;
  18786 }
  18787 
  18788 internal void enumerateSmallJsonF(smallJsont *self, void *closure, enumerateElementSmallArrayFt funcElem) {
  18789 
  18790   // sanity checks
  18791   if (self->topIsA != TOP_IS_ARRAY || !lenSmallJson(self)) {
  18792     return;
  18793   }
  18794 
  18795   enumerateSArray(self->topA, e, i) {
  18796     if (not e) {
  18797       continue;
  18798     }
  18799     baset *E = toBaset(e);
  18800     if (!funcElem(closure, i, E)) {
  18801       if (e->type == CONTAINER && ((sContainert*)e)->dataType == SH_DT_BASET) {
  18802         break;
  18803       }
  18804       finishO(E);
  18805       break;
  18806     }
  18807     if (e->type == CONTAINER && ((sContainert*)e)->dataType == SH_DT_BASET) {
  18808       continue;
  18809     }
  18810     finishO(E);
  18811   }
  18812   return;
  18813 }
  18814 
  18815 internal void enumerateDictSmallJson(smallJsont *self, void *closure, enumerateDictElementSmallJsonFt funcElem) {
  18816 
  18817   if (self->topIsA != TOP_IS_DICT || !lenSmallJson(self)) {
  18818     return;
  18819   }
  18820 
  18821   forEachSDict(self->top, e) {
  18822     if (e->key) {
  18823       baset *E = toBaset(e->data);
  18824       if (!funcElem(closure, e->key, E)) {
  18825         if (e->data->type == CONTAINER && ((sContainert*)e->data)->dataType == SH_DT_BASET) {
  18826           break;
  18827         }
  18828         finishO(E);
  18829         break;
  18830       }
  18831       if (e->data->type == CONTAINER && ((sContainert*)e->data)->dataType == SH_DT_BASET) {
  18832         continue;
  18833       }
  18834       finishO(E);
  18835 }
  18836   }
  18837     }
  18838 
  18839 internal smallStringt* joinSmallJson(smallJsont *self, const char* delim) {
  18840   smallStringt *r = NULL;
  18841 
  18842   // sanity checks
  18843   if (self->topIsA != TOP_IS_ARRAY) {
  18844     return(NULL);
  18845   }
  18846 
  18847   if (!lenSmallJson(self) || !delim) {
  18848     return(NULL);
  18849   }
  18850 
  18851   char *s;
  18852 
  18853   forEachSArray(self->topA, e) {
  18854     if (e) {
  18855       switch (e->type) {
  18856       case STRING:
  18857         if (!r) {
  18858           isError(r, allocSmallString(sStringGetTiny((sStringt*)e))) return(NULL);
  18859         }
  18860         else {
  18861           r->f->appendS(r, delim);
  18862           r->f->appendS(r, sStringGetTiny((sStringt*)e));
  18863         }
  18864         break;
  18865       default:
  18866         s = sToString(e);;
  18867         if (!r) {
  18868           isError(r, allocSmallString(s)) return(NULL);
  18869         }
  18870         else {
  18871           r->f->appendS(r, delim);
  18872           r->f->appendS(r, s);
  18873         }
  18874         free(s);
  18875       }
  18876   }
  18877     }
  18878   return(r);
  18879 }
  18880 
  18881 internal smallStringt* joinCharSmallJson(smallJsont *self, char c) {
  18882 
  18883   charToS(s, c);
  18884   return(joinSmallJson(self, s));
  18885 }
  18886 
  18887 internal smallStringt* joinSmallJsonSmallJson(smallJsont *self, smallJsont* delim) {
  18888 
  18889   if (!delim) {
  18890     return(NULL);
  18891   }
  18892 
  18893   if (checkObjectTypes && !isOSmallJson(delim)) {
  18894     return(NULL);
  18895   }
  18896 
  18897   if (delim->topIsA != TOP_IS_STRING) {
  18898     return(NULL);
  18899   }
  18900 
  18901   return(joinSmallJson(self, sjGet(delim)));
  18902 }
  18903 
  18904 internal smallStringt* joinSmallStringSmallJson(smallJsont *self, smallStringt* delim) {
  18905 
  18906   if (!delim) {
  18907     return(NULL);
  18908   }
  18909   if (checkObjectTypes && !isOSmallString(delim)) {
  18910     return(NULL);
  18911   }
  18912 
  18913   return(joinSmallJson(self, ssGet(delim)));
  18914 }
  18915 
  18916 internal char* joinSSmallJson(smallJsont *self, const char* delim) {
  18917   char *r = NULL;
  18918 
  18919   // sanity checks
  18920   if (self->topIsA != TOP_IS_ARRAY) {
  18921     return(NULL);
  18922   }
  18923 
  18924   if (!lenSmallJson(self) || !delim) {
  18925     return(NULL);
  18926   }
  18927 
  18928   char *s;
  18929 
  18930   forEachSArray(self->topA, e) {
  18931     if (e) {
  18932       switch (e->type) {
  18933       case STRING:
  18934         if (!r) {
  18935           r = strdup(sStringGetTiny((sStringt*)e));
  18936         }
  18937         else {
  18938           pErrorNULL(iAppendS(&r, delim));
  18939           pErrorNULL(iAppendS(&r, sStringGetTiny((sStringt*)e)));
  18940         }
  18941         break;
  18942       default:
  18943         s = sToString(e);
  18944         if (!s) {
  18945           free(r);
  18946           return(NULL);
  18947         }
  18948         if (!r) {
  18949           r = strdup(s);
  18950         }
  18951         else {
  18952           pErrorNULL(iAppendS(&r, delim));
  18953           pErrorNULL(iAppendS(&r, s));
  18954         }
  18955         free(s);
  18956       }
  18957   }
  18958     }
  18959 
  18960   return(r);
  18961 }
  18962 
  18963 internal char* joinCharSSmallJson(smallJsont *self, char c) {
  18964 
  18965   charToS(s, c);
  18966   return(joinSSmallJson(self, s));
  18967 }
  18968 
  18969 internal char* joinSmallJsonSSmallJson(smallJsont *self, smallJsont* delim) {
  18970 
  18971   if (!delim) {
  18972     return(NULL);
  18973   }
  18974 
  18975   if (checkObjectTypes && !isOSmallJson(delim)) {
  18976     return(NULL);
  18977   }
  18978 
  18979   if (delim->topIsA != TOP_IS_STRING) {
  18980     return(NULL);
  18981   }
  18982 
  18983   return(joinSSmallJson(self, sjGet(delim)));
  18984 }
  18985 
  18986 internal char* joinSmallStringSSmallJson(smallJsont *self, smallStringt* delim) {
  18987 
  18988   if (!delim) {
  18989     return(NULL);
  18990   }
  18991   if (checkObjectTypes && !isOSmallString(delim)) {
  18992     return(NULL);
  18993   }
  18994 
  18995   return(joinSSmallJson(self, ssGet(delim)));
  18996 }
  18997 
  18998 internal smallJsont* splitSmallJson(smallJsont *self, const char *delim) {
  18999 
  19000   // sanity checks
  19001   if (self->topIsA != TOP_IS_STRING || !self->topS || !delim) {
  19002     return(NULL);
  19003   }
  19004 
  19005   createAllocateSmallJson(r);
  19006   if (!r) {
  19007     return(NULL);
  19008   }
  19009 
  19010   char **list = splitSSmallJson(self, delim);
  19011   r->f->fromArray(r, list, 0);
  19012   listFreeS(list);
  19013   return(r);
  19014 }
  19015 
  19016 internal smallJsont* splitCharSmallJson(smallJsont *self, char c) {
  19017 
  19018   charToS(s, c);
  19019   return(splitSmallJson(self, s));
  19020 }
  19021 
  19022 internal smallJsont* splitSmallJsonSmallJson(smallJsont *self, smallJsont *delim) {
  19023 
  19024   if (!delim) {
  19025     return(NULL);
  19026   }
  19027 
  19028   if (checkObjectTypes && !isOSmallJson(delim)) {
  19029     return(NULL);
  19030   }
  19031 
  19032   if (delim->topIsA != TOP_IS_STRING) {
  19033     return(NULL);
  19034   }
  19035 
  19036   return(splitSmallJson(self, sjGet(delim)));
  19037 }
  19038 
  19039 internal smallJsont* splitSmallStringSmallJson(smallJsont *self, smallStringt *delim) {
  19040 
  19041   if (!delim) {
  19042     return(NULL);
  19043   }
  19044   if (checkObjectTypes && !isOSmallString(delim)) {
  19045     return(NULL);
  19046   }
  19047 
  19048   return(splitSmallJson(self, ssGet(delim)));
  19049 }
  19050 
  19051 internal char** splitSSmallJson(smallJsont *self, const char *delim) {
  19052   char *startSmallString = NULL;
  19053   char *workingSmallString = NULL;
  19054   char *line = NULL;
  19055   char *token = NULL;
  19056   char **r = NULL;
  19057 
  19058   // sanity checks
  19059   if (self->topIsA != TOP_IS_STRING || !self->topS || !delim) {
  19060     return(NULL);
  19061   }
  19062 
  19063   if (!*delim || !*sStringGetTiny(self->topS)) {
  19064     // empty delimiter or empty string
  19065     pErrorNULL(listPushS(&r, sStringGetTiny(self->topS)));
  19066     return(r);
  19067   }
  19068 
  19069   // split using strtok_r
  19070   startSmallString   = strdup(sStringGetTiny(self->topS));
  19071   workingSmallString = startSmallString;
  19072   line  = workingSmallString;
  19073   while (strlen(workingSmallString) != 0) {
  19074     token = tokS(line, delim, &workingSmallString);
  19075     pErrorNULL(listPushS(&r, token));
  19076     // mac os sets workingSmallString to NULL at the end
  19077     if (!workingSmallString) {
  19078       break; //LCOV_EXCL_LINE
  19079     }
  19080     // first parameter should be NULL in next strtok_r calls
  19081     line  = NULL;
  19082   }
  19083   free(startSmallString);
  19084 
  19085   // check if delim is at the end of smallString
  19086   // if yes, add an empty smallString in the result
  19087   // ["one",""] = split "one/" "/"
  19088   size_t lenD = strlen(delim);
  19089   // +1 for sType
  19090   if (eqS(sStringGetTiny(self->topS)+(lenSmallJson(self)-lenD), delim)) {
  19091     pErrorNULL(listPushS(&r, ""));
  19092   }
  19093 
  19094   return(r);
  19095 }
  19096 
  19097 internal char** splitCharSSmallJson(smallJsont *self, char c) {
  19098 
  19099   charToS(s, c);
  19100   return(splitSSmallJson(self, s));
  19101 }
  19102 
  19103 internal char** splitSmallJsonSSmallJson(smallJsont *self, smallJsont *delim) {
  19104 
  19105   if (!delim) {
  19106     return(NULL);
  19107   }
  19108 
  19109   if (checkObjectTypes && !isOSmallJson(delim)) {
  19110     return(NULL);
  19111   }
  19112 
  19113   if (delim->topIsA != TOP_IS_STRING) {
  19114     return(NULL);
  19115   }
  19116 
  19117   return(splitSSmallJson(self, sjGet(delim)));
  19118 }
  19119 
  19120 internal char** splitSmallStringSSmallJson(smallJsont *self, smallStringt *delim) {
  19121 
  19122   if (!delim) {
  19123     return(NULL);
  19124   }
  19125   if (checkObjectTypes && !isOSmallString(delim)) {
  19126     return(NULL);
  19127   }
  19128 
  19129   return(splitSSmallJson(self, ssGet(delim)));
  19130 }
  19131 
  19132 internal smallJsont* extractSmallJson(smallJsont *self, const char* delim1, const char* delim2) {
  19133   char **tmp = NULL;
  19134   char **r = NULL;
  19135 
  19136   // sanity checks
  19137   if (self->topIsA != TOP_IS_STRING || !self->topS || !delim1 || !delim2) {
  19138     return(NULL);
  19139   }
  19140 
  19141   if (strEq(delim1, delim2)) {
  19142     return(NULL);
  19143   }
  19144 
  19145   tmp = splitSSmallJson(self, delim1);
  19146 
  19147   if (!tmp) {
  19148     return(NULL);
  19149   }
  19150 
  19151   if (listLengthS(tmp) < 2) {
  19152     // delim1 not found
  19153     listFreeS(tmp);
  19154     return(NULL);
  19155   }
  19156 
  19157   // remove first element
  19158   pErrorNULL(iListSliceS(&tmp, 1, 0));
  19159 
  19160   forEachCharP(tmp, e) {
  19161     char **tmp2 = split(*e, delim2);
  19162     if (listLengthS(tmp2) > 1) {
  19163       pErrorNULL(listPushS(&r, tmp2[0]));
  19164     }
  19165     listFreeS(tmp2);
  19166   }
  19167 
  19168   listFreeS(tmp);
  19169 
  19170   if (!r) {
  19171     return(NULL);
  19172   }
  19173 
  19174   createAllocateSmallJson(a);
  19175   if (!a) {
  19176     listFreeS(r);
  19177     return(NULL);
  19178   }
  19179   a->f->fromArrayNFree(a, r, 0);
  19180   return(a);
  19181 }
  19182 
  19183 internal smallJsont* extractCharSSmallJson(smallJsont *self, char delim1, const char* delim2) {
  19184 
  19185   charToS(d1, delim1);
  19186   return(extractSmallJson(self, d1, delim2));
  19187 }
  19188 
  19189 internal smallJsont* extractSCharSmallJson(smallJsont *self, const char* delim1, char delim2) {
  19190 
  19191   charToS(d2, delim2);
  19192   return(extractSmallJson(self, delim1, d2));
  19193 }
  19194 
  19195 internal smallJsont* extractCharCharSmallJson(smallJsont *self, char delim1, char delim2) {
  19196 
  19197   charToS(d1, delim1);
  19198   charToS(d2, delim2);
  19199   return(extractSmallJson(self, d1, d2));
  19200 }
  19201 
  19202 internal smallJsont* extractSmallJsonSmallJsonSmallJson(smallJsont *self, smallJsont* delim1, smallJsont* delim2) {
  19203 
  19204   if (!delim1 || !delim2) {
  19205     return(NULL);
  19206   }
  19207 
  19208   if (checkObjectTypes && !isOSmallJson(delim1)) {
  19209     return(NULL);
  19210   }
  19211 
  19212   if (checkObjectTypes && !isOSmallJson(delim2)) {
  19213     return(NULL);
  19214   }
  19215 
  19216   if (delim1->topIsA != TOP_IS_STRING || delim2->topIsA != TOP_IS_STRING) {
  19217     return(NULL);
  19218   }
  19219 
  19220   return(extractSmallJson(self, sjGet(delim1), sjGet(delim2)));
  19221 }
  19222 
  19223 internal smallJsont* extractSmallJsonSmallStringSmallJson(smallJsont *self, smallJsont* delim1, smallStringt* delim2) {
  19224 
  19225   if (!delim1 || !delim2) {
  19226     return(NULL);
  19227   }
  19228 
  19229   if (checkObjectTypes && !isOSmallJson(delim1)) {
  19230     return(NULL);
  19231   }
  19232 
  19233   if (checkObjectTypes && !isOSmallString(delim2)) {
  19234     return(NULL);
  19235   }
  19236 
  19237   if (delim1->topIsA != TOP_IS_STRING) {
  19238     return(NULL);
  19239   }
  19240 
  19241   return(extractSmallJson(self, sjGet(delim1), ssGet(delim2)));
  19242 }
  19243 
  19244 internal smallJsont* extractSmallJsonSSmallJson(smallJsont *self, smallJsont* delim1, const char* delim2) {
  19245 
  19246   if (!delim1 || !delim2) {
  19247     return(NULL);
  19248   }
  19249 
  19250   if (checkObjectTypes && !isOSmallJson(delim1)) {
  19251     return(NULL);
  19252   }
  19253 
  19254   if (delim1->topIsA != TOP_IS_STRING) {
  19255     return(NULL);
  19256   }
  19257 
  19258   return(extractSmallJson(self, sjGet(delim1), delim2));
  19259 }
  19260 
  19261 internal smallJsont* extractSmallJsonCharSmallJson(smallJsont *self, smallJsont* delim1, char delim2) {
  19262 
  19263   if (!delim1) {
  19264     return(NULL);
  19265   }
  19266 
  19267   if (checkObjectTypes && !isOSmallJson(delim1)) {
  19268     return(NULL);
  19269   }
  19270 
  19271   if (delim1->topIsA != TOP_IS_STRING) {
  19272     return(NULL);
  19273   }
  19274 
  19275   charToS(d2, delim2);
  19276   return(extractSmallJson(self, sjGet(delim1), d2));
  19277 }
  19278 
  19279 internal smallJsont* extractSmallStringSmallJsonSmallJson(smallJsont *self, smallStringt* delim1, smallJsont* delim2) {
  19280 
  19281   if (!delim1 || !delim2) {
  19282     return(NULL);
  19283   }
  19284 
  19285   if (checkObjectTypes && !isOSmallString(delim1)) {
  19286     return(NULL);
  19287   }
  19288 
  19289   if (checkObjectTypes && !isOSmallJson(delim2)) {
  19290     return(NULL);
  19291   }
  19292 
  19293   if (delim2->topIsA != TOP_IS_STRING) {
  19294     return(NULL);
  19295   }
  19296 
  19297   return(extractSmallJson(self, ssGet(delim1), sjGet(delim2)));
  19298 }
  19299 
  19300 internal smallJsont* extractSmallStringSmallStringSmallJson(smallJsont *self, smallStringt* delim1, smallStringt* delim2) {
  19301 
  19302   if (!delim1 || !delim2) {
  19303     return(NULL);
  19304   }
  19305   if (checkObjectTypes && (!isOSmallString(delim1) || !isOSmallString(delim2))) {
  19306     return(NULL);
  19307   }
  19308 
  19309   return(extractSmallJson(self, ssGet(delim1), ssGet(delim2)));
  19310 }
  19311 
  19312 internal smallJsont* extractSmallStringSSmallJson(smallJsont *self, smallStringt* delim1, const char* delim2) {
  19313 
  19314   if (!delim1) {
  19315     return(NULL);
  19316   }
  19317   if (checkObjectTypes && !isOSmallString(delim1)) {
  19318     return(NULL);
  19319   }
  19320 
  19321   return(extractSmallJson(self, ssGet(delim1), delim2));
  19322 }
  19323 
  19324 internal smallJsont* extractSmallStringCharSmallJson(smallJsont *self, smallStringt* delim1, char delim2) {
  19325 
  19326   if (!delim1) {
  19327     return(NULL);
  19328   }
  19329   if (checkObjectTypes && !isOSmallString(delim1)) {
  19330     return(NULL);
  19331   }
  19332 
  19333   charToS(d2, delim2);
  19334   return(extractSmallJson(self, ssGet(delim1), d2));
  19335 }
  19336 
  19337 internal smallJsont* extractSSmallJsonSmallJson(smallJsont *self, const char* delim1, smallJsont* delim2) {
  19338 
  19339   if (!delim2) {
  19340     return(NULL);
  19341   }
  19342 
  19343   if (checkObjectTypes && !isOSmallJson(delim2)) {
  19344     return(NULL);
  19345   }
  19346 
  19347   if (delim2->topIsA != TOP_IS_STRING) {
  19348     return(NULL);
  19349   }
  19350 
  19351   return(extractSmallJson(self, delim1, sjGet(delim2)));
  19352 }
  19353 
  19354 internal smallJsont* extractSSmallStringSmallJson(smallJsont *self, const char* delim1, smallStringt* delim2) {
  19355 
  19356   if (!delim2) {
  19357     return(NULL);
  19358   }
  19359   if (checkObjectTypes && !isOSmallString(delim2)) {
  19360     return(NULL);
  19361   }
  19362 
  19363   return(extractSmallJson(self, delim1, ssGet(delim2)));
  19364 }
  19365 
  19366 internal smallJsont* extractCharSmallJsonSmallJson(smallJsont *self, char delim1, smallJsont* delim2) {
  19367 
  19368   if (!delim2) {
  19369     return(NULL);
  19370   }
  19371 
  19372   if (checkObjectTypes && !isOSmallJson(delim2)) {
  19373     return(NULL);
  19374   }
  19375 
  19376   if (delim2->topIsA != TOP_IS_STRING) {
  19377     return(NULL);
  19378   }
  19379 
  19380   charToS(d1, delim1);
  19381   return(extractSmallJson(self, d1, sjGet(delim2)));
  19382 }
  19383 
  19384 internal smallJsont* extractCharSmallStringSmallJson(smallJsont *self, char delim1, smallStringt* delim2) {
  19385 
  19386   if (!delim2) {
  19387     return(NULL);
  19388   }
  19389   if (checkObjectTypes && !isOSmallString(delim2)) {
  19390     return(NULL);
  19391   }
  19392 
  19393   charToS(d1, delim1);
  19394   return(extractSmallJson(self, d1, ssGet(delim2)));
  19395 }
  19396 
  19397 internal smallJsont* icSplitSmallJson(smallJsont *self, const char *delim) {
  19398 
  19399   // sanity checks
  19400   if (self->topIsA != TOP_IS_STRING || !self->topS || !delim) {
  19401     return(NULL);
  19402   }
  19403 
  19404   createAllocateSmallJson(r);
  19405   if (!r) {
  19406     return(NULL);
  19407   }
  19408 
  19409   char **list = icSplitSSmallJson(self, delim);
  19410   r->f->fromArray(r, list, 0);
  19411   listFreeS(list);
  19412   return(r);
  19413 }
  19414 
  19415 internal smallJsont* icSplitCharSmallJson(smallJsont *self, char c) {
  19416 
  19417   charToS(s, c);
  19418   return(icSplitSmallJson(self, s));
  19419 }
  19420 
  19421 internal smallJsont* icSplitSmallJsonSmallJson(smallJsont *self, smallJsont *delim) {
  19422 
  19423   if (!delim) {
  19424     return(NULL);
  19425   }
  19426 
  19427   if (checkObjectTypes && !isOSmallJson(delim)) {
  19428     return(NULL);
  19429   }
  19430 
  19431   if (delim->topIsA != TOP_IS_STRING) {
  19432     return(NULL);
  19433   }
  19434 
  19435   return(icSplitSmallJson(self, sjGet(delim)));
  19436 }
  19437 
  19438 internal smallJsont* icSplitSmallStringSmallJson(smallJsont *self, smallStringt *delim) {
  19439 
  19440   if (!delim) {
  19441     return(NULL);
  19442   }
  19443   if (checkObjectTypes && !isOSmallString(delim)) {
  19444     return(NULL);
  19445   }
  19446 
  19447   return(icSplitSmallJson(self, ssGet(delim)));
  19448 }
  19449 
  19450 internal char** icSplitSSmallJson(smallJsont *self, const char *delim) {
  19451   char *startSmallString = NULL;
  19452   char *workingSmallString = NULL;
  19453   char *line = NULL;
  19454   char *token = NULL;
  19455   char **r = NULL;
  19456 
  19457   // sanity checks
  19458   if (self->topIsA != TOP_IS_STRING || !self->topS || !delim) {
  19459     return(NULL);
  19460   }
  19461 
  19462   if (!*delim || !*sStringGetTiny(self->topS)) {
  19463     // empty delimiter or empty string
  19464     pErrorNULL(listPushS(&r, sStringGetTiny(self->topS)));
  19465     return(r);
  19466   }
  19467 
  19468   // split using strtok_r
  19469   startSmallString   = strdup(sStringGetTiny(self->topS));
  19470   workingSmallString = startSmallString;
  19471   line  = workingSmallString;
  19472   while (strlen(workingSmallString) != 0) {
  19473     token = icTokS(line, delim, &workingSmallString);
  19474     pErrorNULL(listPushS(&r, token));
  19475     // mac os sets workingSmallString to NULL at the end
  19476     if (!workingSmallString) {
  19477       break; //LCOV_EXCL_LINE
  19478     }
  19479     // first parameter should be NULL in next strtok_r calls
  19480     line  = NULL;
  19481   }
  19482   free(startSmallString);
  19483 
  19484   // check if delim is at the end of smallString
  19485   // if yes, add an empty smallString in the result
  19486   // ["one",""] = split "one/" "/"
  19487   size_t lenD = strlen(delim);
  19488   // +1 for sType
  19489   if (icEqS(sStringGetTiny(self->topS)+(lenSmallJson(self)-lenD), delim)) {
  19490     pErrorNULL(listPushS(&r, ""));
  19491   }
  19492 
  19493   return(r);
  19494 }
  19495 
  19496 internal char** icSplitCharSSmallJson(smallJsont *self, char c) {
  19497 
  19498   charToS(s, c);
  19499   return(icSplitSSmallJson(self, s));
  19500 }
  19501 
  19502 internal char** icSplitSmallJsonSSmallJson(smallJsont *self, smallJsont *delim) {
  19503 
  19504   if (!delim) {
  19505     return(NULL);
  19506   }
  19507 
  19508   if (checkObjectTypes && !isOSmallJson(delim)) {
  19509     return(NULL);
  19510   }
  19511 
  19512   if (delim->topIsA != TOP_IS_STRING) {
  19513     return(NULL);
  19514   }
  19515 
  19516   return(icSplitSSmallJson(self, sjGet(delim)));
  19517 }
  19518 
  19519 internal char** icSplitSmallStringSSmallJson(smallJsont *self, smallStringt *delim) {
  19520 
  19521   if (!delim) {
  19522     return(NULL);
  19523   }
  19524   if (checkObjectTypes && !isOSmallString(delim)) {
  19525     return(NULL);
  19526   }
  19527 
  19528   return(icSplitSSmallJson(self, ssGet(delim)));
  19529 }
  19530 
  19531 internal smallJsont* icExtractSmallJson(smallJsont *self, const char* delim1, const char* delim2) {
  19532   char **tmp = NULL;
  19533   char **r = NULL;
  19534 
  19535   // sanity checks
  19536   if (self->topIsA != TOP_IS_STRING || !self->topS || !delim1 || !delim2) {
  19537     return(NULL);
  19538   }
  19539 
  19540   if (strEq(delim1, delim2)) {
  19541     return(NULL);
  19542   }
  19543 
  19544   tmp = icSplitSSmallJson(self, delim1);
  19545 
  19546   if (!tmp) {
  19547     return(NULL);
  19548   }
  19549 
  19550   if (listLengthS(tmp) < 2) {
  19551     // delim1 not found
  19552     listFreeS(tmp);
  19553     return(NULL);
  19554   }
  19555 
  19556   // remove first element
  19557   pErrorNULL(iListSliceS(&tmp, 1, 0));
  19558 
  19559   forEachCharP(tmp, e) {
  19560     char **tmp2 = icSplit(*e, delim2);
  19561     if (listLengthS(tmp2) > 1) {
  19562       pErrorNULL(listPushS(&r, tmp2[0]));
  19563     }
  19564     listFreeS(tmp2);
  19565   }
  19566 
  19567   listFreeS(tmp);
  19568 
  19569   if (!r) {
  19570     return(NULL);
  19571   }
  19572 
  19573   createAllocateSmallJson(a);
  19574   if (!a) {
  19575     listFreeS(r);
  19576     return(NULL);
  19577   }
  19578   a->f->fromArrayNFree(a, r, 0);
  19579   return(a);
  19580 }
  19581 
  19582 internal smallJsont* icExtractCharSSmallJson(smallJsont *self, char delim1, const char* delim2) {
  19583 
  19584   charToS(d1, delim1);
  19585   return(icExtractSmallJson(self, d1, delim2));
  19586 }
  19587 
  19588 internal smallJsont* icExtractSCharSmallJson(smallJsont *self, const char* delim1, char delim2) {
  19589 
  19590   charToS(d2, delim2);
  19591   return(icExtractSmallJson(self, delim1, d2));
  19592 }
  19593 
  19594 internal smallJsont* icExtractCharCharSmallJson(smallJsont *self, char delim1, char delim2) {
  19595 
  19596   charToS(d1, delim1);
  19597   charToS(d2, delim2);
  19598   return(icExtractSmallJson(self, d1, d2));
  19599 }
  19600 
  19601 internal smallJsont* icExtractSmallJsonSmallJsonSmallJson(smallJsont *self, smallJsont* delim1, smallJsont* delim2) {
  19602 
  19603   if (!delim1 || !delim2) {
  19604     return(NULL);
  19605   }
  19606 
  19607   if (checkObjectTypes && !isOSmallJson(delim1)) {
  19608     return(NULL);
  19609   }
  19610 
  19611   if (checkObjectTypes && !isOSmallJson(delim2)) {
  19612     return(NULL);
  19613   }
  19614 
  19615   if (delim1->topIsA != TOP_IS_STRING || delim2->topIsA != TOP_IS_STRING) {
  19616     return(NULL);
  19617   }
  19618 
  19619   return(icExtractSmallJson(self, sjGet(delim1), sjGet(delim2)));
  19620 }
  19621 
  19622 internal smallJsont* icExtractSmallJsonSmallStringSmallJson(smallJsont *self, smallJsont* delim1, smallStringt* delim2) {
  19623 
  19624   if (!delim1 || !delim2) {
  19625     return(NULL);
  19626   }
  19627 
  19628   if (checkObjectTypes && !isOSmallJson(delim1)) {
  19629     return(NULL);
  19630   }
  19631 
  19632   if (checkObjectTypes && !isOSmallString(delim2)) {
  19633     return(NULL);
  19634   }
  19635 
  19636   if (delim1->topIsA != TOP_IS_STRING) {
  19637     return(NULL);
  19638   }
  19639 
  19640   return(icExtractSmallJson(self, sjGet(delim1), ssGet(delim2)));
  19641 }
  19642 
  19643 internal smallJsont* icExtractSmallJsonSSmallJson(smallJsont *self, smallJsont* delim1, const char* delim2) {
  19644 
  19645   if (!delim1 || !delim2) {
  19646     return(NULL);
  19647   }
  19648 
  19649   if (checkObjectTypes && !isOSmallJson(delim1)) {
  19650     return(NULL);
  19651   }
  19652 
  19653   if (delim1->topIsA != TOP_IS_STRING) {
  19654     return(NULL);
  19655   }
  19656 
  19657   return(icExtractSmallJson(self, sjGet(delim1), delim2));
  19658 }
  19659 
  19660 internal smallJsont* icExtractSmallJsonCharSmallJson(smallJsont *self, smallJsont* delim1, char delim2) {
  19661 
  19662   if (!delim1) {
  19663     return(NULL);
  19664   }
  19665 
  19666   if (checkObjectTypes && !isOSmallJson(delim1)) {
  19667     return(NULL);
  19668   }
  19669 
  19670   if (delim1->topIsA != TOP_IS_STRING) {
  19671     return(NULL);
  19672   }
  19673 
  19674   charToS(d2, delim2);
  19675   return(icExtractSmallJson(self, sjGet(delim1), d2));
  19676 }
  19677 
  19678 internal smallJsont* icExtractSmallStringSmallJsonSmallJson(smallJsont *self, smallStringt* delim1, smallJsont* delim2) {
  19679 
  19680   if (!delim1 || !delim2) {
  19681     return(NULL);
  19682   }
  19683 
  19684   if (checkObjectTypes && !isOSmallString(delim1)) {
  19685     return(NULL);
  19686   }
  19687 
  19688   if (checkObjectTypes && !isOSmallJson(delim2)) {
  19689     return(NULL);
  19690   }
  19691 
  19692   if (delim2->topIsA != TOP_IS_STRING) {
  19693     return(NULL);
  19694   }
  19695 
  19696   return(icExtractSmallJson(self, ssGet(delim1), sjGet(delim2)));
  19697 }
  19698 
  19699 internal smallJsont* icExtractSmallStringSmallStringSmallJson(smallJsont *self, smallStringt* delim1, smallStringt* delim2) {
  19700 
  19701   if (!delim1 || !delim2) {
  19702     return(NULL);
  19703   }
  19704   if (checkObjectTypes && (!isOSmallString(delim1) || !isOSmallString(delim2))) {
  19705     return(NULL);
  19706   }
  19707 
  19708   return(icExtractSmallJson(self, ssGet(delim1), ssGet(delim2)));
  19709 }
  19710 
  19711 internal smallJsont* icExtractSmallStringSSmallJson(smallJsont *self, smallStringt* delim1, const char* delim2) {
  19712 
  19713   if (!delim1) {
  19714     return(NULL);
  19715   }
  19716   if (checkObjectTypes && !isOSmallString(delim1)) {
  19717     return(NULL);
  19718   }
  19719 
  19720   return(icExtractSmallJson(self, ssGet(delim1), delim2));
  19721 }
  19722 
  19723 internal smallJsont* icExtractSmallStringCharSmallJson(smallJsont *self, smallStringt* delim1, char delim2) {
  19724 
  19725   if (!delim1) {
  19726     return(NULL);
  19727   }
  19728   if (checkObjectTypes && !isOSmallString(delim1)) {
  19729     return(NULL);
  19730   }
  19731 
  19732   charToS(d2, delim2);
  19733   return(icExtractSmallJson(self, ssGet(delim1), d2));
  19734 }
  19735 
  19736 internal smallJsont* icExtractSSmallJsonSmallJson(smallJsont *self, const char* delim1, smallJsont* delim2) {
  19737 
  19738   if (!delim2) {
  19739     return(NULL);
  19740   }
  19741 
  19742   if (checkObjectTypes && !isOSmallJson(delim2)) {
  19743     return(NULL);
  19744   }
  19745 
  19746   if (delim2->topIsA != TOP_IS_STRING) {
  19747     return(NULL);
  19748   }
  19749 
  19750   return(icExtractSmallJson(self, delim1, sjGet(delim2)));
  19751 }
  19752 
  19753 internal smallJsont* icExtractSSmallStringSmallJson(smallJsont *self, const char* delim1, smallStringt* delim2) {
  19754 
  19755   if (!delim2) {
  19756     return(NULL);
  19757   }
  19758   if (checkObjectTypes && !isOSmallString(delim2)) {
  19759     return(NULL);
  19760   }
  19761 
  19762   return(icExtractSmallJson(self, delim1, ssGet(delim2)));
  19763 }
  19764 
  19765 internal smallJsont* icExtractCharSmallJsonSmallJson(smallJsont *self, char delim1, smallJsont* delim2) {
  19766 
  19767   if (!delim2) {
  19768     return(NULL);
  19769   }
  19770 
  19771   if (checkObjectTypes && !isOSmallJson(delim2)) {
  19772     return(NULL);
  19773   }
  19774 
  19775   if (delim2->topIsA != TOP_IS_STRING) {
  19776     return(NULL);
  19777   }
  19778 
  19779   charToS(d1, delim1);
  19780   return(icExtractSmallJson(self, d1, sjGet(delim2)));
  19781 }
  19782 
  19783 internal smallJsont* icExtractCharSmallStringSmallJson(smallJsont *self, char delim1, smallStringt* delim2) {
  19784 
  19785   if (!delim2) {
  19786     return(NULL);
  19787   }
  19788   if (checkObjectTypes && !isOSmallString(delim2)) {
  19789     return(NULL);
  19790   }
  19791 
  19792   charToS(d1, delim1);
  19793   return(icExtractSmallJson(self, d1, ssGet(delim2)));
  19794 }
  19795 
  19796 internal smallJsont* colorSmallJson(smallJsont *self, const char *colr) {
  19797 
  19798   if (self->topIsA != TOP_IS_STRING || !self->topS || !colr) {
  19799     return(NULL);
  19800   }
  19801 
  19802   char *s = catS(colr, sStringGetTiny(self->topS), RST);
  19803   freeSmallJson(self);
  19804   setTopStringSmallJson(self, s);
  19805   free(s);
  19806   return(self);
  19807 }
  19808 
  19809 internal char* colordSmallJson(smallJsont *self, const char *color) {
  19810 
  19811   if (self->topIsA != TOP_IS_STRING || !self->topS || !color) {
  19812     return(NULL);
  19813   }
  19814   if (isEmptySmallJson(self)) {
  19815     return(emptySF());
  19816   }
  19817   return(catS(color, sStringGetTiny(self->topS), RST));
  19818 }
  19819 
  19820 
  19821 internal smallJsont* zipSmallJson(smallJsont *self, smallArrayt *array1, smallArrayt *array2) {
  19822   size_t len;
  19823   size_t count;
  19824 
  19825   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  19826     return(NULL);
  19827   }
  19828 
  19829   if (!array1 || !array2) {
  19830     return(NULL);
  19831   }
  19832 
  19833   if (checkObjectTypes && (!isOSmallArray(array1) || !isOSmallArray(array2))) {
  19834     return(NULL);
  19835   }
  19836 
  19837   if (!array1->f->len(array1) || !array2->f->len(array2)) {
  19838     return(self);
  19839   }
  19840 
  19841   len = MIN(array1->f->len(array1), array2->f->len(array2));;
  19842 
  19843   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  19844     self->topIsA = TOP_IS_ARRAY;
  19845   }
  19846 
  19847   if (self->topIsA == TOP_IS_ARRAY) {
  19848     count = 0;
  19849 
  19850     enumerateSmallArray(array1, E1, i) {
  19851       createAllocateSmallArray(a);
  19852       if (!a) {
  19853         finishO(E1);
  19854         return(NULL);
  19855       }
  19856       pushNFreeO(a, E1);
  19857       pushNFreeO(a, getO(array2, (int64_t)i));
  19858       pushNFreeArraySmallJson(self, a);
  19859       count++;
  19860       if (count == len) {
  19861         break;
  19862   }
  19863     }
  19864       }
  19865 
  19866   else if (self->topIsA == TOP_IS_DICT) {
  19867     count = 0;
  19868 
  19869     forEachSmallArray(array1, K) {
  19870       if (!isOSmallString(K)) {
  19871         finishO(K);
  19872         return(NULL);
  19873       }
  19874       sDictSetTiny(&(self->top), ssGet(K), sArrayGetTiny(array2->a, (uint32_t)count));
  19875       finishO(K);
  19876       count++;
  19877       if (count == len) {
  19878         break;
  19879   }
  19880     }
  19881       }
  19882 
  19883 
  19884   return(self);
  19885 }
  19886 
  19887 internal smallJsont* zipArraySmallJson(smallJsont *self, char** array1, smallArrayt *array2) {
  19888   size_t len;
  19889   size_t count;
  19890 
  19891   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  19892     return(NULL);
  19893   }
  19894 
  19895   if (!array1 || !array2) {
  19896     return(NULL);
  19897   }
  19898 
  19899   if (checkObjectTypes && !isOSmallArray(array2)) {
  19900     return(NULL);
  19901   }
  19902 
  19903   if (!listLengthS(array1) || !array2->f->len(array2)) {
  19904     return(self);
  19905   }
  19906 
  19907   len = MIN(listLengthS(array1), array2->f->len(array2));;
  19908 
  19909   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  19910     self->topIsA = TOP_IS_ARRAY;
  19911   }
  19912 
  19913   if (self->topIsA == TOP_IS_ARRAY) {
  19914     count = 0;
  19915 
  19916     enumerateS(array1, E1, i) {
  19917       createAllocateSmallArray(a);
  19918       if (!a) {
  19919         return(NULL);
  19920       }
  19921       a->f->pushNFreeS(a, E1);
  19922       pushNFreeO(a, getO(array2, (int64_t)i));
  19923       pushNFreeArraySmallJson(self, a);
  19924       count++;
  19925       if (count == len) {
  19926         break;
  19927   }
  19928     }
  19929       }
  19930 
  19931   else if (self->topIsA == TOP_IS_DICT) {
  19932     count = 0;
  19933 
  19934     forEachS(array1, k) {
  19935       sDictSetTiny(&(self->top), k, sArrayGetTiny(array2->a, (uint32_t)count));
  19936       count++;
  19937       if (count == len) {
  19938         break;
  19939   }
  19940     }
  19941       }
  19942 
  19943   return(self);
  19944 }
  19945 
  19946 internal smallJsont* zipCArraySmallJson(smallJsont *self, const char** array1, smallArrayt *array2) {
  19947   size_t len;
  19948   size_t count;
  19949 
  19950   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  19951     return(NULL);
  19952   }
  19953 
  19954   if (!array1 || !array2) {
  19955     return(NULL);
  19956   }
  19957 
  19958   if (checkObjectTypes && !isOSmallArray(array2)) {
  19959     return(NULL);
  19960   }
  19961 
  19962   if (!listLengthCS(array1) || !array2->f->len(array2)) {
  19963     return(self);
  19964   }
  19965 
  19966   len = MIN(listLengthCS(array1), array2->f->len(array2));;
  19967 
  19968   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  19969     self->topIsA = TOP_IS_ARRAY;
  19970   }
  19971 
  19972   if (self->topIsA == TOP_IS_ARRAY) {
  19973     count = 0;
  19974 
  19975     enumerateCS(array1, E1, i) {
  19976       createAllocateSmallArray(a);
  19977       if (!a) {
  19978         return(NULL);
  19979       }
  19980       a->f->pushS(a, E1);
  19981       pushNFreeO(a, getO(array2, (int64_t)i));
  19982       pushNFreeArraySmallJson(self, a);
  19983       count++;
  19984       if (count == len) {
  19985         break;
  19986   }
  19987     }
  19988       }
  19989 
  19990   else if (self->topIsA == TOP_IS_DICT) {
  19991     count = 0;
  19992 
  19993     forEachCS(array1, k) {
  19994       sDictSetTiny(&(self->top), k, sArrayGetTiny(array2->a, (uint32_t)count));
  19995       count++;
  19996       if (count == len) {
  19997         break;
  19998   }
  19999     }
  20000       }
  20001 
  20002   return(self);
  20003 }
  20004 
  20005 internal smallJsont* zipCharSmallJson(smallJsont *self, smallArrayt *array1, char** array2) {
  20006   size_t len;
  20007   size_t count;
  20008 
  20009   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20010     return(NULL);
  20011   }
  20012 
  20013   if (!array1 || !array2) {
  20014     return(NULL);
  20015   }
  20016 
  20017   if (checkObjectTypes && !isOSmallArray(array1)) {
  20018     return(NULL);
  20019   }
  20020 
  20021   if (!array1->f->len(array1) || !listLengthS(array2)) {
  20022     return(self);
  20023   }
  20024 
  20025   len = MIN(array1->f->len(array1), listLengthS(array2));;
  20026 
  20027   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20028     self->topIsA = TOP_IS_ARRAY;
  20029   }
  20030 
  20031   if (self->topIsA == TOP_IS_ARRAY) {
  20032     count = 0;
  20033 
  20034     enumerateSmallArray(array1, E1, i) {
  20035       createAllocateSmallArray(a);
  20036       if (!a) {
  20037         finishO(E1);
  20038         return(NULL);
  20039       }
  20040       pushNFreeO(a, E1);
  20041       a->f->pushNFreeS(a, array2[i]);
  20042       pushNFreeArraySmallJson(self, a);
  20043       count++;
  20044       if (count == len) {
  20045         break;
  20046   }
  20047     }
  20048       }
  20049 
  20050   else if (self->topIsA == TOP_IS_DICT) {
  20051     count = 0;
  20052 
  20053     smallt *e;
  20054     forEachSmallArray(array1, K) {
  20055       if (!isOSmallString(K)) {
  20056         finishO(K);
  20057         return(NULL);
  20058       }
  20059       isError(e, (smallt *) allocSStringTiny(array2[count])) {
  20060         finishO(K);
  20061         return(NULL);
  20062       }
  20063       sDictSetTiny(&(self->top), ssGet(K), e);
  20064       finishO(K);
  20065       count++;
  20066       if (count == len) {
  20067         break;
  20068   }
  20069     }
  20070       }
  20071 
  20072   return(self);
  20073 }
  20074 
  20075 internal smallJsont* zipCCharSmallJson(smallJsont *self, smallArrayt *array1, const char** array2) {
  20076   size_t len;
  20077   size_t count;
  20078 
  20079   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20080     return(NULL);
  20081   }
  20082 
  20083   if (!array1 || !array2) {
  20084     return(NULL);
  20085   }
  20086 
  20087   if (checkObjectTypes && !isOSmallArray(array1)) {
  20088     return(NULL);
  20089   }
  20090 
  20091   if (!array1->f->len(array1) || !listLengthCS(array2)) {
  20092     return(self);
  20093   }
  20094 
  20095   len = MIN(array1->f->len(array1), listLengthCS(array2));;
  20096 
  20097   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20098     self->topIsA = TOP_IS_ARRAY;
  20099   }
  20100 
  20101   if (self->topIsA == TOP_IS_ARRAY) {
  20102     count = 0;
  20103 
  20104     enumerateSmallArray(array1, E1, i) {
  20105       createAllocateSmallArray(a);
  20106       if (!a) {
  20107         finishO(E1);
  20108         return(NULL);
  20109       }
  20110       pushNFreeO(a, E1);
  20111       a->f->pushS(a, array2[i]);
  20112       pushNFreeArraySmallJson(self, a);
  20113       count++;
  20114       if (count == len) {
  20115         break;
  20116   }
  20117     }
  20118       }
  20119 
  20120   else if (self->topIsA == TOP_IS_DICT) {
  20121     count = 0;
  20122 
  20123     smallt *e;
  20124     forEachSmallArray(array1, K) {
  20125       if (!isOSmallString(K)) {
  20126         finishO(K);
  20127         return(NULL);
  20128       }
  20129       isError(e, (smallt *) allocSStringTiny(array2[count])) {
  20130         finishO(K);
  20131         return(NULL);
  20132       }
  20133       sDictSetTiny(&(self->top), ssGet(K), e);
  20134       finishO(K);
  20135       count++;
  20136       if (count == len) {
  20137         break;
  20138   }
  20139     }
  20140       }
  20141 
  20142   return(self);
  20143 }
  20144 
  20145 internal smallJsont* zipArrayCharSmallJson(smallJsont *self, char** array1, char** array2) {
  20146   size_t len;
  20147   size_t count;
  20148 
  20149   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20150     return(NULL);
  20151   }
  20152 
  20153   if (!array1 || !array2) {
  20154     return(NULL);
  20155   }
  20156 
  20157   if (!listLengthS(array1) || !listLengthS(array2)) {
  20158     return(self);
  20159   }
  20160 
  20161   len = MIN(listLengthS(array1), listLengthS(array2));;
  20162 
  20163   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20164     self->topIsA = TOP_IS_ARRAY;
  20165   }
  20166 
  20167   if (self->topIsA == TOP_IS_ARRAY) {
  20168     count = 0;
  20169 
  20170     enumerateS(array1, E1, i) {
  20171       createAllocateSmallArray(a);
  20172       if (!a) {
  20173         return(NULL);
  20174       }
  20175       a->f->pushNFreeS(a, E1);
  20176       a->f->pushNFreeS(a, array2[i]);
  20177       pushNFreeArraySmallJson(self, a);
  20178       count++;
  20179       if (count == len) {
  20180         break;
  20181   }
  20182     }
  20183       }
  20184 
  20185   else if (self->topIsA == TOP_IS_DICT) {
  20186     count = 0;
  20187 
  20188     smallt *e;
  20189     forEachS(array1, k) {
  20190       isError(e, (smallt *) allocSStringTiny(array2[count])) return(NULL);
  20191       sDictSetTiny(&(self->top), k, e);
  20192       count++;
  20193       if (count == len) {
  20194         break;
  20195   }
  20196     }
  20197       }
  20198 
  20199   return(self);
  20200 }
  20201 
  20202 internal smallJsont* zipCArrayCharSmallJson(smallJsont *self, const char** array1, char** array2) {
  20203   size_t len;
  20204   size_t count;
  20205 
  20206   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20207     return(NULL);
  20208   }
  20209 
  20210   if (!array1 || !array2) {
  20211     return(NULL);
  20212   }
  20213 
  20214   if (!listLengthCS(array1) || !listLengthS(array2)) {
  20215     return(self);
  20216   }
  20217 
  20218   len = MIN(listLengthCS(array1), listLengthS(array2));;
  20219 
  20220   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20221     self->topIsA = TOP_IS_ARRAY;
  20222   }
  20223 
  20224   if (self->topIsA == TOP_IS_ARRAY) {
  20225     count = 0;
  20226 
  20227     enumerateCS(array1, E1, i) {
  20228       createAllocateSmallArray(a);
  20229       if (!a) {
  20230         return(NULL);
  20231       }
  20232       a->f->pushS(a, E1);
  20233       a->f->pushNFreeS(a, array2[i]);
  20234       pushNFreeArraySmallJson(self, a);
  20235       count++;
  20236       if (count == len) {
  20237         break;
  20238   }
  20239     }
  20240       }
  20241 
  20242   else if (self->topIsA == TOP_IS_DICT) {
  20243     count = 0;
  20244 
  20245     smallt *e;
  20246     forEachCS(array1, k) {
  20247       isError(e, (smallt *) allocSStringTiny(array2[count])) return(NULL);
  20248       sDictSetTiny(&(self->top), k, e);
  20249       count++;
  20250       if (count == len) {
  20251         break;
  20252   }
  20253     }
  20254       }
  20255 
  20256   return(self);
  20257 }
  20258 
  20259 internal smallJsont* zipArrayCCharSmallJson(smallJsont *self, char** array1, const char** array2) {
  20260   size_t len;
  20261   size_t count;
  20262 
  20263   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20264     return(NULL);
  20265   }
  20266 
  20267   if (!array1 || !array2) {
  20268     return(NULL);
  20269   }
  20270 
  20271   if (!listLengthS(array1) || !listLengthCS(array2)) {
  20272     return(self);
  20273   }
  20274 
  20275   len = MIN(listLengthS(array1), listLengthCS(array2));;
  20276 
  20277   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20278     self->topIsA = TOP_IS_ARRAY;
  20279   }
  20280 
  20281   if (self->topIsA == TOP_IS_ARRAY) {
  20282     count = 0;
  20283 
  20284     enumerateS(array1, E1, i) {
  20285       createAllocateSmallArray(a);
  20286       if (!a) {
  20287         return(NULL);
  20288       }
  20289       a->f->pushNFreeS(a, E1);
  20290       a->f->pushS(a, array2[i]);
  20291       pushNFreeArraySmallJson(self, a);
  20292       count++;
  20293       if (count == len) {
  20294         break;
  20295   }
  20296     }
  20297       }
  20298 
  20299   else if (self->topIsA == TOP_IS_DICT) {
  20300     count = 0;
  20301 
  20302     smallt *e;
  20303     forEachS(array1, k) {
  20304       isError(e, (smallt *) allocSStringTiny(array2[count])) return(NULL);
  20305       sDictSetTiny(&(self->top), k, e);
  20306       count++;
  20307       if (count == len) {
  20308         break;
  20309   }
  20310     }
  20311       }
  20312 
  20313   return(self);
  20314 }
  20315 
  20316 internal smallJsont* zipCArrayCCharSmallJson(smallJsont *self, const char** array1, const char** array2) {
  20317   size_t len;
  20318   size_t count;
  20319 
  20320   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20321     return(NULL);
  20322   }
  20323 
  20324   if (!array1 || !array2) {
  20325     return(NULL);
  20326   }
  20327 
  20328   if (!listLengthCS(array1) || !listLengthCS(array2)) {
  20329     return(self);
  20330   }
  20331 
  20332   len = MIN(listLengthCS(array1), listLengthCS(array2));;
  20333 
  20334   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20335     self->topIsA = TOP_IS_ARRAY;
  20336   }
  20337 
  20338   if (self->topIsA == TOP_IS_ARRAY) {
  20339     count = 0;
  20340 
  20341     enumerateCS(array1, E1, i) {
  20342       createAllocateSmallArray(a);
  20343       if (!a) {
  20344         return(NULL);
  20345       }
  20346       a->f->pushS(a, E1);
  20347       a->f->pushS(a, array2[i]);
  20348       pushNFreeArraySmallJson(self, a);
  20349       count++;
  20350       if (count == len) {
  20351         break;
  20352   }
  20353     }
  20354       }
  20355 
  20356   else if (self->topIsA == TOP_IS_DICT) {
  20357     count = 0;
  20358 
  20359     smallt *e;
  20360     forEachCS(array1, k) {
  20361       isError(e, (smallt *) allocSStringTiny(array2[count])) return(NULL);
  20362       sDictSetTiny(&(self->top), k, e);
  20363       count++;
  20364       if (count == len) {
  20365         break;
  20366   }
  20367     }
  20368       }
  20369 
  20370   return(self);
  20371 }
  20372 
  20373 smallJsont* zipJsonSmallJson(smallJsont *self, smallJsont *array1, smallJsont *array2) {
  20374   size_t len;
  20375   size_t count;
  20376 
  20377   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20378     return(NULL);
  20379   }
  20380 
  20381   if (!array1 || !array2) {
  20382     return(NULL);
  20383   }
  20384 
  20385   if (checkObjectTypes && (!isOSmallJson(array1) || !isOSmallJson(array2))) {
  20386     return(NULL);
  20387   }
  20388 
  20389   if (array1->topIsA != TOP_IS_ARRAY || array2->topIsA != TOP_IS_ARRAY) {
  20390     return(NULL);
  20391   }
  20392 
  20393   if (!array1->f->len(array1) || !array2->f->len(array2)) {
  20394     return(self);
  20395   }
  20396 
  20397   len = MIN(array1->f->len(array1), array2->f->len(array2));
  20398 
  20399   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20400     self->topIsA = TOP_IS_ARRAY;
  20401   }
  20402 
  20403   if (self->topIsA == TOP_IS_ARRAY) {
  20404     count = 0;
  20405 
  20406     enumerateSmallJson(array1, E1, i) {
  20407       createAllocateSmallArray(a);
  20408       if (!a) {
  20409         finishO(E1);
  20410         return(NULL);
  20411       }
  20412       pushNFreeO(a, E1);
  20413       pushNFreeO(a, getAtO(array2, (int64_t)i));
  20414       pushNFreeArraySmallJson(self, a);
  20415       count++;
  20416       if (count == len) {
  20417         break;
  20418   }
  20419     }
  20420       }
  20421 
  20422   else if (self->topIsA == TOP_IS_DICT) {
  20423     count = 0;
  20424 
  20425     forEachSmallJson(array1, K) {
  20426       if (!isOSmallString(K)) {
  20427         finishO(K);
  20428         return(NULL);
  20429       }
  20430       sDictSetTiny(&(self->top), ssGet(K), sArrayGetTiny(array2->topA, (uint32_t)count));
  20431       finishO(K);
  20432       count++;
  20433       if (count == len) {
  20434         break;
  20435   }
  20436     }
  20437       }
  20438 
  20439 
  20440   return(self);
  20441 }
  20442 
  20443 smallJsont* zipJsonSmallArraySmallJson(smallJsont *self, smallJsont *array1, smallArrayt *array2) {
  20444   size_t len;
  20445   size_t count;
  20446 
  20447   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20448     return(NULL);
  20449   }
  20450 
  20451   if (!array1 || !array2) {
  20452     return(NULL);
  20453   }
  20454 
  20455   if (checkObjectTypes && (!isOSmallJson(array1) || !isOSmallArray(array2))) {
  20456     return(NULL);
  20457   }
  20458 
  20459   if (array1->topIsA != TOP_IS_ARRAY) {
  20460     return(NULL);
  20461   }
  20462 
  20463   if (!array1->f->len(array1) || !array2->f->len(array2)) {
  20464     return(self);
  20465   }
  20466 
  20467   len = MIN(array1->f->len(array1), array2->f->len(array2));
  20468 
  20469   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20470     self->topIsA = TOP_IS_ARRAY;
  20471   }
  20472 
  20473   if (self->topIsA == TOP_IS_ARRAY) {
  20474     count = 0;
  20475 
  20476     enumerateSmallJson(array1, E1, i) {
  20477       createAllocateSmallArray(a);
  20478       if (!a) {
  20479         finishO(E1);
  20480         return(NULL);
  20481       }
  20482       pushNFreeO(a, E1);
  20483       pushNFreeO(a, getAtO(array2, (int64_t)i));
  20484       pushNFreeArraySmallJson(self, a);
  20485       count++;
  20486       if (count == len) {
  20487         break;
  20488   }
  20489     }
  20490       }
  20491 
  20492   else if (self->topIsA == TOP_IS_DICT) {
  20493     count = 0;
  20494 
  20495     forEachSmallJson(array1, K) {
  20496       if (!isOSmallString(K)) {
  20497         finishO(K);
  20498         return(NULL);
  20499       }
  20500       sDictSetTiny(&(self->top), ssGet(K), sArrayGetTiny(array2->a, (uint32_t)count));
  20501       finishO(K);
  20502       count++;
  20503       if (count == len) {
  20504         break;
  20505   }
  20506     }
  20507       }
  20508 
  20509 
  20510   return(self);
  20511 }
  20512 
  20513 smallJsont* zipJsonArraySmallJson(smallJsont *self, smallJsont *array1, char** array2) {
  20514   size_t len;
  20515   size_t count;
  20516 
  20517   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20518     return(NULL);
  20519   }
  20520 
  20521   if (!array1 || !array2) {
  20522     return(NULL);
  20523   }
  20524 
  20525   if (checkObjectTypes && !isOSmallJson(array1)) {
  20526     return(NULL);
  20527   }
  20528 
  20529   if (array1->topIsA != TOP_IS_ARRAY) {
  20530     return(NULL);
  20531   }
  20532 
  20533   if (!array1->f->len(array1) || !listLengthS(array2)) {
  20534     return(self);
  20535   }
  20536 
  20537   len = MIN(array1->f->len(array1), listLengthS(array2));;
  20538 
  20539   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20540     self->topIsA = TOP_IS_ARRAY;
  20541   }
  20542 
  20543   if (self->topIsA == TOP_IS_ARRAY) {
  20544     count = 0;
  20545 
  20546     enumerateSmallJson(array1, E1, i) {
  20547       createAllocateSmallArray(a);
  20548       if (!a) {
  20549         finishO(E1);
  20550         return(NULL);
  20551       }
  20552       pushNFreeO(a, E1);
  20553       a->f->pushNFreeS(a, array2[i]);
  20554       pushNFreeArraySmallJson(self, a);
  20555       count++;
  20556       if (count == len) {
  20557         break;
  20558   }
  20559     }
  20560       }
  20561 
  20562   else if (self->topIsA == TOP_IS_DICT) {
  20563     count = 0;
  20564 
  20565     smallt *e;
  20566     forEachSmallJson(array1, K) {
  20567       if (!isOSmallString(K)) {
  20568         finishO(K);
  20569         return(NULL);
  20570       }
  20571       isError(e, (smallt *) allocSStringTiny(array2[count])) {
  20572         finishO(K);
  20573         return(NULL);
  20574       }
  20575       sDictSetTiny(&(self->top), ssGet(K), e);
  20576       finishO(K);
  20577       count++;
  20578       if (count == len) {
  20579         break;
  20580   }
  20581     }
  20582       }
  20583 
  20584   return(self);
  20585 }
  20586 
  20587 smallJsont* zipJsonCArraySmallJson(smallJsont *self, smallJsont *array1, const char** array2) {
  20588   size_t len;
  20589   size_t count;
  20590 
  20591   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20592     return(NULL);
  20593   }
  20594 
  20595   if (!array1 || !array2) {
  20596     return(NULL);
  20597   }
  20598 
  20599   if (checkObjectTypes && !isOSmallJson(array1)) {
  20600     return(NULL);
  20601   }
  20602 
  20603   if (array1->topIsA != TOP_IS_ARRAY) {
  20604     return(NULL);
  20605   }
  20606 
  20607   if (!array1->f->len(array1) || !listLengthCS(array2)) {
  20608     return(self);
  20609   }
  20610 
  20611   len = MIN(array1->f->len(array1), listLengthCS(array2));;
  20612 
  20613   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20614     self->topIsA = TOP_IS_ARRAY;
  20615   }
  20616 
  20617   if (self->topIsA == TOP_IS_ARRAY) {
  20618     count = 0;
  20619 
  20620     enumerateSmallJson(array1, E1, i) {
  20621       createAllocateSmallArray(a);
  20622       if (!a) {
  20623         finishO(E1);
  20624         return(NULL);
  20625       }
  20626       pushNFreeO(a, E1);
  20627       a->f->pushS(a, array2[i]);
  20628       pushNFreeArraySmallJson(self, a);
  20629       count++;
  20630       if (count == len) {
  20631         break;
  20632   }
  20633     }
  20634       }
  20635 
  20636   else if (self->topIsA == TOP_IS_DICT) {
  20637     count = 0;
  20638 
  20639     smallt *e;
  20640     forEachSmallJson(array1, K) {
  20641       if (!isOSmallString(K)) {
  20642         finishO(K);
  20643         return(NULL);
  20644       }
  20645       isError(e, (smallt *) allocSStringTiny(array2[count])) {
  20646         finishO(K);
  20647         return(NULL);
  20648       }
  20649       sDictSetTiny(&(self->top), ssGet(K), e);
  20650       finishO(K);
  20651       count++;
  20652       if (count == len) {
  20653         break;
  20654   }
  20655     }
  20656       }
  20657 
  20658   return(self);
  20659 }
  20660 
  20661 smallJsont* zipSmallArrayJsonSmallJson(smallJsont *self, smallArrayt *array1, smallJsont *array2) {
  20662   size_t len;
  20663   size_t count;
  20664 
  20665   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20666     return(NULL);
  20667   }
  20668 
  20669   if (!array1 || !array2) {
  20670     return(NULL);
  20671   }
  20672 
  20673   if (checkObjectTypes && (!isOSmallArray(array1) || !isOSmallJson(array2))) {
  20674     return(NULL);
  20675   }
  20676 
  20677   if (array2->topIsA != TOP_IS_ARRAY) {
  20678     return(NULL);
  20679   }
  20680 
  20681   if (!array1->f->len(array1) || !array2->f->len(array2)) {
  20682     return(self);
  20683   }
  20684 
  20685   len = MIN(array1->f->len(array1), array2->f->len(array2));
  20686 
  20687   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20688     self->topIsA = TOP_IS_ARRAY;
  20689   }
  20690 
  20691   if (self->topIsA == TOP_IS_ARRAY) {
  20692     count = 0;
  20693 
  20694     enumerateSmallArray(array1, E1, i) {
  20695       createAllocateSmallArray(a);
  20696       if (!a) {
  20697         finishO(E1);
  20698         return(NULL);
  20699       }
  20700       pushNFreeO(a, E1);
  20701       pushNFreeO(a, getAtO(array2, (int64_t)i));
  20702       pushNFreeArraySmallJson(self, a);
  20703       count++;
  20704       if (count == len) {
  20705         break;
  20706   }
  20707     }
  20708       }
  20709 
  20710   else if (self->topIsA == TOP_IS_DICT) {
  20711     count = 0;
  20712 
  20713     forEachSmallArray(array1, K) {
  20714       if (!isOSmallString(K)) {
  20715         finishO(K);
  20716         return(NULL);
  20717       }
  20718       sDictSetTiny(&(self->top), ssGet(K), sArrayGetTiny(array2->topA, (uint32_t)count));
  20719       finishO(K);
  20720       count++;
  20721       if (count == len) {
  20722         break;
  20723   }
  20724     }
  20725       }
  20726 
  20727 
  20728   return(self);
  20729 }
  20730 
  20731 smallJsont* zipArrayJsonSmallJson(smallJsont *self, char** array1, smallJsont *array2) {
  20732   size_t len;
  20733   size_t count;
  20734 
  20735   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20736     return(NULL);
  20737   }
  20738 
  20739   if (!array1 || !array2) {
  20740     return(NULL);
  20741   }
  20742 
  20743   if (checkObjectTypes && !isOSmallJson(array2)) {
  20744     return(NULL);
  20745   }
  20746 
  20747   if (array2->topIsA != TOP_IS_ARRAY) {
  20748     return(NULL);
  20749   }
  20750 
  20751   if (!listLengthS(array1) || !array2->f->len(array2)) {
  20752     return(self);
  20753   }
  20754 
  20755   len = MIN(listLengthS(array1), array2->f->len(array2));;
  20756 
  20757   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20758     self->topIsA = TOP_IS_ARRAY;
  20759   }
  20760 
  20761   if (self->topIsA == TOP_IS_ARRAY) {
  20762     count = 0;
  20763 
  20764     enumerateS(array1, E1, i) {
  20765       createAllocateSmallArray(a);
  20766       if (!a) {
  20767         return(NULL);
  20768       }
  20769       a->f->pushNFreeS(a, E1);
  20770       pushNFreeO(a, getAtO(array2, (int64_t)i));
  20771       pushNFreeArraySmallJson(self, a);
  20772       count++;
  20773       if (count == len) {
  20774         break;
  20775   }
  20776     }
  20777       }
  20778 
  20779   else if (self->topIsA == TOP_IS_DICT) {
  20780     count = 0;
  20781 
  20782     forEachS(array1, k) {
  20783       sDictSetTiny(&(self->top), k, sArrayGetTiny(array2->topA, (uint32_t)count));
  20784       count++;
  20785       if (count == len) {
  20786         break;
  20787   }
  20788     }
  20789       }
  20790 
  20791   return(self);
  20792 }
  20793 
  20794 smallJsont* zipCArrayJsonSmallJson(smallJsont *self, const char** array1, smallJsont *array2) {
  20795   size_t len;
  20796   size_t count;
  20797 
  20798   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_DICT && self->topIsA != TOP_IS_ARRAY) {
  20799     return(NULL);
  20800   }
  20801 
  20802   if (!array1 || !array2) {
  20803     return(NULL);
  20804   }
  20805 
  20806   if (checkObjectTypes && !isOSmallJson(array2)) {
  20807     return(NULL);
  20808   }
  20809 
  20810   if (array2->topIsA != TOP_IS_ARRAY) {
  20811     return(NULL);
  20812   }
  20813 
  20814   if (!listLengthCS(array1) || !array2->f->len(array2)) {
  20815     return(self);
  20816   }
  20817 
  20818   len = MIN(listLengthCS(array1), array2->f->len(array2));;
  20819 
  20820   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  20821     self->topIsA = TOP_IS_ARRAY;
  20822   }
  20823 
  20824   if (self->topIsA == TOP_IS_ARRAY) {
  20825     count = 0;
  20826 
  20827     enumerateCS(array1, E1, i) {
  20828       createAllocateSmallArray(a);
  20829       if (!a) {
  20830         return(NULL);
  20831       }
  20832       a->f->pushS(a, E1);
  20833       pushNFreeO(a, getAtO(array2, (int64_t)i));
  20834       pushNFreeArraySmallJson(self, a);
  20835       count++;
  20836       if (count == len) {
  20837         break;
  20838   }
  20839     }
  20840       }
  20841 
  20842   else if (self->topIsA == TOP_IS_DICT) {
  20843     count = 0;
  20844 
  20845     forEachCS(array1, k) {
  20846       sDictSetTiny(&(self->top), k, sArrayGetTiny(array2->topA, (uint32_t)count));
  20847       count++;
  20848       if (count == len) {
  20849         break;
  20850   }
  20851     }
  20852       }
  20853 
  20854   return(self);
  20855 }
  20856 
  20857 
  20858 internal baset* iterStartSmallJson(smallJsont *self) {
  20859   smallt *o = NULL;
  20860 
  20861   // reset iterIndex to a known value
  20862   self->iterIndex = -1;
  20863   if (isEmptySmallJson(self)) {
  20864     // no iteration on empty arrays
  20865     return(NULL);
  20866   }
  20867 
  20868   switch(self->topIsA) {
  20869     case TOP_IS_DICT:
  20870       // get first element
  20871       range(i, self->top->count)
  20872         if ((&((self->top)->elements) + i)->key) {
  20873           self->iterIndex = (ssize_t)i;
  20874           break;
  20875         }
  20876       if (self->iterElementDataType != SH_DT_BASET) {
  20877         // free already created base object
  20878         finishO(self->iterElement);
  20879       }
  20880       self->iterKey = (&((self->top)->elements) + self->iterIndex)->key;
  20881       o             = (&((self->top)->elements) + self->iterIndex)->data;
  20882       if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
  20883         self->iterElementDataType = SH_DT_BASET;
  20884       }
  20885       else {
  20886         self->iterElementDataType = SH_DT_UNKNOWN;
  20887       }
  20888       self->iterElement = toBaset(o);
  20889       break;
  20890     case TOP_IS_ARRAY:
  20891       // get first element
  20892       // find first non NULL element, deleted element can be at index 0
  20893       range(i, self->topA->count)
  20894         if (sArrayGetTiny(self->topA, (uint32_t)i)) {
  20895           self->iterIndex = (ssize_t)i;
  20896           break;
  20897         }
  20898       self->iterStep = 1;
  20899       if (self->iterElementDataType != SH_DT_BASET) {
  20900         // free already created base object
  20901         finishO(self->iterElement);
  20902       }
  20903       // TODO find first non NULL element, deleted element can be at index 0
  20904       o              = sArrayGetTiny(self->topA, (uint32_t)self->iterIndex);
  20905       if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
  20906         self->iterElementDataType = SH_DT_BASET;
  20907       }
  20908       else {
  20909         self->iterElementDataType = SH_DT_UNKNOWN;
  20910       }
  20911       self->iterElement = toBaset(o);
  20912       break;
  20913     default:;
  20914       // return NULL (self->iterElement is NULL)
  20915   }
  20916   return(self->iterElement);
  20917 }
  20918 
  20919 internal const char* iterStartKeySmallJson(smallJsont *self) {
  20920 
  20921   if (self->topIsA != TOP_IS_DICT) {
  20922     return(NULL);
  20923   }
  20924 
  20925   // reset iterIndex to a known value
  20926   self->iterIndex = -1;
  20927   if (isEmptySmallJson(self)) {
  20928     // no iteration on empty arrays
  20929     return(NULL);
  20930   }
  20931 
  20932   // get first element
  20933   range(i, self->top->count)
  20934     if ((&((self->top)->elements) + i)->key) {
  20935       self->iterIndex = (ssize_t)i;
  20936       break;
  20937     }
  20938   if (self->iterElementDataType != SH_DT_BASET) {
  20939     // free already created base object
  20940     finishO(self->iterElement);
  20941   }
  20942   self->iterKey     = (&((self->top)->elements) + self->iterIndex)->key;
  20943   smallt *o         = (&((self->top)->elements) + self->iterIndex)->data;
  20944   if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
  20945     self->iterElementDataType = SH_DT_BASET;
  20946   }
  20947   else {
  20948     self->iterElementDataType = SH_DT_UNKNOWN;
  20949   }
  20950   self->iterElement = toBaset(o);
  20951   return(self->iterKey);
  20952 }
  20953 
  20954 
  20955 internal baset* iterStartLastSmallJson(smallJsont *self) {
  20956 
  20957   if (self->topIsA != TOP_IS_ARRAY) {
  20958     return(NULL);
  20959   }
  20960 
  20961   // reset iterIndex to a known value
  20962   self->iterIndex = -1;
  20963   if (isEmptySmallJson(self)) {
  20964     // no iteration on empty arrays
  20965     return(NULL);
  20966   }
  20967 
  20968   // get first element
  20969   // find first non NULL element, deleted element can be at index 0
  20970   rangeDown(i, self->topA->count)
  20971     if (sArrayGetTiny(self->topA, (uint32_t)i)) {
  20972       self->iterIndex = i;
  20973       break;
  20974     }
  20975   self->iterStep = -1;
  20976   if (self->iterElementDataType != SH_DT_BASET) {
  20977     // free already created base object
  20978     finishO(self->iterElement);
  20979   }
  20980   smallt *o      = sArrayGetTiny(self->topA, (uint32_t)self->iterIndex);
  20981   if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
  20982     self->iterElementDataType = SH_DT_BASET;
  20983   }
  20984   else {
  20985     self->iterElementDataType = SH_DT_UNKNOWN;
  20986   }
  20987   self->iterElement = toBaset(o);
  20988   return(self->iterElement);
  20989 }
  20990 
  20991 internal baset* iterStartFromSmallJson(smallJsont *self, int64_t index) {
  20992 
  20993   if (self->topIsA != TOP_IS_ARRAY) {
  20994     return(NULL);
  20995   }
  20996 
  20997   // reset iterIndex to a known value
  20998   self->iterIndex = -1;
  20999   if (isEmptySmallJson(self)) {
  21000     // no iteration on empty arrays
  21001     return(NULL);
  21002   }
  21003 
  21004   if (index >= (int64_t)lenSmallJson(self)) {
  21005     return(NULL);
  21006   }
  21007   if (index < -(int64_t)lenSmallJson(self)) {
  21008     return(NULL);
  21009   }
  21010   if (index < 0) {
  21011     index = (int64_t)lenSmallJson(self) + index;
  21012   }
  21013 
  21014   // get first element
  21015   // find first non NULL element, deleted element can be at index 0
  21016   rangeFrom(i, (size_t)index, self->topA->count)
  21017     if (sArrayGetTiny(self->topA, (uint32_t)i)) {
  21018       self->iterIndex = (ssize_t)i;
  21019       break;
  21020     }
  21021   if (self->iterIndex == -1) {
  21022     // no element was found in the dictionary
  21023     return(NULL);
  21024   }
  21025   self->iterStep = 1;
  21026   if (self->iterElementDataType != SH_DT_BASET) {
  21027     // free already created base object
  21028     finishO(self->iterElement);
  21029   }
  21030   smallt *o      = sArrayGetTiny(self->topA, (uint32_t) self->iterIndex);
  21031   if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
  21032     self->iterElementDataType = SH_DT_BASET;
  21033   }
  21034   else {
  21035     self->iterElementDataType = SH_DT_UNKNOWN;
  21036   }
  21037   self->iterElement = toBaset(o);
  21038   return(self->iterElement);
  21039 }
  21040 
  21041 internal baset* iterStartFromStepSmallJson(smallJsont *self, int64_t index, int64_t step) {
  21042 
  21043   if (self->topIsA != TOP_IS_ARRAY) {
  21044     return(NULL);
  21045   }
  21046 
  21047   // reset iterIndex to a known value
  21048   self->iterIndex = -1;
  21049   if (isEmptySmallJson(self)) {
  21050     // no iteration on empty arrays
  21051     return(NULL);
  21052   }
  21053 
  21054   if (!step) {
  21055     // step 0 is invalid because it causes an infinite loop
  21056     return(NULL);
  21057   }
  21058 
  21059   if (index >= (int64_t)lenSmallJson(self)) {
  21060     return(NULL);
  21061   }
  21062   if (index < -(int64_t)lenSmallJson(self)) {
  21063     return(NULL);
  21064   }
  21065   if (index < 0) {
  21066     index = (int64_t)lenSmallJson(self) + index;
  21067   }
  21068 
  21069   // get first element
  21070   // find first non NULL element, deleted element can be at index 0
  21071   rangeFromStep(i, (size_t)index, self->topA->count, step)
  21072     if (sArrayGetTiny(self->topA, (uint32_t)i)) {
  21073       self->iterIndex = (ssize_t)i;
  21074       break;
  21075     }
  21076   if (self->iterIndex == -1) {
  21077     // no element was found in the dictionary
  21078     return(NULL);
  21079   }
  21080   self->iterStep = step;
  21081   if (self->iterElementDataType != SH_DT_BASET) {
  21082     // free already created base object
  21083     finishO(self->iterElement);
  21084   }
  21085   smallt *o      = sArrayGetTiny(self->topA, (uint32_t)self->iterIndex);
  21086   if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
  21087     self->iterElementDataType = SH_DT_BASET;
  21088   }
  21089   else {
  21090     self->iterElementDataType = SH_DT_UNKNOWN;
  21091   }
  21092   self->iterElement = toBaset(o);
  21093   return(self->iterElement);
  21094 }
  21095 
  21096 internal baset* iterNextSmallJson(smallJsont *self) {
  21097 
  21098   if (self->iterIndex == -1) {
  21099     // the iteration hasn't started
  21100     return(NULL);
  21101   }
  21102 
  21103   switch(self->topIsA) {
  21104     case TOP_IS_DICT: {
  21105       // get next element
  21106       self->iterIndex++;
  21107       // free already created base object
  21108       if (self->iterElementDataType != SH_DT_BASET) {
  21109         finishO(self->iterElement);
  21110       }
  21111       rangeFrom(i, (size_t)self->iterIndex, self->top->count) {
  21112         if ((&((self->top)->elements) + i)->key) {
  21113           self->iterIndex = (ssize_t)i;
  21114           break;
  21115         }
  21116         if (!(&((self->top)->elements) + i)->key && (i == (self->top->count -1))) {
  21117           // last element is null, finish iteration
  21118           self->iterIndex = self->top->count;
  21119         }
  21120       }
  21121       if ((self->iterIndex >= self->top->count)) {
  21122         // the index is outside the array, the iteration is finished
  21123         self->iterIndex = -1;
  21124         return(NULL);
  21125       }
  21126       self->iterKey     = (&((self->top)->elements) + self->iterIndex)->key;
  21127       smallt *o         = (&((self->top)->elements) + self->iterIndex)->data;
  21128       if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
  21129         self->iterElementDataType = SH_DT_BASET;
  21130       }
  21131       else {
  21132         self->iterElementDataType = SH_DT_UNKNOWN;
  21133       }
  21134       self->iterElement = toBaset(o);
  21135       }
  21136       break;
  21137     case TOP_IS_ARRAY: {
  21138       // free already created base object
  21139       if (self->iterElementDataType != SH_DT_BASET) {
  21140         finishO(self->iterElement);
  21141       }
  21142       else {
  21143         self->iterElement = NULL;
  21144       }
  21145       // get next element until we get a valid item or the end is reached
  21146       while (!self->iterElement) {
  21147         // get next element
  21148         self->iterIndex  += self->iterStep;
  21149         if ((self->iterIndex >= (int64_t)lenSmallJson(self) || self->iterIndex < 0)) {
  21150           // the index is outside the array, the iteration is finished
  21151           self->iterIndex = -1;
  21152           return(NULL);
  21153         }
  21154         smallt *o         = sArrayGetTiny(self->topA, (uint32_t)self->iterIndex);
  21155         if (!o) {
  21156           continue;
  21157         }
  21158         if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
  21159           self->iterElementDataType = SH_DT_BASET;
  21160         }
  21161         else {
  21162           self->iterElementDataType = SH_DT_UNKNOWN;
  21163         }
  21164         self->iterElement = toBaset(o);
  21165       }
  21166       }
  21167       break;
  21168     default:
  21169       logC("Check iterator!");
  21170       return(NULL);
  21171   }
  21172   return(self->iterElement);
  21173 }
  21174 
  21175 internal const char* iterNextKeySmallJson(smallJsont *self) {
  21176 
  21177   if (self->topIsA != TOP_IS_DICT) {
  21178     return(NULL);
  21179   }
  21180 
  21181   if (self->iterIndex == -1) {
  21182     // the iteration hasn't started
  21183     return(NULL);
  21184   }
  21185   // get next element
  21186   self->iterIndex++;
  21187   // free already created base object
  21188   if (self->iterElementDataType != SH_DT_BASET) {
  21189     finishO(self->iterElement);
  21190   }
  21191   rangeFrom(i, (size_t)self->iterIndex, self->top->count) {
  21192     if ((&((self->top)->elements) + i)->key) {
  21193       self->iterIndex = (ssize_t)i;
  21194       break;
  21195     }
  21196     if (!(&((self->top)->elements) + i)->key && (i == (self->top->count -1))) {
  21197       // last element is null, finish iteration
  21198       self->iterIndex = self->top->count;
  21199     }
  21200   }
  21201   if ((self->iterIndex >= self->top->count)) {
  21202     // the index is outside the array, the iteration is finished
  21203     self->iterIndex = -1;
  21204     return(NULL);
  21205   }
  21206   self->iterKey     = (&((self->top)->elements) + self->iterIndex)->key;
  21207   smallt *o         = (&((self->top)->elements) + self->iterIndex)->data;
  21208   if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
  21209     self->iterElementDataType = SH_DT_BASET;
  21210   }
  21211   else {
  21212     self->iterElementDataType = SH_DT_UNKNOWN;
  21213   }
  21214   self->iterElement = toBaset(o);
  21215   return(self->iterKey);
  21216 }
  21217 
  21218 internal baset* iterElementSmallJson(smallJsont *self) {
  21219 
  21220   return(self->iterElement);
  21221 }
  21222 
  21223 internal const char* iterKeySmallJson(smallJsont *self) {
  21224 
  21225   if (self->topIsA != TOP_IS_DICT) {
  21226     return(NULL);
  21227   }
  21228 
  21229   return(self->iterKey);
  21230 }
  21231 
  21232 internal ssize_t iterIndexSmallJson(smallJsont *self) {
  21233 
  21234   if (self->topIsA != TOP_IS_ARRAY) {
  21235     return(-1);
  21236   }
  21237 
  21238   return(self->iterIndex);
  21239 }
  21240 
  21241 internal int64_t iterStepSmallJson(smallJsont *self) {
  21242 
  21243   if (self->topIsA != TOP_IS_ARRAY) {
  21244     return(-1);
  21245   }
  21246 
  21247   return(self->iterStep);
  21248 }
  21249 
  21250 internal baset* getSmallJson(smallJsont *self, const char *key) {
  21251 
  21252   smallt *o = NULL;
  21253   getJsonPath;
  21254   pass:
  21255   return(toBaset(o));
  21256   fail:
  21257   return(NULL);
  21258 }
  21259 
  21260 internal undefinedt* getUndefinedSmallJson(smallJsont *self, const char *key) {
  21261 
  21262   smallt *o = NULL;
  21263   getJsonPath;
  21264   pass:
  21265   if (!o) {
  21266     return(NULL);
  21267   }
  21268   if (o->type != UNDEFINED) {
  21269     return(NULL);
  21270   }
  21271   return(allocUndefined());
  21272   fail:
  21273   return(NULL);
  21274 }
  21275 
  21276 internal bool getBoolSmallJson(smallJsont *self, const char *key) {
  21277   smallBoolt *e = NULL;
  21278   bool r = false;;
  21279 
  21280   e = getSmallBoolSmallJson(self, key);
  21281   if (e) {
  21282     r = e->f->get(e);
  21283     finishO(e);
  21284   }
  21285   return(r);
  21286 }
  21287 
  21288 internal bool* getBoolPSmallJson(smallJsont *self, const char *key) {
  21289   smallBoolt *e = NULL;
  21290   bool* r = NULL;
  21291 
  21292   e = getSmallBoolSmallJson(self, key);
  21293   if (e) {
  21294     r = e->f->getP(e);
  21295     finishO(e);
  21296   }
  21297   return(r);
  21298 }
  21299 
  21300 internal double getDoubleSmallJson(smallJsont *self, const char *key) {
  21301   smallDoublet *e = NULL;
  21302   double r = 0;;
  21303 
  21304   e = getSmallDoubleSmallJson(self, key);
  21305   if (e) {
  21306     r = e->f->get(e);
  21307     finishO(e);
  21308   }
  21309   return(r);
  21310 }
  21311 
  21312 internal double* getDoublePSmallJson(smallJsont *self, const char *key) {
  21313   smallDoublet *e = NULL;
  21314   double* r = NULL;
  21315 
  21316   e = getSmallDoubleSmallJson(self, key);
  21317   if (e) {
  21318     r = e->f->getP(e);
  21319     finishO(e);
  21320   }
  21321   return(r);
  21322 }
  21323 
  21324 internal int64_t getIntSmallJson(smallJsont *self, const char *key) {
  21325   smallIntt *e = NULL;
  21326   int64_t r = 0;;
  21327 
  21328   e = getSmallIntSmallJson(self, key);
  21329   if (e) {
  21330     r = e->f->get(e);
  21331     finishO(e);
  21332   }
  21333   return(r);
  21334 }
  21335 
  21336 internal int64_t* getIntPSmallJson(smallJsont *self, const char *key) {
  21337   smallIntt *e = NULL;
  21338   int64_t* r = NULL;
  21339 
  21340   e = getSmallIntSmallJson(self, key);
  21341   if (e) {
  21342     r = e->f->getP(e);
  21343     finishO(e);
  21344   }
  21345   return(r);
  21346 }
  21347 
  21348 internal int32_t getInt32SmallJson(smallJsont *self, const char *key) {
  21349   smallIntt *e = NULL;
  21350   int32_t r = 0;;
  21351 
  21352   e = getSmallIntSmallJson(self, key);
  21353   if (e) {
  21354     r = (int32_t)e->f->get(e);
  21355     finishO(e);
  21356   }
  21357   return(r);
  21358 }
  21359 
  21360 internal int32_t* getInt32PSmallJson(smallJsont *self, const char *key) {
  21361   smallIntt *e = NULL;
  21362   int32_t* r = NULL;
  21363 
  21364   e = getSmallIntSmallJson(self, key);
  21365   if (e) {
  21366     r = (int32_t *)e->f->getP(e);
  21367     finishO(e);
  21368   }
  21369   return(r);
  21370 }
  21371 
  21372 internal uint64_t getUintSmallJson(smallJsont *self, const char *key) {
  21373   smallIntt *e = NULL;
  21374   uint64_t r = 0;;
  21375 
  21376   e = getSmallIntSmallJson(self, key);
  21377   if (e) {
  21378     r = (uint64_t)e->f->get(e);
  21379     finishO(e);
  21380   }
  21381   return(r);
  21382 }
  21383 
  21384 internal uint64_t* getUintPSmallJson(smallJsont *self, const char *key) {
  21385   smallIntt *e = NULL;
  21386   uint64_t* r = NULL;
  21387 
  21388   e = getSmallIntSmallJson(self, key);
  21389   if (e) {
  21390     r = (uint64_t *)e->f->getP(e);
  21391     finishO(e);
  21392   }
  21393   return(r);
  21394 }
  21395 
  21396 internal uint32_t getUint32SmallJson(smallJsont *self, const char *key) {
  21397   smallIntt *e = NULL;
  21398   uint32_t r = 0;;
  21399 
  21400   e = getSmallIntSmallJson(self, key);
  21401   if (e) {
  21402     r = (uint32_t)e->f->get(e);
  21403     finishO(e);
  21404   }
  21405   return(r);
  21406 }
  21407 
  21408 internal uint32_t* getUint32PSmallJson(smallJsont *self, const char *key) {
  21409   smallIntt *e = NULL;
  21410   uint32_t* r = NULL;
  21411 
  21412   e = getSmallIntSmallJson(self, key);
  21413   if (e) {
  21414     r = (uint32_t *)e->f->getP(e);
  21415     finishO(e);
  21416   }
  21417   return(r);
  21418 }
  21419 
  21420 internal char* getSSmallJson(smallJsont *self, const char *key) {
  21421   smallStringt *e = NULL;
  21422   char* r = NULL;
  21423 
  21424   e = getSmallStringSmallJson(self, key);
  21425   if (e) {
  21426     r = e->f->get(e);
  21427     finishO(e);
  21428   }
  21429   return(r);
  21430 }
  21431 
  21432 internal smallDictt* getDictSmallJson(smallJsont *self, const char *key) {
  21433 
  21434   smallt *o = NULL;
  21435   getJsonPath;
  21436   pass:
  21437   if (!o) {
  21438     return(NULL);
  21439   }
  21440   if (o->type != DICT) {
  21441     return(NULL);
  21442   }
  21443   return((smallDictt*) toBaset(o));
  21444   fail:
  21445   return(NULL);
  21446 }
  21447 
  21448 internal smallArrayt* getArraySmallJson(smallJsont *self, const char *key) {
  21449 
  21450   smallt *o = NULL;
  21451   getJsonPath;
  21452   pass:
  21453   if (!o) {
  21454     return(NULL);
  21455   }
  21456   if (o->type != ARRAY) {
  21457     return(NULL);
  21458   }
  21459   return((smallArrayt*) toBaset(o));
  21460   fail:
  21461   return(NULL);
  21462 }
  21463 
  21464 internal smallBoolt* getSmallBoolSmallJson(smallJsont *self, const char *key) {
  21465 
  21466   smallt *o = NULL;
  21467   getJsonPath;
  21468   pass:
  21469   if (!o) {
  21470     return(NULL);
  21471   }
  21472   if (o->type != BOOL) {
  21473     return(NULL);
  21474   }
  21475   return((smallBoolt*) toBaset(o));
  21476   fail:
  21477   return(NULL);
  21478 }
  21479 
  21480 internal smallBytest* getSmallBytesSmallJson(smallJsont *self, const char *key) {
  21481 
  21482   smallt *o = NULL;
  21483   getJsonPath;
  21484   pass:
  21485   if (!o) {
  21486     return(NULL);
  21487   }
  21488   if (o->type != BYTES) {
  21489     return(NULL);
  21490   }
  21491   return((smallBytest*) toBaset(o));
  21492   fail:
  21493   return(NULL);
  21494 }
  21495 
  21496 internal smallDoublet* getSmallDoubleSmallJson(smallJsont *self, const char *key) {
  21497 
  21498   smallt *o = NULL;
  21499   getJsonPath;
  21500   pass:
  21501   if (!o) {
  21502     return(NULL);
  21503   }
  21504   if (o->type != DOUBLE) {
  21505     return(NULL);
  21506   }
  21507   return((smallDoublet*) toBaset(o));
  21508   fail:
  21509   return(NULL);
  21510 }
  21511 
  21512 internal smallIntt* getSmallIntSmallJson(smallJsont *self, const char *key) {
  21513 
  21514   smallt *o = NULL;
  21515   getJsonPath;
  21516   pass:
  21517   if (!o) {
  21518     return(NULL);
  21519   }
  21520   if (o->type != INT) {
  21521     return(NULL);
  21522   }
  21523   return((smallIntt*) toBaset(o));
  21524   fail:
  21525   return(NULL);
  21526 }
  21527 
  21528 internal smallJsont* getSmallJsonSmallJson(smallJsont *self, const char *key) {
  21529 
  21530   smallt *o = NULL;
  21531   getJsonPath;
  21532   pass:
  21533   if (!o) {
  21534     return(NULL);
  21535   }
  21536   if ((o->type == BYTES) || (o->type == CONTAINER)) {
  21537     return(NULL);
  21538   }
  21539 
  21540   baset *e = toBaset(o);
  21541 
  21542   if (!e) {
  21543     return(NULL);
  21544   }
  21545 
  21546   createAllocateSmallJson(r);
  21547   if (!r) {
  21548     finishO(e);
  21549     return(NULL);
  21550   }
  21551   setTopNFreeSmallJson(r, e);
  21552   return(r);
  21553   fail:
  21554   return(NULL);
  21555 }
  21556 
  21557 internal smallStringt* getSmallStringSmallJson(smallJsont *self, const char *key) {
  21558 
  21559   smallt *o = NULL;
  21560   getJsonPath;
  21561   pass:
  21562   if (!o) {
  21563     return(NULL);
  21564   }
  21565   if (o->type != STRING) {
  21566     return(NULL);
  21567   }
  21568   return((smallStringt*) toBaset(o));
  21569   fail:
  21570   return(NULL);
  21571 }
  21572 
  21573 internal void* getVoidSmallJson(smallJsont *self, const char *key) {
  21574   smallt *o = NULL;
  21575 
  21576   getJsonPath;
  21577   pass:
  21578   if (!o) {
  21579     return(NULL);
  21580   }
  21581   if (o->type != CONTAINER) {
  21582     return(NULL);
  21583   }
  21584   if (((sContainert*)o)->dataType == SH_DT_BASET) {
  21585     return(NULL);
  21586   }
  21587   return(((sContainert*)o)->data);
  21588   fail:
  21589   return(NULL);
  21590 }
  21591 
  21592 internal smallContainert* getSmallContainerSmallJson(smallJsont *self, const char *key) {
  21593 
  21594   smallt *o = NULL;
  21595   getJsonPath;
  21596   pass:
  21597   if (!o) {
  21598     return(NULL);
  21599   }
  21600   if (o->type != CONTAINER) {
  21601     return(NULL);
  21602   }
  21603   if (((sContainert*)o)->dataType == SH_DT_BASET) {
  21604     return(NULL);
  21605   }
  21606   return((smallContainert*) toBaset(o));
  21607   fail:
  21608   return(NULL);
  21609 }
  21610 
  21611 //getNDup
  21612 internal baset* getNDupSmallJson(smallJsont *self, const char *key) {
  21613 
  21614   smallt *o = NULL;
  21615   getJsonPath;
  21616   pass:
  21617   if (!o) {
  21618     return(NULL);
  21619   }
  21620   if (o->type == CONTAINER && (((sContainert*)o)->dataType == SH_DT_BASET)) {
  21621     baset *b = ((sContainert*)o)->data;
  21622     return(duplicateO(b));
  21623   }
  21624   return(toBaset(sDuplicate(o)));
  21625   fail:
  21626   return(NULL);
  21627 }
  21628 
  21629 internal undefinedt* getNDupUndefinedSmallJson(smallJsont *self, const char *key) {
  21630 
  21631   smallt *o = NULL;
  21632   getJsonPath;
  21633   pass:
  21634   if (!o) {
  21635     return(NULL);
  21636   }
  21637   if (o->type != UNDEFINED) {
  21638     return(NULL);
  21639   }
  21640   return(allocUndefined());
  21641   fail:
  21642   return(NULL);
  21643 }
  21644 
  21645 internal bool getNDupBoolSmallJson(smallJsont *self, const char *key) {
  21646   smallBoolt *e = NULL;
  21647   bool r = false;;
  21648 
  21649   e = getSmallBoolSmallJson(self, key);
  21650   if (e) {
  21651     r = e->f->get(e);
  21652     finishO(e);
  21653   }
  21654   return(r);
  21655 }
  21656 
  21657 internal double getNDupDoubleSmallJson(smallJsont *self, const char *key) {
  21658   smallDoublet *e = NULL;
  21659   double r = 0;;
  21660 
  21661   e = getSmallDoubleSmallJson(self, key);
  21662   if (e) {
  21663     r = e->f->get(e);
  21664     finishO(e);
  21665   }
  21666   return(r);
  21667 }
  21668 
  21669 internal int64_t getNDupIntSmallJson(smallJsont *self, const char *key) {
  21670   smallIntt *e = NULL;
  21671   int64_t r = 0;;
  21672 
  21673   e = getSmallIntSmallJson(self, key);
  21674   if (e) {
  21675     r = e->f->get(e);
  21676     finishO(e);
  21677   }
  21678   return(r);
  21679 }
  21680 
  21681 internal int32_t getNDupInt32SmallJson(smallJsont *self, const char *key) {
  21682   smallIntt *e = NULL;
  21683   int32_t r = 0;;
  21684 
  21685   e = getSmallIntSmallJson(self, key);
  21686   if (e) {
  21687     r = (int32_t)e->f->get(e);
  21688     finishO(e);
  21689   }
  21690   return(r);
  21691 }
  21692 
  21693 internal uint64_t getNDupUintSmallJson(smallJsont *self, const char *key) {
  21694   smallIntt *e = NULL;
  21695   uint64_t r = 0;;
  21696 
  21697   e = getSmallIntSmallJson(self, key);
  21698   if (e) {
  21699     r = (uint64_t)e->f->get(e);
  21700     finishO(e);
  21701   }
  21702   return(r);
  21703 }
  21704 
  21705 internal uint32_t getNDupUint32SmallJson(smallJsont *self, const char *key) {
  21706   smallIntt *e = NULL;
  21707   uint32_t r = 0;;
  21708 
  21709   e = getSmallIntSmallJson(self, key);
  21710   if (e) {
  21711     r = (uint32_t)e->f->get(e);
  21712     finishO(e);
  21713   }
  21714   return(r);
  21715 }
  21716 
  21717 internal char* getNDupSSmallJson(smallJsont *self, const char *key) {
  21718   smallStringt *e = NULL;
  21719   char* r = NULL;
  21720 
  21721   e = getSmallStringSmallJson(self, key);
  21722   if (e) {
  21723     r = e->f->toString(e);
  21724     finishO(e);
  21725   }
  21726   return(r);
  21727 }
  21728 
  21729 internal smallDictt* getNDupDictSmallJson(smallJsont *self, const char *key) {
  21730 
  21731   smallt *o = NULL;
  21732   getJsonPath;
  21733   pass:
  21734   if (!o) {
  21735     return(NULL);
  21736   }
  21737   if (o->type != DICT) {
  21738     return(NULL);
  21739   }
  21740   return((smallDictt*) toBaset(sDuplicate(o)));
  21741   fail:
  21742   return(NULL);
  21743 }
  21744 
  21745 internal smallArrayt* getNDupArraySmallJson(smallJsont *self, const char *key) {
  21746 
  21747   smallt *o = NULL;
  21748   getJsonPath;
  21749   pass:
  21750   if (!o) {
  21751     return(NULL);
  21752   }
  21753   if (o->type != ARRAY) {
  21754     return(NULL);
  21755   }
  21756   return((smallArrayt*) toBaset(sDuplicate(o)));
  21757   fail:
  21758   return(NULL);
  21759 }
  21760 
  21761 internal smallBoolt* getNDupSmallBoolSmallJson(smallJsont *self, const char *key) {
  21762 
  21763   smallt *o = NULL;
  21764   getJsonPath;
  21765   pass:
  21766   if (!o) {
  21767     return(NULL);
  21768   }
  21769   if (o->type != BOOL) {
  21770     return(NULL);
  21771   }
  21772   return((smallBoolt*) toBaset(sDuplicate(o)));
  21773   fail:
  21774   return(NULL);
  21775 }
  21776 
  21777 internal smallBytest* getNDupSmallBytesSmallJson(smallJsont *self, const char *key) {
  21778 
  21779   smallt *o = NULL;
  21780   getJsonPath;
  21781   pass:
  21782   if (!o) {
  21783     return(NULL);
  21784   }
  21785   if (o->type != BYTES) {
  21786     return(NULL);
  21787   }
  21788   return((smallBytest*) toBaset(sDuplicate(o)));
  21789   fail:
  21790   return(NULL);
  21791 }
  21792 
  21793 internal smallDoublet* getNDupSmallDoubleSmallJson(smallJsont *self, const char *key) {
  21794 
  21795   smallt *o = NULL;
  21796   getJsonPath;
  21797   pass:
  21798   if (!o) {
  21799     return(NULL);
  21800   }
  21801   if (o->type != DOUBLE) {
  21802     return(NULL);
  21803   }
  21804   return((smallDoublet*) toBaset(sDuplicate(o)));
  21805   fail:
  21806   return(NULL);
  21807 }
  21808 
  21809 internal smallIntt* getNDupSmallIntSmallJson(smallJsont *self, const char *key) {
  21810 
  21811   smallt *o = NULL;
  21812   getJsonPath;
  21813   pass:
  21814   if (!o) {
  21815     return(NULL);
  21816   }
  21817   if (o->type != INT) {
  21818     return(NULL);
  21819   }
  21820   return((smallIntt*) toBaset(sDuplicate(o)));
  21821   fail:
  21822   return(NULL);
  21823 }
  21824 
  21825 internal smallJsont* getNDupSmallJsonSmallJson(smallJsont *self, const char *key) {
  21826 
  21827   smallt *o = NULL;
  21828   getJsonPath;
  21829   pass:
  21830   if (!o) {
  21831     return(NULL);
  21832   }
  21833   if ((o->type == BYTES) || (o->type == CONTAINER)) {
  21834     return(NULL);
  21835   }
  21836 
  21837   baset *e = toBaset(sDuplicate(o));
  21838 
  21839   if (!e) {
  21840     return(NULL);
  21841   }
  21842 
  21843   createAllocateSmallJson(r);
  21844   if (!r) {
  21845     finishO(e);
  21846     return(NULL);
  21847   }
  21848   setTopNFreeSmallJson(r, e);
  21849   return(r);
  21850   fail:
  21851   return(NULL);
  21852 }
  21853 
  21854 internal smallStringt* getNDupSmallStringSmallJson(smallJsont *self, const char *key) {
  21855 
  21856   smallt *o = NULL;
  21857   getJsonPath;
  21858   pass:
  21859   if (!o) {
  21860     return(NULL);
  21861   }
  21862   if (o->type != STRING) {
  21863     return(NULL);
  21864   }
  21865   return((smallStringt*) toBaset(sDuplicate(o)));
  21866   fail:
  21867   return(NULL);
  21868 }
  21869 
  21870 internal void* getNDupVoidSmallJson(smallJsont *self, const char *key) {
  21871   smallContainert *e = NULL;
  21872   void* r = NULL;
  21873 
  21874   e = getNDupSmallContainerSmallJson(self, key);
  21875   if (e) {
  21876     r = e->f->get(e);
  21877     terminateO(e);
  21878   }
  21879   return(r);
  21880 }
  21881 
  21882 internal smallContainert* getNDupSmallContainerSmallJson(smallJsont *self, const char *key) {
  21883 
  21884   smallt *o = NULL;
  21885   getJsonPath;
  21886   pass:
  21887   if (!o) {
  21888     return(NULL);
  21889   }
  21890   if (o->type != CONTAINER) {
  21891     return(NULL);
  21892   }
  21893   if (((sContainert*)o)->dataType == SH_DT_BASET) {
  21894     return(NULL);
  21895   }
  21896   smallContainert *e = (smallContainert*) toBaset(o);
  21897   smallContainert *r = duplicateO(e);
  21898   finishO(e);
  21899   return(r);
  21900   fail:
  21901   return(NULL);
  21902 }
  21903 
  21904 baset* getAtSmallJson(smallJsont *self, int64_t index) {
  21905 
  21906   if (self->topIsA != TOP_IS_ARRAY) {
  21907     return(NULL);
  21908   }
  21909 
  21910   if (index >= (int64_t)lenSmallJson(self)) {
  21911     return(NULL);
  21912   }
  21913   if (index < -(int64_t)lenSmallJson(self)) {
  21914     return(NULL);
  21915   }
  21916   if (index < 0) {
  21917     index = (int64_t)lenSmallJson(self) + index;
  21918   }
  21919 
  21920   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
  21921   if (!o) {
  21922     return(NULL);
  21923   }
  21924 
  21925   baset *r = toBaset(o);
  21926   return(r);
  21927 }
  21928 
  21929 internal undefinedt* getAtUndefinedSmallJson(smallJsont *self, int64_t index) {
  21930 
  21931   if (self->topIsA != TOP_IS_ARRAY) {
  21932     return(NULL);
  21933   }
  21934 
  21935   if (index >= (int64_t)lenSmallJson(self)) {
  21936     return(NULL);
  21937   }
  21938   if (index < -(int64_t)lenSmallJson(self)) {
  21939     return(NULL);
  21940   }
  21941   if (index < 0) {
  21942     index = (int64_t)lenSmallJson(self) + index;
  21943   }
  21944 
  21945   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
  21946   if (!o) {
  21947     return(NULL);
  21948   }
  21949   if (o->type != UNDEFINED) {
  21950     return(NULL);
  21951   }
  21952   return(allocUndefined());
  21953 }
  21954 
  21955 internal bool getAtBoolSmallJson(smallJsont *self, int64_t index) {
  21956   smallBoolt *e = NULL;
  21957   bool r = false;;
  21958 
  21959   e = getAtSmallBoolSmallJson(self, index);
  21960   if (e) {
  21961     r = e->f->get(e);
  21962     finishO(e);
  21963   }
  21964   return(r);
  21965 }
  21966 
  21967 internal bool* getAtBoolPSmallJson(smallJsont *self, int64_t index) {
  21968   smallBoolt *e = NULL;
  21969   bool* r = NULL;
  21970 
  21971   e = getAtSmallBoolSmallJson(self, index);
  21972   if (e) {
  21973     r = e->f->getP(e);
  21974     finishO(e);
  21975   }
  21976   return(r);
  21977 }
  21978 
  21979 internal double getAtDoubleSmallJson(smallJsont *self, int64_t index) {
  21980   smallDoublet *e = NULL;
  21981   double r = 0;;
  21982 
  21983   e = getAtSmallDoubleSmallJson(self, index);
  21984   if (e) {
  21985     r = e->f->get(e);
  21986     finishO(e);
  21987   }
  21988   return(r);
  21989 }
  21990 
  21991 internal double* getAtDoublePSmallJson(smallJsont *self, int64_t index) {
  21992   smallDoublet *e = NULL;
  21993   double* r = NULL;
  21994 
  21995   e = getAtSmallDoubleSmallJson(self, index);
  21996   if (e) {
  21997     r = e->f->getP(e);
  21998     finishO(e);
  21999   }
  22000   return(r);
  22001 }
  22002 
  22003 internal int64_t getAtIntSmallJson(smallJsont *self, int64_t index) {
  22004   smallIntt *e = NULL;
  22005   int64_t r = 0;;
  22006 
  22007   e = getAtSmallIntSmallJson(self, index);
  22008   if (e) {
  22009     r = e->f->get(e);
  22010     finishO(e);
  22011   }
  22012   return(r);
  22013 }
  22014 
  22015 internal int64_t* getAtIntPSmallJson(smallJsont *self, int64_t index) {
  22016   smallIntt *e = NULL;
  22017   int64_t* r = NULL;
  22018 
  22019   e = getAtSmallIntSmallJson(self, index);
  22020   if (e) {
  22021     r = e->f->getP(e);
  22022     finishO(e);
  22023   }
  22024   return(r);
  22025 }
  22026 
  22027 internal int32_t getAtInt32SmallJson(smallJsont *self, int64_t index) {
  22028   smallIntt *e = NULL;
  22029   int32_t r = 0;;
  22030 
  22031   e = getAtSmallIntSmallJson(self, index);
  22032   if (e) {
  22033     r = (int32_t)e->f->get(e);
  22034     finishO(e);
  22035   }
  22036   return(r);
  22037 }
  22038 
  22039 internal int32_t* getAtInt32PSmallJson(smallJsont *self, int64_t index) {
  22040   smallIntt *e = NULL;
  22041   int32_t* r = NULL;
  22042 
  22043   e = getAtSmallIntSmallJson(self, index);
  22044   if (e) {
  22045     r = (int32_t *)e->f->getP(e);
  22046     finishO(e);
  22047   }
  22048   return(r);
  22049 }
  22050 
  22051 internal uint64_t getAtUintSmallJson(smallJsont *self, int64_t index) {
  22052   smallIntt *e = NULL;
  22053   uint64_t r = 0;;
  22054 
  22055   e = getAtSmallIntSmallJson(self, index);
  22056   if (e) {
  22057     r = (uint64_t)e->f->get(e);
  22058     finishO(e);
  22059   }
  22060   return(r);
  22061 }
  22062 
  22063 internal uint64_t* getAtUintPSmallJson(smallJsont *self, int64_t index) {
  22064   smallIntt *e = NULL;
  22065   uint64_t* r = NULL;
  22066 
  22067   e = getAtSmallIntSmallJson(self, index);
  22068   if (e) {
  22069     r = (uint64_t *)e->f->getP(e);
  22070     finishO(e);
  22071   }
  22072   return(r);
  22073 }
  22074 
  22075 internal uint32_t getAtUint32SmallJson(smallJsont *self, int64_t index) {
  22076   smallIntt *e = NULL;
  22077   uint32_t r = 0;;
  22078 
  22079   e = getAtSmallIntSmallJson(self, index);
  22080   if (e) {
  22081     r = (uint32_t)e->f->get(e);
  22082     finishO(e);
  22083   }
  22084   return(r);
  22085 }
  22086 
  22087 internal uint32_t* getAtUint32PSmallJson(smallJsont *self, int64_t index) {
  22088   smallIntt *e = NULL;
  22089   uint32_t* r = NULL;
  22090 
  22091   e = getAtSmallIntSmallJson(self, index);
  22092   if (e) {
  22093     r = (uint32_t *)e->f->getP(e);
  22094     finishO(e);
  22095   }
  22096   return(r);
  22097 }
  22098 
  22099 internal char* getAtSSmallJson(smallJsont *self, int64_t index) {
  22100   smallStringt *e = NULL;
  22101   char* r = NULL;
  22102 
  22103   e = getAtSmallStringSmallJson(self, index);
  22104   if (e) {
  22105     r = e->f->get(e);
  22106     finishO(e);
  22107   }
  22108   return(r);
  22109 }
  22110 
  22111 internal smallDictt* getAtDictSmallJson(smallJsont *self, int64_t index) {
  22112 
  22113   if (self->topIsA != TOP_IS_ARRAY) {
  22114     return(NULL);
  22115   }
  22116 
  22117   if (index >= (int64_t)lenSmallJson(self)) {
  22118     return(NULL);
  22119   }
  22120   if (index < -(int64_t)lenSmallJson(self)) {
  22121     return(NULL);
  22122   }
  22123   if (index < 0) {
  22124     index = (int64_t)lenSmallJson(self) + index;
  22125   }
  22126 
  22127   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
  22128   if (!o) {
  22129     return(NULL);
  22130   }
  22131   if (o->type != DICT) {
  22132     return(NULL);
  22133   }
  22134   return((smallDictt*) toBaset(o));
  22135 }
  22136 
  22137 internal smallArrayt* getAtArraySmallJson(smallJsont *self, int64_t index) {
  22138 
  22139   if (self->topIsA != TOP_IS_ARRAY) {
  22140     return(NULL);
  22141   }
  22142 
  22143   if (index >= (int64_t)lenSmallJson(self)) {
  22144     return(NULL);
  22145   }
  22146   if (index < -(int64_t)lenSmallJson(self)) {
  22147     return(NULL);
  22148   }
  22149   if (index < 0) {
  22150     index = (int64_t)lenSmallJson(self) + index;
  22151   }
  22152 
  22153   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
  22154   if (!o) {
  22155     return(NULL);
  22156   }
  22157   if (o->type != ARRAY) {
  22158     return(NULL);
  22159   }
  22160   return((smallArrayt*) toBaset(o));
  22161 }
  22162 
  22163 internal smallBoolt* getAtSmallBoolSmallJson(smallJsont *self, int64_t index) {
  22164 
  22165   if (self->topIsA != TOP_IS_ARRAY) {
  22166     return(NULL);
  22167   }
  22168 
  22169   if (index >= (int64_t)lenSmallJson(self)) {
  22170     return(NULL);
  22171   }
  22172   if (index < -(int64_t)lenSmallJson(self)) {
  22173     return(NULL);
  22174   }
  22175   if (index < 0) {
  22176     index = (int64_t)lenSmallJson(self) + index;
  22177   }
  22178 
  22179   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
  22180   if (!o) {
  22181     return(NULL);
  22182   }
  22183   if (o->type != BOOL) {
  22184     return(NULL);
  22185   }
  22186   return((smallBoolt*) toBaset(o));
  22187 }
  22188 
  22189 internal smallBytest* getAtSmallBytesSmallJson(smallJsont *self, int64_t index) {
  22190 
  22191   if (self->topIsA != TOP_IS_ARRAY) {
  22192     return(NULL);
  22193   }
  22194 
  22195   if (index >= (int64_t)lenSmallJson(self)) {
  22196     return(NULL);
  22197   }
  22198   if (index < -(int64_t)lenSmallJson(self)) {
  22199     return(NULL);
  22200   }
  22201   if (index < 0) {
  22202     index = (int64_t)lenSmallJson(self) + index;
  22203   }
  22204 
  22205   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
  22206   if (!o) {
  22207     return(NULL);
  22208   }
  22209   if (o->type != BYTES) {
  22210     return(NULL);
  22211   }
  22212   return((smallBytest*) toBaset(o));
  22213 }
  22214 
  22215 internal smallDoublet* getAtSmallDoubleSmallJson(smallJsont *self, int64_t index) {
  22216 
  22217   if (self->topIsA != TOP_IS_ARRAY) {
  22218     return(NULL);
  22219   }
  22220 
  22221   if (index >= (int64_t)lenSmallJson(self)) {
  22222     return(NULL);
  22223   }
  22224   if (index < -(int64_t)lenSmallJson(self)) {
  22225     return(NULL);
  22226   }
  22227   if (index < 0) {
  22228     index = (int64_t)lenSmallJson(self) + index;
  22229   }
  22230 
  22231   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
  22232   if (!o) {
  22233     return(NULL);
  22234   }
  22235   if (o->type != DOUBLE) {
  22236     return(NULL);
  22237   }
  22238   return((smallDoublet*) toBaset(o));
  22239 }
  22240 
  22241 internal smallIntt* getAtSmallIntSmallJson(smallJsont *self, int64_t index) {
  22242 
  22243   if (self->topIsA != TOP_IS_ARRAY) {
  22244     return(NULL);
  22245   }
  22246 
  22247   if (index >= (int64_t)lenSmallJson(self)) {
  22248     return(NULL);
  22249   }
  22250   if (index < -(int64_t)lenSmallJson(self)) {
  22251     return(NULL);
  22252   }
  22253   if (index < 0) {
  22254     index = (int64_t)lenSmallJson(self) + index;
  22255   }
  22256 
  22257   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
  22258   if (!o) {
  22259     return(NULL);
  22260   }
  22261   if (o->type != INT) {
  22262     return(NULL);
  22263   }
  22264   return((smallIntt*) toBaset(o));
  22265 }
  22266 
  22267 internal smallJsont* getAtSmallJsonSmallJson(smallJsont *self, int64_t index) {
  22268 
  22269   if (self->topIsA != TOP_IS_ARRAY) {
  22270     return(NULL);
  22271   }
  22272 
  22273   if (index >= (int64_t)lenSmallJson(self)) {
  22274     return(NULL);
  22275   }
  22276   if (index < -(int64_t)lenSmallJson(self)) {
  22277     return(NULL);
  22278   }
  22279   if (index < 0) {
  22280     index = (int64_t)lenSmallJson(self) + index;
  22281   }
  22282 
  22283   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
  22284   if (!o) {
  22285     return(NULL);
  22286   }
  22287   if ((o->type == BYTES) || (o->type == CONTAINER)) {
  22288     return(NULL);
  22289   }
  22290   baset *e = toBaset(o);
  22291 
  22292   createAllocateSmallJson(r);
  22293   if (!r) {
  22294     finishO(e);
  22295     return(NULL);
  22296   }
  22297   setTopNFreeSmallJson(r, e);
  22298   return(r);
  22299 }
  22300 
  22301 internal smallStringt* getAtSmallStringSmallJson(smallJsont *self, int64_t index) {
  22302 
  22303   if (self->topIsA != TOP_IS_ARRAY) {
  22304     return(NULL);
  22305   }
  22306 
  22307   if (index >= (int64_t)lenSmallJson(self)) {
  22308     return(NULL);
  22309   }
  22310   if (index < -(int64_t)lenSmallJson(self)) {
  22311     return(NULL);
  22312   }
  22313   if (index < 0) {
  22314     index = (int64_t)lenSmallJson(self) + index;
  22315   }
  22316 
  22317   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
  22318   if (!o) {
  22319     return(NULL);
  22320   }
  22321   if (o->type != STRING) {
  22322     return(NULL);
  22323   }
  22324   return((smallStringt*) toBaset(o));
  22325 }
  22326 
  22327 internal void* getAtVoidSmallJson(smallJsont *self, int64_t index) {
  22328   smallContainert *e = NULL;
  22329   void* r = NULL;
  22330 
  22331   e = getAtSmallContainerSmallJson(self, index);
  22332   if (e) {
  22333     r = e->f->get(e);
  22334     finishO(e);
  22335   }
  22336   return(r);
  22337 }
  22338 
  22339 internal smallContainert* getAtSmallContainerSmallJson(smallJsont *self, int64_t index) {
  22340 
  22341   if (self->topIsA != TOP_IS_ARRAY) {
  22342     return(NULL);
  22343   }
  22344 
  22345   if (index >= (int64_t)lenSmallJson(self)) {
  22346     return(NULL);
  22347   }
  22348   if (index < -(int64_t)lenSmallJson(self)) {
  22349     return(NULL);
  22350   }
  22351   if (index < 0) {
  22352     index = (int64_t)lenSmallJson(self) + index;
  22353   }
  22354 
  22355   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
  22356   if (!o) {
  22357     return(NULL);
  22358   }
  22359   if (o->type != CONTAINER) {
  22360     return(NULL);
  22361   }
  22362   if (((sContainert*)o)->dataType == SH_DT_BASET) {
  22363     return(NULL);
  22364   }
  22365   return((smallContainert*) toBaset(o));
  22366 }
  22367 
  22368 baset* getAtNDupSmallJson(smallJsont *self, int64_t index) {
  22369 
  22370   if (self->topIsA != TOP_IS_ARRAY) {
  22371     return(NULL);
  22372   }
  22373 
  22374   if (index >= (int64_t)lenSmallJson(self)) {
  22375     return(NULL);
  22376   }
  22377   if (index < -(int64_t)lenSmallJson(self)) {
  22378     return(NULL);
  22379   }
  22380   if (index < 0) {
  22381     index = (int64_t)lenSmallJson(self) + index;
  22382   }
  22383 
  22384   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
  22385   if (!o) {
  22386     return(NULL);
  22387   }
  22388 
  22389   if (o->type == UNDEFINED) {
  22390     return((baset*) allocUndefined());
  22391   }
  22392 
  22393   if (o->type == CONTAINER && (((sContainert*)o)->dataType == SH_DT_BASET)) {
  22394     baset *b = ((sContainert*)o)->data;
  22395     return(duplicateO(b));
  22396   }
  22397   return(toBaset(sDuplicate(o)));
  22398 }
  22399 
  22400 internal undefinedt* getAtNDupUndefinedSmallJson(smallJsont *self, int64_t index) {
  22401 
  22402   if (self->topIsA != TOP_IS_ARRAY) {
  22403     return(NULL);
  22404   }
  22405 
  22406   if (index >= (int64_t)lenSmallJson(self)) {
  22407     return(NULL);
  22408   }
  22409   if (index < -(int64_t)lenSmallJson(self)) {
  22410     return(NULL);
  22411   }
  22412   if (index < 0) {
  22413     index = (int64_t)lenSmallJson(self) + index;
  22414   }
  22415 
  22416   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
  22417   if (!o) {
  22418     return(NULL);
  22419   }
  22420   if (o->type != UNDEFINED) {
  22421     return(NULL);
  22422   }
  22423   return(allocUndefined());
  22424 }
  22425 
  22426 internal bool getAtNDupBoolSmallJson(smallJsont *self, int64_t index) {
  22427   smallBoolt *e = NULL;
  22428   bool r = false;;
  22429 
  22430   e = getAtNDupSmallBoolSmallJson(self, index);
  22431   if (e) {
  22432     r = e->f->get(e);
  22433     terminateO(e);
  22434   }
  22435   return(r);
  22436 }
  22437 
  22438 internal double getAtNDupDoubleSmallJson(smallJsont *self, int64_t index) {
  22439   smallDoublet *e = NULL;
  22440   double r = 0;;
  22441 
  22442   e = getAtNDupSmallDoubleSmallJson(self, index);
  22443   if (e) {
  22444     r = e->f->get(e);
  22445     terminateO(e);
  22446   }
  22447   return(r);
  22448 }
  22449 
  22450 internal int64_t getAtNDupIntSmallJson(smallJsont *self, int64_t index) {
  22451   smallIntt *e = NULL;
  22452   int64_t r = 0;;
  22453 
  22454   e = getAtNDupSmallIntSmallJson(self, index);
  22455   if (e) {
  22456     r = e->f->get(e);
  22457     terminateO(e);
  22458   }
  22459   return(r);
  22460 }
  22461 
  22462 internal int32_t getAtNDupInt32SmallJson(smallJsont *self, int64_t index) {
  22463   smallIntt *e = NULL;
  22464   int32_t r = 0;;
  22465 
  22466   e = getAtNDupSmallIntSmallJson(self, index);
  22467   if (e) {
  22468     r = (int32_t)e->f->get(e);
  22469     terminateO(e);
  22470   }
  22471   return(r);
  22472 }
  22473 
  22474 internal uint64_t getAtNDupUintSmallJson(smallJsont *self, int64_t index) {
  22475   smallIntt *e = NULL;
  22476   uint64_t r = 0;;
  22477 
  22478   e = getAtNDupSmallIntSmallJson(self, index);
  22479   if (e) {
  22480     r = (uint64_t)e->f->get(e);
  22481     terminateO(e);
  22482   }
  22483   return(r);
  22484 }
  22485 
  22486 internal uint32_t getAtNDupUint32SmallJson(smallJsont *self, int64_t index) {
  22487   smallIntt *e = NULL;
  22488   uint32_t r = 0;;
  22489 
  22490   e = getAtNDupSmallIntSmallJson(self, index);
  22491   if (e) {
  22492     r = (uint32_t)e->f->get(e);
  22493     terminateO(e);
  22494   }
  22495   return(r);
  22496 }
  22497 
  22498 internal char* getAtNDupSSmallJson(smallJsont *self, int64_t index) {
  22499   smallStringt *e = NULL;
  22500   char* r = NULL;
  22501 
  22502   e = getAtNDupSmallStringSmallJson(self, index);
  22503   if (e) {
  22504     r = e->f->toString(e);
  22505     terminateO(e);
  22506   }
  22507   return(r);
  22508 }
  22509 
  22510 internal smallDictt* getAtNDupDictSmallJson(smallJsont *self, int64_t index) {
  22511 
  22512   if (self->topIsA != TOP_IS_ARRAY) {
  22513     return(NULL);
  22514   }
  22515 
  22516   if (index >= (int64_t)lenSmallJson(self)) {
  22517     return(NULL);
  22518   }
  22519   if (index < -(int64_t)lenSmallJson(self)) {
  22520     return(NULL);
  22521   }
  22522   if (index < 0) {
  22523     index = (int64_t)lenSmallJson(self) + index;
  22524   }
  22525 
  22526   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
  22527   if (!o) {
  22528     return(NULL);
  22529   }
  22530   if (o->type != DICT) {
  22531     return(NULL);
  22532   }
  22533   return((smallDictt*)toBaset(sDuplicate(o)));
  22534 }
  22535 
  22536 internal smallArrayt* getAtNDupArraySmallJson(smallJsont *self, int64_t index) {
  22537 
  22538   if (self->topIsA != TOP_IS_ARRAY) {
  22539     return(NULL);
  22540   }
  22541 
  22542   if (index >= (int64_t)lenSmallJson(self)) {
  22543     return(NULL);
  22544   }
  22545   if (index < -(int64_t)lenSmallJson(self)) {
  22546     return(NULL);
  22547   }
  22548   if (index < 0) {
  22549     index = (int64_t)lenSmallJson(self) + index;
  22550   }
  22551 
  22552   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
  22553   if (!o) {
  22554     return(NULL);
  22555   }
  22556   if (o->type != ARRAY) {
  22557     return(NULL);
  22558   }
  22559   return((smallArrayt*)toBaset(sDuplicate(o)));
  22560 }
  22561 
  22562 internal smallBoolt* getAtNDupSmallBoolSmallJson(smallJsont *self, int64_t index) {
  22563 
  22564   if (self->topIsA != TOP_IS_ARRAY) {
  22565     return(NULL);
  22566   }
  22567 
  22568   if (index >= (int64_t)lenSmallJson(self)) {
  22569     return(NULL);
  22570   }
  22571   if (index < -(int64_t)lenSmallJson(self)) {
  22572     return(NULL);
  22573   }
  22574   if (index < 0) {
  22575     index = (int64_t)lenSmallJson(self) + index;
  22576   }
  22577 
  22578   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
  22579   if (!o) {
  22580     return(NULL);
  22581   }
  22582   if (o->type != BOOL) {
  22583     return(NULL);
  22584   }
  22585   return((smallBoolt*)toBaset(sDuplicate(o)));
  22586 }
  22587 
  22588 internal smallBytest* getAtNDupSmallBytesSmallJson(smallJsont *self, int64_t index) {
  22589 
  22590   if (self->topIsA != TOP_IS_ARRAY) {
  22591     return(NULL);
  22592   }
  22593 
  22594   if (index >= (int64_t)lenSmallJson(self)) {
  22595     return(NULL);
  22596   }
  22597   if (index < -(int64_t)lenSmallJson(self)) {
  22598     return(NULL);
  22599   }
  22600   if (index < 0) {
  22601     index = (int64_t)lenSmallJson(self) + index;
  22602   }
  22603 
  22604   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
  22605   if (!o) {
  22606     return(NULL);
  22607   }
  22608   if (o->type != BYTES) {
  22609     return(NULL);
  22610   }
  22611   return((smallBytest*)toBaset(sDuplicate(o)));
  22612 }
  22613 
  22614 internal smallDoublet* getAtNDupSmallDoubleSmallJson(smallJsont *self, int64_t index) {
  22615 
  22616   if (self->topIsA != TOP_IS_ARRAY) {
  22617     return(NULL);
  22618   }
  22619 
  22620   if (index >= (int64_t)lenSmallJson(self)) {
  22621     return(NULL);
  22622   }
  22623   if (index < -(int64_t)lenSmallJson(self)) {
  22624     return(NULL);
  22625   }
  22626   if (index < 0) {
  22627     index = (int64_t)lenSmallJson(self) + index;
  22628   }
  22629 
  22630   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
  22631   if (!o) {
  22632     return(NULL);
  22633   }
  22634   if (o->type != DOUBLE) {
  22635     return(NULL);
  22636   }
  22637   return((smallDoublet*)toBaset(sDuplicate(o)));
  22638 }
  22639 
  22640 internal smallIntt* getAtNDupSmallIntSmallJson(smallJsont *self, int64_t index) {
  22641 
  22642   if (self->topIsA != TOP_IS_ARRAY) {
  22643     return(NULL);
  22644   }
  22645 
  22646   if (index >= (int64_t)lenSmallJson(self)) {
  22647     return(NULL);
  22648   }
  22649   if (index < -(int64_t)lenSmallJson(self)) {
  22650     return(NULL);
  22651   }
  22652   if (index < 0) {
  22653     index = (int64_t)lenSmallJson(self) + index;
  22654   }
  22655 
  22656   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
  22657   if (!o) {
  22658     return(NULL);
  22659   }
  22660   if (o->type != INT) {
  22661     return(NULL);
  22662   }
  22663   return((smallIntt*)toBaset(sDuplicate(o)));
  22664 }
  22665 
  22666 internal smallJsont* getAtNDupSmallJsonSmallJson(smallJsont *self, int64_t index) {
  22667 
  22668   if (self->topIsA != TOP_IS_ARRAY) {
  22669     return(NULL);
  22670   }
  22671 
  22672   if (index >= (int64_t)lenSmallJson(self)) {
  22673     return(NULL);
  22674   }
  22675   if (index < -(int64_t)lenSmallJson(self)) {
  22676     return(NULL);
  22677   }
  22678   if (index < 0) {
  22679     index = (int64_t)lenSmallJson(self) + index;
  22680   }
  22681 
  22682   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
  22683   if (!o) {
  22684     return(NULL);
  22685   }
  22686   if ((o->type == BYTES) || (o->type == CONTAINER)) {
  22687     return(NULL);
  22688   }
  22689 
  22690   baset *e = toBaset(sDuplicate(o));
  22691 
  22692   createAllocateSmallJson(r);
  22693   if (!r) {
  22694     finishO(e);
  22695     return(NULL);
  22696   }
  22697   setTopNFreeSmallJson(r, e);
  22698   return(r);
  22699 }
  22700 
  22701 internal smallStringt* getAtNDupSmallStringSmallJson(smallJsont *self, int64_t index) {
  22702 
  22703   if (self->topIsA != TOP_IS_ARRAY) {
  22704     return(NULL);
  22705   }
  22706 
  22707   if (index >= (int64_t)lenSmallJson(self)) {
  22708     return(NULL);
  22709   }
  22710   if (index < -(int64_t)lenSmallJson(self)) {
  22711     return(NULL);
  22712   }
  22713   if (index < 0) {
  22714     index = (int64_t)lenSmallJson(self) + index;
  22715   }
  22716 
  22717   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
  22718   if (!o) {
  22719     return(NULL);
  22720   }
  22721   if (o->type != STRING) {
  22722     return(NULL);
  22723   }
  22724   return((smallStringt*)toBaset(sDuplicate(o)));
  22725 }
  22726 
  22727 internal void* getAtNDupVoidSmallJson(smallJsont *self, int64_t index) {
  22728   smallContainert *e = NULL;
  22729   void* r = NULL;
  22730 
  22731   e = getAtNDupSmallContainerSmallJson(self, index);
  22732   if (e) {
  22733     r = e->f->get(e);
  22734     smashO(e);
  22735   }
  22736   return(r);
  22737 }
  22738 
  22739 internal smallContainert* getAtNDupSmallContainerSmallJson(smallJsont *self, int64_t index) {
  22740 
  22741   if (self->topIsA != TOP_IS_ARRAY) {
  22742     return(NULL);
  22743   }
  22744 
  22745   if (index >= (int64_t)lenSmallJson(self)) {
  22746     return(NULL);
  22747   }
  22748   if (index < -(int64_t)lenSmallJson(self)) {
  22749     return(NULL);
  22750   }
  22751   if (index < 0) {
  22752     index = (int64_t)lenSmallJson(self) + index;
  22753   }
  22754 
  22755   smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
  22756   if (!o) {
  22757     return(NULL);
  22758   }
  22759   if (o->type != CONTAINER) {
  22760     return(NULL);
  22761   }
  22762   if (((sContainert*)o)->dataType == SH_DT_BASET) {
  22763     return(NULL);
  22764   }
  22765   smallContainert *e = (smallContainert*)toBaset(o);
  22766   smallContainert *r = duplicateO(e);
  22767   finishO(e);
  22768   return(r);
  22769 }
  22770 
  22771 internal double getNumSmallJson(smallJsont *self, const char *key) {
  22772 
  22773   smallt *o = NULL;
  22774   getJsonPath;
  22775   pass:
  22776   if (!o) {
  22777     return(0);
  22778   }
  22779   if (o->type != INT && o->type != DOUBLE) {
  22780     return(0);
  22781   }
  22782 
  22783   baset *e = toBaset(o);
  22784 
  22785   double r = 0;
  22786   if (isOSmallDouble(e)) {
  22787     r = getValO((smallDoublet*)e);
  22788   }
  22789   elif (isOSmallInt(e)) {
  22790     r = (double)getValO((smallIntt*)e);
  22791   }
  22792   finishO(e);
  22793   return(r);
  22794   fail:
  22795   return(0);
  22796 }
  22797 
  22798 internal double getNumAtSmallJson(smallJsont *self, int64_t index) {
  22799 
  22800   if (self->topIsA != TOP_IS_ARRAY) {
  22801     return(0);
  22802   }
  22803 
  22804   if (index >= (int64_t)lenSmallJson(self)) {
  22805     return(0);
  22806   }
  22807   if (index < -(int64_t)lenSmallJson(self)) {
  22808     return(0);
  22809   }
  22810   if (index < 0) {
  22811     index = (int64_t)lenSmallJson(self) + index;
  22812   }
  22813 
  22814   smallt *e = sArrayGetTiny(self->topA, (uint32_t)index);
  22815   if (!e) {
  22816     return(0);
  22817   }
  22818   if (e->type != INT && e->type != DOUBLE) {
  22819     return(0);
  22820   }
  22821 
  22822   baset *o = toBaset(e);
  22823 
  22824   double r = 0;
  22825   if (isOSmallDouble(o)) {
  22826     r = getValO((smallDoublet*)o);
  22827   }
  22828   elif (isOSmallInt(o)) {
  22829     r = (double)getValO((smallIntt*)o);
  22830   }
  22831   finishO(o);
  22832   return(r);
  22833 }
  22834 
  22835 
  22836 internal smallJsont* delElemSmallJson(smallJsont *self, const char *key) {
  22837 
  22838   delJsonPath;
  22839   return(self);
  22840 }
  22841 
  22842 internal smallJsont* delSmallJson(smallJsont *self, int64_t start, int64_t end) {
  22843   size_t len;
  22844 
  22845   switch(self->topIsA) {
  22846     case TOP_IS_STRING:
  22847       ;char *s;
  22848 
  22849       len = lenSmallJson(self);
  22850 
  22851       // sanity checks
  22852       if (!self->topS || !len) {
  22853         return(NULL);
  22854       }
  22855 
  22856       if (start >= (int64_t)len) {
  22857         start = (int64_t)len;
  22858       }
  22859       if (end > (int64_t)len) {
  22860         end = (int64_t)len;
  22861       }
  22862       if (start <= -(int64_t)len) {
  22863         start = -(int64_t)len;
  22864       }
  22865       if (end <= -(int64_t)len) {
  22866         end = -(int64_t)len;
  22867       }
  22868       if (start < 0) {
  22869         start = (int64_t)len + start;
  22870       }
  22871       if (end <= 0) {
  22872         end = (int64_t)len + end;
  22873       }
  22874       if (end < start) {
  22875         return(NULL);
  22876       }
  22877 
  22878       if (start == end) {
  22879         return(self);
  22880       }
  22881 
  22882       // start < end < len
  22883       // copy range to a new smallString
  22884       int64_t n;
  22885       n = end - start;
  22886       // +2 for sType at the beginning
  22887       s = malloc(len - (size_t)n +2);
  22888       if (!s) {
  22889         return(NULL);
  22890       }
  22891       // +1 for sType
  22892       strncpy(s, (char *)self->topS, (size_t)start+1);
  22893       strncpy(s+start+1, (char *)self->topS + end +1, len - (size_t)end);
  22894       s[len - (size_t)n +1] = 0;
  22895 
  22896       free(self->topS);
  22897       self->topS = (sStringt *)s;
  22898       return(self);
  22899     case TOP_IS_ARRAY:
  22900       len = lenSmallJson(self);
  22901 
  22902       // sanity checks
  22903       if (len == 0) {
  22904         return(NULL);
  22905       }
  22906 
  22907       if (start >= (int64_t)len) {
  22908         start = (int64_t)len;
  22909       }
  22910       if (end > (int64_t)len) {
  22911         end = (int64_t)len;
  22912       }
  22913       if (start <= -(int64_t)len) {
  22914         start = -(int64_t)len;
  22915       }
  22916       if (end <= -(int64_t)len) {
  22917         end = -(int64_t)len;
  22918       }
  22919       if (start < 0) {
  22920         start = (int64_t)len + start;
  22921       }
  22922       if (end <= 0) {
  22923         end = (int64_t)len + end;
  22924       }
  22925       if (end < start) {
  22926         return(NULL);
  22927       }
  22928 
  22929       if (start == end) {
  22930         return(self);
  22931       }
  22932 
  22933       // start < end < len
  22934       sArrayDelRangeTiny(self->topA, (uint32_t)start, (uint32_t)end);
  22935       return(self);
  22936     default:
  22937       return(NULL);
  22938   }
  22939 }
  22940 
  22941 internal smallJsont* delElemIndexSmallJson(smallJsont *self, int64_t index) {
  22942   size_t len;
  22943 
  22944   switch(self->topIsA) {
  22945     case TOP_IS_STRING:
  22946       ;char *s;
  22947 
  22948       len = lenSmallJson(self);
  22949 
  22950       if (index >= (int64_t)len) {
  22951         return(NULL);
  22952       }
  22953       if (index < -(int64_t)len) {
  22954         return(NULL);
  22955       }
  22956       if (index < 0) {
  22957         index = (int64_t)len + index;
  22958       }
  22959 
  22960       // copy range to a new smallString
  22961       // +2 for sType at the beginning
  22962       s = malloc(len - 1 +2);
  22963       if (!s) {
  22964         return(NULL);
  22965       }
  22966       // +1 for sType
  22967       strncpy(s, (char *)self->topS, (size_t)index+1);
  22968       strncpy(s+index+1, (char *)self->topS + index+1 +1, len - ((size_t)index+1));
  22969       s[len - 1 +1] = 0;
  22970 
  22971       free(self->topS);
  22972       self->topS = (sStringt *)s;
  22973       return(self);
  22974     case TOP_IS_ARRAY:
  22975       len = lenSmallJson(self);
  22976 
  22977       if (index >= (int64_t)len) {
  22978         return(NULL);
  22979       }
  22980       if (index < -(int64_t)len) {
  22981         return(NULL);
  22982       }
  22983       if (index < 0) {
  22984         index = (int64_t)len + index;
  22985       }
  22986 
  22987       sArrayDelTiny(self->topA, (uint32_t)index);
  22988       return(self);
  22989     default:
  22990       return(NULL);
  22991   }
  22992 }
  22993 
  22994 internal smallJsont* removeElemSmallJson(smallJsont *self, const char *key) {
  22995 
  22996   removeJsonPath;
  22997   return(self);
  22998 }
  22999 
  23000 internal smallJsont* removeSmallJson(smallJsont *self, int64_t start, int64_t end) {
  23001   size_t len;
  23002 
  23003   switch(self->topIsA) {
  23004     case TOP_IS_STRING:
  23005       ;char *s;
  23006 
  23007       len = lenSmallJson(self);
  23008 
  23009       // sanity checks
  23010       if (!self->topS || !len) {
  23011         return(NULL);
  23012       }
  23013 
  23014       if (start >= (int64_t)len) {
  23015         start = (int64_t)len;
  23016       }
  23017       if (end > (int64_t)len) {
  23018         end = (int64_t)len;
  23019       }
  23020       if (start <= -(int64_t)len) {
  23021         start = -(int64_t)len;
  23022       }
  23023       if (end <= -(int64_t)len) {
  23024         end = -(int64_t)len;
  23025       }
  23026       if (start < 0) {
  23027         start = (int64_t)len + start;
  23028       }
  23029       if (end <= 0) {
  23030         end = (int64_t)len + end;
  23031       }
  23032       if (end < start) {
  23033         return(NULL);
  23034       }
  23035 
  23036       if (start == end) {
  23037         return(self);
  23038       }
  23039 
  23040       // start < end < len
  23041       // copy range to a new smallString
  23042       int64_t n;
  23043       n = end - start;
  23044       // +2 for sType at the beginning
  23045       s = malloc(len - (size_t)n +2);
  23046       if (!s) {
  23047         return(NULL);
  23048       }
  23049       // +1 for sType
  23050       strncpy(s, (char *)self->topS, (size_t)start+1);
  23051       strncpy(s+start+1, (char *)self->topS + end +1, len - (size_t)end);
  23052       s[len - (size_t)n +1] = 0;
  23053 
  23054       free(self->topS);
  23055       self->topS = (sStringt *)s;
  23056       return(self);
  23057     case TOP_IS_ARRAY:
  23058       len = lenSmallJson(self);
  23059 
  23060       // sanity checks
  23061       if (len == 0) {
  23062         return(NULL);
  23063       }
  23064 
  23065       if (start >= (int64_t)len) {
  23066         start = (int64_t)len;
  23067       }
  23068       if (end > (int64_t)len) {
  23069         end = (int64_t)len;
  23070       }
  23071       if (start <= -(int64_t)len) {
  23072         start = -(int64_t)len;
  23073       }
  23074       if (end <= -(int64_t)len) {
  23075         end = -(int64_t)len;
  23076       }
  23077       if (start < 0) {
  23078         start = (int64_t)len + start;
  23079       }
  23080       if (end <= 0) {
  23081         end = (int64_t)len + end;
  23082       }
  23083       if (end < start) {
  23084         return(NULL);
  23085       }
  23086 
  23087       if (start == end) {
  23088         return(self);
  23089       }
  23090 
  23091       // start < end < len
  23092       for (uint32_t i = (uint32_t)start ; i < end ; i++) {
  23093         sArraySetShortTiny(self->topA, i, NULL);
  23094       }
  23095       return(self);
  23096     default:
  23097       return(NULL);
  23098   }
  23099 }
  23100 
  23101 internal smallJsont* removeElemIndexSmallJson(smallJsont *self, int64_t index) {
  23102   size_t len;
  23103 
  23104   switch(self->topIsA) {
  23105     case TOP_IS_STRING:
  23106       ;char *s;
  23107 
  23108       len = lenSmallJson(self);
  23109 
  23110       if (index >= (int64_t)len) {
  23111         return(NULL);
  23112       }
  23113       if (index < -(int64_t)len) {
  23114         return(NULL);
  23115       }
  23116       if (index < 0) {
  23117         index = (int64_t)len + index;
  23118       }
  23119 
  23120       // copy range to a new smallString
  23121       // +2 for sType at the beginning
  23122       s = malloc(len - 1 +2);
  23123       if (!s) {
  23124         return(NULL);
  23125       }
  23126       // +1 for sType
  23127       strncpy(s, (char *)self->topS, (size_t)index+1);
  23128       strncpy(s+index+1, (char *)self->topS + index+1 +1, len - ((size_t)index+1));
  23129       s[len - 1 +1] = 0;
  23130 
  23131       free(self->topS);
  23132       self->topS = (sStringt *)s;
  23133       return(self);
  23134     case TOP_IS_ARRAY:
  23135       len = lenSmallJson(self);
  23136 
  23137       if (index >= (int64_t)len) {
  23138         return(NULL);
  23139       }
  23140       if (index < -(int64_t)len) {
  23141         return(NULL);
  23142       }
  23143       if (index < 0) {
  23144         index = (int64_t)len + index;
  23145       }
  23146 
  23147       sArraySetShortTiny(self->topA, (uint32_t)index, NULL);
  23148       return(self);
  23149     default:
  23150       return(NULL);
  23151   }
  23152 }
  23153 
  23154 
  23155 internal char** sDictStringifyForeach(sDictElemt *e, char *indentS2, int indent, int level) {
  23156   char *line = NULL;
  23157   char **r = NULL;
  23158   smallt *obj = NULL;
  23159 
  23160   line = catS(indentS2, "\"", e->key, "\"");;
  23161 
  23162   obj = e->data;
  23163 
  23164   if (isSType(obj, STRING) || isSType(obj, CONTAINER)) {
  23165     // add quotes for strings
  23166     pErrorNULL(iAppendS(&line, ": \""));
  23167     char *s;
  23168     s = sToStringTiny(obj);
  23169     if (hasS(s, "\\") || hasS(s, "\"")) {
  23170       char *q = replaceS_max(s, "\\", "\\\\");
  23171       pErrorNULL(iReplaceS_max(&q, "\"", "\\\""));
  23172       pErrorNULL(iAppendS(&line, q));
  23173       free(q);
  23174     }
  23175     else {
  23176       pErrorNULL(iAppendS(&line, s));
  23177     }
  23178     free(s);
  23179     pErrorNULL(iAppendS(&line, "\",\n"));
  23180     pErrorNULL(iListPushS(&r, line));
  23181   }
  23182 
  23183   if (!isSType(obj, STRING) && !isSType(obj, CONTAINER) && !isSType(obj, DICT) && !isSType(obj, ARRAY)) {
  23184     pErrorNULL(iAppendS(&line, ": "));
  23185     char *s;
  23186     s = sToStringTiny(obj);
  23187     pErrorNULL(iAppendS(&line, s));
  23188     free(s);
  23189     pErrorNULL(iAppendS(&line, ",\n"));
  23190     pErrorNULL(iListPushS(&r, line));
  23191   }
  23192 
  23193   if (isSType(obj, DICT)) {
  23194     pErrorNULL(iAppendS(&line, ": "));
  23195     pErrorNULL(iListPushS(&r, line));
  23196 
  23197     char **nextLevel = sDictStringify((sDictt *)obj, indent, level+1); {
  23198 
  23199     pErrorNULL(iListAppendS(&r, nextLevel));
  23200     size_t len = listLengthS(r);;
  23201     pErrorNULL(setS(r[len-1], -1, ','));
  23202     pErrorNULL(iAppendS(&(r[len-1]), "\n"));
  23203     free(nextLevel);
  23204   }
  23205     }
  23206 
  23207   if (isSType(obj, ARRAY)) {
  23208     pErrorNULL(iAppendS(&line, ": "));
  23209     pErrorNULL(iListPushS(&r, line));
  23210 
  23211     char **nextLevel = sArrayStringify((sArrayt *)obj, indent, level+1); {
  23212 
  23213     pErrorNULL(iListAppendS(&r, nextLevel));
  23214     size_t len = listLengthS(r);;
  23215     pErrorNULL(setS(r[len-1], -1, ','));
  23216     pErrorNULL(iAppendS(&(r[len-1]), "\n"));
  23217     free(nextLevel);
  23218   }
  23219     }
  23220   return(r);
  23221 }
  23222 
  23223 internal char** sDictStringify(sDictt *dict, int indent, int level) {
  23224   char **r = NULL;
  23225   char indentS[800];
  23226   char indentS2[800];
  23227 
  23228   if (!dict || !dict->count) {
  23229     pErrorNULL(listPushS(&r, "{}\n"));
  23230     return(r);
  23231   }
  23232 
  23233   size_t c;
  23234   for (c = 0 ; c < (size_t)(indent * level); c++) {
  23235     indentS[c] = indentS2[c] = ' ';
  23236   }
  23237   indentS[c] = 0;
  23238   size_t c2;
  23239   for (c2 = 0 ; c2 < (size_t)indent ; c2++) {
  23240     indentS2[c+c2] = ' ';
  23241   }
  23242   indentS2[c+c2] = 0;
  23243 
  23244   pErrorNULL(listPushS(&r, "{\n"));
  23245   forEachSDict(dict, e) {
  23246     if (e->key) {
  23247       char **list = sDictStringifyForeach(e, indentS2, indent, level); {
  23248       pErrorNULL(iListAppendS(&r, list));
  23249       free(list);
  23250   }
  23251     }
  23252       }
  23253 
  23254   // remove the comma on the line before }
  23255   // "hash": "hello, Im string",
  23256   size_t len;
  23257   len = listLengthS(r);
  23258   pErrorNULL(iDelS(&(r[len-1]), -2, -1));
  23259 
  23260   pErrorNULL(iListPushS(&r, catS(indentS, "}\n")));
  23261 
  23262   return(r);
  23263 }
  23264 
  23265 internal char** sArrayStringify(sArrayt *array, int indent, int level) {
  23266   char **r = NULL;
  23267   size_t len;
  23268   char indentS[800];
  23269   char indentS2[800];
  23270 
  23271   if (!array || !array->count) {
  23272     pErrorNULL(listPushS(&r, "[]\n"));
  23273     return(r);
  23274   }
  23275 
  23276   size_t c;
  23277   for (c = 0 ; c < (size_t)(indent * level); c++) {
  23278     indentS[c] = indentS2[c] = ' ';
  23279   }
  23280   indentS[c] = 0;
  23281   size_t c2;
  23282   for (c2 = 0 ; c2 < (size_t)indent ; c2++) {
  23283     indentS2[c+c2] = ' ';
  23284   }
  23285   indentS2[c+c2] = 0;
  23286 
  23287   pErrorNULL(listPushS(&r, "[\n"));
  23288   forEachSArray(array, o) {
  23289     if (!o) {
  23290       // empty slot
  23291       continue;
  23292     }
  23293 
  23294     if (isSType(o, STRING) || isSType(o, CONTAINER)) {
  23295       // add quotes for strings
  23296       char *line;
  23297       char *s;
  23298       s = sToStringTiny(o);
  23299       if (hasS(s, "\\") || hasS(s, "\"")) {
  23300         char *q = replaceS_max(s, "\\", "\\\\");
  23301         pErrorNULL(iReplaceS_max(&q, "\"", "\\\""));
  23302         line = catS(indentS2, "\"", q, "\"");;
  23303         free(q);
  23304       }
  23305       else {
  23306         line = catS(indentS2, "\"", s, "\"");;
  23307       }
  23308       free(s);
  23309       pErrorNULL(iAppendS(&line, ",\n"));
  23310       pErrorNULL(iListPushS(&r, line));
  23311     }
  23312 
  23313     if (!isSType(o, STRING) && !isSType(o, CONTAINER) && !isSType(o, DICT) && !isSType(o, ARRAY)) {
  23314       char *line;
  23315       char *s;
  23316       s = sToStringTiny(o);
  23317       line = catS(indentS2, s);;
  23318       free(s);
  23319       pErrorNULL(iAppendS(&line, ",\n"));
  23320       pErrorNULL(iListPushS(&r, line));
  23321     }
  23322 
  23323     if (isSType(o, DICT)) {
  23324       char **nextLevel = sDictStringify((sDictt *)o, indent, level+1); {
  23325 
  23326       // shift {
  23327       char *line = catS(indentS2, nextLevel[0]);
  23328       pErrorNULL(iListSetS(nextLevel, 0, line));
  23329 
  23330       // add ,
  23331       size_t nextLevelLen = listLengthS(nextLevel);
  23332       pErrorNULL(setS(nextLevel[nextLevelLen-1], -1, ','));
  23333       pErrorNULL(iAppendS(&(nextLevel[nextLevelLen-1]), "\n"));
  23334       pErrorNULL(iListAppendS(&r, nextLevel));
  23335       free(nextLevel);
  23336     }
  23337       }
  23338 
  23339     if (isSType(o, ARRAY)) {
  23340       char **nextLevel = sArrayStringify((sArrayt *)o, indent, level+1); {
  23341 
  23342       // shift [
  23343       char *line = catS(indentS2, nextLevel[0]);
  23344       pErrorNULL(iListSetS(nextLevel, 0, line));
  23345 
  23346       // add ,
  23347       size_t nextLevelLen = listLengthS(nextLevel);
  23348       pErrorNULL(setS(nextLevel[nextLevelLen-1], -1, ','));
  23349       pErrorNULL(iAppendS(&(nextLevel[nextLevelLen-1]), "\n"));
  23350       pErrorNULL(iListAppendS(&r, nextLevel));
  23351       free(nextLevel);
  23352   }
  23353     }
  23354       }
  23355 
  23356   // remove the comma on the line before ]
  23357   // "hash": "hello, Im string",
  23358   len = listLengthS(r);
  23359   pErrorNULL(iDelS(&(r[len-1]), -2, -1));
  23360 
  23361   pErrorNULL(iListPushS(&r, catS(indentS, "]\n")));
  23362   return(r);
  23363 }
  23364 
  23365 internal char* stringifySmallJson(smallJsont *self, int indent) {
  23366   char *r = NULL;
  23367   char *s = NULL;
  23368   char **list = NULL;
  23369 
  23370   switch(self->topIsA) {
  23371     case SMALLJSON_IS_EMPTY:
  23372       return(strdup("{}"));
  23373     case TOP_IS_UNDEFINED:
  23374       return(sToStringTiny((smallt *)self->topU));
  23375     case TOP_IS_BOOL:
  23376       return(sToStringTiny((smallt *)self->topB));
  23377     case TOP_IS_DOUBLE:
  23378       return(sToStringTiny((smallt *)self->topD));
  23379     case TOP_IS_INT:
  23380       return(sToStringTiny((smallt *)self->topI));
  23381     case TOP_IS_STRING:
  23382       s = sToStringTiny((smallt *)self->topS);
  23383       r = catS("\"", s, "\"");
  23384       free(s);
  23385       return(r);
  23386     case TOP_IS_DICT:
  23387       list = sDictStringify(self->top, indent, 0); {
  23388       break;
  23389       }
  23390     case TOP_IS_ARRAY:
  23391       list = sArrayStringify(self->topA, indent, 0); {
  23392       break;
  23393       }
  23394     default:
  23395       // not reachable
  23396       logC("Check this function!");
  23397       return(NULL);
  23398   }
  23399   r = join(list, "");
  23400 
  23401   listFreeS(list);
  23402   return(r);
  23403 }
  23404 
  23405 internal smallStringt* stringifySmallStringSmallJson(smallJsont *self, int indent) {
  23406 
  23407   char *s         = stringifySmallJson(self, indent); {
  23408   smallStringt *r = allocSmallString(s);
  23409   free(s);
  23410   return(r);
  23411 }
  23412   }
  23413 
  23414 internal char** sDictToYMLForeach(sDictElemt *e, char *indentS2, int indent, int level) {
  23415   char *line = NULL;
  23416   char **r = NULL;
  23417   smallt *obj = NULL;
  23418 
  23419   if (isBlankS(e->key)) {
  23420     line = catS(indentS2, "\"", e->key, "\"");;
  23421   }
  23422   else {
  23423     line = catS(indentS2, e->key);;
  23424   }
  23425 
  23426   obj = e->data;
  23427 
  23428   if (isSType(obj, STRING) || isSType(obj, CONTAINER)) {
  23429     char *s;
  23430     s = sToStringTiny(obj);
  23431     // quote string if there are special characters
  23432     if (hasS(s, ":") || hasS(s, "{") || hasS(s, "}") || hasS(s, "[") || hasS(s, "]") || hasS(s, ",") || hasS(s, "&") || hasS(s, "*") || hasS(s, "#") || hasS(s, "?") || hasS(s, "|") || hasS(s, "-") || hasS(s, "<") || hasS(s, ">") || hasS(s, "==") || hasS(s, "!") || hasS(s, "%") || hasS(s, "@") || hasS(s, "\\") || hasS(s, "\"") || isBlankS(s) || isNumber(s)) {
  23433       pErrorNULL(iAppendS(&line, ": \""));
  23434       char *q = replaceS_max(s, "\\", "\\\\");
  23435       if (!isEmptyS(q)) {
  23436         // replace only when q is non empty, to avoid printing an error with pErrorNULL when q is empty
  23437         pErrorNULL(iReplaceS_max(&q, "\"", "\\\""));
  23438       }
  23439       pErrorNULL(iAppendNFreeS(&line, q));
  23440       free(s);
  23441       pErrorNULL(iAppendS(&line, "\"\n"));
  23442     }
  23443     else {
  23444       pErrorNULL(iAppendS(&line, ": "));
  23445       pErrorNULL(iAppendNFreeS(&line, s));
  23446       pErrorNULL(iAppendS(&line, "\n"));
  23447     }
  23448     pErrorNULL(iListPushS(&r, line));
  23449   }
  23450 
  23451   if (!isSType(obj, STRING) && !isSType(obj, CONTAINER) && !isSType(obj, DICT) && !isSType(obj, ARRAY)) {
  23452     pErrorNULL(iAppendS(&line, ": "));
  23453     char *s;
  23454     s = sToStringTiny(obj);
  23455     pErrorNULL(iAppendS(&line, s));
  23456     free(s);
  23457     pErrorNULL(iAppendS(&line, "\n"));
  23458     pErrorNULL(iListPushS(&r, line));
  23459   }
  23460 
  23461   if (isSType(obj, DICT)) {
  23462     pErrorNULL(iAppendS(&line, ":\n"));
  23463     pErrorNULL(iListPushS(&r, line));
  23464 
  23465     char **nextLevel = sDictToYML((sDictt *)obj, indent, level+1);
  23466 
  23467     pErrorNULL(iListAppendS(&r, nextLevel));
  23468     free(nextLevel);
  23469   }
  23470 
  23471   if (isSType(obj, ARRAY)) {
  23472     pErrorNULL(iAppendS(&line, ":\n"));
  23473     pErrorNULL(iListPushS(&r, line));
  23474 
  23475     char **nextLevel = sArrayToYML((sArrayt *)obj, indent, level+1);
  23476 
  23477     pErrorNULL(iListAppendS(&r, nextLevel));
  23478     free(nextLevel);
  23479   }
  23480 
  23481   return(r);
  23482 }
  23483 
  23484 internal char **sDictToYML(sDictt* dict, int indent, int level) {
  23485   char **r = NULL;
  23486   char indentS2[800];
  23487 
  23488   size_t c;
  23489   for (c = 0 ; c < (size_t)(indent * level); c++) {
  23490     indentS2[c] = ' ';
  23491   }
  23492   size_t c2;
  23493   for (c2 = 0 ; c2 < (size_t)indent ; c2++) {
  23494     indentS2[c+c2] = ' ';
  23495   }
  23496   indentS2[c+c2] = 0;
  23497 
  23498   if (!dict || !dict->count) {
  23499     pErrorNULL(iListPushS(&r, catS(indentS2, "{}\n")));
  23500     return(r);
  23501   }
  23502 
  23503   forEachSDict(dict, e) {
  23504     if (e->key) {
  23505       char **list = sDictToYMLForeach(e, indentS2, indent, level);
  23506       pErrorNULL(iListAppendS(&r, list));
  23507       free(list);
  23508   }
  23509     }
  23510 
  23511   return(r);
  23512 }
  23513 
  23514 internal char **sArrayToYML(sArrayt* array, int indent, int level) {
  23515   char **r = NULL;
  23516   char indentS2[800];
  23517 
  23518   size_t c;
  23519   for (c = 0 ; c < (size_t)(indent * level); c++) {
  23520     indentS2[c] = ' ';
  23521   }
  23522   size_t c2;
  23523   for (c2 = 0 ; c2 < (size_t)indent ; c2++) {
  23524     indentS2[c+c2] = ' ';
  23525   }
  23526   indentS2[c+c2] = 0;
  23527 
  23528   if (!array || !array->count) {
  23529     pErrorNULL(iListPushS(&r, catS(indentS2, "[]\n")));
  23530     return(r);
  23531   }
  23532 
  23533   forEachSArray(array, o) {
  23534     if (!o) {
  23535       // empty slot
  23536       continue;
  23537     }
  23538 
  23539     if (isSType(o, STRING) || isSType(o, CONTAINER)) {
  23540       char *line;
  23541       char *s;
  23542       s = sToStringTiny(o);
  23543       // quote string if there are special characters
  23544       if (hasS(s, ":") || hasS(s, "{") || hasS(s, "}") || hasS(s, "[") || hasS(s, "]") || hasS(s, ",") || hasS(s, "&") || hasS(s, "*") || hasS(s, "#") || hasS(s, "?") || hasS(s, "|") || hasS(s, "-") || hasS(s, "<") || hasS(s, ">") || hasS(s, "==") || hasS(s, "!") || hasS(s, "%") || hasS(s, "@") || hasS(s, "\\") || hasS(s, "\"") || isBlankS(s) || isNumber(s)) {
  23545         char *q = replaceS_max(s, "\\", "\\\\");
  23546         if (!isEmptyS(q)) {
  23547           // replace only when q is non empty, to avoid printing an error with pErrorNULL when q is empty
  23548           pErrorNULL(iReplaceS_max(&q, "\"", "\\\""));
  23549         }
  23550         line = catS(indentS2, "- \"", q, "\"\n");;
  23551         free(q);
  23552       }
  23553       else {
  23554         line = catS(indentS2, "- ", s, "\n");;
  23555       }
  23556       free(s);
  23557       pErrorNULL(iListPushS(&r, line));
  23558     }
  23559 
  23560     if (!isSType(o, STRING) && !isSType(o, CONTAINER) && !isSType(o, DICT) && !isSType(o, ARRAY)) {
  23561       char *line;
  23562       char *s;
  23563       s = sToStringTiny(o);
  23564       line = catS(indentS2, "- ", s, "\n");;
  23565       free(s);
  23566       pErrorNULL(iListPushS(&r, line));
  23567     }
  23568 
  23569     if (isSType(o, DICT)) {
  23570       char **nextLevel = sDictToYML((sDictt *)o, indent, level+1);
  23571 
  23572       // detect when array is empty, add '-'
  23573       //if !tommy_hashlin_count(&(obj->h))
  23574       pErrorNULL(setS(nextLevel[0], (int64_t)(c+c2), '-'));
  23575 
  23576       pErrorNULL(iListAppendS(&r, nextLevel));
  23577       free(nextLevel);
  23578     }
  23579 
  23580     if (isSType(o, ARRAY)) {
  23581       char **nextLevel = sArrayToYML((sArrayt *)o, indent, level+1);
  23582 
  23583       // detect when array is empty, add '-'
  23584       //if !tommy_arrayblk_size(obj->arr)
  23585       pErrorNULL(setS(nextLevel[0], (int64_t)(c+c2), '-'));
  23586 
  23587       pErrorNULL(iListAppendS(&r, nextLevel));
  23588       free(nextLevel);
  23589   }
  23590     }
  23591 
  23592   return(r);
  23593 }
  23594 
  23595 internal char* toYMLSmallJson(smallJsont *self, int indent) {
  23596   char *r = NULL;
  23597   char *s = NULL;
  23598   char **list = NULL;
  23599 
  23600   switch(self->topIsA) {
  23601     case SMALLJSON_IS_EMPTY:
  23602       return(strdup("---\n"));
  23603     case TOP_IS_UNDEFINED:
  23604       s = sToString((smallt *)self->topU);
  23605       r = catS("---\n  ", s);
  23606       free(s);
  23607       return(r);
  23608     case TOP_IS_BOOL:
  23609       s = sToString((smallt *)self->topB);
  23610       r = catS("---\n  ", s);
  23611       free(s);
  23612       return(r);
  23613     case TOP_IS_DOUBLE:
  23614       s = sToString((smallt *)self->topD);
  23615       r = catS("---\n  ", s);
  23616       free(s);
  23617       return(r);
  23618     case TOP_IS_INT:
  23619       s = sToString((smallt *)self->topI);
  23620       r = catS("---\n  ", s);
  23621       free(s);
  23622       return(r);
  23623     case TOP_IS_STRING:
  23624       s = sToString((smallt *)self->topS);
  23625       if (!isEmptyS(s)) {
  23626         // replace only when s is non empty, to avoid printing an error with pErrorNULL when s is empty
  23627         pErrorNULL(iReplaceS_max(&s, "\\", "\\\\"));
  23628         pErrorNULL(iReplaceS_max(&s, "\"", "\\\""));
  23629       }
  23630       r = catS("---\n  \"", s, "\"");
  23631       free(s);
  23632       return(r);
  23633     case TOP_IS_DICT:
  23634       list = sDictToYML(self->top, indent, 0);
  23635       break;
  23636     case TOP_IS_ARRAY:
  23637       list = sArrayToYML(self->topA, indent, 0);
  23638       break;
  23639     default:
  23640       // not reachable
  23641       logC("Check this function!");
  23642       return(NULL);
  23643   }
  23644   pErrorNULL(listPrependS(&list, "---\n"));
  23645   r = join(list, "");
  23646 
  23647   listFreeS(list);
  23648   return(r);
  23649 }
  23650 
  23651 internal smallStringt* toYMLSmallStringSmallJson(smallJsont *self, int indent) {
  23652 
  23653   char *s         = toYMLSmallJson(self, indent);
  23654   smallStringt *r = allocSmallString(s);
  23655   free(s);
  23656   return(r);
  23657 }
  23658 
  23659 // smallJson parsing functions
  23660 
  23661 internal bool parseSmallJson(smallJsont *self, const char *input) {
  23662 
  23663   if (isBlankS(input)) {
  23664     return(false);
  23665   }
  23666 
  23667   size_t jsLen = lenS(input);
  23668 
  23669   self->stack  = NULL;
  23670   self->istack = -1;;
  23671   self->parseP = NULL;
  23672   self->iProp  = -1;;
  23673 
  23674   sFree((smallt *)self->top);
  23675   sFree((smallt *)self->topA);
  23676   isError(self->top, allocSDict()) return(false);
  23677   isError(self->topA, allocSArray()) return(false);
  23678 
  23679   struct LaxJsonContext *context;
  23680   context            = lax_json_create();
  23681 
  23682   context->userdata  = self;
  23683   context->string    = on_string;
  23684   context->number    = on_number;
  23685   context->primitive = on_primitive;
  23686   context->begin     = on_begin;
  23687   context->end       = on_end;
  23688   context->max_value_buffer_size = jsonMaxValueBufferSize;
  23689 
  23690   int err = lax_json_feed(context, (int32_t)jsLen, input);
  23691   if (err) {
  23692     eprintf("Line %d, column %d: %s\n", context->line, context->column, lax_json_str_err(err));
  23693     lax_json_destroy(context);
  23694     // clean up
  23695     if (self->topIsA != TOP_IS_DICT) {
  23696       // free unused dict (not in self->stack)
  23697       free(self->top);
  23698     }
  23699     if (self->topIsA != TOP_IS_ARRAY) {
  23700       // free unused array (not in self->stack)
  23701       free(self->topA);
  23702     }
  23703     self->topIsA = SMALLJSON_IS_EMPTY;
  23704     self->top    = NULL;
  23705     self->topA   = NULL;
  23706     if (self->stack) {
  23707       sArrayFreeTiny(self->stack);
  23708     }
  23709     if (self->parseP) {
  23710       sArrayFreeTiny(self->parseP);
  23711     }
  23712     return(false);
  23713   }
  23714 
  23715   lax_json_destroy(context);
  23716   if (self->stack) {
  23717     free(self->stack);
  23718   }
  23719   if (self->parseP) {
  23720     sArrayFreeTiny(self->parseP);
  23721   }
  23722 
  23723   // clean up unused data structures
  23724   if (self->topIsA != TOP_IS_DICT) {
  23725     // free unused dict (not in self->stack)
  23726     free(self->top);
  23727     self->top = NULL;
  23728   }
  23729   if (self->topIsA != TOP_IS_ARRAY) {
  23730     // free unused array (not in self->stack)
  23731     free(self->topA);
  23732     self->topA = NULL;
  23733   }
  23734   return(true);
  23735 }
  23736 
  23737 internal bool parseSmallJsonSmallJson(smallJsont *self, smallJsont *input) {
  23738 
  23739   if (!input) {
  23740     return(false);
  23741   }
  23742 
  23743   if (checkObjectTypes && !isOSmallJson(input)) {
  23744     return(false);
  23745   }
  23746 
  23747   if (input->topIsA != TOP_IS_STRING) {
  23748     return(false);
  23749   }
  23750 
  23751   return(parseSmallJson(self, sjGet(input)));
  23752 }
  23753 
  23754 internal bool parseSmallStringSmallJson(smallJsont *self, smallStringt *input) {
  23755 
  23756   if (!input) {
  23757     return(false);
  23758   }
  23759   if (checkObjectTypes && !isOSmallString(input)) {
  23760     return(false);
  23761   }
  23762 
  23763   return(parseSmallJson(self, ssGet(input)));
  23764 }
  23765 
  23766 // this function is used in smallJson and yaml parsers
  23767 internal void addObject(smallJsont *self, smallt *obj) {
  23768 
  23769   //puts("addObject");
  23770   if (self->istack == -1) {
  23771     // the smallJson is a basic type - null(undefined) bool double int string
  23772     baset *o;
  23773     if (obj->type == UNDEFINED) {
  23774       free(obj);
  23775       isError(o, (baset*) allocUndefined()) {
  23776         return;
  23777       }
  23778     }
  23779     else {
  23780       isError(o, toBaset(obj)) {
  23781         return;
  23782       }
  23783     }
  23784     setTopSmallJson(self, o);
  23785     finishO(o);
  23786     return;
  23787   }
  23788 
  23789   //print 'addObject top count %d', self->top->count
  23790   //print 'addObject stack count %d   props %s', self->stack->count, sToStringTiny((smallt *)self->parseP)
  23791   //print 'addObject stack types %s', sTypesTiny((smallt *)self->stack)
  23792   if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack), DICT)) {
  23793     //print 'addObject to dict'
  23794     sDictt *parseD = (sDictt *) sArrayGetTiny(self->stack, (uint32_t)self->istack);
  23795     //print 'add key: iProp %d istack %d %s - %s', self->iProp, self->istack, sStringGetTiny((sStringt *) sArrayGetTiny(self->parseP, self->iProp)), sToStringTiny(obj)
  23796     smallt *s = sArrayPopTiny(self->parseP);
  23797     sDictPushTiny(&parseD, sStringGetTiny((sStringt *) s), obj);
  23798     sArraySetShortTiny(self->stack, (uint32_t)self->istack, (smallt *) parseD);
  23799     self->iProp--;
  23800     free(s);
  23801     if (self->istack == 0) {
  23802       // update top dict pointer in object
  23803       self->top = parseD;
  23804   }
  23805     }
  23806   else if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack), ARRAY)) {
  23807     //print 'addObject to array'
  23808     sArrayt *parseA = (sArrayt *) sArrayGetTiny(self->stack, (uint32_t)self->istack);
  23809     //print 'addObject element %s', sToStringTiny(obj)
  23810     sArrayPushTiny(&parseA, obj);
  23811     sArraySetShortTiny(self->stack, (uint32_t)self->istack, (smallt *) parseA);
  23812     if (self->istack == 0) {
  23813       // update top dict pointer in object
  23814       self->topA = parseA;
  23815   }
  23816     }
  23817   //print 'addObject top count %d', self->top->count
  23818 }
  23819 
  23820 internal int on_string(struct LaxJsonContext *context, enum LaxJsonType type, const char *value, int length UNUSED) {
  23821     //const char *type_name
  23822 
  23823     smallJsont *self = (smallJsont *) context->userdata;
  23824 
  23825     //print 'on_string top count %d', self->top->count
  23826     if (type == LaxJsonTypeProperty) {
  23827       //type_name = "property"
  23828       sStringt *s = allocSStringTiny(value);
  23829       if (!s) {
  23830         return(1);
  23831       }
  23832       sArrayPushTiny(&(self->parseP), (smallt *)s);
  23833       self->iProp++;
  23834       //print 'on_string Prop  %d %s', self->iProp, sStringGetTiny((sStringt *) sArrayGetTiny(self->parseP, self->iProp))
  23835     }
  23836     else {
  23837       //type_name = "string"
  23838       sStringt *parseS = allocSStringTiny(value);
  23839       if (!parseS) {
  23840         return(1);
  23841       }
  23842       addObject(self, (smallt *) parseS);
  23843     }
  23844 
  23845     //printf("%s: %s\n", type_name, value);
  23846     return(0);
  23847 }
  23848 
  23849 internal int on_number(struct LaxJsonContext *context, char *x) {
  23850 
  23851     smallJsont *self = (smallJsont *) context->userdata;
  23852 
  23853     if (!isInt(x)) {
  23854       char *endp;
  23855       sDoublet *parseF = allocSDouble(strtod(x, &endp));
  23856       if (!parseF) {
  23857         return(1);
  23858       }
  23859       addObject(self, (smallt *) parseF);
  23860     }
  23861     else {
  23862       sIntt *parseI = allocSInt(parseInt(x));
  23863       if (!parseI) {
  23864         return(1);
  23865       }
  23866       addObject(self, (smallt *) parseI);
  23867     }
  23868 
  23869     //printf("number: %s\n", x);
  23870     return(0);
  23871 }
  23872 
  23873 internal int on_primitive(struct LaxJsonContext *context, enum LaxJsonType type) {
  23874     //const char *type_name
  23875     smallt *o = NULL;
  23876 
  23877     smallJsont *self = (smallJsont *) context->userdata;
  23878 
  23879     if (type == LaxJsonTypeTrue) {
  23880         //type_name = "true"
  23881 
  23882         sBoolt *parseB = allocSBool(true);
  23883         if (!parseB) {
  23884           return(1);
  23885         }
  23886         o = (smallt *) parseB;
  23887     }
  23888 
  23889     else if (type == LaxJsonTypeFalse) {
  23890         //type_name = "false"
  23891 
  23892         sBoolt *parseB = allocSBool(false);
  23893         if (!parseB) {
  23894           return(1);
  23895         }
  23896         o = (smallt *) parseB;
  23897     }
  23898 
  23899     else {
  23900         //type_name = "null"
  23901 
  23902         sUndefinedt *parseU = allocSUndefined();
  23903         if (!parseU) {
  23904           return(1);
  23905         }
  23906         o = (smallt *) parseU;
  23907     }
  23908 
  23909     addObject(self, o);
  23910     //printf("primitive: %s\n", type_name);
  23911     return(0);
  23912 }
  23913 
  23914 internal int on_begin(struct LaxJsonContext *context, enum LaxJsonType type) {
  23915     //const char *type_name
  23916 
  23917     smallJsont *self = (smallJsont *) context->userdata;
  23918 
  23919     self->istack++;
  23920     if (type == LaxJsonTypeArray) {
  23921       //type_name = "array"
  23922       if (self->istack == 0) {
  23923         //print 'on_begin top array'
  23924         self->topIsA = TOP_IS_ARRAY;
  23925         sArrayPushTiny(&(self->stack), (smallt *)self->topA);
  23926       }
  23927       else {
  23928         //print 'on_begin array'
  23929         sArrayt *parseA = allocSArray();
  23930         if (!parseA) {
  23931           return(1);
  23932         }
  23933         sArrayPushTiny(&(self->stack), (smallt *) parseA);
  23934     }
  23935       }
  23936     else {
  23937       //type_name = "object"
  23938       if (self->istack == 0) {
  23939         //print 'on_begin top dict'
  23940         self->topIsA = TOP_IS_DICT;
  23941         sArrayPushTiny(&(self->stack), (smallt *)self->top);
  23942       }
  23943       else {
  23944         //print 'on_begin dict'
  23945         sDictt *parseD = allocSDict();
  23946         if (!parseD) {
  23947           return(1);
  23948         }
  23949         sArrayPushTiny(&(self->stack), (smallt *) parseD);
  23950     }
  23951       }
  23952     //print 'on_begin istack       %d', self->istack
  23953     //print 'on_begin stack count  %d', self->stack->count
  23954     //print 'on_begin stack types %s', sTypesTiny((smallt *)self->stack)
  23955     //print 'on_begin stack len %d, istack %d', listLength(self->stack), self->istack
  23956     //printf("begin %s %d\n", type_name, self->istack);
  23957     return(0);
  23958 }
  23959 
  23960 internal int on_end(struct LaxJsonContext *context, enum LaxJsonType type UNUSED) {
  23961     //const char *type_name
  23962 
  23963     smallJsont *self = (smallJsont *) context->userdata;
  23964 
  23965     //if type = LaxJsonTypeArray
  23966     //  type_name = "array"
  23967     //else
  23968     //  type_name = "object"
  23969 
  23970     //print 'on_end istack      %d', self->istack
  23971     //print 'on_end iProp       %d', self->iProp
  23972     //print 'on_end stack count %d', self->stack->count
  23973     //if self->iProp > -1
  23974     //  print 'on_end Prop        %s', sStringGetTiny((sStringt *) sArrayGetTiny(self->parseP, self->iProp))
  23975     //print 'on_end top count   %d', self->top->count
  23976     //print 'on_end stack types %s', sTypesTiny((smallt *)self->stack)
  23977     if (self->istack) {
  23978       if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack-1), DICT)) {
  23979         //print 'on_end to dict'
  23980         sDictt *parseD = (sDictt *) sArrayGetTiny(self->stack, (uint32_t)self->istack -1);
  23981         smallt *s = sArrayPopTiny(self->parseP);
  23982         smallt *v = sArrayPopTiny(self->stack);
  23983         sDictPushTiny(&parseD, sStringGetTiny((sStringt *) s), v);
  23984         sArraySetShortTiny(self->stack, (uint32_t)self->istack-1, (smallt *) parseD);
  23985         self->iProp--;
  23986         free(s);
  23987         if (self->istack == 1) {
  23988           // update top dict pointer in object
  23989           self->top = parseD;
  23990       }
  23991         }
  23992       else if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack - 1), ARRAY)) {
  23993         //print 'on_end to array'
  23994         sArrayt *parseA = (sArrayt *) sArrayGetTiny(self->stack, (uint32_t)self->istack -1);
  23995         sArrayPushTiny(&parseA, sArrayPopTiny(self->stack));
  23996         sArraySetShortTiny(self->stack, (uint32_t)self->istack-1, (smallt *) parseA);
  23997         if (self->istack == 1) {
  23998           // update top dict pointer in object
  23999           self->topA = parseA;
  24000     }
  24001       }
  24002         }
  24003 
  24004     // remove element from the stack
  24005     //self->stack[self->istack] = NULL
  24006     self->istack--;
  24007     //printf("end %s %d\n", type_name, self->istack);
  24008     return(0);
  24009 }
  24010 
  24011 
  24012 // yml parsing functions
  24013 
  24014 internal bool parseYMLSmallJson(smallJsont *self, const char *input) {
  24015   yaml_parser_t parser;
  24016   yaml_event_t  event;
  24017 
  24018   self->stack = NULL;
  24019   self->istack = -1;;
  24020   self->parseP = NULL;
  24021   self->iProp  = -1;;
  24022   self->propertyOrValue = NULL;
  24023   pErrorNULL(listPush(&(self->propertyOrValue), (void*)1));
  24024 
  24025   sFree((smallt *)self->top);
  24026   sFree((smallt *)self->topA);
  24027   isError(self->top, allocSDict()) return(false);
  24028   isError(self->topA, allocSArray()) return(false);
  24029 
  24030   if (!yaml_parser_initialize(&parser)) {
  24031     eprintf("Failed to initialize parser!\n");
  24032   }
  24033 
  24034 
  24035   size_t yLen = lenS(input);
  24036   yaml_parser_set_input_string(&parser, (const unsigned char *)input, yLen);
  24037   yaml_parser_parse(&parser, &event);
  24038 
  24039   while (event.type != YAML_STREAM_END_EVENT) {
  24040     if (!yaml_parser_parse(&parser, &event)) {
  24041       eprintf("Parser error %d\n", parser.error);
  24042       return(false);
  24043     }
  24044 
  24045     //print 'propertyOrValue %d istack %d iProp %d', (long)self->propertyOrValue[self->istack+1], self->istack, self->iProp
  24046     //print '%s', join(self->parseP, " ")
  24047 
  24048     switch(event.type) {
  24049       case YAML_NO_EVENT:
  24050         //puts("No event!");
  24051         break;
  24052       case YAML_STREAM_START_EVENT:
  24053         //puts("STREAM START");
  24054         break;
  24055       case YAML_STREAM_END_EVENT:
  24056         //puts("STREAM END");
  24057         break;
  24058       /* Block delimeters */
  24059       case YAML_DOCUMENT_START_EVENT:
  24060         //puts("<b>Start Document</b>");
  24061         break;
  24062       case YAML_DOCUMENT_END_EVENT:
  24063         //puts("<b>End Document</b>");
  24064         break;
  24065       case YAML_SEQUENCE_START_EVENT:
  24066         //puts("<b>Start Sequence</b>");
  24067         on_beginYArray(self);
  24068         break;
  24069       case YAML_SEQUENCE_END_EVENT:
  24070         //puts("<b>End Sequence</b>");
  24071         on_endY(self);
  24072         break;
  24073       case YAML_MAPPING_START_EVENT:
  24074         //puts("<b>Start Mapping</b>");
  24075         on_beginYDict(self);
  24076         break;
  24077       case YAML_MAPPING_END_EVENT:
  24078         //puts("<b>End Mapping</b>");
  24079         on_endY(self);
  24080         break;
  24081       /* Data */
  24082       case YAML_ALIAS_EVENT:
  24083         //printf("Got alias (anchor %s)\n", event.data.alias.anchor);
  24084         break;
  24085       case YAML_SCALAR_EVENT:
  24086         if (self->istack > -1) {
  24087           // an array or dict has to be on the stack before this event (invalid yml when this condition is false)
  24088           //printf("Got scalar (value %s)\n", event.data.scalar.value);
  24089           if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack), ARRAY)) {
  24090             //on_stringY(event.data.scalar.value, LaxJsonTypeString);
  24091             pushTypeY(self, (char *)event.data.scalar.value);
  24092           }
  24093           else {
  24094             if ((long)self->propertyOrValue[self->istack+1] == 1) {
  24095               on_stringY(self, (const char *)event.data.scalar.value, LaxJsonTypeProperty);
  24096               self->propertyOrValue[self->istack+1] = (void*)2;
  24097             }
  24098             else {
  24099               pushTypeY(self, (char *)event.data.scalar.value);
  24100               self->propertyOrValue[self->istack+1] = (void*)1;
  24101         }
  24102           }
  24103             }
  24104 
  24105         break;
  24106       default:;
  24107         // do nothing
  24108     }
  24109     if (event.type != YAML_STREAM_END_EVENT) {
  24110       yaml_event_delete(&event);
  24111   }
  24112     }
  24113 
  24114   yaml_event_delete(&event);
  24115   yaml_parser_delete(&parser);
  24116   if (self->stack) {
  24117     free(self->stack);
  24118   }
  24119   if (self->parseP) {
  24120     free(self->parseP);
  24121   }
  24122   if (self->propertyOrValue) {
  24123     free(self->propertyOrValue);
  24124   }
  24125 
  24126   // clean up unused data structures
  24127   if (self->topIsA != TOP_IS_DICT) {
  24128     // free unused dict (not in self->stack)
  24129     free(self->top);
  24130     self->top = NULL;
  24131   }
  24132   if (self->topIsA != TOP_IS_ARRAY) {
  24133     // free unused array (not in self->stack)
  24134     free(self->topA);
  24135     self->topA = NULL;
  24136   }
  24137   return(true);
  24138 }
  24139 
  24140 internal bool parseYMLSmallJsonSmallJson(smallJsont *self, smallJsont *input) {
  24141 
  24142   if (!input) {
  24143     return(false);
  24144   }
  24145 
  24146   if (checkObjectTypes && !isOSmallJson(input)) {
  24147     return(false);
  24148   }
  24149 
  24150   if (input->topIsA != TOP_IS_STRING) {
  24151     return(false);
  24152   }
  24153 
  24154   return(parseYMLSmallJson(self, sjGet(input)));
  24155 }
  24156 
  24157 internal bool parseYMLSmallStringSmallJson(smallJsont *self, smallStringt *input) {
  24158 
  24159   if (!input) {
  24160     return(false);
  24161   }
  24162   if (checkObjectTypes && !isOSmallString(input)) {
  24163     return(false);
  24164   }
  24165 
  24166   return(parseYMLSmallJson(self, ssGet(input)));
  24167 }
  24168 
  24169 internal int on_stringY(smallJsont *self, const char *value, enum LaxJsonType type) {
  24170 
  24171     if (type == LaxJsonTypeProperty) {
  24172       sStringt *s = allocSStringTiny(value);
  24173       if (!s) {
  24174         return(1);
  24175       }
  24176       sArrayPushTiny(&(self->parseP), (smallt *)s);
  24177       self->iProp++;
  24178     }
  24179     else {
  24180       // type_name = "string"
  24181       sStringt *parseS = allocSStringTiny(value);
  24182       if (!parseS) {
  24183         return(1);
  24184       }
  24185       addObject(self, (smallt *) parseS);
  24186     }
  24187     return(0);
  24188 }
  24189 
  24190 internal int on_beginYDict(smallJsont *self) {
  24191 
  24192     self->istack++;
  24193     pErrorNULL(listPush(&(self->propertyOrValue), (void*)1));
  24194 
  24195     if (self->istack == 0) {
  24196       self->topIsA = TOP_IS_DICT;
  24197       sArrayPushTiny(&(self->stack), (smallt *)self->top);
  24198     }
  24199     else {
  24200       sDictt *parseD = allocSDict();
  24201       if (!parseD) {
  24202         return(1);
  24203       }
  24204       sArrayPushTiny(&(self->stack), (smallt *) parseD);
  24205     }
  24206     return(0);
  24207 }
  24208 
  24209 internal int on_beginYArray(smallJsont *self) {
  24210 
  24211     self->istack++;
  24212     pErrorNULL(listPush(&(self->propertyOrValue), (void*)1));
  24213 
  24214     if (self->istack == 0) {
  24215       self->topIsA = TOP_IS_ARRAY;
  24216       sArrayPushTiny(&(self->stack), (smallt *)self->topA);
  24217     }
  24218     else {
  24219       sArrayt *parseA = allocSArray();
  24220       if (!parseA) {
  24221         return(1);
  24222       }
  24223       sArrayPushTiny(&(self->stack), (smallt *) parseA);
  24224     }
  24225     return(0);
  24226 }
  24227 
  24228 internal int on_endY(smallJsont *self) {
  24229 
  24230     if (self->istack) {
  24231       if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack-1), DICT)) {
  24232         sDictt *parseD = (sDictt *) sArrayGetTiny(self->stack, (uint32_t)self->istack -1);
  24233         smallt *s = sArrayPopTiny(self->parseP);
  24234         smallt *v = sArrayPopTiny(self->stack);
  24235         sDictPushTiny(&parseD, sStringGetTiny((sStringt *) s), v);
  24236         sArraySetShortTiny(self->stack, (uint32_t)self->istack-1, (smallt *) parseD);
  24237         self->iProp--;
  24238         free(s);
  24239         if (self->istack == 1) {
  24240           // update top dict pointer in object
  24241           self->top = parseD;
  24242       }
  24243         }
  24244       if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack - 1), ARRAY)) {
  24245         sArrayt *parseA = (sArrayt *) sArrayGetTiny(self->stack, (uint32_t)self->istack -1);
  24246         sArrayPushTiny(&parseA, sArrayPopTiny(self->stack));
  24247         sArraySetShortTiny(self->stack, (uint32_t)self->istack-1, (smallt *) parseA);
  24248         if (self->istack == 1) {
  24249           // update top dict pointer in object
  24250           self->topA = parseA;
  24251     }
  24252       }
  24253         }
  24254 
  24255     self->istack--;
  24256     self->propertyOrValue[self->istack+1] = (void*)1;
  24257     return(0);
  24258 }
  24259 
  24260 internal int on_primitiveY(smallJsont *self, enum LaxJsonType type) {
  24261     //const char *type_name
  24262     smallt *o = NULL;
  24263 
  24264     if (type == LaxJsonTypeTrue) {
  24265         //type_name = "true"
  24266 
  24267         sBoolt *parseB = allocSBool(true);
  24268         if (!parseB) {
  24269           return(1);
  24270         }
  24271         o = (smallt *) parseB;
  24272     }
  24273 
  24274     else if (type == LaxJsonTypeFalse) {
  24275         //type_name = "false"
  24276 
  24277         sBoolt *parseB = allocSBool(false);
  24278         if (!parseB) {
  24279           return(1);
  24280         }
  24281         o = (smallt *) parseB;
  24282     }
  24283 
  24284     else {
  24285         //type_name = "null"
  24286 
  24287         sUndefinedt *parseU = allocSUndefined();
  24288         if (!parseU) {
  24289           return(1);
  24290         }
  24291         o = (smallt *) parseU;
  24292     }
  24293 
  24294     addObject(self, o);
  24295     //printf("primitive: %s\n", type_name);
  24296     return(0);
  24297 }
  24298 
  24299 internal int on_numberY(smallJsont *self UNUSED, char *x) {
  24300 
  24301     if (!isInt(x)) {
  24302       char *endp;
  24303       sDoublet *parseF = allocSDouble(strtod(x, &endp));
  24304       if (!parseF) {
  24305         return(1);
  24306       }
  24307       addObject(self, (smallt *) parseF);
  24308     }
  24309     else {
  24310       sIntt *parseI = allocSInt(parseInt(x));
  24311       if (!parseI) {
  24312         return(1);
  24313       }
  24314       addObject(self, (smallt *) parseI);
  24315     }
  24316 
  24317     //printf("number: %s\n", x);
  24318     return(0);
  24319 }
  24320 
  24321 // detect type and push to object
  24322 internal void pushTypeY(smallJsont *self, char *v) {
  24323 
  24324   if (strEq(v, "true")) {
  24325     on_primitiveY(self, LaxJsonTypeTrue);
  24326     return;
  24327   }
  24328   if (strEq(v, "false")) {
  24329     on_primitiveY(self, LaxJsonTypeFalse);
  24330     return;
  24331   }
  24332   if (strEq(v, "null")) {
  24333     on_primitiveY(self, LaxJsonTypeNull);
  24334     return;
  24335   }
  24336 
  24337   //TODO keep integer in strings as strings ("1")
  24338   if (isNumber(v)) {
  24339     // int or double
  24340     on_numberY(self, v);
  24341     return;
  24342   }
  24343 
  24344   on_stringY(self, v, LaxJsonTypeString);
  24345 }
  24346 
  24347 internal smallBytest* serialSmallJson(smallJsont *self) {
  24348   smallt *o = NULL;
  24349 
  24350   switch(self->topIsA) {
  24351     case SMALLJSON_IS_EMPTY:
  24352       return(NULL);
  24353     case TOP_IS_UNDEFINED:
  24354       o = (smallt *)self->topU;
  24355       break;
  24356     case TOP_IS_BOOL:
  24357       o = (smallt *)self->topB;
  24358       break;
  24359     case TOP_IS_DOUBLE:
  24360       o = (smallt *)self->topD;
  24361       break;
  24362     case TOP_IS_INT:
  24363       o = (smallt *)self->topI;
  24364       break;
  24365     case TOP_IS_STRING:
  24366       o = (smallt *)self->topS;
  24367       break;
  24368     case TOP_IS_DICT:
  24369       o = (smallt *)self->top;
  24370       break;
  24371     case TOP_IS_ARRAY:
  24372       o = (smallt *)self->topA;
  24373       break;
  24374     default:
  24375       // not reachable
  24376       logC("Check this function");
  24377       return(NULL);
  24378   }
  24379 
  24380   sBytest *B = sSerial(o);
  24381 
  24382   if (!B) {
  24383     return(NULL);
  24384   }
  24385 
  24386   createAllocateSmallBytes(r);
  24387   if (!r) {
  24388     sFree((smallt*)B);
  24389     return(NULL);
  24390   }
  24391   r->B = B;
  24392   return(r);
  24393 }
  24394 
  24395 internal smallJsont* deserialSmallJson(smallJsont *self, smallBytest *data) {
  24396 
  24397   if (!data) {
  24398     return(self);
  24399   }
  24400 
  24401   smallt *o = sDeserial(data->B);
  24402 
  24403   if (!o) {
  24404     return(self);
  24405   }
  24406 
  24407   freeSmallJson(self);
  24408 
  24409   switch(o->type) {
  24410     case UNDEFINED:
  24411       self->topIsA = TOP_IS_UNDEFINED;
  24412       self->topU = (sUndefinedt *)o;
  24413       break;
  24414     case BOOL:
  24415       self->topIsA = TOP_IS_BOOL;
  24416       self->topB = (sBoolt *)o;
  24417       break;
  24418     case DOUBLE:
  24419       self->topIsA = TOP_IS_DOUBLE;
  24420       self->topD = (sDoublet *)o;
  24421       break;
  24422     case INT:
  24423       self->topIsA = TOP_IS_INT;
  24424       self->topI = (sIntt *)o;
  24425       break;
  24426     case STRING:
  24427       self->topIsA = TOP_IS_STRING;
  24428       self->topS = (sStringt *)o;
  24429       break;
  24430     case DICT:
  24431       self->topIsA = TOP_IS_DICT;
  24432       self->top  = (sDictt *)o;
  24433       break;
  24434     case ARRAY:
  24435       self->topIsA = TOP_IS_ARRAY;
  24436       self->topA = (sArrayt *)o;
  24437       break;
  24438     default:
  24439       sFree(o);
  24440   }
  24441   return(self);
  24442 }
  24443 
  24444 internal void logSmallJson(smallJsont *self) {
  24445 
  24446   char *s = stringifySmallJson(self, 2);; {
  24447   logNFree(s);
  24448 }
  24449   }
  24450 
  24451 internal smallJsont* readFileSmallJson(smallJsont *self, const char *filePath) {
  24452   char *s = NULL;
  24453 
  24454   if (!filePath) {
  24455     return(NULL);
  24456   }
  24457 
  24458   bool r = false;
  24459   char *tmp = strdup(filePath);
  24460   if (!tmp) {
  24461     return(NULL);
  24462   }
  24463   pErrorNULL(iLowerS(&tmp));
  24464   if (endsWithS(tmp, ".json")) {
  24465     s = readFileToS(filePath);;
  24466     if (!s) {
  24467       free(tmp);
  24468       return(NULL);
  24469     }
  24470     r = parseSmallJson(self, s);
  24471   }
  24472   elif (endsWithS(tmp, ".yml")) {
  24473     s = readFileToS(filePath);;
  24474     if (!s) {
  24475       free(tmp);
  24476       return(NULL);
  24477     }
  24478     r = parseYMLSmallJson(self, s);
  24479   }
  24480   elif (endsWithS(tmp, ".bin")) {
  24481     createAllocateSmallBytes(B);
  24482     if (!B) {
  24483       free(tmp);
  24484       return(NULL);
  24485     }
  24486     smallBytest *rB = readFileO(B, filePath);;
  24487     if (!rB) {
  24488       terminateO(B);
  24489       free(tmp);
  24490       return(NULL);
  24491     }
  24492     deserialSmallJson(self, B);
  24493     terminateO(B);
  24494     r = true;
  24495   }
  24496   free(s);
  24497   free(tmp);
  24498   if (r) {
  24499     return(self);
  24500   }
  24501   return(NULL);
  24502 }
  24503 
  24504 
  24505 internal smallJsont* readFileSmallStringSmallJson(smallJsont *self, smallStringt *filePath) {
  24506 
  24507   if (!filePath) {
  24508     return(NULL);
  24509   }
  24510 
  24511   if (checkObjectTypes && !isOSmallString(filePath)) {
  24512     return(NULL);
  24513   }
  24514 
  24515   return(readFileSmallJson(self, ssGet(filePath)));
  24516 }
  24517 
  24518 internal smallJsont* readFileJsonSmallJson(smallJsont *self, smallJsont *filePath) {
  24519 
  24520   if (!filePath) {
  24521     return(NULL);
  24522   }
  24523 
  24524   if (checkObjectTypes && !isOSmallJson(filePath)) {
  24525     return(NULL);
  24526   }
  24527 
  24528   return(readFileSmallJson(self, sjGet(filePath)));
  24529 }
  24530 
  24531 internal smallJsont* readStreamSmallJson(smallJsont *self, FILE *fp) {
  24532 
  24533   if (!fp) {
  24534     return(NULL);
  24535   }
  24536 
  24537   char *s = readStreamToS(fp);;
  24538 
  24539   if (!s) {
  24540     return(NULL);
  24541   }
  24542 
  24543   bool r = parseSmallJson(self, s);
  24544   free(s);
  24545   if (r) {
  24546     return(self);
  24547   }
  24548   return(NULL);
  24549 }
  24550 
  24551 internal int writeFileSmallJson(smallJsont *self, const char *filePath) {
  24552   int r;
  24553 
  24554   if (!filePath || isBlankS(filePath)) {
  24555     return(0);
  24556   }
  24557 
  24558   char *tmp = strdup(filePath);
  24559   pErrorNULL(iLowerS(&tmp));
  24560 
  24561   char *s = NULL;
  24562 
  24563   if (endsWithS(tmp, ".json")) {
  24564     s = stringifySmallJson(self, 2);
  24565   } {
  24566   if (endsWithS(tmp, ".yml")) {
  24567     s = toYMLSmallJson(self, 2);
  24568   }
  24569   if (endsWithS(tmp, ".bin")) {
  24570     smallBytest *B = serialSmallJson(self);
  24571     if (!B) {
  24572       free(tmp);
  24573       return(0);
  24574     }
  24575     r = writeFileO(B, filePath);
  24576     terminateO(B);
  24577     free(tmp);
  24578     goto end;
  24579   }
  24580 
  24581   r = writeFileS(filePath, s);
  24582   freeManyS(s, tmp);
  24583   end:
  24584   if (r) {
  24585     return(1);
  24586   }
  24587   return(0);
  24588 }
  24589     }
  24590 
  24591 internal int writeFileSmallStringSmallJson(smallJsont *self, smallStringt *filePath) {
  24592 
  24593   if (!filePath) {
  24594     return(0);
  24595   }
  24596 
  24597   if (checkObjectTypes && !isOSmallString(filePath)) {
  24598     return(0);
  24599   }
  24600 
  24601   return(writeFileSmallJson(self, ssGet(filePath)));
  24602 }
  24603 
  24604 internal int writeFileJsonSmallJson(smallJsont *self, smallJsont *filePath) {
  24605 
  24606   if (!filePath) {
  24607     return(0);
  24608   }
  24609 
  24610   if (checkObjectTypes && !isOSmallJson(filePath)) {
  24611     return(0);
  24612   }
  24613 
  24614   return(writeFileSmallJson(self, sjGet(filePath)));
  24615 }
  24616 
  24617 internal int writeStreamSmallJson(smallJsont *self, FILE *fp) {
  24618 
  24619   if (!fp) {
  24620     return(0);
  24621   }
  24622 
  24623   char *s = stringifySmallJson(self, 2); {
  24624   int r   = writeStreamS(fp, s);
  24625   free(s);
  24626   if (r) {
  24627     return(1);
  24628   }
  24629   return(0);
  24630 }
  24631   }
  24632 
  24633 internal int appendFileSmallJson(smallJsont *self, const char *filePath) {
  24634   int r;
  24635 
  24636   if (!filePath || isBlankS(filePath)) {
  24637     return(0);
  24638   }
  24639 
  24640   char *tmp = strdup(filePath);
  24641   if (!tmp) {
  24642     return(0);
  24643   }
  24644   pErrorNULL(iLowerS(&tmp));
  24645 
  24646   char *s = NULL;
  24647 
  24648   if (endsWithS(tmp, ".json")) {
  24649     s = stringifySmallJson(self, 2);
  24650   } {
  24651   // cg_c bug if in stringifySmallJson
  24652   if (endsWithS(tmp, ".yml")) {
  24653     s = toYMLSmallJson(self, 2);
  24654   }
  24655   else if (!endsWithS(tmp, ".json")) {
  24656     if (self->topIsA == TOP_IS_STRING) {
  24657       s = strdup(sStringGetTiny(self->topS));
  24658     }
  24659     else if (self->topIsA == TOP_IS_ARRAY) {
  24660       r = appendTextSmallJson(self, filePath);
  24661       goto done;
  24662   }
  24663     }
  24664   r = appendFileS(filePath, s);
  24665   done:
  24666   // s can be null when filePath doesn't end with json or yml and self is not string or array
  24667   freeManyS(tmp, s);
  24668   if (r) {
  24669     return(1);
  24670   }
  24671   return(0);
  24672 }
  24673     }
  24674 
  24675 internal int appendFileSmallStringSmallJson(smallJsont *self, smallStringt *filePath) {
  24676 
  24677   if (!filePath) {
  24678     return(0);
  24679   }
  24680 
  24681   if (checkObjectTypes && !isOSmallString(filePath)) {
  24682     return(0);
  24683   }
  24684 
  24685   return(appendFileSmallJson(self, ssGet(filePath)));
  24686 }
  24687 
  24688 internal int appendFileJsonSmallJson(smallJsont *self, smallJsont *filePath) {
  24689 
  24690   if (!filePath) {
  24691     return(0);
  24692   }
  24693 
  24694   if (checkObjectTypes && !isOSmallJson(filePath)) {
  24695     return(0);
  24696   }
  24697 
  24698   return(appendFileSmallJson(self, sjGet(filePath)));
  24699 }
  24700 
  24701 internal smallJsont* readTextSmallJson(smallJsont *self, const char *filePath) {
  24702   FILE *fp = NULL;
  24703   size_t len;
  24704   char* line = NULL;
  24705   ssize_t read;
  24706 
  24707   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  24708     return(NULL);
  24709   }
  24710 
  24711   // sanity checks
  24712   if (!filePath || isBlankS(filePath)) {
  24713     return(NULL);
  24714   }
  24715   fp = fopen(filePath, "r");
  24716   if (!fp) {
  24717     pFuncError
  24718     shEPrintfS("The path was: \"%s\"\n", filePath);
  24719     return(NULL);
  24720   }
  24721 
  24722   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  24723     self->topIsA = TOP_IS_ARRAY;
  24724   }
  24725 
  24726   // read all lines
  24727   read = getline(&line, &len, fp);
  24728   while (read != -1) {
  24729     {
  24730         char* pos = NULL;
  24731         pos = strchr(line, '\n');
  24732         if (pos != NULL)
  24733             *pos = '\0';
  24734     }
  24735     pushSSmallJson(self, line);
  24736     read = getline(&line, &len, fp);
  24737   }
  24738   fclose(fp);
  24739   free(line);
  24740   return(self);
  24741 }
  24742 
  24743 internal smallJsont* readTextSmallStringSmallJson(smallJsont *self, smallStringt *filePath) {
  24744 
  24745   if (!filePath) {
  24746     return(NULL);
  24747   }
  24748 
  24749   if (checkObjectTypes && !isOSmallString(filePath)) {
  24750     return(NULL);
  24751   }
  24752 
  24753   return(readTextSmallJson(self, ssGet(filePath)));
  24754 }
  24755 
  24756 internal smallJsont* readTextJsonSmallJson(smallJsont *self, smallJsont *filePath) {
  24757 
  24758   if (!filePath) {
  24759     return(NULL);
  24760   }
  24761 
  24762   if (checkObjectTypes && !isOSmallJson(filePath)) {
  24763     return(NULL);
  24764   }
  24765 
  24766   return(readTextSmallJson(self, sjGet(filePath)));
  24767 }
  24768 
  24769 internal smallJsont* readTextStreamSmallJson(smallJsont *self, FILE *fp) {
  24770   size_t len;
  24771   char* line = NULL;
  24772   ssize_t read;
  24773 
  24774   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  24775     return(NULL);
  24776   }
  24777 
  24778   if (!fp) {
  24779     return(NULL);
  24780   }
  24781 
  24782   if (self->topIsA == SMALLJSON_IS_EMPTY) {
  24783     self->topIsA = TOP_IS_ARRAY;
  24784   }
  24785 
  24786   // read all lines
  24787   read = getline(&line, &len,  (FILE*)fp);
  24788   while (read != -1) {
  24789     {
  24790         char* pos = NULL;
  24791         pos = strchr(line, '\n');
  24792         if (pos != NULL)
  24793             *pos = '\0';
  24794     }
  24795     pushSSmallJson(self, line);
  24796     read = getline(&line, &len,  (FILE*)fp);
  24797   }
  24798   free(line);
  24799   return(self);
  24800 }
  24801 
  24802 internal bool writeTextSmallJson(smallJsont *self, const char *filePath) {
  24803   FILE *fp = NULL;
  24804 
  24805   // sanity checks
  24806   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  24807     return(false);
  24808   }
  24809 
  24810   if (!filePath || isBlankS(filePath)) {
  24811     return(false);
  24812   }
  24813 
  24814   fp = fopen(filePath, "w");
  24815   if (!fp) {
  24816     pStrError("writeText error");
  24817     return(false);
  24818   }
  24819   if (!lenSmallJson(self)) {
  24820     fclose(fp);
  24821     return(false);
  24822   }
  24823   forEachSArray(self->topA, e) {
  24824     if (e) {
  24825       // add new line
  24826       fprintf(fp, "%s\n", sStringGetTiny((sStringt*)e));
  24827   }
  24828     }
  24829   fclose(fp);
  24830   return(true);
  24831 }
  24832 
  24833 internal bool writeTextSmallStringSmallJson(smallJsont *self, smallStringt *filePath) {
  24834 
  24835   if (!filePath) {
  24836     return(false);
  24837   }
  24838 
  24839   if (checkObjectTypes && !isOSmallString(filePath)) {
  24840     return(false);
  24841   }
  24842 
  24843   return(writeTextSmallJson(self, ssGet(filePath)));
  24844 }
  24845 
  24846 internal bool writeTextJsonSmallJson(smallJsont *self, smallJsont *filePath) {
  24847 
  24848   if (!filePath) {
  24849     return(false);
  24850   }
  24851 
  24852   if (checkObjectTypes && !isOSmallJson(filePath)) {
  24853     return(false);
  24854   }
  24855 
  24856   return(writeTextSmallJson(self, sjGet(filePath)));
  24857 }
  24858 
  24859 internal bool writeTextStreamSmallJson(smallJsont *self, FILE *fp) {
  24860 
  24861   // sanity checks
  24862   if (self->topIsA != TOP_IS_ARRAY) {
  24863     return(false);
  24864   }
  24865 
  24866   if (!fp || !lenSmallJson(self)) {
  24867     return(false);
  24868   }
  24869   forEachSArray(self->topA, e) {
  24870     if (e) {
  24871       // add new line
  24872       fprintf((FILE*)fp, "%s\n", sStringGetTiny((sStringt*)e));
  24873   }
  24874     }
  24875   return(true);
  24876 }
  24877 
  24878 internal bool appendTextSmallJson(smallJsont *self, const char *filePath) {
  24879   FILE *fp = NULL;
  24880 
  24881   // sanity checks
  24882   if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
  24883     return(false);
  24884   }
  24885 
  24886   if (!filePath || isBlankS(filePath)) {
  24887     return(false);
  24888   }
  24889 
  24890   fp = fopen(filePath, "a");
  24891   if (!fp) {
  24892     pStrError("writeText error");
  24893     return(false);
  24894   }
  24895   if (!lenSmallJson(self)) {
  24896     fclose(fp);
  24897     return(false);
  24898   }
  24899   forEachSArray(self->topA, e) {
  24900     if (e) {
  24901       // add new line
  24902       fprintf(fp, "%s\n", sStringGetTiny((sStringt*)e));
  24903   }
  24904     }
  24905   fclose(fp);
  24906   return(true);
  24907 }
  24908 
  24909 internal bool appendTextSmallStringSmallJson(smallJsont *self, smallStringt *filePath) {
  24910 
  24911   if (!filePath) {
  24912     return(false);
  24913   }
  24914 
  24915   if (checkObjectTypes && !isOSmallString(filePath)) {
  24916     return(false);
  24917   }
  24918 
  24919   return(appendTextSmallJson(self, ssGet(filePath)));
  24920 }
  24921 
  24922 internal bool appendTextJsonSmallJson(smallJsont *self, smallJsont *filePath) {
  24923 
  24924   if (!filePath) {
  24925     return(false);
  24926   }
  24927 
  24928   if (checkObjectTypes && !isOSmallJson(filePath)) {
  24929     return(false);
  24930   }
  24931 
  24932   return(appendTextSmallJson(self, sjGet(filePath)));
  24933 }
  24934 
  24935 
  24936 internal const char* typeStringSmallJson(smallJsont *self, const char *key) {
  24937 
  24938   smallt *o = NULL;
  24939   typeStringJsonPath;
  24940 
  24941   if (!o) {
  24942     // not reachable, but make sure this function is robust
  24943     return(NULL);
  24944   }
  24945 
  24946   return(SMALL_TYPE_NAMES[(size_t)o->type]);
  24947 }
  24948 
  24949 internal smallStringt* typeSmallStringSmallJson(smallJsont *self, const char *key) {
  24950 
  24951   const char *r = typeStringSmallJson(self, key);
  24952   if (!r) {
  24953     return(NULL);
  24954   }
  24955   return(allocSmallString(r));
  24956 }
  24957 
  24958 internal const char* typeAtStringSmallJson(smallJsont *self, int64_t index) {
  24959 
  24960   return(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)]);
  24961 }
  24962 
  24963 internal smallStringt* typeAtSmallStringSmallJson(smallJsont *self, int64_t index) {
  24964 
  24965   return(allocSmallString(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)]));
  24966 }
  24967 
  24968 internal const char* typeStringKCharSmallJson(smallJsont *self, char key) {
  24969 
  24970   charToS(s, key);
  24971   return(typeStringSmallJson(self, s));
  24972 }
  24973 
  24974 internal smallStringt* typeSmallStringKCharSmallJson(smallJsont *self, char key) {
  24975 
  24976   charToS(s, key);
  24977   return(typeSmallStringSmallJson(self, s));
  24978 }
  24979 
  24980 internal char typeSmallJson(smallJsont *self, const char *key) {
  24981 
  24982   smallt *o = NULL;
  24983   typeJsonPath;
  24984 
  24985   if (!o) {
  24986     // not reachable, but make sure this function is robust
  24987     return(0);
  24988   }
  24989 
  24990   return(o->type);
  24991 }
  24992 
  24993 internal char typeKCharSmallJson(smallJsont *self, char key) {
  24994 
  24995   charToS(s, key);
  24996   return(typeSmallJson(self, s));
  24997 }
  24998 
  24999 internal char typeAtSmallJson(smallJsont *self, int64_t index) {
  25000   size_t len;
  25001 
  25002   if (self->topIsA == TOP_IS_ARRAY) {
  25003     len = lenSmallJson(self);
  25004 
  25005     if (!len) {
  25006       return(0);
  25007     }
  25008 
  25009     if (index >= (int64_t)len) {
  25010       return(0);
  25011     }
  25012     if (index < -(int64_t)len) {
  25013       return(0);
  25014     }
  25015     if (index < 0) {
  25016       index = (int64_t)len + index;
  25017     }
  25018 
  25019     smallt *r = sArrayGetTiny(self->topA, (uint32_t)index);
  25020     if (!r) {
  25021       return(0);
  25022     }
  25023 
  25024     return(r->type);
  25025   }
  25026   return(0);
  25027 }
  25028 
  25029 internal smallJsont* typeStringsSmallJson(smallJsont *self) {
  25030 
  25031   switch(self->topIsA) {
  25032     case TOP_IS_DICT:
  25033       if (!self->top) {
  25034         return(NULL);
  25035       }
  25036 
  25037       createAllocateSmallJson(r);
  25038       if (!r) {
  25039         return(NULL);
  25040       }
  25041       setTypeDictSmallJson(r);
  25042 
  25043       forEachSDict(self->top, e) {
  25044         if (e->key) {
  25045           smallt *s = (smallt *)allocSStringTiny(SMALL_TYPE_NAMES[(size_t)e->data->type]);
  25046           if (!s) {
  25047             terminateO(r);
  25048             return(NULL);
  25049           }
  25050           sDictPushTiny(&(r->top), e->key, s);
  25051       }
  25052         }
  25053 
  25054       return(r);
  25055     case TOP_IS_ARRAY:
  25056       ;const char** a = sArrayTypeStrings(self->topA);
  25057       // the strings in a are const char*, just free the array, not the strings
  25058       if (!a) {
  25059         return(NULL);
  25060       }
  25061       createAllocateSmallJson(ra);
  25062       if (!ra) {
  25063         free(a);
  25064         return(NULL);
  25065       }
  25066       setTopCArraycSmallJson(ra, a);
  25067       free(a);
  25068       return(ra);
  25069     default:;
  25070       // return NULL
  25071   }
  25072   return(NULL);
  25073 }
  25074 
  25075 internal smallBytest* typesSmallJson(smallJsont *self) {
  25076   sBytest *types = NULL;
  25077 
  25078   if (self->topIsA != TOP_IS_ARRAY) {
  25079     return(NULL);
  25080   }
  25081 
  25082   types = sArrayTypes(self->topA);
  25083 
  25084   if (!types) {
  25085     return(NULL);
  25086   }
  25087 
  25088   createAllocateSmallBytes(r);
  25089   if (!r) {
  25090     sFree((smallt*)types);
  25091     return(NULL);
  25092   }
  25093   r->B = types;
  25094   return(r);
  25095 }
  25096 
  25097 internal bool isETypeAtSmallJson(smallJsont *self, int64_t index, const char *type) {
  25098 
  25099   if (self->topIsA != TOP_IS_ARRAY) {
  25100     return(false);
  25101   }
  25102 
  25103   if (!type) {
  25104     return(false);
  25105   }
  25106 
  25107   return(eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)], type));
  25108 }
  25109 
  25110 internal bool isEUndefinedAtSmallJson(smallJsont *self, int64_t index) {
  25111 
  25112   if (self->topIsA != TOP_IS_ARRAY) {
  25113     return(false);
  25114   }
  25115 
  25116   return(eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)], "undefined"));
  25117 }
  25118 
  25119 internal bool isEBoolAtSmallJson(smallJsont *self, int64_t index) {
  25120 
  25121   if (self->topIsA != TOP_IS_ARRAY) {
  25122     return(false);
  25123   }
  25124 
  25125   return(eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)], "bool"));
  25126 }
  25127 
  25128 internal bool isEContainerAtSmallJson(smallJsont *self, int64_t index) {
  25129 
  25130   if (self->topIsA != TOP_IS_ARRAY) {
  25131     return(false);
  25132   }
  25133 
  25134   return(eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)], "container"));
  25135 }
  25136 
  25137 internal bool isEDictAtSmallJson(smallJsont *self, int64_t index) {
  25138 
  25139   if (self->topIsA != TOP_IS_ARRAY) {
  25140     return(false);
  25141   }
  25142 
  25143   return(eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)], "dict"));
  25144 }
  25145 
  25146 internal bool isEDoubleAtSmallJson(smallJsont *self, int64_t index) {
  25147 
  25148   if (self->topIsA != TOP_IS_ARRAY) {
  25149     return(false);
  25150   }
  25151 
  25152   return(eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)], "double"));
  25153 }
  25154 
  25155 internal bool isEIntAtSmallJson(smallJsont *self, int64_t index) {
  25156 
  25157   if (self->topIsA != TOP_IS_ARRAY) {
  25158     return(false);
  25159   }
  25160 
  25161   return(eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)], "int"));
  25162 }
  25163 
  25164 internal bool isEStringAtSmallJson(smallJsont *self, int64_t index) {
  25165 
  25166   if (self->topIsA != TOP_IS_ARRAY) {
  25167     return(false);
  25168   }
  25169 
  25170   return(eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)], "string"));
  25171 }
  25172 
  25173 internal bool isEFaststringAtSmallJson(smallJsont *self, int64_t index) {
  25174 
  25175   if (self->topIsA != TOP_IS_ARRAY) {
  25176     return(false);
  25177   }
  25178 
  25179   return(eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)], "faststring"));
  25180 }
  25181 
  25182 internal bool isEArrayAtSmallJson(smallJsont *self, int64_t index) {
  25183 
  25184   if (self->topIsA != TOP_IS_ARRAY) {
  25185     return(false);
  25186   }
  25187 
  25188   return(eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)], "array"));
  25189 }
  25190 
  25191 internal bool isEBytesAtSmallJson(smallJsont *self, int64_t index) {
  25192 
  25193   if (self->topIsA != TOP_IS_ARRAY) {
  25194     return(false);
  25195   }
  25196 
  25197   return(eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, index)], "bytes"));
  25198 }
  25199 
  25200 internal bool isETypeSmallJson(smallJsont *self, const char *key, const char *type) {
  25201 
  25202   if (!type) {
  25203     return(false);
  25204   }
  25205 
  25206   smallt *o = NULL;
  25207   isEJsonPath(eqS(SMALL_TYPE_NAMES[(size_t)o->type], type));
  25208 
  25209   if (!o) {
  25210     return(false);
  25211   }
  25212 
  25213   return(eqS(SMALL_TYPE_NAMES[(size_t)o->type], type));
  25214 }
  25215 
  25216 internal bool isEUndefinedSmallJson(smallJsont *self, const char *key) {
  25217 
  25218   smallt *o = NULL;
  25219   isEJsonPath(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "undefined"));
  25220 
  25221   if (!o) {
  25222     return(false);
  25223   }
  25224 
  25225   return(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "undefined"));
  25226 }
  25227 
  25228 internal bool isEBoolSmallJson(smallJsont *self, const char *key) {
  25229 
  25230   smallt *o = NULL;
  25231   isEJsonPath(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "bool"));
  25232 
  25233   if (!o) {
  25234     return(false);
  25235   }
  25236 
  25237   return(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "bool"));
  25238 }
  25239 
  25240 internal bool isEContainerSmallJson(smallJsont *self, const char *key) {
  25241 
  25242   smallt *o = NULL;
  25243   isEJsonPath(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "container"));
  25244 
  25245   if (!o) {
  25246     return(false);
  25247   }
  25248 
  25249   return(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "container"));
  25250 }
  25251 
  25252 internal bool isEDictSmallJson(smallJsont *self, const char *key) {
  25253 
  25254   smallt *o = NULL;
  25255   isEJsonPath(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "dict"));
  25256 
  25257   if (!o) {
  25258     return(false);
  25259   }
  25260 
  25261   return(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "dict"));
  25262 }
  25263 
  25264 internal bool isEDoubleSmallJson(smallJsont *self, const char *key) {
  25265 
  25266   smallt *o = NULL;
  25267   isEJsonPath(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "double"));
  25268 
  25269   if (!o) {
  25270     return(false);
  25271   }
  25272 
  25273   return(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "double"));
  25274 }
  25275 
  25276 internal bool isEIntSmallJson(smallJsont *self, const char *key) {
  25277 
  25278   smallt *o = NULL;
  25279   isEJsonPath(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "int"));
  25280 
  25281   if (!o) {
  25282     return(false);
  25283   }
  25284 
  25285   return(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "int"));
  25286 }
  25287 
  25288 internal bool isEStringSmallJson(smallJsont *self, const char *key) {
  25289 
  25290   smallt *o = NULL;
  25291   isEJsonPath(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "string"));
  25292 
  25293   if (!o) {
  25294     return(false);
  25295   }
  25296 
  25297   return(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "string"));
  25298 }
  25299 
  25300 internal bool isEFaststringSmallJson(smallJsont *self, const char *key) {
  25301 
  25302   smallt *o = NULL;
  25303   isEJsonPath(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "faststring"));
  25304 
  25305   if (!o) {
  25306     return(false);
  25307   }
  25308 
  25309   return(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "faststring"));
  25310 }
  25311 
  25312 internal bool isEArraySmallJson(smallJsont *self, const char *key) {
  25313 
  25314   smallt *o = NULL;
  25315   isEJsonPath(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "array"));
  25316 
  25317   if (!o) {
  25318     return(false);
  25319   }
  25320 
  25321   return(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "array"));
  25322 }
  25323 
  25324 internal bool isEBytesSmallJson(smallJsont *self, const char *key) {
  25325 
  25326   smallt *o = NULL;
  25327   isEJsonPath(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "bytes"));
  25328 
  25329   if (!o) {
  25330     return(false);
  25331   }
  25332 
  25333   return(eqS(SMALL_TYPE_NAMES[(size_t)o->type], "bytes"));
  25334 }
  25335 
  25336 internal bool areAllETypeSmallJson(smallJsont *self, const char *type) {
  25337   size_t len;
  25338   bool r = true;;
  25339 
  25340   switch(self->topIsA) {
  25341     case TOP_IS_DICT:
  25342       if (!self->top or !type) {
  25343         return(false);
  25344       }
  25345 
  25346       len = lenSmallJson(self);
  25347 
  25348       if (!len) {
  25349         return(false);
  25350       }
  25351 
  25352       bool foundAnElement = false;
  25353       forEachSDict(self->top, e) {
  25354         if (e->key) {
  25355           foundAnElement = true;
  25356           smallt *o = sDictGetTiny(self->top, e->key);
  25357 
  25358           if (!o) {
  25359             r = false;
  25360             break;
  25361           }
  25362           if (!eqS(SMALL_TYPE_NAMES[(size_t)o->type], type)) {
  25363             r = false;
  25364             break;
  25365       }
  25366         }
  25367           }
  25368 
  25369       if (!foundAnElement) {
  25370         // detect when elements are deleted, len > 0 and e->key is null
  25371         return(false);
  25372       }
  25373       return(r);
  25374     case TOP_IS_ARRAY:
  25375       if (!type) {
  25376         return(false);
  25377       }
  25378 
  25379       len = lenSmallJson(self);
  25380 
  25381       if (!len) {
  25382         return(false);
  25383       }
  25384 
  25385       range(i, len) {
  25386         if (!eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, (int64_t)i)], type)) {
  25387           r = false;
  25388           break;
  25389         }
  25390       }
  25391       return(r);
  25392     default:;
  25393       // return false
  25394   }
  25395   return(false);
  25396 }
  25397 
  25398 internal bool areAllEUndefinedSmallJson(smallJsont *self) {
  25399 
  25400   return(areAllETypeSmallJson(self, "undefined"));
  25401 }
  25402 
  25403 internal bool areAllEBoolSmallJson(smallJsont *self) {
  25404 
  25405   return(areAllETypeSmallJson(self, "bool"));
  25406 }
  25407 
  25408 internal bool areAllEContainerSmallJson(smallJsont *self) {
  25409 
  25410   return(areAllETypeSmallJson(self, "container"));
  25411 }
  25412 
  25413 internal bool areAllEDictSmallJson(smallJsont *self) {
  25414 
  25415   return(areAllETypeSmallJson(self, "dict"));
  25416 }
  25417 
  25418 internal bool areAllEDoubleSmallJson(smallJsont *self) {
  25419 
  25420   return(areAllETypeSmallJson(self, "double"));
  25421 }
  25422 
  25423 internal bool areAllEIntSmallJson(smallJsont *self) {
  25424 
  25425   return(areAllETypeSmallJson(self, "int"));
  25426 }
  25427 
  25428 internal bool areAllEStringSmallJson(smallJsont *self) {
  25429 
  25430   return(areAllETypeSmallJson(self, "string"));
  25431 }
  25432 
  25433 internal bool areAllEFaststringSmallJson(smallJsont *self) {
  25434 
  25435   return(areAllETypeSmallJson(self, "faststring"));
  25436 }
  25437 
  25438 internal bool areAllEArraySmallJson(smallJsont *self) {
  25439 
  25440   return(areAllETypeSmallJson(self, "array"));
  25441 }
  25442 
  25443 internal bool areAllEBytesSmallJson(smallJsont *self) {
  25444 
  25445   return(areAllETypeSmallJson(self, "bytes"));
  25446 }
  25447 
  25448 
  25449 
  25450 smallJsont* allocSmallJsonG(smallJsont *self UNUSED) {
  25451 
  25452   return(allocSmallJson());
  25453 }
  25454 
  25455 smallJsont* duplicateSmallJsonG (smallJsont *self) {
  25456 
  25457   return(self->f->duplicate(self));
  25458 }
  25459 
  25460 void freeSmallJsonG         (smallJsont *self) {self->f->free(self);}
  25461 
  25462 smallJsont* setTopSmallJsonG           (smallJsont *self, baset *value) {
  25463 
  25464   return(self->f->setTop(self, value));
  25465 }
  25466 
  25467 smallJsont* setTopBoolSmallJsonG       (smallJsont *self, bool value) {
  25468 
  25469   return(self->f->setTopBool(self, value));
  25470 }
  25471 
  25472 smallJsont* setTopDoubleSmallJsonG     (smallJsont *self, double value) {
  25473 
  25474   return(self->f->setTopDouble(self, value));
  25475 }
  25476 
  25477 smallJsont* setTopIntSmallJsonG        (smallJsont *self, int64_t value) {
  25478 
  25479   return(self->f->setTopInt(self, value));
  25480 }
  25481 
  25482 smallJsont* setTopStringSmallJsonG     (smallJsont *self, const char *value) {
  25483 
  25484   return(self->f->setTopString(self, value));
  25485 }
  25486 
  25487 smallJsont* setTopCharSmallJsonG(smallJsont *self, char c) {
  25488 
  25489   return(self->f->setTopChar(self,c));
  25490 }
  25491 
  25492 smallJsont* setTopDictSmallJsonG       (smallJsont *self, smallDictt *value) {
  25493 
  25494   return(self->f->setTopDict(self, value));
  25495 }
  25496 
  25497 smallJsont* setTopArraySmallJsonG      (smallJsont *self, smallArrayt *value) {
  25498 
  25499   return(self->f->setTopArray(self, value));
  25500 }
  25501 
  25502 smallJsont* setTopArraycSmallJsonG     (smallJsont *self, char **value) {
  25503 
  25504   return(self->f->setTopArrayc(self, value));
  25505 }
  25506 
  25507 smallJsont* setTopCArraycSmallJsonG    (smallJsont *self, const char **value) {
  25508 
  25509   return(self->f->setTopCArrayc(self, value));
  25510 }
  25511 
  25512 smallJsont* setTopSmallBoolSmallJsonG  (smallJsont *self, smallBoolt *value) {
  25513 
  25514   return(self->f->setTopSmallBool(self, value));
  25515 }
  25516 
  25517 smallJsont* setTopSmallDoubleSmallJsonG(smallJsont *self, smallDoublet *value) {
  25518 
  25519   return(self->f->setTopSmallDouble(self, value));
  25520 }
  25521 
  25522 smallJsont* setTopSmallIntSmallJsonG   (smallJsont *self, smallIntt *value) {
  25523 
  25524   return(self->f->setTopSmallInt(self, value));
  25525 }
  25526 
  25527 smallJsont* setTopSmallJsonSmallJsonG(smallJsont *self, smallJsont *value) {
  25528 
  25529   return(self->f->setTopSmallJson(self, value));
  25530 }
  25531 
  25532 smallJsont* setTopSmallStringSmallJsonG(smallJsont *self, smallStringt *value) {
  25533 
  25534   return(self->f->setTopSmallString(self, value));
  25535 }
  25536 
  25537 smallJsont* setTopNFreeSmallJsonG           (smallJsont *self, baset *value) {
  25538 
  25539   return(self->f->setTopNFree(self, value));
  25540 }
  25541 
  25542 smallJsont* setTopNFreeBoolSmallJsonG       (smallJsont *self, bool value) {
  25543 
  25544   return(self->f->setTopNFreeBool(self, value));
  25545 }
  25546 
  25547 smallJsont* setTopNFreeDoubleSmallJsonG     (smallJsont *self, double value) {
  25548 
  25549   return(self->f->setTopNFreeDouble(self, value));
  25550 }
  25551 
  25552 smallJsont* setTopNFreeIntSmallJsonG        (smallJsont *self, int64_t value) {
  25553 
  25554   return(self->f->setTopNFreeInt(self, value));
  25555 }
  25556 
  25557 smallJsont* setTopNFreeStringSmallJsonG     (smallJsont *self, char *value) {
  25558 
  25559   return(self->f->setTopNFreeString(self, value));
  25560 }
  25561 
  25562 smallJsont* setTopNFreeDictSmallJsonG       (smallJsont *self, smallDictt *value) {
  25563 
  25564   return(self->f->setTopNFreeDict(self, value));
  25565 }
  25566 
  25567 smallJsont* setTopNFreeArraySmallJsonG      (smallJsont *self, smallArrayt *value) {
  25568 
  25569   return(self->f->setTopNFreeArray(self, value));
  25570 }
  25571 
  25572 smallJsont* setTopNFreeArraycSmallJsonG      (smallJsont *self, char **value) {
  25573 
  25574   return(self->f->setTopNFreeArrayc(self, value));
  25575 }
  25576 
  25577 smallJsont* setTopNFreeSmallBoolSmallJsonG  (smallJsont *self, smallBoolt *value) {
  25578 
  25579   return(self->f->setTopNFreeSmallBool(self, value));
  25580 }
  25581 
  25582 smallJsont* setTopNFreeSmallDoubleSmallJsonG(smallJsont *self, smallDoublet *value) {
  25583 
  25584   return(self->f->setTopNFreeSmallDouble(self, value));
  25585 }
  25586 
  25587 smallJsont* setTopNFreeSmallIntSmallJsonG   (smallJsont *self, smallIntt *value) {
  25588 
  25589   return(self->f->setTopNFreeSmallInt(self, value));
  25590 }
  25591 
  25592 smallJsont* setTopNFreeSmallJsonSmallJsonG  (smallJsont *self, smallJsont *value) {
  25593 
  25594   return(self->f->setTopNFreeSmallJson(self, value));
  25595 }
  25596 
  25597 smallJsont* setTopNFreeSmallStringSmallJsonG(smallJsont *self, smallStringt *value) {
  25598 
  25599   return(self->f->setTopNFreeSmallString(self, value));
  25600 }
  25601 
  25602 smallJsont*  fromArraySmallJsonG    (smallJsont *self, char **array, size_t size) {
  25603 
  25604   return(self->f->fromArray(self, array, size));
  25605 }
  25606 
  25607 smallJsont*  fromCArraySmallJsonG   (smallJsont *self, const char **array, size_t size) {
  25608 
  25609   return(self->f->fromCArray(self, array, size));
  25610 }
  25611 
  25612 
  25613 baset*        getTopSmallJsonG           (smallJsont *self,baset* retType UNUSED) {
  25614 
  25615   return(self->f->getTop(self));
  25616 }
  25617 
  25618 undefinedt*   getTopUndefinedSmallJsonG  (smallJsont *self,undefinedt* retType UNUSED) {
  25619 
  25620   return(self->f->getTopUndefined(self));
  25621 }
  25622 
  25623 bool          getTopBoolSmallJsonG      (smallJsont *self,bool retType UNUSED) {
  25624 
  25625   return(self->f->getTopBool(self));
  25626 }
  25627 
  25628 bool*         getTopBoolPSmallJsonG      (smallJsont *self,bool* retType UNUSED) {
  25629 
  25630   return(self->f->getTopBoolP(self));
  25631 }
  25632 
  25633 double        getTopDoubleSmallJsonG    (smallJsont *self,double retType UNUSED) {
  25634 
  25635   return(self->f->getTopDouble(self));
  25636 }
  25637 
  25638 double*       getTopDoublePSmallJsonG    (smallJsont *self,double* retType UNUSED) {
  25639 
  25640   return(self->f->getTopDoubleP(self));
  25641 }
  25642 
  25643 int64_t       getTopIntSmallJsonG       (smallJsont *self,int64_t retType UNUSED) {
  25644 
  25645   return(self->f->getTopInt(self));
  25646 }
  25647 
  25648 int64_t*      getTopIntPSmallJsonG       (smallJsont *self,int64_t* retType UNUSED) {
  25649 
  25650   return(self->f->getTopIntP(self));
  25651 }
  25652 
  25653 int32_t       getTopInt32SmallJsonG     (smallJsont *self,int32_t retType UNUSED) {
  25654 
  25655   return(self->f->getTopInt32(self));
  25656 }
  25657 
  25658 int32_t*      getTopInt32PSmallJsonG     (smallJsont *self,int32_t* retType UNUSED) {
  25659 
  25660   return(self->f->getTopInt32P(self));
  25661 }
  25662 
  25663 uint64_t      getTopUintSmallJsonG      (smallJsont *self,uint64_t retType UNUSED) {
  25664 
  25665   return(self->f->getTopUint(self));
  25666 }
  25667 
  25668 uint64_t*     getTopUintPSmallJsonG      (smallJsont *self,uint64_t* retType UNUSED) {
  25669 
  25670   return(self->f->getTopUintP(self));
  25671 }
  25672 
  25673 uint32_t      getTopUint32SmallJsonG    (smallJsont *self,uint32_t retType UNUSED) {
  25674 
  25675   return(self->f->getTopUint32(self));
  25676 }
  25677 
  25678 uint32_t*     getTopUint32PSmallJsonG    (smallJsont *self,uint32_t* retType UNUSED) {
  25679 
  25680   return(self->f->getTopUint32P(self));
  25681 }
  25682 
  25683 char*         getTopSSmallJsonG          (smallJsont *self,char* retType UNUSED) {
  25684 
  25685   return(self->f->getTopS(self));
  25686 }
  25687 
  25688 smallDictt*   getTopDictSmallJsonG       (smallJsont *self,smallDictt* retType UNUSED) {
  25689 
  25690   return(self->f->getTopDict(self));
  25691 }
  25692 
  25693 smallArrayt*  getTopArraySmallJsonG      (smallJsont *self,smallArrayt* retType UNUSED) {
  25694 
  25695   return(self->f->getTopArray(self));
  25696 }
  25697 
  25698 smallBoolt*   getTopSmallBoolSmallJsonG  (smallJsont *self,smallBoolt* retType UNUSED) {
  25699 
  25700   return(self->f->getTopSmallBool(self));
  25701 }
  25702 
  25703 smallDoublet* getTopSmallDoubleSmallJsonG(smallJsont *self,smallDoublet* retType UNUSED) {
  25704 
  25705   return(self->f->getTopSmallDouble(self));
  25706 }
  25707 
  25708 smallIntt*    getTopSmallIntSmallJsonG   (smallJsont *self,smallIntt* retType UNUSED) {
  25709 
  25710   return(self->f->getTopSmallInt(self));
  25711 }
  25712 
  25713 smallStringt* getTopSmallStringSmallJsonG(smallJsont *self,smallStringt* retType UNUSED) {
  25714 
  25715   return(self->f->getTopSmallString(self));
  25716 }
  25717 
  25718 
  25719 smallJsont* pushSmallJsonG         (smallJsont *self, baset *value) {
  25720 
  25721   return(self->f->push(self, value));
  25722 }
  25723 
  25724 smallJsont* pushUndefinedSmallJsonG(smallJsont *self, void *value UNUSED) {
  25725 
  25726   return(self->f->pushUndefined(self));
  25727 }
  25728 
  25729 smallJsont* pushBoolSmallJsonG     (smallJsont *self, bool value) {
  25730 
  25731   return(self->f->pushBool(self,value));
  25732 }
  25733 
  25734 smallJsont* pushDoubleSmallJsonG   (smallJsont *self, double value) {
  25735 
  25736   return(self->f->pushDouble(self,value));
  25737 }
  25738 
  25739 smallJsont* pushIntSmallJsonG      (smallJsont *self, int64_t value) {
  25740 
  25741   return(self->f->pushInt(self,value));
  25742 }
  25743 
  25744 smallJsont* pushSSmallJsonG        (smallJsont *self, const char *string) {
  25745 
  25746   return(self->f->pushS(self,string));
  25747 }
  25748 
  25749 smallJsont* pushCharSmallJsonG(smallJsont *self, char c) {
  25750 
  25751   return(self->f->pushChar(self,c));
  25752 }
  25753 
  25754 smallJsont* pushDictSmallJsonG     (smallJsont *self, smallDictt *dict) {
  25755 
  25756   return(self->f->pushDict(self,dict));
  25757 }
  25758 
  25759 smallJsont* pushArraySmallJsonG    (smallJsont *self, smallArrayt *array) {
  25760 
  25761   return(self->f->pushArray(self,array));
  25762 }
  25763 
  25764 smallJsont* pushArraycSmallJsonG   (smallJsont *self, char **array) {
  25765 
  25766   return(self->f->pushArrayc(self,array));
  25767 }
  25768 
  25769 smallJsont* pushCArraycSmallJsonG  (smallJsont *self, const char **array) {
  25770 
  25771   return(self->f->pushCArrayc(self,array));
  25772 }
  25773 
  25774 smallJsont* pushVoidSmallJsonG     (smallJsont *self, void *value) {
  25775 
  25776   if (value) {
  25777     smallContainert *c = allocSmallContainer(value);
  25778     if (!c) {
  25779       return(NULL);
  25780     }
  25781     return(self->f->pushNFreeSmallContainer(self, c));
  25782   }
  25783   return(self->f->pushUndefined(self));
  25784 }
  25785 
  25786 smallJsont* pushSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value) {
  25787 
  25788   return(self->f->pushSmallBool(self,value));
  25789 }
  25790 
  25791 smallJsont* pushSmallBytesSmallJsonG     (smallJsont *self, smallBytest *value) {
  25792 
  25793   return(self->f->pushSmallBytes(self,value));
  25794 }
  25795 
  25796 smallJsont* pushSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value) {
  25797 
  25798   return(self->f->pushSmallDouble(self,value));
  25799 }
  25800 
  25801 smallJsont* pushSmallIntSmallJsonG      (smallJsont *self, smallIntt *value) {
  25802 
  25803   return(self->f->pushSmallInt(self,value));
  25804 }
  25805 
  25806 smallJsont* pushSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value) {
  25807 
  25808   return(self->f->pushSmallJson(self,value));
  25809 }
  25810 
  25811 smallJsont* pushSmallStringSmallJsonG   (smallJsont *self, smallStringt *string) {
  25812 
  25813   return(self->f->pushSmallString(self,string));
  25814 }
  25815 
  25816 smallJsont* pushSmallContainerSmallJsonG(smallJsont *self, smallContainert *container) {
  25817 
  25818   return(self->f->pushSmallContainer(self,container));
  25819 }
  25820 
  25821 
  25822 smallJsont* pushNFreeSmallJsonG         (smallJsont *self, baset *value) {
  25823 
  25824   return(self->f->pushNFree(self,value));
  25825 }
  25826 
  25827 smallJsont* pushNFreeUndefinedSmallJsonG(smallJsont *self, undefinedt *value) {
  25828 
  25829   return(self->f->pushNFreeUndefined(self,value));
  25830 }
  25831 
  25832 smallJsont* pushNFreeSSmallJsonG        (smallJsont *self, char *string) {
  25833 
  25834   return(self->f->pushNFreeS(self,string));
  25835 }
  25836 
  25837 smallJsont* pushNFreeDictSmallJsonG     (smallJsont *self, smallDictt *dict) {
  25838 
  25839   return(self->f->pushNFreeDict(self,dict));
  25840 }
  25841 
  25842 smallJsont* pushNFreeArraySmallJsonG    (smallJsont *self, smallArrayt *array) {
  25843 
  25844   return(self->f->pushNFreeArray(self,array));
  25845 }
  25846 
  25847 smallJsont* pushNFreeArraycSmallJsonG   (smallJsont *self, char **array) {
  25848 
  25849   return(self->f->pushNFreeArrayc(self,array));
  25850 }
  25851 
  25852 smallJsont* pushNFreeSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value) {
  25853 
  25854   return(self->f->pushNFreeSmallBool(self,value));
  25855 }
  25856 
  25857 smallJsont* pushNFreeSmallBytesSmallJsonG     (smallJsont *self, smallBytest *value) {
  25858 
  25859   return(self->f->pushNFreeSmallBytes(self,value));
  25860 }
  25861 
  25862 smallJsont* pushNFreeSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value) {
  25863 
  25864   return(self->f->pushNFreeSmallDouble(self,value));
  25865 }
  25866 
  25867 smallJsont* pushNFreeSmallIntSmallJsonG      (smallJsont *self, smallIntt *value) {
  25868 
  25869   return(self->f->pushNFreeSmallInt(self,value));
  25870 }
  25871 
  25872 smallJsont* pushNFreeSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value) {
  25873 
  25874   return(self->f->pushNFreeSmallJson(self,value));
  25875 }
  25876 
  25877 smallJsont* pushNFreeSmallStringSmallJsonG   (smallJsont *self, smallStringt *string) {
  25878 
  25879   return(self->f->pushNFreeSmallString(self,string));
  25880 }
  25881 
  25882 smallJsont* pushNFreeSmallContainerSmallJsonG(smallJsont *self, smallContainert *container) {
  25883 
  25884   return(self->f->pushNFreeSmallContainer(self,container));
  25885 }
  25886 
  25887 baset*           popSmallJsonG              (smallJsont *self, baset* retType UNUSED) {
  25888 
  25889   return(self->f->pop(self));
  25890 }
  25891 
  25892 undefinedt*      popUndefinedSmallJsonG     (smallJsont *self, undefinedt* retType UNUSED) {
  25893 
  25894   return(self->f->popUndefined(self));
  25895 }
  25896 
  25897 bool             popBoolSmallJsonG          (smallJsont *self, bool retType UNUSED) {
  25898 
  25899   return(self->f->popBool(self));
  25900 }
  25901 
  25902 double           popDoubleSmallJsonG        (smallJsont *self, double retType UNUSED) {
  25903 
  25904   return(self->f->popDouble(self));
  25905 }
  25906 
  25907 int64_t          popIntSmallJsonG           (smallJsont *self, int64_t retType UNUSED) {
  25908 
  25909   return(self->f->popInt(self));
  25910 }
  25911 
  25912 int32_t          popInt32SmallJsonG         (smallJsont *self, int32_t retType UNUSED) {
  25913 
  25914   return(self->f->popInt32(self));
  25915 }
  25916 
  25917 uint64_t         popUintSmallJsonG          (smallJsont *self, uint64_t retType UNUSED) {
  25918 
  25919   return(self->f->popUint(self));
  25920 }
  25921 
  25922 uint32_t         popUint32SmallJsonG        (smallJsont *self, uint32_t retType UNUSED) {
  25923 
  25924   return(self->f->popUint32(self));
  25925 }
  25926 
  25927 char*            popSSmallJsonG             (smallJsont *self, char* retType UNUSED) {
  25928 
  25929   return(self->f->popS(self));
  25930 }
  25931 
  25932 smallDictt*      popDictSmallJsonG          (smallJsont *self, smallDictt* retType UNUSED) {
  25933 
  25934   return(self->f->popDict(self));
  25935 }
  25936 
  25937 smallArrayt*     popArraySmallJsonG         (smallJsont *self, smallArrayt* retType UNUSED) {
  25938 
  25939   return(self->f->popArray(self));
  25940 }
  25941 
  25942 smallBoolt*      popSmallBoolSmallJsonG     (smallJsont *self, smallBoolt* retType UNUSED) {
  25943 
  25944   return(self->f->popSmallBool(self));
  25945 }
  25946 
  25947 smallBytest*      popSmallBytesSmallJsonG     (smallJsont *self, smallBytest* retType UNUSED) {
  25948 
  25949   return(self->f->popSmallBytes(self));
  25950 }
  25951 
  25952 smallDoublet*    popSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet* retType UNUSED) {
  25953 
  25954   return(self->f->popSmallDouble(self));
  25955 }
  25956 
  25957 smallIntt*       popSmallIntSmallJsonG      (smallJsont *self, smallIntt* retType UNUSED) {
  25958 
  25959   return(self->f->popSmallInt(self));
  25960 }
  25961 
  25962 smallJsont*      popSmallJsonSmallJsonG     (smallJsont *self, smallJsont* retType UNUSED) {
  25963 
  25964   return(self->f->popSmallJson(self));
  25965 }
  25966 
  25967 smallStringt*    popSmallStringSmallJsonG   (smallJsont *self, smallStringt* retType UNUSED) {
  25968 
  25969   return(self->f->popSmallString(self));
  25970 }
  25971 
  25972 void*            popVoidSmallJsonG          (smallJsont *self, void* retType UNUSED) {
  25973 
  25974   return(self->f->popVoid(self));
  25975 }
  25976 
  25977 smallContainert* popSmallContainerSmallJsonG(smallJsont *self, smallContainert* retType UNUSED) {
  25978 
  25979   return(self->f->popSmallContainer(self));
  25980 }
  25981 
  25982 
  25983 
  25984 smallJsont*   setSmallJsonG       (smallJsont *self, const char *key, baset *value) {
  25985 
  25986   return(self->f->set(self, key, value));
  25987 }
  25988 
  25989 smallJsont* setUndefinedSmallJsonG(smallJsont *self, const char *key, void *value UNUSED) {
  25990 
  25991   return(self->f->setUndefined(self,key));
  25992 }
  25993 
  25994 smallJsont* setBoolSmallJsonG     (smallJsont *self, const char *key, bool value) {
  25995 
  25996   return(self->f->setBool(self,key,value));
  25997 }
  25998 
  25999 smallJsont* setDoubleSmallJsonG   (smallJsont *self, const char *key, double value) {
  26000 
  26001   return(self->f->setDouble(self,key,value));
  26002 }
  26003 
  26004 smallJsont* setIntSmallJsonG      (smallJsont *self, const char *key, int64_t value) {
  26005 
  26006   return(self->f->setInt(self,key,value));
  26007 }
  26008 
  26009 smallJsont* setSSmallJsonG        (smallJsont *self, const char *key, const char *string) {
  26010 
  26011   return(self->f->setS(self,key,string));
  26012 }
  26013 
  26014 smallJsont* setCharSmallJsonG(smallJsont *self, const char *key, char c) {
  26015 
  26016   return(self->f->setChar(self,key,c));
  26017 }
  26018 
  26019 smallJsont* setDictSmallJsonG     (smallJsont *self, const char *key, smallDictt *dict) {
  26020 
  26021   return(self->f->setDict(self,key,dict));
  26022 }
  26023 
  26024 smallJsont* setArraySmallJsonG    (smallJsont *self, const char *key, smallArrayt *array) {
  26025 
  26026   return(self->f->setArray(self,key,array));
  26027 }
  26028 
  26029 smallJsont* setArraycSmallJsonG   (smallJsont *self, const char *key, char **array) {
  26030 
  26031   return(self->f->setArrayc(self,key,array));
  26032 }
  26033 
  26034 smallJsont* setCArraycSmallJsonG  (smallJsont *self, const char *key, const char **array) {
  26035 
  26036   return(self->f->setCArrayc(self,key,array));
  26037 }
  26038 
  26039 smallJsont* setVoidSmallJsonG     (smallJsont *self, const char *key, void *value) {
  26040   smallJsont *r = NULL;
  26041 
  26042   if (key && value) {
  26043     smallContainert *c = allocSmallContainer(value);
  26044     if (!c) {
  26045       return(NULL);
  26046     }
  26047     r = self->f->setNFreeSmallContainer(self, key, c);;
  26048     return(r);
  26049   }
  26050   r = self->f->setUndefined(self,key);;
  26051   return(r);
  26052 }
  26053 
  26054 smallJsont* setSmallBoolSmallJsonG     (smallJsont *self, const char *key, smallBoolt *value) {
  26055 
  26056   return(self->f->setSmallBool(self,key,value));
  26057 }
  26058 
  26059 smallJsont* setSmallBytesSmallJsonG    (smallJsont *self, const char *key, smallBytest *value) {
  26060 
  26061   return(self->f->setSmallBytes(self,key,value));
  26062 }
  26063 
  26064 smallJsont* setSmallDoubleSmallJsonG   (smallJsont *self, const char *key, smallDoublet *value) {
  26065 
  26066   return(self->f->setSmallDouble(self,key,value));
  26067 }
  26068 
  26069 smallJsont* setSmallIntSmallJsonG      (smallJsont *self, const char *key, smallIntt *value) {
  26070 
  26071   return(self->f->setSmallInt(self,key,value));
  26072 }
  26073 
  26074 smallJsont* setSmallJsonSmallJsonG     (smallJsont *self, const char *key, smallJsont *value) {
  26075 
  26076   return(self->f->setSmallJson(self,key,value));
  26077 }
  26078 
  26079 smallJsont* setSmallStringSmallJsonG   (smallJsont *self, const char *key, smallStringt *string) {
  26080 
  26081   return(self->f->setSmallString(self,key,string));
  26082 }
  26083 
  26084 smallJsont* setSmallContainerSmallJsonG(smallJsont *self, const char *key, smallContainert *container) {
  26085 
  26086   return(self->f->setSmallContainer(self,key,container));
  26087 }
  26088 
  26089 smallJsont* setNFreeSmallJsonG         (smallJsont *self, const char *key, baset *value) {
  26090 
  26091   return(self->f->setNFree(self,key,value));
  26092 }
  26093 
  26094 smallJsont* setNFreeUndefinedSmallJsonG(smallJsont *self, const char *key, undefinedt *value) {
  26095 
  26096   return(self->f->setNFreeUndefined(self,key,value));
  26097 }
  26098 
  26099 smallJsont* setNFreeSSmallJsonG        (smallJsont *self, const char *key, char *string) {
  26100 
  26101   return(self->f->setNFreeS(self,key,string));
  26102 }
  26103 
  26104 smallJsont* setNFreeDictSmallJsonG     (smallJsont *self, const char *key, smallDictt *dict) {
  26105 
  26106   return(self->f->setNFreeDict(self,key,dict));
  26107 }
  26108 
  26109 smallJsont* setNFreeArraySmallJsonG    (smallJsont *self, const char *key, smallArrayt *array) {
  26110 
  26111   return(self->f->setNFreeArray(self,key,array));
  26112 }
  26113 
  26114 smallJsont* setNFreeArraycSmallJsonG   (smallJsont *self, const char *key, char **array) {
  26115 
  26116   return(self->f->setNFreeArrayc(self,key,array));
  26117 }
  26118 
  26119 smallJsont* setNFreeSmallBoolSmallJsonG     (smallJsont *self, const char *key, smallBoolt *value) {
  26120 
  26121   return(self->f->setNFreeSmallBool(self,key,value));
  26122 }
  26123 
  26124 smallJsont* setNFreeSmallBytesSmallJsonG    (smallJsont *self, const char *key, smallBytest *value) {
  26125 
  26126   return(self->f->setNFreeSmallBytes(self,key,value));
  26127 }
  26128 
  26129 smallJsont* setNFreeSmallDoubleSmallJsonG   (smallJsont *self, const char *key, smallDoublet *value) {
  26130 
  26131   return(self->f->setNFreeSmallDouble(self,key,value));
  26132 }
  26133 
  26134 smallJsont* setNFreeSmallIntSmallJsonG      (smallJsont *self, const char *key, smallIntt *value) {
  26135 
  26136   return(self->f->setNFreeSmallInt(self,key,value));
  26137 }
  26138 
  26139 smallJsont* setNFreeSmallJsonSmallJsonG     (smallJsont *self, const char *key, smallJsont *value) {
  26140 
  26141   return(self->f->setNFreeSmallJson(self,key,value));
  26142 }
  26143 
  26144 smallJsont* setNFreeSmallStringSmallJsonG   (smallJsont *self, const char *key, smallStringt *string) {
  26145 
  26146   return(self->f->setNFreeSmallString(self,key,string));
  26147 }
  26148 
  26149 smallJsont* setNFreeSmallContainerSmallJsonG(smallJsont *self, const char *key, smallContainert *container) {
  26150 
  26151   return(self->f->setNFreeSmallContainer(self,key,container));
  26152 }
  26153 
  26154 
  26155 smallJsont* setPDictSmallJsonG    (smallJsont *self, const char *key, smallDictt *dict) {
  26156 
  26157   return(self->f->setPDict(self,key,dict));
  26158 }
  26159 
  26160 smallJsont* setPArraySmallJsonG   (smallJsont *self, const char *key, smallArrayt *array) {
  26161 
  26162   return(self->f->setPArray(self,key,array));
  26163 }
  26164 
  26165 smallJsont* setPSmallJsonSmallJsonG(smallJsont *self, const char *key, smallJsont *value) {
  26166 
  26167   return(self->f->setPSmallJson(self,key,value));
  26168 }
  26169 
  26170 smallJsont* setPSmallStringSmallJsonG(smallJsont *self, const char *key, smallStringt *string) {
  26171 
  26172   return(self->f->setPSmallString(self,key,string));
  26173 }
  26174 
  26175 smallJsont* setNFreePDictSmallJsonG    (smallJsont *self, const char *key, smallDictt *dict) {
  26176 
  26177   return(self->f->setNFreePDict(self,key,dict));
  26178 }
  26179 
  26180 smallJsont* setNFreePArraySmallJsonG   (smallJsont *self, const char *key, smallArrayt *array) {
  26181 
  26182   return(self->f->setNFreePArray(self,key,array));
  26183 }
  26184 
  26185 smallJsont* setNFreePSmallJsonSmallJsonG(smallJsont *self, const char *key, smallJsont *value) {
  26186 
  26187   return(self->f->setNFreePSmallJson(self,key,value));
  26188 }
  26189 
  26190 smallJsont* setNFreePSmallStringSmallJsonG(smallJsont *self, const char *key, smallStringt *string) {
  26191 
  26192   return(self->f->setNFreePSmallString(self,key,string));
  26193 }
  26194 
  26195 
  26196 
  26197 smallJsont* setAtSmallJsonG         (smallJsont *self, int64_t index, baset *value) {
  26198 
  26199   return(self->f->setAt(self, index, value));
  26200 }
  26201 
  26202 smallJsont* setAtUndefinedSmallJsonG(smallJsont *self, int64_t index, void *value) {
  26203 
  26204   if (value) {
  26205     free(value);
  26206   }
  26207   self->f->setAtUndefined(self,index);
  26208   return(self);
  26209 }
  26210 
  26211 smallJsont* setAtBoolSmallJsonG     (smallJsont *self, int64_t index, bool value) {
  26212 
  26213   return(self->f->setAtBool(self,index,value));
  26214 }
  26215 
  26216 smallJsont* setAtDoubleSmallJsonG   (smallJsont *self, int64_t index, double value) {
  26217 
  26218   return(self->f->setAtDouble(self,index,value));
  26219 }
  26220 
  26221 smallJsont* setAtIntSmallJsonG      (smallJsont *self, int64_t index, int64_t value) {
  26222 
  26223   return(self->f->setAtInt(self,index,value));
  26224 }
  26225 
  26226 smallJsont* setAtSSmallJsonG        (smallJsont *self, int64_t index, const char *string) {
  26227 
  26228   return(self->f->setAtS(self,index,string));
  26229 }
  26230 
  26231 smallJsont* setAtCharSmallJsonG(smallJsont *self, int64_t index, char c) {
  26232 
  26233   return(self->f->setAtChar(self,index,c));
  26234 }
  26235 
  26236 smallJsont* setAtDictSmallJsonG     (smallJsont *self, int64_t index, smallDictt *dict) {
  26237 
  26238   return(self->f->setAtDict(self,index,dict));
  26239 }
  26240 
  26241 smallJsont* setAtArraySmallJsonG    (smallJsont *self, int64_t index, smallArrayt *array) {
  26242 
  26243   return(self->f->setAtArray(self,index,array));
  26244 }
  26245 
  26246 smallJsont* setAtArraycSmallJsonG   (smallJsont *self, int64_t index, char **array) {
  26247 
  26248   return(self->f->setAtArrayc(self,index,array));
  26249 }
  26250 
  26251 smallJsont* setAtCArraycSmallJsonG  (smallJsont *self, int64_t index, const char **array) {
  26252 
  26253   return(self->f->setAtCArrayc(self,index,array));
  26254 }
  26255 
  26256 smallJsont* setAtVoidSmallJsonG     (smallJsont *self, int64_t index, void *value) {
  26257 
  26258   if (value) {
  26259     smallContainert *c = allocSmallContainer(value);
  26260     if (!c) {
  26261       return(NULL);
  26262     }
  26263     return(self->f->setAtNFreeSmallContainer(self, index, c));
  26264   }
  26265   return(self->f->setAtUndefined(self,index));
  26266 }
  26267 
  26268 smallJsont* setAtSmallBoolSmallJsonG     (smallJsont *self, int64_t index, smallBoolt *value) {
  26269 
  26270   return(self->f->setAtSmallBool(self,index,value));
  26271 }
  26272 
  26273 smallJsont* setAtSmallBytesSmallJsonG    (smallJsont *self, int64_t index, smallBytest *value) {
  26274 
  26275   return(self->f->setAtSmallBytes(self,index,value));
  26276 }
  26277 
  26278 smallJsont* setAtSmallDoubleSmallJsonG   (smallJsont *self, int64_t index, smallDoublet *value) {
  26279 
  26280   return(self->f->setAtSmallDouble(self,index,value));
  26281 }
  26282 
  26283 smallJsont* setAtSmallIntSmallJsonG      (smallJsont *self, int64_t index, smallIntt *value) {
  26284 
  26285   return(self->f->setAtSmallInt(self,index,value));
  26286 }
  26287 
  26288 smallJsont* setAtSmallJsonSmallJsonG     (smallJsont *self, int64_t index, smallJsont *value) {
  26289 
  26290   return(self->f->setAtSmallJson(self,index,value));
  26291 }
  26292 
  26293 smallJsont* setAtSmallStringSmallJsonG   (smallJsont *self, int64_t index, smallStringt *string) {
  26294 
  26295   return(self->f->setAtSmallString(self,index,string));
  26296 }
  26297 
  26298 smallJsont* setAtSmallContainerSmallJsonG(smallJsont *self, int64_t index, smallContainert *container) {
  26299 
  26300   return(self->f->setAtSmallContainer(self,index,container));
  26301 }
  26302 
  26303 
  26304 smallJsont* setAtNFreeSmallJsonG    (smallJsont *self, int64_t index, baset *value) {
  26305 
  26306   return(self->f->setAtNFree(self,index,value));
  26307 }
  26308 
  26309 smallJsont* setAtNFreeUndefinedSmallJsonG(smallJsont *self, int64_t index, void *value) {
  26310 
  26311   return(self->f->setAtNFreeUndefined(self,index,value));
  26312 }
  26313 
  26314 smallJsont* setAtNFreeSSmallJsonG        (smallJsont *self, int64_t index, char *string) {
  26315 
  26316   return(self->f->setAtNFreeS(self,index,string));
  26317 }
  26318 
  26319 smallJsont* setAtNFreeDictSmallJsonG     (smallJsont *self, int64_t index, smallDictt *dict) {
  26320 
  26321   return(self->f->setAtNFreeDict(self,index,dict));
  26322 }
  26323 
  26324 smallJsont* setAtNFreeArraySmallJsonG    (smallJsont *self, int64_t index, smallArrayt *array) {
  26325 
  26326   return(self->f->setAtNFreeArray(self,index,array));
  26327 }
  26328 
  26329 smallJsont* setAtNFreeArraycSmallJsonG   (smallJsont *self, int64_t index, char **array) {
  26330 
  26331   return(self->f->setAtNFreeArrayc(self,index,array));
  26332 }
  26333 
  26334 smallJsont* setAtNFreeSmallBoolSmallJsonG     (smallJsont *self, int64_t index, smallBoolt *value) {
  26335 
  26336   return(self->f->setAtNFreeSmallBool(self,index,value));
  26337 }
  26338 
  26339 smallJsont* setAtNFreeSmallBytesSmallJsonG    (smallJsont *self, int64_t index, smallBytest *value) {
  26340 
  26341   return(self->f->setAtNFreeSmallBytes(self,index,value));
  26342 }
  26343 
  26344 smallJsont* setAtNFreeSmallDoubleSmallJsonG   (smallJsont *self, int64_t index, smallDoublet *value) {
  26345 
  26346   return(self->f->setAtNFreeSmallDouble(self,index,value));
  26347 }
  26348 
  26349 smallJsont* setAtNFreeSmallIntSmallJsonG      (smallJsont *self, int64_t index, smallIntt *value) {
  26350 
  26351   return(self->f->setAtNFreeSmallInt(self,index,value));
  26352 }
  26353 
  26354 smallJsont* setAtNFreeSmallJsonSmallJsonG     (smallJsont *self, int64_t index, smallJsont *value) {
  26355 
  26356   return(self->f->setAtNFreeSmallJson(self,index,value));
  26357 }
  26358 
  26359 smallJsont* setAtNFreeSmallStringSmallJsonG   (smallJsont *self, int64_t index, smallStringt *string) {
  26360 
  26361   return(self->f->setAtNFreeSmallString(self,index,string));
  26362 }
  26363 
  26364 smallJsont* setAtNFreeSmallContainerSmallJsonG(smallJsont *self, int64_t index, smallContainert *container) {
  26365 
  26366   return(self->f->setAtNFreeSmallContainer(self,index,container));
  26367 }
  26368 
  26369 
  26370 smallJsont* setPAtDictSmallJsonG     (smallJsont *self, int64_t index, smallDictt *dict) {
  26371 
  26372   return(self->f->setPAtDict(self,index,dict));
  26373 }
  26374 
  26375 smallJsont* setPAtArraySmallJsonG    (smallJsont *self, int64_t index, smallArrayt *array) {
  26376 
  26377   return(self->f->setPAtArray(self,index,array));
  26378 }
  26379 
  26380 smallJsont* setPAtSmallJsonSmallJsonG     (smallJsont *self, int64_t index, smallJsont *value) {
  26381 
  26382   return(self->f->setPAtSmallJson(self,index,value));
  26383 }
  26384 
  26385 smallJsont* setPAtSmallStringSmallJsonG     (smallJsont *self, int64_t index, smallStringt *string) {
  26386 
  26387   return(self->f->setPAtSmallString(self,index,string));
  26388 }
  26389 
  26390 smallJsont* setPAtNFreeDictSmallJsonG     (smallJsont *self, int64_t index, smallDictt *dict) {
  26391 
  26392   return(self->f->setPAtNFreeDict(self,index,dict));
  26393 }
  26394 
  26395 smallJsont* setPAtNFreeArraySmallJsonG    (smallJsont *self, int64_t index, smallArrayt *array) {
  26396 
  26397   return(self->f->setPAtNFreeArray(self,index,array));
  26398 }
  26399 
  26400 smallJsont* setPAtNFreeSmallJsonSmallJsonG     (smallJsont *self, int64_t index, smallJsont *value) {
  26401 
  26402   return(self->f->setPAtNFreeSmallJson(self,index,value));
  26403 }
  26404 
  26405 smallJsont* setPAtNFreeSmallStringSmallJsonG     (smallJsont *self, int64_t index, smallStringt *string) {
  26406 
  26407   return(self->f->setPAtNFreeSmallString(self,index,string));
  26408 }
  26409 
  26410 
  26411 baset*           getSmallJsonG              (smallJsont *self, baset* retType UNUSED, const char *key) {
  26412 
  26413   return(self->f->get(self,key));
  26414 }
  26415 
  26416 undefinedt*      getUndefinedSmallJsonG     (smallJsont *self, undefinedt* retType UNUSED, const char *key) {
  26417 
  26418   return(self->f->getUndefined(self,key));
  26419 }
  26420 
  26421 bool             getBoolSmallJsonG          (smallJsont *self, bool retType UNUSED, const char *key) {
  26422 
  26423   return(self->f->getBool(self,key));
  26424 }
  26425 
  26426 bool*            getBoolPSmallJsonG         (smallJsont *self, bool* retType UNUSED, const char *key) {
  26427 
  26428   return(self->f->getBoolP(self,key));
  26429 }
  26430 
  26431 double           getDoubleSmallJsonG        (smallJsont *self, double retType UNUSED, const char *key) {
  26432 
  26433   return(self->f->getDouble(self,key));
  26434 }
  26435 
  26436 double*          getDoublePSmallJsonG       (smallJsont *self, double* retType UNUSED, const char *key) {
  26437 
  26438   return(self->f->getDoubleP(self,key));
  26439 }
  26440 
  26441 int64_t          getIntSmallJsonG           (smallJsont *self, int64_t retType UNUSED, const char *key) {
  26442 
  26443   return(self->f->getInt(self,key));
  26444 }
  26445 
  26446 int64_t*         getIntPSmallJsonG          (smallJsont *self, int64_t* retType UNUSED, const char *key) {
  26447 
  26448   return(self->f->getIntP(self,key));
  26449 }
  26450 
  26451 int32_t          getInt32SmallJsonG         (smallJsont *self, int32_t retType UNUSED, const char *key) {
  26452 
  26453   return(self->f->getInt32(self,key));
  26454 }
  26455 
  26456 int32_t*         getInt32PSmallJsonG        (smallJsont *self, int32_t* retType UNUSED, const char *key) {
  26457 
  26458   return(self->f->getInt32P(self,key));
  26459 }
  26460 
  26461 uint64_t         getUintSmallJsonG          (smallJsont *self, uint64_t retType UNUSED, const char *key) {
  26462 
  26463   return(self->f->getUint(self,key));
  26464 }
  26465 
  26466 uint64_t*        getUintPSmallJsonG         (smallJsont *self, uint64_t* retType UNUSED, const char *key) {
  26467 
  26468   return(self->f->getUintP(self,key));
  26469 }
  26470 
  26471 uint32_t         getUint32SmallJsonG        (smallJsont *self, uint32_t retType UNUSED, const char *key) {
  26472 
  26473   return(self->f->getUint32(self,key));
  26474 }
  26475 
  26476 uint32_t*        getUint32PSmallJsonG       (smallJsont *self, uint32_t* retType UNUSED, const char *key) {
  26477 
  26478   return(self->f->getUint32P(self,key));
  26479 }
  26480 
  26481 char*            getSSmallJsonG             (smallJsont *self, char* retType UNUSED, const char *key) {
  26482 
  26483   return(self->f->getS(self,key));
  26484 }
  26485 
  26486 smallDictt*      getDictSmallJsonG          (smallJsont *self, smallDictt* retType UNUSED, const char *key) {
  26487 
  26488   return(self->f->getDict(self,key));
  26489 }
  26490 
  26491 smallArrayt*     getArraySmallJsonG         (smallJsont *self, smallArrayt* retType UNUSED, const char *key) {
  26492 
  26493   return(self->f->getArray(self,key));
  26494 }
  26495 
  26496 smallBoolt*      getSmallBoolSmallJsonG     (smallJsont *self, smallBoolt* retType UNUSED, const char *key) {
  26497 
  26498   return(self->f->getSmallBool(self,key));
  26499 }
  26500 
  26501 smallBytest*     getSmallBytesSmallJsonG    (smallJsont *self, smallBytest* retType UNUSED, const char *key) {
  26502 
  26503   return(self->f->getSmallBytes(self,key));
  26504 }
  26505 
  26506 smallDoublet*    getSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet* retType UNUSED, const char *key) {
  26507 
  26508   return(self->f->getSmallDouble(self,key));
  26509 }
  26510 
  26511 smallIntt*       getSmallIntSmallJsonG      (smallJsont *self, smallIntt* retType UNUSED, const char *key) {
  26512 
  26513   return(self->f->getSmallInt(self,key));
  26514 }
  26515 
  26516 smallJsont*       getSmallJsonSmallJsonG    (smallJsont *self, smallJsont* retType UNUSED, const char *key) {
  26517 
  26518   return(self->f->getSmallJson(self,key));
  26519 }
  26520 
  26521 smallStringt*    getSmallStringSmallJsonG   (smallJsont *self, smallStringt* retType UNUSED, const char *key) {
  26522 
  26523   return(self->f->getSmallString(self,key));
  26524 }
  26525 
  26526 void*            getVoidSmallJsonG          (smallJsont *self, void* retType UNUSED, const char *key) {
  26527 
  26528   return(self->f->getVoid(self,key));
  26529 }
  26530 
  26531 smallContainert* getSmallContainerSmallJsonG(smallJsont *self, smallContainert* retType UNUSED, const char *key) {
  26532 
  26533   return(self->f->getSmallContainer(self,key));
  26534 }
  26535 
  26536 baset*           getNDupSmallJsonG              (smallJsont *self, baset* retType UNUSED, const char *key) {
  26537 
  26538   return(self->f->getNDup(self,key));
  26539 }
  26540 
  26541 undefinedt*      getNDupUndefinedSmallJsonG     (smallJsont *self, undefinedt* retType UNUSED, const char *key) {
  26542 
  26543   return(self->f->getNDupUndefined(self,key));
  26544 }
  26545 
  26546 bool             getNDupBoolSmallJsonG          (smallJsont *self, bool retType UNUSED, const char *key) {
  26547 
  26548   return(self->f->getNDupBool(self,key));
  26549 }
  26550 
  26551 double           getNDupDoubleSmallJsonG        (smallJsont *self, double retType UNUSED, const char *key) {
  26552 
  26553   return(self->f->getNDupDouble(self,key));
  26554 }
  26555 
  26556 int64_t          getNDupIntSmallJsonG           (smallJsont *self, int64_t retType UNUSED, const char *key) {
  26557 
  26558   return(self->f->getNDupInt(self,key));
  26559 }
  26560 
  26561 int32_t          getNDupInt32SmallJsonG         (smallJsont *self, int32_t retType UNUSED, const char *key) {
  26562 
  26563   return(self->f->getNDupInt32(self,key));
  26564 }
  26565 
  26566 uint64_t         getNDupUintSmallJsonG          (smallJsont *self, uint64_t retType UNUSED, const char *key) {
  26567 
  26568   return(self->f->getNDupUint(self,key));
  26569 }
  26570 
  26571 uint32_t         getNDupUint32SmallJsonG        (smallJsont *self, uint32_t retType UNUSED, const char *key) {
  26572 
  26573   return(self->f->getNDupUint32(self,key));
  26574 }
  26575 
  26576 char*            getNDupSSmallJsonG             (smallJsont *self, char* retType UNUSED, const char *key) {
  26577 
  26578   return(self->f->getNDupS(self,key));
  26579 }
  26580 
  26581 smallDictt*      getNDupDictSmallJsonG          (smallJsont *self, smallDictt* retType UNUSED, const char *key) {
  26582 
  26583   return(self->f->getNDupDict(self,key));
  26584 }
  26585 
  26586 smallArrayt*     getNDupArraySmallJsonG         (smallJsont *self, smallArrayt* retType UNUSED, const char *key) {
  26587 
  26588   return(self->f->getNDupArray(self,key));
  26589 }
  26590 
  26591 smallBoolt*      getNDupSmallBoolSmallJsonG     (smallJsont *self, smallBoolt* retType UNUSED, const char *key) {
  26592 
  26593   return(self->f->getNDupSmallBool(self,key));
  26594 }
  26595 
  26596 smallBytest*     getNDupSmallBytesSmallJsonG    (smallJsont *self, smallBytest* retType UNUSED, const char *key) {
  26597 
  26598   return(self->f->getNDupSmallBytes(self,key));
  26599 }
  26600 
  26601 smallDoublet*    getNDupSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet* retType UNUSED, const char *key) {
  26602 
  26603   return(self->f->getNDupSmallDouble(self,key));
  26604 }
  26605 
  26606 smallIntt*       getNDupSmallIntSmallJsonG      (smallJsont *self, smallIntt* retType UNUSED, const char *key) {
  26607 
  26608   return(self->f->getNDupSmallInt(self,key));
  26609 }
  26610 
  26611 smallJsont*       getNDupSmallJsonSmallJsonG    (smallJsont *self, smallJsont* retType UNUSED, const char *key) {
  26612 
  26613   return(self->f->getNDupSmallJson(self,key));
  26614 }
  26615 
  26616 smallStringt*    getNDupSmallStringSmallJsonG   (smallJsont *self, smallStringt* retType UNUSED, const char *key) {
  26617 
  26618   return(self->f->getNDupSmallString(self,key));
  26619 }
  26620 
  26621 void*            getNDupVoidSmallJsonG          (smallJsont *self, void* retType UNUSED, const char *key) {
  26622 
  26623   return(self->f->getNDupVoid(self,key));
  26624 }
  26625 
  26626 smallContainert* getNDupSmallContainerSmallJsonG(smallJsont *self, smallContainert* retType UNUSED, const char *key) {
  26627 
  26628   return(self->f->getNDupSmallContainer(self,key));
  26629 }
  26630 
  26631 baset*           getAtSmallJsonG              (smallJsont *self, baset* retType UNUSED, int64_t index) {
  26632 
  26633   return(self->f->getAt(self,index));
  26634 }
  26635 
  26636 undefinedt*      getAtUndefinedSmallJsonG     (smallJsont *self, undefinedt* retType UNUSED, int64_t index) {
  26637 
  26638   return(self->f->getAtUndefined(self,index));
  26639 }
  26640 
  26641 bool             getAtBoolSmallJsonG          (smallJsont *self, bool retType UNUSED, int64_t index) {
  26642 
  26643   return(self->f->getAtBool(self,index));
  26644 }
  26645 
  26646 bool*            getAtBoolPSmallJsonG         (smallJsont *self, bool* retType UNUSED, int64_t index) {
  26647 
  26648   return(self->f->getAtBoolP(self,index));
  26649 }
  26650 
  26651 double           getAtDoubleSmallJsonG        (smallJsont *self, double retType UNUSED, int64_t index) {
  26652 
  26653   return(self->f->getAtDouble(self,index));
  26654 }
  26655 
  26656 double*          getAtDoublePSmallJsonG       (smallJsont *self, double* retType UNUSED, int64_t index) {
  26657 
  26658   return(self->f->getAtDoubleP(self,index));
  26659 }
  26660 
  26661 int64_t          getAtIntSmallJsonG           (smallJsont *self, int64_t retType UNUSED, int64_t index) {
  26662 
  26663   return(self->f->getAtInt(self,index));
  26664 }
  26665 
  26666 int64_t*         getAtIntPSmallJsonG          (smallJsont *self, int64_t* retType UNUSED, int64_t index) {
  26667 
  26668   return(self->f->getAtIntP(self,index));
  26669 }
  26670 
  26671 int32_t          getAtInt32SmallJsonG         (smallJsont *self, int32_t retType UNUSED, int64_t index) {
  26672 
  26673   return(self->f->getAtInt32(self,index));
  26674 }
  26675 
  26676 int32_t*         getAtInt32PSmallJsonG        (smallJsont *self, int32_t* retType UNUSED, int64_t index) {
  26677 
  26678   return(self->f->getAtInt32P(self,index));
  26679 }
  26680 
  26681 uint64_t         getAtUintSmallJsonG          (smallJsont *self, uint64_t retType UNUSED, int64_t index) {
  26682 
  26683   return(self->f->getAtUint(self,index));
  26684 }
  26685 
  26686 uint64_t*        getAtUintPSmallJsonG         (smallJsont *self, uint64_t* retType UNUSED, int64_t index) {
  26687 
  26688   return(self->f->getAtUintP(self,index));
  26689 }
  26690 
  26691 uint32_t         getAtUint32SmallJsonG        (smallJsont *self, uint32_t retType UNUSED, int64_t index) {
  26692 
  26693   return(self->f->getAtUint32(self,index));
  26694 }
  26695 
  26696 uint32_t*        getAtUint32PSmallJsonG       (smallJsont *self, uint32_t* retType UNUSED, int64_t index) {
  26697 
  26698   return(self->f->getAtUint32P(self,index));
  26699 }
  26700 
  26701 char*            getAtSSmallJsonG             (smallJsont *self, char* retType UNUSED, int64_t index) {
  26702 
  26703   return(self->f->getAtS(self,index));
  26704 }
  26705 
  26706 smallDictt*      getAtDictSmallJsonG          (smallJsont *self, smallDictt* retType UNUSED, int64_t index) {
  26707 
  26708   return(self->f->getAtDict(self,index));
  26709 }
  26710 
  26711 smallArrayt*     getAtArraySmallJsonG         (smallJsont *self, smallArrayt* retType UNUSED, int64_t index) {
  26712 
  26713   return(self->f->getAtArray(self,index));
  26714 }
  26715 
  26716 smallBoolt*      getAtSmallBoolSmallJsonG     (smallJsont *self, smallBoolt* retType UNUSED, int64_t index) {
  26717 
  26718   return(self->f->getAtSmallBool(self,index));
  26719 }
  26720 
  26721 smallBytest*     getAtSmallBytesSmallJsonG    (smallJsont *self, smallBytest* retType UNUSED, int64_t index) {
  26722 
  26723   return(self->f->getAtSmallBytes(self,index));
  26724 }
  26725 
  26726 smallDoublet*    getAtSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet* retType UNUSED, int64_t index) {
  26727 
  26728   return(self->f->getAtSmallDouble(self,index));
  26729 }
  26730 
  26731 smallIntt*       getAtSmallIntSmallJsonG      (smallJsont *self, smallIntt* retType UNUSED, int64_t index) {
  26732 
  26733   return(self->f->getAtSmallInt(self,index));
  26734 }
  26735 
  26736 smallJsont*       getAtSmallJsonSmallJsonG    (smallJsont *self, smallJsont* retType UNUSED, int64_t index) {
  26737 
  26738   return(self->f->getAtSmallJson(self,index));
  26739 }
  26740 
  26741 smallStringt*    getAtSmallStringSmallJsonG   (smallJsont *self, smallStringt* retType UNUSED, int64_t index) {
  26742 
  26743   return(self->f->getAtSmallString(self,index));
  26744 }
  26745 
  26746 void*            getAtVoidSmallJsonG          (smallJsont *self, void* retType UNUSED, int64_t index) {
  26747 
  26748   return(self->f->getAtVoid(self,index));
  26749 }
  26750 
  26751 smallContainert* getAtSmallContainerSmallJsonG(smallJsont *self, smallContainert* retType UNUSED, int64_t index) {
  26752 
  26753   return(self->f->getAtSmallContainer(self,index));
  26754 }
  26755 
  26756 
  26757 baset*           getAtNDupSmallJsonG              (smallJsont *self, baset* retType UNUSED, int64_t index) {
  26758 
  26759   return(self->f->getAtNDup(self,index));
  26760 }
  26761 
  26762 undefinedt*      getAtNDupUndefinedSmallJsonG     (smallJsont *self, undefinedt* retType UNUSED, int64_t index) {
  26763 
  26764   return(self->f->getAtNDupUndefined(self,index));
  26765 }
  26766 
  26767 bool             getAtNDupBoolSmallJsonG          (smallJsont *self, bool retType UNUSED, int64_t index) {
  26768 
  26769   return(self->f->getAtNDupBool(self,index));
  26770 }
  26771 
  26772 double           getAtNDupDoubleSmallJsonG        (smallJsont *self, double retType UNUSED, int64_t index) {
  26773 
  26774   return(self->f->getAtNDupDouble(self,index));
  26775 }
  26776 
  26777 int64_t          getAtNDupIntSmallJsonG           (smallJsont *self, int64_t retType UNUSED, int64_t index) {
  26778 
  26779   return(self->f->getAtNDupInt(self,index));
  26780 }
  26781 
  26782 int32_t          getAtNDupInt32SmallJsonG         (smallJsont *self, int32_t retType UNUSED, int64_t index) {
  26783 
  26784   return(self->f->getAtNDupInt32(self,index));
  26785 }
  26786 
  26787 uint64_t         getAtNDupUintSmallJsonG          (smallJsont *self, uint64_t retType UNUSED, int64_t index) {
  26788 
  26789   return(self->f->getAtNDupUint(self,index));
  26790 }
  26791 
  26792 uint32_t         getAtNDupUint32SmallJsonG        (smallJsont *self, uint32_t retType UNUSED, int64_t index) {
  26793 
  26794   return(self->f->getAtNDupUint32(self,index));
  26795 }
  26796 
  26797 char*            getAtNDupSSmallJsonG             (smallJsont *self, char* retType UNUSED, int64_t index) {
  26798 
  26799   return(self->f->getAtNDupS(self,index));
  26800 }
  26801 
  26802 smallDictt*      getAtNDupDictSmallJsonG          (smallJsont *self, smallDictt* retType UNUSED, int64_t index) {
  26803 
  26804   return(self->f->getAtNDupDict(self,index));
  26805 }
  26806 
  26807 smallArrayt*     getAtNDupArraySmallJsonG         (smallJsont *self, smallArrayt* retType UNUSED, int64_t index) {
  26808 
  26809   return(self->f->getAtNDupArray(self,index));
  26810 }
  26811 
  26812 smallBoolt*      getAtNDupSmallBoolSmallJsonG     (smallJsont *self, smallBoolt* retType UNUSED, int64_t index) {
  26813 
  26814   return(self->f->getAtNDupSmallBool(self,index));
  26815 }
  26816 
  26817 smallBytest*     getAtNDupSmallBytesSmallJsonG    (smallJsont *self, smallBytest* retType UNUSED, int64_t index) {
  26818 
  26819   return(self->f->getAtNDupSmallBytes(self,index));
  26820 }
  26821 
  26822 smallDoublet*    getAtNDupSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet* retType UNUSED, int64_t index) {
  26823 
  26824   return(self->f->getAtNDupSmallDouble(self,index));
  26825 }
  26826 
  26827 smallIntt*       getAtNDupSmallIntSmallJsonG      (smallJsont *self, smallIntt* retType UNUSED, int64_t index) {
  26828 
  26829   return(self->f->getAtNDupSmallInt(self,index));
  26830 }
  26831 
  26832 smallJsont*       getAtNDupSmallJsonSmallJsonG    (smallJsont *self, smallJsont* retType UNUSED, int64_t index) {
  26833 
  26834   return(self->f->getAtNDupSmallJson(self,index));
  26835 }
  26836 
  26837 smallStringt*    getAtNDupSmallStringSmallJsonG   (smallJsont *self, smallStringt* retType UNUSED, int64_t index) {
  26838 
  26839   return(self->f->getAtNDupSmallString(self,index));
  26840 }
  26841 
  26842 void*            getAtNDupVoidSmallJsonG          (smallJsont *self, void* retType UNUSED, int64_t index) {
  26843 
  26844   return(self->f->getAtNDupVoid(self,index));
  26845 }
  26846 
  26847 smallContainert* getAtNDupSmallContainerSmallJsonG(smallJsont *self, smallContainert* retType UNUSED, int64_t index) {
  26848 
  26849   return(self->f->getAtNDupSmallContainer(self,index));
  26850 }
  26851 
  26852 double getNumSmallJsonG(smallJsont *self, const char *key) {
  26853 
  26854   return(self->f->getNum(self, key));
  26855 }
  26856 
  26857 double getNumAtSmallJsonG(smallJsont *self, int64_t index) {
  26858 
  26859   return(self->f->getNumAt(self, index));
  26860 }
  26861 
  26862 smallJsont* delKeySmallJsonG(smallJsont *self, const char *key, int unused UNUSED) {
  26863 
  26864   return(self->f->delElem(self,key));
  26865 }
  26866 
  26867 smallJsont* delSmallJsonG(smallJsont *self, int64_t start, int64_t end) {
  26868 
  26869   return(self->f->del(self, start, end));
  26870 }
  26871 
  26872 smallJsont* delElemSmallJsonG(smallJsont *self, const char *key) {
  26873 
  26874   return(self->f->delElem(self,key));
  26875 }
  26876 
  26877 smallJsont* delElemIndexSmallJsonG(smallJsont *self, int64_t index) {
  26878 
  26879   return(self->f->delElemIndex(self,index));
  26880 }
  26881 
  26882 smallJsont* prependSmallJsonG         (smallJsont *self, baset *value) {
  26883 
  26884   return(self->f->prepend(self, value));
  26885 }
  26886 
  26887 smallJsont* prependUndefinedSmallJsonG(smallJsont *self, void *value UNUSED) {
  26888 
  26889   return(self->f->prependUndefined(self));
  26890 }
  26891 
  26892 smallJsont* prependBoolSmallJsonG     (smallJsont *self, bool value) {
  26893 
  26894   return(self->f->prependBool(self,value));
  26895 }
  26896 
  26897 smallJsont* prependDoubleSmallJsonG   (smallJsont *self, double value) {
  26898 
  26899   return(self->f->prependDouble(self,value));
  26900 }
  26901 
  26902 smallJsont* prependIntSmallJsonG      (smallJsont *self, int64_t value) {
  26903 
  26904   return(self->f->prependInt(self,value));
  26905 }
  26906 
  26907 smallJsont* prependSSmallJsonG        (smallJsont *self, const char *string) {
  26908 
  26909   return(self->f->prependS(self,string));
  26910 }
  26911 
  26912 smallJsont* prependCharSmallJsonG(smallJsont *self, char c) {
  26913 
  26914   return(self->f->prependChar(self,c));
  26915 }
  26916 
  26917 smallJsont* prependDictSmallJsonG     (smallJsont *self, smallDictt *dict) {
  26918 
  26919   return(self->f->prependDict(self,dict));
  26920 }
  26921 
  26922 smallJsont* prependArraySmallJsonG    (smallJsont *self, smallArrayt *array) {
  26923 
  26924   return(self->f->prependArray(self,array));
  26925 }
  26926 
  26927 smallJsont* prependArraycSmallJsonG   (smallJsont *self, char **array) {
  26928 
  26929   return(self->f->prependArrayc(self,array));
  26930 }
  26931 
  26932 smallJsont* prependCArraycSmallJsonG  (smallJsont *self, const char **array) {
  26933 
  26934   return(self->f->prependCArrayc(self,array));
  26935 }
  26936 
  26937 smallJsont* prependVoidSmallJsonG     (smallJsont *self, void *value) {
  26938 
  26939   if (value) {
  26940     smallContainert *c = allocSmallContainer(value);
  26941     if (!c) {
  26942       return(NULL);
  26943     }
  26944     return(self->f->prependNFreeSmallContainer(self, c));
  26945   }
  26946   return(self->f->prependUndefined(self));
  26947 }
  26948 
  26949 smallJsont* prependSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value) {
  26950 
  26951   return(self->f->prependSmallBool(self,value));
  26952 }
  26953 
  26954 smallJsont* prependSmallBytesSmallJsonG    (smallJsont *self, smallBytest *value) {
  26955 
  26956   return(self->f->prependSmallBytes(self,value));
  26957 }
  26958 
  26959 smallJsont* prependSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value) {
  26960 
  26961   return(self->f->prependSmallDouble(self,value));
  26962 }
  26963 
  26964 smallJsont* prependSmallIntSmallJsonG      (smallJsont *self, smallIntt *value) {
  26965 
  26966   return(self->f->prependSmallInt(self,value));
  26967 }
  26968 
  26969 smallJsont* prependSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value) {
  26970 
  26971   return(self->f->prependSmallJson(self,value));
  26972 }
  26973 
  26974 smallJsont* prependSmallStringSmallJsonG   (smallJsont *self, smallStringt *string) {
  26975 
  26976   return(self->f->prependSmallString(self,string));
  26977 }
  26978 
  26979 smallJsont* prependSmallContainerSmallJsonG(smallJsont *self, smallContainert *container) {
  26980 
  26981   return(self->f->prependSmallContainer(self,container));
  26982 }
  26983 
  26984 
  26985 smallJsont* prependNFreeSmallJsonG         (smallJsont *self, baset *value) {
  26986 
  26987   return(self->f->prependNFree(self,value));
  26988 }
  26989 
  26990 smallJsont* prependNFreeUndefinedSmallJsonG(smallJsont *self, undefinedt *value) {
  26991 
  26992   return(self->f->prependNFreeUndefined(self,value));
  26993 }
  26994 
  26995 smallJsont* prependNFreeSSmallJsonG        (smallJsont *self, char *string) {
  26996 
  26997   return(self->f->prependNFreeS(self,string));
  26998 }
  26999 
  27000 smallJsont* prependNFreeDictSmallJsonG     (smallJsont *self, smallDictt *dict) {
  27001 
  27002   return(self->f->prependNFreeDict(self,dict));
  27003 }
  27004 
  27005 smallJsont* prependNFreeArraySmallJsonG    (smallJsont *self, smallArrayt *array) {
  27006 
  27007   return(self->f->prependNFreeArray(self,array));
  27008 }
  27009 
  27010 smallJsont* prependNFreeArraycSmallJsonG         (smallJsont *self, char **array) {
  27011 
  27012   return(self->f->prependNFreeArrayc(self,array));
  27013 }
  27014 
  27015 smallJsont* prependNFreeSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value) {
  27016 
  27017   return(self->f->prependNFreeSmallBool(self,value));
  27018 }
  27019 
  27020 smallJsont* prependNFreeSmallBytesSmallJsonG    (smallJsont *self, smallBytest *value) {
  27021 
  27022   return(self->f->prependNFreeSmallBytes(self,value));
  27023 }
  27024 
  27025 smallJsont* prependNFreeSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value) {
  27026 
  27027   return(self->f->prependNFreeSmallDouble(self,value));
  27028 }
  27029 
  27030 smallJsont* prependNFreeSmallIntSmallJsonG      (smallJsont *self, smallIntt *value) {
  27031 
  27032   return(self->f->prependNFreeSmallInt(self,value));
  27033 }
  27034 
  27035 smallJsont* prependNFreeSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value) {
  27036 
  27037   return(self->f->prependNFreeSmallJson(self,value));
  27038 }
  27039 
  27040 smallJsont* prependNFreeSmallStringSmallJsonG   (smallJsont *self, smallStringt *string) {
  27041 
  27042   return(self->f->prependNFreeSmallString(self,string));
  27043 }
  27044 
  27045 smallJsont* prependNFreeSmallContainerSmallJsonG(smallJsont *self, smallContainert *container) {
  27046 
  27047   return(self->f->prependNFreeSmallContainer(self,container));
  27048 }
  27049 
  27050 baset*           dequeueSmallJsonG              (smallJsont *self, baset* retType UNUSED) {
  27051 
  27052   return(self->f->dequeue(self));
  27053 }
  27054 
  27055 undefinedt*      dequeueUndefinedSmallJsonG     (smallJsont *self, undefinedt* retType UNUSED) {
  27056 
  27057   return(self->f->dequeueUndefined(self));
  27058 }
  27059 
  27060 bool             dequeueBoolSmallJsonG          (smallJsont *self, bool retType UNUSED) {
  27061 
  27062   return(self->f->dequeueBool(self));
  27063 }
  27064 
  27065 double           dequeueDoubleSmallJsonG        (smallJsont *self, double retType UNUSED) {
  27066 
  27067   return(self->f->dequeueDouble(self));
  27068 }
  27069 
  27070 int64_t          dequeueIntSmallJsonG           (smallJsont *self, int64_t retType UNUSED) {
  27071 
  27072   return(self->f->dequeueInt(self));
  27073 }
  27074 
  27075 int32_t          dequeueInt32SmallJsonG         (smallJsont *self, int32_t retType UNUSED) {
  27076 
  27077   return(self->f->dequeueInt32(self));
  27078 }
  27079 
  27080 uint64_t         dequeueUintSmallJsonG          (smallJsont *self, uint64_t retType UNUSED) {
  27081 
  27082   return(self->f->dequeueUint(self));
  27083 }
  27084 
  27085 uint32_t         dequeueUint32SmallJsonG        (smallJsont *self, uint32_t retType UNUSED) {
  27086 
  27087   return(self->f->dequeueUint32(self));
  27088 }
  27089 
  27090 char*            dequeueSSmallJsonG             (smallJsont *self, char* retType UNUSED) {
  27091 
  27092   return(self->f->dequeueS(self));
  27093 }
  27094 
  27095 smallDictt*      dequeueDictSmallJsonG          (smallJsont *self, smallDictt* retType UNUSED) {
  27096 
  27097   return(self->f->dequeueDict(self));
  27098 }
  27099 
  27100 smallArrayt*     dequeueArraySmallJsonG         (smallJsont *self, smallArrayt* retType UNUSED) {
  27101 
  27102   return(self->f->dequeueArray(self));
  27103 }
  27104 
  27105 smallBoolt*      dequeueSmallBoolSmallJsonG     (smallJsont *self, smallBoolt* retType UNUSED) {
  27106 
  27107   return(self->f->dequeueSmallBool(self));
  27108 }
  27109 
  27110 smallBytest*     dequeueSmallBytesSmallJsonG    (smallJsont *self, smallBytest* retType UNUSED) {
  27111 
  27112   return(self->f->dequeueSmallBytes(self));
  27113 }
  27114 
  27115 smallDoublet*    dequeueSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet* retType UNUSED) {
  27116 
  27117   return(self->f->dequeueSmallDouble(self));
  27118 }
  27119 
  27120 smallIntt*       dequeueSmallIntSmallJsonG      (smallJsont *self, smallIntt* retType UNUSED) {
  27121 
  27122   return(self->f->dequeueSmallInt(self));
  27123 }
  27124 
  27125 smallJsont*       dequeueSmallJsonSmallJsonG     (smallJsont *self, smallJsont* retType UNUSED) {
  27126 
  27127   return(self->f->dequeueSmallJson(self));
  27128 }
  27129 
  27130 smallStringt*    dequeueSmallStringSmallJsonG   (smallJsont *self, smallStringt* retType UNUSED) {
  27131 
  27132   return(self->f->dequeueSmallString(self));
  27133 }
  27134 
  27135 void*            dequeueVoidSmallJsonG          (smallJsont *self, void* retType UNUSED) {
  27136 
  27137   return(self->f->dequeueVoid(self));
  27138 }
  27139 
  27140 smallContainert* dequeueSmallContainerSmallJsonG(smallJsont *self, smallContainert* retType UNUSED) {
  27141 
  27142   return(self->f->dequeueSmallContainer(self));
  27143 }
  27144 
  27145 smallJsont* reverseSmallJsonG       (smallJsont *self) {
  27146 
  27147   return(self->f->reverse(self));
  27148 }
  27149 
  27150 smallJsont*  mergeDictSmallJsonG       (smallJsont *self, smallDictt *smallDict) {
  27151 
  27152   return(self->f->mergeDict(self,smallDict));
  27153 }
  27154 
  27155 smallJsont*  mergeDictNSmashSmallJsonG (smallJsont *self, smallDictt *smallDict) {
  27156 
  27157   return(self->f->mergeDictNSmash(self,smallDict));
  27158 }
  27159 
  27160 smallJsont*  mergeSmallJsonG       (smallJsont *self, smallJsont *smallJson) {
  27161 
  27162   return(self->f->merge(self,smallJson));
  27163 }
  27164 
  27165 smallJsont*  mergeNSmashSmallJsonG (smallJsont *self, smallJsont *smallJson) {
  27166 
  27167   return(self->f->mergeNSmash(self,smallJson));
  27168 }
  27169 
  27170 smallJsont* appendSmallJsonG        (smallJsont *self, smallArrayt *array) {
  27171 
  27172   return(self->f->append(self, array));
  27173 }
  27174 
  27175 smallJsont* appendNSmashSmallJsonG  (smallJsont *self, smallArrayt *array) {
  27176 
  27177   return(self->f->appendNSmash(self,array));
  27178 }
  27179 
  27180 // not used, included in mergeSmallJsonG
  27181 /* smallJsont* appendSmallJsonSmallJsonG(smallJsont *self, smallJsont *array) */
  27182 /*  */
  27183 /*   return self->f->appendSmallJson(self, array) */
  27184 /*  */
  27185 /* smallJsont* appendSmallJsonNSmashSmallJsonG(smallJsont *self, smallJsont *array) */
  27186 /*  */
  27187 /*   return self->f->appendSmallJsonNSmash(self,array) */
  27188 
  27189 smallJsont* appendArraySmallJsonG        (smallJsont *self, char **array) {
  27190 
  27191   return(self->f->appendArray(self, array));
  27192 }
  27193 
  27194 smallJsont* appendNSmashArraySmallJsonG  (smallJsont *self, char **array) {
  27195 
  27196   return(self->f->appendNSmashArray(self,array));
  27197 }
  27198 
  27199 smallJsont* appendCArraySmallJsonG        (smallJsont *self, const char **array) {
  27200 
  27201   return(self->f->appendCArray(self, array));
  27202 }
  27203 
  27204 smallJsont* shiftSmallJsonG        (smallJsont *self, smallArrayt *array) {
  27205 
  27206   return(self->f->shift(self, array)); {
  27207   // cg c bug if
  27208 }
  27209   }
  27210 
  27211 smallJsont* shiftNSmashSmallJsonG  (smallJsont *self, smallArrayt *array) {
  27212 
  27213   return(self->f->shiftNSmash(self,array)); {
  27214   // cg c bug if
  27215 }
  27216   }
  27217 
  27218 smallJsont* shiftSmallJsonSmallJsonG(smallJsont *self, smallJsont *array) {
  27219 
  27220   return(self->f->shiftSmallJson(self, array)); {
  27221   // cg c bug if
  27222 }
  27223   }
  27224 
  27225 smallJsont* shiftNSmashSmallJsonSmallJsonG(smallJsont *self, smallJsont *array) {
  27226 
  27227   return(self->f->shiftNSmashSmallJson(self,array)); {
  27228   // cg c bug if
  27229 }
  27230   }
  27231 
  27232 smallJsont* addSmallJsonG  (smallJsont *self, smallArrayt *array) {
  27233 
  27234   return(self->f->add(self, array));
  27235 }
  27236 
  27237 smallJsont* addJsonSmallJsonG  (smallJsont *self, smallJsont *array) {
  27238 
  27239   return(self->f->addJson(self, array));
  27240 }
  27241 
  27242 smallJsont* sliceSmallJsonG(smallJsont *self, int64_t start, int64_t end) {
  27243 
  27244   return(self->f->slice(self, start, end));
  27245 }
  27246 
  27247 smallJsont* cropSmallJsonG                          (smallJsont *self, int64_t start, int64_t end) {
  27248 
  27249   return(self->f->crop(self, start, end));
  27250 }
  27251 
  27252 char* cropSSmallJsonG                               (smallJsont *self, int64_t start, int64_t end) {
  27253 
  27254   return(self->f->cropS(self, start, end));
  27255 }
  27256 
  27257 smallStringt* cropSmallStringSmallJsonG             (smallJsont *self, int64_t start, int64_t end) {
  27258 
  27259   return(self->f->cropSmallString(self, start, end));
  27260 }
  27261 
  27262 baset* cropElemAtSmallJsonG                         (smallJsont *self, int64_t index) {
  27263 
  27264   return(self->f->cropElemAt(self, index));
  27265 }
  27266 
  27267 undefinedt* cropElemAtUndefinedSmallJsonG           (smallJsont *self, int64_t index) {
  27268 
  27269   return(self->f->cropElemAtUndefined(self, index));
  27270 }
  27271 
  27272 bool cropElemAtBoolSmallJsonG                       (smallJsont *self, int64_t index) {
  27273 
  27274   return(self->f->cropElemAtBool(self, index));
  27275 }
  27276 
  27277 double cropElemAtDoubleSmallJsonG                   (smallJsont *self, int64_t index) {
  27278 
  27279   return(self->f->cropElemAtDouble(self, index));
  27280 }
  27281 
  27282 int64_t cropElemAtIntSmallJsonG                     (smallJsont *self, int64_t index) {
  27283 
  27284   return(self->f->cropElemAtInt(self, index));
  27285 }
  27286 
  27287 int32_t cropElemAtInt32SmallJsonG                   (smallJsont *self, int64_t index) {
  27288 
  27289   return(self->f->cropElemAtInt32(self, index));
  27290 }
  27291 
  27292 uint64_t cropElemAtUintSmallJsonG                   (smallJsont *self, int64_t index) {
  27293 
  27294   return(self->f->cropElemAtUint(self, index));
  27295 }
  27296 
  27297 uint32_t cropElemAtUint32SmallJsonG                 (smallJsont *self, int64_t index) {
  27298 
  27299   return(self->f->cropElemAtUint32(self, index));
  27300 }
  27301 
  27302 char* cropElemAtSSmallJsonG                         (smallJsont *self, int64_t index) {
  27303 
  27304   return(self->f->cropElemAtS(self, index));
  27305 }
  27306 
  27307 char cropElemAtCharSmallJsonG                       (smallJsont *self, int64_t index) {
  27308 
  27309   return(self->f->cropElemAtChar(self, index));
  27310 }
  27311 
  27312 smallDictt* cropElemAtDictSmallJsonG                (smallJsont *self, int64_t index) {
  27313 
  27314   return(self->f->cropElemAtDict(self, index));
  27315 }
  27316 
  27317 smallArrayt* cropElemAtArraySmallJsonG              (smallJsont *self, int64_t index) {
  27318 
  27319   return(self->f->cropElemAtArray(self, index));
  27320 }
  27321 
  27322 smallBoolt* cropElemAtSmallBoolSmallJsonG           (smallJsont *self, int64_t index) {
  27323 
  27324   return(self->f->cropElemAtSmallBool(self, index));
  27325 }
  27326 
  27327 smallBytest* cropElemAtSmallBytesSmallJsonG         (smallJsont *self, int64_t index) {
  27328 
  27329   return(self->f->cropElemAtSmallBytes(self, index));
  27330 }
  27331 
  27332 smallDoublet* cropElemAtSmallDoubleSmallJsonG       (smallJsont *self, int64_t index) {
  27333 
  27334   return(self->f->cropElemAtSmallDouble(self, index));
  27335 }
  27336 
  27337 smallIntt* cropElemAtSmallIntSmallJsonG             (smallJsont *self, int64_t index) {
  27338 
  27339   return(self->f->cropElemAtSmallInt(self, index));
  27340 }
  27341 
  27342 smallJsont* cropElemAtSmallJsonSmallJsonG           (smallJsont *self, int64_t index) {
  27343 
  27344   return(self->f->cropElemAtSmallJson(self, index));
  27345 }
  27346 
  27347 smallStringt* cropElemAtSmallStringSmallJsonG       (smallJsont *self, int64_t index) {
  27348 
  27349   return(self->f->cropElemAtSmallString(self, index));
  27350 }
  27351 
  27352 void* cropElemAtVoidSmallJsonG                      (smallJsont *self, int64_t index) {
  27353 
  27354   return(self->f->cropElemAtVoid(self, index));
  27355 }
  27356 
  27357 smallContainert* cropElemAtSmallContainerSmallJsonG (smallJsont *self, int64_t index) {
  27358 
  27359   return(self->f->cropElemAtSmallContainer(self, index));
  27360 }
  27361 
  27362 baset* cropElemKeySmallJsonG                        (smallJsont *self, const char* key) {
  27363 
  27364   return(self->f->cropElemKey(self, key));
  27365 }
  27366 
  27367 undefinedt* cropElemKeyUndefinedSmallJsonG          (smallJsont *self, const char* key) {
  27368 
  27369   return(self->f->cropElemKeyUndefined(self, key));
  27370 }
  27371 
  27372 bool cropElemKeyBoolSmallJsonG                      (smallJsont *self, const char* key) {
  27373 
  27374   return(self->f->cropElemKeyBool(self, key));
  27375 }
  27376 
  27377 double cropElemKeyDoubleSmallJsonG                  (smallJsont *self, const char* key) {
  27378 
  27379   return(self->f->cropElemKeyDouble(self, key));
  27380 }
  27381 
  27382 int64_t cropElemKeyIntSmallJsonG                    (smallJsont *self, const char* key) {
  27383 
  27384   return(self->f->cropElemKeyInt(self, key));
  27385 }
  27386 
  27387 int32_t cropElemKeyInt32SmallJsonG                  (smallJsont *self, const char* key) {
  27388 
  27389   return(self->f->cropElemKeyInt32(self, key));
  27390 }
  27391 
  27392 uint64_t cropElemKeyUintSmallJsonG                  (smallJsont *self, const char* key) {
  27393 
  27394   return(self->f->cropElemKeyUint(self, key));
  27395 }
  27396 
  27397 uint32_t cropElemKeyUint32SmallJsonG                (smallJsont *self, const char* key) {
  27398 
  27399   return(self->f->cropElemKeyUint32(self, key));
  27400 }
  27401 
  27402 char* cropElemKeySSmallJsonG                        (smallJsont *self, const char* key) {
  27403 
  27404   return(self->f->cropElemKeyS(self, key));
  27405 }
  27406 
  27407 smallDictt* cropElemKeyDictSmallJsonG               (smallJsont *self, const char* key) {
  27408 
  27409   return(self->f->cropElemKeyDict(self, key));
  27410 }
  27411 
  27412 smallArrayt* cropElemKeyArraySmallJsonG             (smallJsont *self, const char* key) {
  27413 
  27414   return(self->f->cropElemKeyArray(self, key));
  27415 }
  27416 
  27417 smallBoolt* cropElemKeySmallBoolSmallJsonG          (smallJsont *self, const char* key) {
  27418 
  27419   return(self->f->cropElemKeySmallBool(self, key));
  27420 }
  27421 
  27422 smallBytest* cropElemKeySmallBytesSmallJsonG        (smallJsont *self, const char* key) {
  27423 
  27424   return(self->f->cropElemKeySmallBytes(self, key));
  27425 }
  27426 
  27427 smallDoublet* cropElemKeySmallDoubleSmallJsonG      (smallJsont *self, const char* key) {
  27428 
  27429   return(self->f->cropElemKeySmallDouble(self, key));
  27430 }
  27431 
  27432 smallIntt* cropElemKeySmallIntSmallJsonG            (smallJsont *self, const char* key) {
  27433 
  27434   return(self->f->cropElemKeySmallInt(self, key));
  27435 }
  27436 
  27437 smallJsont* cropElemKeySmallJsonSmallJsonG          (smallJsont *self, const char* key) {
  27438 
  27439   return(self->f->cropElemKeySmallJson(self, key));
  27440 }
  27441 
  27442 smallStringt* cropElemKeySmallStringSmallJsonG      (smallJsont *self, const char* key) {
  27443 
  27444   return(self->f->cropElemKeySmallString(self, key));
  27445 }
  27446 
  27447 void* cropElemKeyVoidSmallJsonG                     (smallJsont *self, const char* key) {
  27448 
  27449   return(self->f->cropElemKeyVoid(self, key));
  27450 }
  27451 
  27452 smallContainert* cropElemKeySmallContainerSmallJsonG(smallJsont *self, const char* key) {
  27453 
  27454   return(self->f->cropElemKeySmallContainer(self, key));
  27455 }
  27456 
  27457 smallJsont* copySmallJsonG (smallJsont *self, int64_t start, int64_t end) {
  27458 
  27459   return(self->f->copy(self, start, end));
  27460 }
  27461 
  27462 smallJsont*          insertSmallJsonG(smallJsont *self, int64_t index, smallArrayt *toInsert) {
  27463 
  27464   return(self->f->insert(self, index, toInsert));
  27465 }
  27466 
  27467 smallJsont*          insertNSmashSmallJsonG(smallJsont *self, int64_t index, smallArrayt *toInsert) {
  27468 
  27469   return(self->f->insertNSmash(self, index, toInsert));
  27470 }
  27471 
  27472 smallJsont*          insertSmallJsonSmallJsonG(smallJsont *self, int64_t index, smallJsont *toInsert) {
  27473 
  27474   return(self->f->insertSmallJson(self, index, toInsert));
  27475 }
  27476 
  27477 smallJsont*          insertNSmashSmallJsonSmallJsonG(smallJsont *self, int64_t index, smallJsont *toInsert) {
  27478 
  27479   return(self->f->insertNSmashSmallJson(self, index, toInsert));
  27480 }
  27481 
  27482 smallJsont*    insertStringSmallJsonG     (smallJsont *self, int64_t index, smallStringt *toInsert) {
  27483 
  27484   return(self->f->insertString(self, index, toInsert));
  27485 }
  27486 
  27487 smallJsont*    insertSSmallJsonG    (smallJsont *self, int64_t index, const char *toInsert) {
  27488 
  27489   return(self->f->insertS(self, index, toInsert));
  27490 }
  27491 
  27492 smallJsont*    insertNFreeStringSmallJsonG(smallJsont *self, int64_t index, smallStringt *toInsert) {
  27493 
  27494   return(self->f->insertNFreeString(self, index, toInsert));
  27495 }
  27496 
  27497 smallJsont*    insertNFreeSSmallJsonG(smallJsont *self, int64_t index, char *toInsert) {
  27498 
  27499   return(self->f->insertSNFree(self, index, toInsert));
  27500 }
  27501 
  27502 
  27503 smallJsont* injectSmallJsonG         (smallJsont *self, int64_t index, baset *value) {
  27504 
  27505   return(self->f->inject(self, index, value));
  27506 }
  27507 
  27508 smallJsont* injectUndefinedSmallJsonG(smallJsont *self, int64_t index, void *value UNUSED) {
  27509 
  27510   return(self->f->injectUndefined(self,index));
  27511 }
  27512 
  27513 smallJsont* injectBoolSmallJsonG     (smallJsont *self, int64_t index, bool value) {
  27514 
  27515   return(self->f->injectBool(self,index,value));
  27516 }
  27517 
  27518 smallJsont* injectDoubleSmallJsonG   (smallJsont *self, int64_t index, double value) {
  27519 
  27520   return(self->f->injectDouble(self,index,value));
  27521 }
  27522 
  27523 smallJsont* injectIntSmallJsonG      (smallJsont *self, int64_t index, int64_t value) {
  27524 
  27525   return(self->f->injectInt(self,index,value));
  27526 }
  27527 
  27528 smallJsont* injectSSmallJsonG        (smallJsont *self, int64_t index, const char *string) {
  27529 
  27530   return(self->f->injectS(self,index,string));
  27531 }
  27532 
  27533 smallJsont* injectCharSmallJsonG(smallJsont *self, int64_t index, char c) {
  27534 
  27535   return(self->f->injectChar(self,index,c));
  27536 }
  27537 
  27538 smallJsont* injectDictSmallJsonG     (smallJsont *self, int64_t index, smallDictt *dict) {
  27539 
  27540   return(self->f->injectDict(self,index,dict));
  27541 }
  27542 
  27543 smallJsont* injectArraySmallJsonG    (smallJsont *self, int64_t index, smallArrayt *array) {
  27544 
  27545   return(self->f->injectArray(self,index,array));
  27546 }
  27547 
  27548 smallJsont* injectArraycSmallJsonG   (smallJsont *self, int64_t index, char **array) {
  27549 
  27550   return(self->f->injectArrayc(self,index,array));
  27551 }
  27552 
  27553 smallJsont* injectCArraycSmallJsonG   (smallJsont *self, int64_t index, const char **array) {
  27554 
  27555   return(self->f->injectCArrayc(self,index,array));
  27556 }
  27557 
  27558 smallJsont* injectVoidSmallJsonG     (smallJsont *self, int64_t index, void *value) {
  27559 
  27560   if (value) {
  27561     smallContainert *c = allocSmallContainer(value);
  27562     if (!c) {
  27563       return(NULL);
  27564     }
  27565     self->f->injectNFreeSmallContainer(self, index, c);
  27566     return(self);
  27567   }
  27568   self->f->injectUndefined(self,index);
  27569   return(self);
  27570 }
  27571 
  27572 smallJsont* injectSmallBoolSmallJsonG     (smallJsont *self, int64_t index, smallBoolt *value) {
  27573 
  27574   return(self->f->injectSmallBool(self,index,value));
  27575 }
  27576 
  27577 smallJsont* injectSmallBytesSmallJsonG    (smallJsont *self, int64_t index, smallBytest *value) {
  27578 
  27579   return(self->f->injectSmallBytes(self,index,value));
  27580 }
  27581 
  27582 smallJsont* injectSmallDoubleSmallJsonG   (smallJsont *self, int64_t index, smallDoublet *value) {
  27583 
  27584   return(self->f->injectSmallDouble(self,index,value));
  27585 }
  27586 
  27587 smallJsont* injectSmallIntSmallJsonG      (smallJsont *self, int64_t index, smallIntt *value) {
  27588 
  27589   return(self->f->injectSmallInt(self,index,value));
  27590 }
  27591 
  27592 smallJsont* injectSmallJsonSmallJsonG     (smallJsont *self, int64_t index, smallJsont *value) {
  27593 
  27594   return(self->f->injectSmallJson(self,index,value));
  27595 }
  27596 
  27597 smallJsont* injectSmallStringSmallJsonG   (smallJsont *self, int64_t index, smallStringt *string) {
  27598 
  27599   return(self->f->injectSmallString(self,index,string));
  27600 }
  27601 
  27602 smallJsont* injectSmallContainerSmallJsonG(smallJsont *self, int64_t index, smallContainert *container) {
  27603 
  27604   return(self->f->injectSmallContainer(self,index,container));
  27605 }
  27606 
  27607 
  27608 smallJsont* injectNFreeSmallJsonG    (smallJsont *self, int64_t index, baset *value) {
  27609 
  27610   return(self->f->injectNFree(self,index,value));
  27611 }
  27612 
  27613 smallJsont* injectNFreeUndefinedSmallJsonG(smallJsont *self, int64_t index, void *value) {
  27614 
  27615   return(self->f->injectNFreeUndefined(self,index,value));
  27616 }
  27617 
  27618 smallJsont* injectNFreeSSmallJsonG        (smallJsont *self, int64_t index, char *string) {
  27619 
  27620   return(self->f->injectNFreeS(self,index,string));
  27621 }
  27622 
  27623 smallJsont* injectNFreeDictSmallJsonG     (smallJsont *self, int64_t index, smallDictt *dict) {
  27624 
  27625   return(self->f->injectNFreeDict(self,index,dict));
  27626 }
  27627 
  27628 smallJsont* injectNFreeArraySmallJsonG    (smallJsont *self, int64_t index, smallArrayt *array) {
  27629 
  27630   return(self->f->injectNFreeArray(self,index,array));
  27631 }
  27632 
  27633 smallJsont* injectNFreeArraycSmallJsonG   (smallJsont *self, int64_t index, char **array) {
  27634 
  27635   return(self->f->injectNFreeArrayc(self,index,array));
  27636 }
  27637 
  27638 smallJsont* injectNFreeSmallBoolSmallJsonG     (smallJsont *self, int64_t index, smallBoolt *value) {
  27639 
  27640   return(self->f->injectNFreeSmallBool(self,index,value));
  27641 }
  27642 
  27643 smallJsont* injectNFreeSmallBytesSmallJsonG    (smallJsont *self, int64_t index, smallBytest *value) {
  27644 
  27645   return(self->f->injectNFreeSmallBytes(self,index,value));
  27646 }
  27647 
  27648 smallJsont* injectNFreeSmallDoubleSmallJsonG   (smallJsont *self, int64_t index, smallDoublet *value) {
  27649 
  27650   return(self->f->injectNFreeSmallDouble(self,index,value));
  27651 }
  27652 
  27653 smallJsont* injectNFreeSmallIntSmallJsonG      (smallJsont *self, int64_t index, smallIntt *value) {
  27654 
  27655   return(self->f->injectNFreeSmallInt(self,index,value));
  27656 }
  27657 
  27658 smallJsont* injectNFreeSmallJsonSmallJsonG     (smallJsont *self, int64_t index, smallJsont *value) {
  27659 
  27660   return(self->f->injectNFreeSmallJson(self,index,value));
  27661 }
  27662 
  27663 smallJsont* injectNFreeSmallStringSmallJsonG   (smallJsont *self, int64_t index, smallStringt *string) {
  27664 
  27665   return(self->f->injectNFreeSmallString(self,index,string));
  27666 }
  27667 
  27668 smallJsont* injectNFreeSmallContainerSmallJsonG(smallJsont *self, int64_t index, smallContainert *container) {
  27669 
  27670   return(self->f->injectNFreeSmallContainer(self,index,container));
  27671 }
  27672 
  27673 smallJsont* uniqSmallJsonG(smallJsont *self, char c) {
  27674 
  27675   if (self->topIsA == TOP_IS_STRING) {
  27676     return(self->f->uniqChar(self, c));
  27677   }
  27678   else {
  27679     return(self->f->uniq(self));
  27680 }
  27681   }
  27682 
  27683 smallJsont* sortSmallJsonG          (smallJsont *self) {
  27684 
  27685   return(self->f->sort(self));
  27686 }
  27687 
  27688 smallJsont* sortFSmallJsonG(smallJsont *self, shCmpt compareFunction) {
  27689 
  27690   return(self->f->sortF(self,compareFunction));
  27691 }
  27692 
  27693 smallJsont* icSortSmallJsonG          (smallJsont *self) {
  27694 
  27695   return(self->f->icSort(self));
  27696 }
  27697 
  27698 smallJsont* icUniqSmallJsonG(smallJsont *self, char c) {
  27699 
  27700   if (self->topIsA == TOP_IS_STRING) {
  27701     return(self->f->icUniqChar(self, c));
  27702   }
  27703   else {
  27704     return(self->f->icUniq(self));
  27705 }
  27706   }
  27707 
  27708 bool hasSmallJsonG         (smallJsont *self, baset *value) {
  27709 
  27710   return(self->f->has(self, value));
  27711 }
  27712 
  27713 bool hasUndefinedSmallJsonG(smallJsont *self, undefinedt *value) {
  27714 
  27715   return(self->f->hasUndefined(self, value));
  27716 }
  27717 
  27718 bool hasBoolSmallJsonG     (smallJsont *self, bool value) {
  27719 
  27720   return(self->f->hasBool(self,value));
  27721 }
  27722 
  27723 bool hasDoubleSmallJsonG   (smallJsont *self, double value) {
  27724 
  27725   return(self->f->hasDouble(self,value));
  27726 }
  27727 
  27728 bool hasIntSmallJsonG      (smallJsont *self, int64_t value) {
  27729 
  27730   return(self->f->hasInt(self,value));
  27731 }
  27732 
  27733 bool hasSSmallJsonG        (smallJsont *self, const char *string) {
  27734 
  27735   return(self->f->hasS(self,string));
  27736 }
  27737 
  27738 bool hasCharSmallJsonG(smallJsont *self, char c) {
  27739 
  27740   return(self->f->hasChar(self,c));
  27741 }
  27742 
  27743 bool hasDictSmallJsonG     (smallJsont *self, smallDictt *dict) {
  27744 
  27745   return(self->f->hasDict(self,dict));
  27746 }
  27747 
  27748 bool hasArraySmallJsonG    (smallJsont *self, smallArrayt *array) {
  27749 
  27750   return(self->f->hasArray(self,array));
  27751 }
  27752 
  27753 bool hasArraycSmallJsonG   (smallJsont *self, char **array) {
  27754 
  27755   return(self->f->hasArrayc(self,array));
  27756 }
  27757 
  27758 bool hasCArraycSmallJsonG  (smallJsont *self, const char **array) {
  27759 
  27760   return(self->f->hasCArrayc(self,array));
  27761 }
  27762 
  27763 bool hasSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value) {
  27764 
  27765   return(self->f->hasSmallBool(self,value));
  27766 }
  27767 
  27768 bool hasSmallBytesSmallJsonG    (smallJsont *self, smallBytest *value) {
  27769 
  27770   return(self->f->hasSmallBytes(self,value));
  27771 }
  27772 
  27773 bool hasSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value) {
  27774 
  27775   return(self->f->hasSmallDouble(self,value));
  27776 }
  27777 
  27778 bool hasSmallIntSmallJsonG      (smallJsont *self, smallIntt *value) {
  27779 
  27780   return(self->f->hasSmallInt(self,value));
  27781 }
  27782 
  27783 bool hasSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value) {
  27784 
  27785   return(self->f->hasSmallJson(self,value));
  27786 }
  27787 
  27788 bool hasSmallStringSmallJsonG   (smallJsont *self, smallStringt *string) {
  27789 
  27790   return(self->f->hasSmallString(self,string));
  27791 }
  27792 
  27793 bool hasSmallContainerSmallJsonG(smallJsont *self, smallContainert *container) {
  27794 
  27795   return(self->f->hasSmallContainer(self,container));
  27796 }
  27797 
  27798 smallJsont* findSmallJsonG(smallJsont *self, const char *needle) {
  27799 
  27800   return(self->f->find(self, needle));
  27801 }
  27802 
  27803 smallJsont* findCharSmallJsonG(smallJsont *self, char c) {
  27804 
  27805   return(self->f->findChar(self,c));
  27806 }
  27807 
  27808 smallJsont* findSmallStringSmallJsonG(smallJsont *self, smallStringt *needle) {
  27809 
  27810   return(self->f->findSmallString(self,needle));
  27811 }
  27812 
  27813 smallJsont* findJsonSmallJsonG(smallJsont *self, smallJsont *needle) {
  27814 
  27815   return(self->f->findJson(self,needle));
  27816 }
  27817 
  27818 ssize_t indexOfSmallJsonG         (smallJsont *self, baset *value) {
  27819 
  27820   return(self->f->indexOf(self, value));
  27821 }
  27822 
  27823 ssize_t indexOfUndefinedSmallJsonG(smallJsont *self, undefinedt *value) {
  27824 
  27825   return(self->f->indexOfUndefined(self, value));
  27826 }
  27827 
  27828 ssize_t indexOfBoolSmallJsonG     (smallJsont *self, bool value) {
  27829 
  27830   return(self->f->indexOfBool(self,value));
  27831 }
  27832 
  27833 ssize_t indexOfDoubleSmallJsonG   (smallJsont *self, double value) {
  27834 
  27835   return(self->f->indexOfDouble(self,value));
  27836 }
  27837 
  27838 ssize_t indexOfIntSmallJsonG      (smallJsont *self, int64_t value) {
  27839 
  27840   return(self->f->indexOfInt(self,value));
  27841 }
  27842 
  27843 ssize_t indexOfSSmallJsonG        (smallJsont *self, const char *string) {
  27844 
  27845   return(self->f->indexOfS(self,string));
  27846 }
  27847 
  27848 ssize_t indexOfCharSmallJsonG(smallJsont *self, char c) {
  27849 
  27850   return(self->f->indexOfChar(self,c));
  27851 }
  27852 
  27853 ssize_t indexOfDictSmallJsonG     (smallJsont *self, smallDictt *dict) {
  27854 
  27855   return(self->f->indexOfDict(self,dict));
  27856 }
  27857 
  27858 ssize_t indexOfArraySmallJsonG    (smallJsont *self, smallArrayt *array) {
  27859 
  27860   return(self->f->indexOfArray(self,array));
  27861 }
  27862 
  27863 ssize_t indexOfArraycSmallJsonG    (smallJsont *self, char **array) {
  27864 
  27865   return(self->f->indexOfArrayc(self,array));
  27866 }
  27867 
  27868 ssize_t indexOfCArraycSmallJsonG   (smallJsont *self, const char **array) {
  27869 
  27870   return(self->f->indexOfCArrayc(self,array));
  27871 }
  27872 
  27873 ssize_t indexOfSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value) {
  27874 
  27875   return(self->f->indexOfSmallBool(self,value));
  27876 }
  27877 
  27878 ssize_t indexOfSmallBytesSmallJsonG    (smallJsont *self, smallBytest *value) {
  27879 
  27880   return(self->f->indexOfSmallBytes(self,value));
  27881 }
  27882 
  27883 ssize_t indexOfSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value) {
  27884 
  27885   return(self->f->indexOfSmallDouble(self,value));
  27886 }
  27887 
  27888 ssize_t indexOfSmallIntSmallJsonG      (smallJsont *self, smallIntt *value) {
  27889 
  27890   return(self->f->indexOfSmallInt(self,value));
  27891 }
  27892 
  27893 ssize_t indexOfSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value) {
  27894 
  27895   return(self->f->indexOfSmallJson(self,value));
  27896 }
  27897 
  27898 ssize_t indexOfSmallStringSmallJsonG   (smallJsont *self, smallStringt *string) {
  27899 
  27900   return(self->f->indexOfSmallString(self,string));
  27901 }
  27902 
  27903 ssize_t indexOfSmallContainerSmallJsonG(smallJsont *self, smallContainert *container) {
  27904 
  27905   return(self->f->indexOfSmallContainer(self,container));
  27906 }
  27907 
  27908 ssize_t binarySearchSmallJsonG         (smallJsont *self, baset *value) {
  27909 
  27910   return(self->f->binarySearch(self, value));
  27911 }
  27912 
  27913 ssize_t binarySearchUndefinedSmallJsonG(smallJsont *self, undefinedt *value) {
  27914 
  27915   return(self->f->binarySearchUndefined(self, value));
  27916 }
  27917 
  27918 ssize_t binarySearchBoolSmallJsonG     (smallJsont *self, bool value) {
  27919 
  27920   return(self->f->binarySearchBool(self,value));
  27921 }
  27922 
  27923 ssize_t binarySearchDoubleSmallJsonG   (smallJsont *self, double value) {
  27924 
  27925   return(self->f->binarySearchDouble(self,value));
  27926 }
  27927 
  27928 ssize_t binarySearchIntSmallJsonG      (smallJsont *self, int64_t value) {
  27929 
  27930   return(self->f->binarySearchInt(self,value));
  27931 }
  27932 
  27933 ssize_t binarySearchSSmallJsonG        (smallJsont *self, const char *string) {
  27934 
  27935   return(self->f->binarySearchS(self,string));
  27936 }
  27937 
  27938 ssize_t binarySearchCharSmallJsonG(smallJsont *self, char c) {
  27939 
  27940   return(self->f->binarySearchChar(self,c));
  27941 }
  27942 
  27943 ssize_t binarySearchDictSmallJsonG     (smallJsont *self, smallDictt *dict) {
  27944 
  27945   return(self->f->binarySearchDict(self,dict));
  27946 }
  27947 
  27948 ssize_t binarySearchArraySmallJsonG    (smallJsont *self, smallArrayt *array) {
  27949 
  27950   return(self->f->binarySearchArray(self,array));
  27951 }
  27952 
  27953 ssize_t binarySearchArraycSmallJsonG   (smallJsont *self, char **array) {
  27954 
  27955   return(self->f->binarySearchArrayc(self,array));
  27956 }
  27957 
  27958 ssize_t binarySearchCArraycSmallJsonG   (smallJsont *self, const char **array) {
  27959 
  27960   return(self->f->binarySearchCArrayc(self,array));
  27961 }
  27962 
  27963 ssize_t binarySearchSmallBoolSmallJsonG     (smallJsont *self, smallBoolt *value) {
  27964 
  27965   return(self->f->binarySearchSmallBool(self,value));
  27966 }
  27967 
  27968 ssize_t binarySearchSmallBytesSmallJsonG    (smallJsont *self, smallBytest *value) {
  27969 
  27970   return(self->f->binarySearchSmallBytes(self,value));
  27971 }
  27972 
  27973 ssize_t binarySearchSmallDoubleSmallJsonG   (smallJsont *self, smallDoublet *value) {
  27974 
  27975   return(self->f->binarySearchSmallDouble(self,value));
  27976 }
  27977 
  27978 ssize_t binarySearchSmallIntSmallJsonG      (smallJsont *self, smallIntt *value) {
  27979 
  27980   return(self->f->binarySearchSmallInt(self,value));
  27981 }
  27982 
  27983 ssize_t binarySearchSmallJsonSmallJsonG     (smallJsont *self, smallJsont *value) {
  27984 
  27985   return(self->f->binarySearchSmallJson(self,value));
  27986 }
  27987 
  27988 ssize_t binarySearchSmallStringSmallJsonG   (smallJsont *self, smallStringt *string) {
  27989 
  27990   return(self->f->binarySearchSmallString(self,string));
  27991 }
  27992 
  27993 ssize_t binarySearchSmallContainerSmallJsonG(smallJsont *self, smallContainert *container) {
  27994 
  27995   return(self->f->binarySearchSmallContainer(self,container));
  27996 }
  27997 
  27998 bool icHasSmallJsonG         (smallJsont *self, baset *value) {
  27999 
  28000   return(self->f->icHas(self, value));
  28001 }
  28002 
  28003 bool icHasSSmallJsonG        (smallJsont *self, const char *string) {
  28004 
  28005   return(self->f->icHasS(self,string));
  28006 }
  28007 
  28008 bool icHasCharSmallJsonG(smallJsont *self, char c) {
  28009 
  28010   return(self->f->icHasChar(self,c));
  28011 }
  28012 
  28013 bool icHasDictSmallJsonG     (smallJsont *self, smallDictt *dict) {
  28014 
  28015   return(self->f->icHasDict(self,dict));
  28016 }
  28017 
  28018 bool icHasArraySmallJsonG    (smallJsont *self, smallArrayt *array) {
  28019 
  28020   return(self->f->icHasArray(self,array));
  28021 }
  28022 
  28023 bool icHasArraycSmallJsonG   (smallJsont *self, char **array) {
  28024 
  28025   return(self->f->icHasArrayc(self,array));
  28026 }
  28027 
  28028 bool icHasCArraycSmallJsonG  (smallJsont *self, const char **array) {
  28029 
  28030   return(self->f->icHasCArrayc(self,array));
  28031 }
  28032 
  28033 bool icHasSmallStringSmallJsonG   (smallJsont *self, smallStringt *string) {
  28034 
  28035   return(self->f->icHasSmallString(self,string));
  28036 }
  28037 
  28038 smallJsont* icFindSmallJsonG(smallJsont *self, const char *needle) {
  28039 
  28040   return(self->f->icFind(self, needle));
  28041 }
  28042 
  28043 smallJsont* icFindCharSmallJsonG(smallJsont *self, char c) {
  28044 
  28045   return(self->f->icFindChar(self,c));
  28046 }
  28047 
  28048 smallJsont* icFindSmallStringSmallJsonG(smallJsont *self, smallStringt *needle) {
  28049 
  28050   return(self->f->icFindSmallString(self,needle));
  28051 }
  28052 
  28053 smallJsont* icFindJsonSmallJsonG(smallJsont *self, smallJsont *needle) {
  28054 
  28055   return(self->f->icFindJson(self,needle));
  28056 }
  28057 
  28058 ssize_t icIndexOfSmallJsonG         (smallJsont *self, baset *value) {
  28059 
  28060   return(self->f->icIndexOf(self, value));
  28061 }
  28062 
  28063 ssize_t icIndexOfSSmallJsonG        (smallJsont *self, const char *string) {
  28064 
  28065   return(self->f->icIndexOfS(self,string));
  28066 }
  28067 
  28068 ssize_t icIndexOfCharSmallJsonG(smallJsont *self, char c) {
  28069 
  28070   return(self->f->icIndexOfChar(self,c));
  28071 }
  28072 
  28073 ssize_t icIndexOfDictSmallJsonG     (smallJsont *self, smallDictt *dict) {
  28074 
  28075   return(self->f->icIndexOfDict(self,dict));
  28076 }
  28077 
  28078 ssize_t icIndexOfArraySmallJsonG    (smallJsont *self, smallArrayt *array) {
  28079 
  28080   return(self->f->icIndexOfArray(self,array));
  28081 }
  28082 
  28083 ssize_t icIndexOfArraycSmallJsonG   (smallJsont *self, char **array) {
  28084 
  28085   return(self->f->icIndexOfArrayc(self,array));
  28086 }
  28087 
  28088 ssize_t icIndexOfCArraycSmallJsonG  (smallJsont *self, const char **array) {
  28089 
  28090   return(self->f->icIndexOfCArrayc(self,array));
  28091 }
  28092 
  28093 ssize_t icIndexOfSmallStringSmallJsonG   (smallJsont *self, smallStringt *string) {
  28094 
  28095   return(self->f->icIndexOfSmallString(self,string));
  28096 }
  28097 
  28098 ssize_t icBinarySearchSmallJsonG         (smallJsont *self, baset *value) {
  28099 
  28100   return(self->f->icBinarySearch(self, value));
  28101 }
  28102 
  28103 ssize_t icBinarySearchSSmallJsonG        (smallJsont *self, const char *string) {
  28104 
  28105   return(self->f->icBinarySearchS(self,string));
  28106 }
  28107 
  28108 ssize_t icBinarySearchCharSmallJsonG(smallJsont *self, char c) {
  28109 
  28110   return(self->f->icBinarySearchChar(self,c));
  28111 }
  28112 
  28113 ssize_t icBinarySearchDictSmallJsonG     (smallJsont *self, smallDictt *dict) {
  28114 
  28115   return(self->f->icBinarySearchDict(self,dict));
  28116 }
  28117 
  28118 ssize_t icBinarySearchArraySmallJsonG    (smallJsont *self, smallArrayt *array) {
  28119 
  28120   return(self->f->icBinarySearchArray(self,array));
  28121 }
  28122 
  28123 ssize_t icBinarySearchArraycSmallJsonG   (smallJsont *self, char **array) {
  28124 
  28125   return(self->f->icBinarySearchArrayc(self,array));
  28126 }
  28127 
  28128 ssize_t icBinarySearchCArraycSmallJsonG  (smallJsont *self, const char **array) {
  28129 
  28130   return(self->f->icBinarySearchCArrayc(self,array));
  28131 }
  28132 
  28133 ssize_t icBinarySearchSmallStringSmallJsonG   (smallJsont *self, smallStringt *string) {
  28134 
  28135   return(self->f->icBinarySearchSmallString(self,string));
  28136 }
  28137 
  28138 char* keyBySmallJsonG(smallJsont *self, baset *value) {
  28139 
  28140   return(self->f->keyBy(self,value));
  28141 }
  28142 
  28143 char* keyByUndefinedSmallJsonG(smallJsont *self, undefinedt *u) {
  28144 
  28145   return(self->f->keyByUndefined(self,u));
  28146 }
  28147 
  28148 char* keyByBoolSmallJsonG(smallJsont *self, bool value) {
  28149 
  28150   return(self->f->keyByBool(self,value));
  28151 }
  28152 
  28153 char* keyByDoubleSmallJsonG(smallJsont *self, double value) {
  28154 
  28155   return(self->f->keyByDouble(self,value));
  28156 }
  28157 
  28158 char* keyByIntSmallJsonG(smallJsont *self, int64_t value) {
  28159 
  28160   return(self->f->keyByInt(self,value));
  28161 }
  28162 
  28163 char* keyBySSmallJsonG(smallJsont *self, const char *string) {
  28164 
  28165   return(self->f->keyByS(self,string));
  28166 }
  28167 
  28168 char* keyByCharSmallJsonG(smallJsont *self, char c) {
  28169 
  28170   return(self->f->keyByChar(self,c));
  28171 }
  28172 
  28173 char* keyByDictSmallJsonG(smallJsont *self, smallDictt *dict) {
  28174 
  28175   return(self->f->keyByDict(self,dict));
  28176 }
  28177 
  28178 char* keyByArraySmallJsonG(smallJsont *self, smallArrayt *array) {
  28179 
  28180   return(self->f->keyByArray(self,array));
  28181 }
  28182 
  28183 char* keyByArraycSmallJsonG(smallJsont *self, char **array) {
  28184 
  28185   return(self->f->keyByArrayc(self,array));
  28186 }
  28187 
  28188 char* keyByCArraycSmallJsonG(smallJsont *self, const char **array) {
  28189 
  28190   return(self->f->keyByCArrayc(self,array));
  28191 }
  28192 
  28193 char* keyBySmallBoolSmallJsonG(smallJsont *self, smallBoolt *value) {
  28194 
  28195   return(self->f->keyBySmallBool(self,value));
  28196 }
  28197 
  28198 char* keyBySmallBytesSmallJsonG(smallJsont *self, smallBytest *value) {
  28199 
  28200   return(self->f->keyBySmallBytes(self,value));
  28201 }
  28202 
  28203 char* keyBySmallDoubleSmallJsonG(smallJsont *self, smallDoublet *value) {
  28204 
  28205   return(self->f->keyBySmallDouble(self,value));
  28206 }
  28207 
  28208 char* keyBySmallIntSmallJsonG(smallJsont *self, smallIntt *value) {
  28209 
  28210   return(self->f->keyBySmallInt(self,value));
  28211 }
  28212 
  28213 char* keyBySmallJsonSmallJsonG(smallJsont *self, smallJsont *value) {
  28214 
  28215   return(self->f->keyBySmallJson(self,value));
  28216 }
  28217 
  28218 char* keyBySmallStringSmallJsonG(smallJsont *self, smallStringt *string) {
  28219 
  28220   return(self->f->keyBySmallString(self,string));
  28221 }
  28222 
  28223 char* keyBySmallContainerSmallJsonG(smallJsont *self, smallContainert *container) {
  28224 
  28225   return(self->f->keyBySmallContainer(self,container));
  28226 }
  28227 
  28228 char* icKeyBySmallJsonG(smallJsont *self, baset *value) {
  28229 
  28230   return(self->f->icKeyBy(self,value));
  28231 }
  28232 
  28233 char* icKeyBySSmallJsonG(smallJsont *self, const char *string) {
  28234 
  28235   return(self->f->icKeyByS(self,string));
  28236 }
  28237 
  28238 char* icKeyByCharSmallJsonG(smallJsont *self, char c) {
  28239 
  28240   return(self->f->icKeyByChar(self,c));
  28241 }
  28242 
  28243 char* icKeyByDictSmallJsonG(smallJsont *self, smallDictt *dict) {
  28244 
  28245   return(self->f->icKeyByDict(self,dict));
  28246 }
  28247 
  28248 char* icKeyByArraySmallJsonG(smallJsont *self, smallArrayt *array) {
  28249 
  28250   return(self->f->icKeyByArray(self,array));
  28251 }
  28252 
  28253 char* icKeyByArraycSmallJsonG(smallJsont *self, char **array) {
  28254 
  28255   return(self->f->icKeyByArrayc(self,array));
  28256 }
  28257 
  28258 char* icKeyByCArraycSmallJsonG(smallJsont *self, const char **array) {
  28259 
  28260   return(self->f->icKeyByCArrayc(self,array));
  28261 }
  28262 
  28263 char* icKeyBySmallStringSmallJsonG(smallJsont *self, smallStringt *string) {
  28264 
  28265   return(self->f->icKeyBySmallString(self,string));
  28266 }
  28267 
  28268 smallJsont*  replaceSmallJsonG      (smallJsont *self, const char *olds, const char *news, size_t max) {
  28269 
  28270   return(self->f->replace(self, olds, news, max));
  28271 }
  28272 
  28273 smallJsont* replaceCharSSmallJsonG(smallJsont *self, char olds, const char *news, size_t max) {
  28274 
  28275   return(self->f->replaceCharS(self,olds,news,max));
  28276 }
  28277 
  28278 smallJsont* replaceSCharSmallJsonG(smallJsont *self, const char *olds, char news, size_t max) {
  28279 
  28280   return(self->f->replaceSChar(self,olds,news,max));
  28281 }
  28282 
  28283 smallJsont* replaceCharCharSmallJsonG(smallJsont *self, char olds, char news, size_t max) {
  28284 
  28285   return(self->f->replaceCharChar(self,olds,news,max));
  28286 }
  28287 
  28288 smallJsont* replaceSmallStringSmallStringSmallJsonG(smallJsont *self, smallStringt *olds, smallStringt *news, size_t max) {
  28289 
  28290   return(self->f->replaceSmallStringSmallString(self,olds,news,max));
  28291 }
  28292 
  28293 smallJsont* replaceSmallStringSSmallJsonG(smallJsont *self, smallStringt *olds, const char *news, size_t max) {
  28294 
  28295   return(self->f->replaceSmallStringS(self,olds,news,max));
  28296 }
  28297 
  28298 smallJsont* replaceSmallStringCharSmallJsonG(smallJsont *self, smallStringt *olds, char news, size_t max) {
  28299 
  28300   return(self->f->replaceSmallStringChar(self,olds,news,max));
  28301 }
  28302 
  28303 smallJsont* replaceSSmallStringSmallJsonG(smallJsont *self, const char *olds, smallStringt *news, size_t max) {
  28304 
  28305   return(self->f->replaceSSmallString(self,olds,news,max));
  28306 }
  28307 
  28308 
  28309 smallJsont* replaceCharSmallStringSmallJsonG(smallJsont *self, char olds, smallStringt *news, size_t max) {
  28310 
  28311   return(self->f->replaceCharSmallString(self,olds,news,max));
  28312 }
  28313 
  28314 smallJsont* replaceJsonJsonSmallJsonG       (smallJsont *self, smallJsont *olds, smallJsont *news, size_t max) {
  28315 
  28316   return(self->f->replaceJsonJson(self,olds,news,max));
  28317 }
  28318 
  28319 smallJsont* replaceJsonSmallStringSmallJsonG(smallJsont *self, smallJsont *olds, smallStringt *news, size_t max) {
  28320 
  28321   return(self->f->replaceJsonSmallString(self,olds,news,max));
  28322 }
  28323 
  28324 smallJsont* replaceJsonSSmallJsonG          (smallJsont *self, smallJsont *olds, const char *news, size_t max) {
  28325 
  28326   return(self->f->replaceJsonS(self,olds,news,max));
  28327 }
  28328 
  28329 smallJsont* replaceJsonCharSmallJsonG       (smallJsont *self, smallJsont *olds, char news, size_t max) {
  28330 
  28331   return(self->f->replaceJsonChar(self,olds,news,max));
  28332 }
  28333 
  28334 smallJsont* replaceSmallStringJsonSmallJsonG(smallJsont *self, smallStringt *olds, smallJsont *news, size_t max) {
  28335 
  28336   return(self->f->replaceSmallStringJson(self,olds,news,max));
  28337 }
  28338 
  28339 smallJsont* replaceSJsonSmallJsonG          (smallJsont *self, const char *olds, smallJsont *news, size_t max) {
  28340 
  28341   return(self->f->replaceSJson(self,olds,news,max));
  28342 }
  28343 
  28344 smallJsont* replaceCharJsonSmallJsonG       (smallJsont *self, char olds, smallJsont *news, size_t max) {
  28345 
  28346   return(self->f->replaceCharJson(self,olds,news,max));
  28347 }
  28348 
  28349 
  28350 smallJsont*  icReplaceSmallJsonG      (smallJsont *self, const char *olds, const char *news, size_t max) {
  28351 
  28352   return(self->f->icReplace(self, olds, news, max));
  28353 }
  28354 
  28355 smallJsont* icReplaceCharSSmallJsonG(smallJsont *self, char olds, const char *news, size_t max) {
  28356 
  28357   return(self->f->icReplaceCharS(self,olds,news,max));
  28358 }
  28359 
  28360 smallJsont* icReplaceSCharSmallJsonG(smallJsont *self, const char *olds, char news, size_t max) {
  28361 
  28362   return(self->f->icReplaceSChar(self,olds,news,max));
  28363 }
  28364 
  28365 smallJsont* icReplaceCharCharSmallJsonG(smallJsont *self, char olds, char news, size_t max) {
  28366 
  28367   return(self->f->icReplaceCharChar(self,olds,news,max));
  28368 }
  28369 
  28370 smallJsont* icReplaceSmallStringSmallStringSmallJsonG(smallJsont *self, smallStringt *olds, smallStringt *news, size_t max) {
  28371 
  28372   return(self->f->icReplaceSmallStringSmallString(self,olds,news,max));
  28373 }
  28374 
  28375 smallJsont* icReplaceSmallStringSSmallJsonG(smallJsont *self, smallStringt *olds, const char *news, size_t max) {
  28376 
  28377   return(self->f->icReplaceSmallStringS(self,olds,news,max));
  28378 }
  28379 
  28380 smallJsont* icReplaceSmallStringCharSmallJsonG(smallJsont *self, smallStringt *olds, char news, size_t max) {
  28381 
  28382   return(self->f->icReplaceSmallStringChar(self,olds,news,max));
  28383 }
  28384 
  28385 smallJsont* icReplaceSSmallStringSmallJsonG(smallJsont *self, const char *olds, smallStringt *news, size_t max) {
  28386 
  28387   return(self->f->icReplaceSSmallString(self,olds,news,max));
  28388 }
  28389 
  28390 smallJsont* icReplaceCharSmallStringSmallJsonG(smallJsont *self, char olds, smallStringt *news, size_t max) {
  28391 
  28392   return(self->f->icReplaceCharSmallString(self,olds,news,max));
  28393 }
  28394 
  28395 smallJsont* icReplaceJsonJsonSmallJsonG       (smallJsont *self, smallJsont *olds, smallJsont *news, size_t max) {
  28396 
  28397   return(self->f->icReplaceJsonJson(self,olds,news,max));
  28398 }
  28399 
  28400 smallJsont* icReplaceJsonSmallStringSmallJsonG(smallJsont *self, smallJsont *olds, smallStringt *news, size_t max) {
  28401 
  28402   return(self->f->icReplaceJsonSmallString(self,olds,news,max));
  28403 }
  28404 
  28405 smallJsont* icReplaceJsonSSmallJsonG          (smallJsont *self, smallJsont *olds, const char *news, size_t max) {
  28406 
  28407   return(self->f->icReplaceJsonS(self,olds,news,max));
  28408 }
  28409 
  28410 smallJsont* icReplaceJsonCharSmallJsonG       (smallJsont *self, smallJsont *olds, char news, size_t max) {
  28411 
  28412   return(self->f->icReplaceJsonChar(self,olds,news,max));
  28413 }
  28414 
  28415 smallJsont* icReplaceSmallStringJsonSmallJsonG(smallJsont *self, smallStringt *olds, smallJsont *news, size_t max) {
  28416 
  28417   return(self->f->icReplaceSmallStringJson(self,olds,news,max));
  28418 }
  28419 
  28420 smallJsont* icReplaceSJsonSmallJsonG          (smallJsont *self, const char *olds, smallJsont *news, size_t max) {
  28421 
  28422   return(self->f->icReplaceSJson(self,olds,news,max));
  28423 }
  28424 
  28425 smallJsont* icReplaceCharJsonSmallJsonG       (smallJsont *self, char olds, smallJsont *news, size_t max) {
  28426 
  28427   return(self->f->icReplaceCharJson(self,olds,news,max));
  28428 }
  28429 
  28430 bool equalSmallJsonSmallArrayG(smallJsont *self, smallArrayt *array) {
  28431 
  28432   return(self->f->equalSmallArray(self, array));
  28433 }
  28434 
  28435 bool equalSmallJsonArrayG(smallJsont *self, char ** p2) {
  28436 
  28437   return(self->f->equalArray(self, p2));
  28438 }
  28439 
  28440 bool equalSmallJsonCArrayG(smallJsont *self, const char ** p2) {
  28441 
  28442   return(self->f->equalCArray(self, p2));
  28443 }
  28444 
  28445 bool equalSmallJsonBaseG(smallJsont *self, baset* p2) {
  28446 
  28447   return(self->f->equalBase(self, p2));
  28448 }
  28449 
  28450 bool equalSmallJsonChaG(smallJsont* self, char p2) {
  28451 
  28452   return(self->f->equalCha(self, p2));
  28453 }
  28454 
  28455 bool equalSmallJsonCharG(smallJsont* self, const char * p2) {
  28456 
  28457   return(self->f->equalChar(self, p2));
  28458 }
  28459 
  28460 bool equalSmallJsonBoolG(smallJsont* self, bool p2) {
  28461 
  28462   return(self->f->equalBool(self, p2));
  28463 }
  28464 
  28465 bool equalSmallJsonDoubleG(smallJsont* self, double p2) {
  28466 
  28467   return(self->f->equalDouble(self, p2));
  28468 }
  28469 
  28470 bool equalSmallJsonInt64G(smallJsont* self, int64_t p2) {
  28471 
  28472   return(self->f->equalInt64(self, p2));
  28473 }
  28474 
  28475 bool equalSmallJsonInt32G(smallJsont* self, int32_t p2) {
  28476 
  28477   return(self->f->equalInt32(self, p2));
  28478 }
  28479 
  28480 bool equalSmallJsonUint32G(smallJsont* self, uint32_t p2) {
  28481 
  28482   return(self->f->equalUint32(self, p2));
  28483 }
  28484 
  28485 bool equalSmallJsonUint64G(smallJsont* self, uint64_t p2) {
  28486 
  28487   return(self->f->equalUint64(self, p2));
  28488 }
  28489 
  28490 bool equalSmallJsonSmallBoolG(smallJsont* self, smallBoolt* p2) {
  28491 
  28492   return(self->f->equalSmallBool(self, p2));
  28493 }
  28494 
  28495 bool equalSmallJsonSmallBytesG(smallJsont* self, smallBytest* p2) {
  28496 
  28497   return(self->f->equalSmallBytes(self, p2));
  28498 }
  28499 
  28500 bool equalSmallJsonSmallDoubleG(smallJsont* self, smallDoublet* p2) {
  28501 
  28502   return(self->f->equalSmallDouble(self, p2));
  28503 }
  28504 
  28505 bool equalSmallJsonSmallIntG(smallJsont* self, smallIntt* p2) {
  28506 
  28507   return(self->f->equalSmallInt(self, p2));
  28508 }
  28509 
  28510 bool equalSmallJsonSmallJsonG(smallJsont* self, smallJsont* p2) {
  28511 
  28512   return(self->f->equalSmallJson(self, p2));
  28513 }
  28514 
  28515 bool equalSmallJsonSmallStringG(smallJsont* self, smallStringt* p2) {
  28516 
  28517   return(self->f->equalSmallString(self, p2));
  28518 }
  28519 
  28520 bool equalSmallJsonSmallDictG(smallJsont* self, smallDictt* p2) {
  28521 
  28522   return(self->f->equalSmallDict(self, p2));
  28523 }
  28524 
  28525 bool icEqualSmallJsonSmallArrayG(smallJsont *self, smallArrayt *array) {
  28526 
  28527   return(self->f->icEqualSmallArray(self, array));
  28528 }
  28529 
  28530 bool icEqualSmallJsonArrayG(smallJsont *self, char ** p2) {
  28531 
  28532   return(self->f->icEqualArray(self, p2));
  28533 }
  28534 
  28535 bool icEqualSmallJsonCArrayG(smallJsont *self, const char ** p2) {
  28536 
  28537   return(self->f->icEqualCArray(self, p2));
  28538 }
  28539 
  28540 bool icEqualSmallJsonBaseG(smallJsont *self, baset* p2) {
  28541 
  28542   return(self->f->icEqualBase(self, p2));
  28543 }
  28544 
  28545 bool icEqualSmallJsonSmallDictG(smallJsont* self, smallDictt* p2) {
  28546 
  28547   return(self->f->icEqualSmallDict(self, p2));
  28548 }
  28549 
  28550 bool icEqualSmallJsonSmallJsonG(smallJsont* self, smallJsont* p2) {
  28551 
  28552   return(self->f->icEqualSmallJson(self, p2));
  28553 }
  28554 
  28555 bool icEqualSmallJsonSmallStringG(smallJsont* self, smallStringt* p2) {
  28556 
  28557   return(self->f->icEqualSmallString(self, p2));
  28558 }
  28559 
  28560 bool icEqualCharSmallJsonG(smallJsont *self, char c) {
  28561 
  28562   return(self->f->icEqualChar(self,c));
  28563 }
  28564 
  28565 bool icEqualSSmallJsonG       (smallJsont *self, const char *string) {
  28566 
  28567   return(self->f->icEqualS(self, string));
  28568 }
  28569 
  28570 bool equalISSmallJsonG      (smallJsont *self, const char *string, int64_t index) {
  28571 
  28572   return(self->f->equalIS(self, string, index));
  28573 }
  28574 
  28575 bool equalICharSmallJsonG(smallJsont *self, char c, int64_t index) {
  28576 
  28577   return(self->f->equalIChar(self,c,index));
  28578 }
  28579 
  28580 bool equalIJsonSmallJsonG(smallJsont *self, smallJsont *string, int64_t index) {
  28581 
  28582   return(self->f->equalIJson(self,string,index));
  28583 }
  28584 
  28585 bool equalISmallStringSmallJsonG(smallJsont *self, smallStringt *string, int64_t index) {
  28586 
  28587   return(self->f->equalISmallString(self,string,index));
  28588 }
  28589 
  28590 bool startsWithSSmallJsonG  (smallJsont *self, const char *string) {
  28591 
  28592   return(self->f->startsWithS(self, string));
  28593 }
  28594 
  28595 bool startsWithCharSmallJsonG(smallJsont *self, char c) {
  28596 
  28597   return(self->f->startsWithChar(self,c));
  28598 }
  28599 
  28600 bool startsWithSmallStringSmallJsonG(smallJsont *self, smallStringt *string) {
  28601 
  28602   return(self->f->startsWithSmallString(self,string));
  28603 }
  28604 
  28605 bool startsWithJsonSmallJsonG(smallJsont *self, smallJsont *string) {
  28606 
  28607   return(self->f->startsWithJson(self,string));
  28608 }
  28609 
  28610 bool endsWithSSmallJsonG    (smallJsont *self, const char *string) {
  28611 
  28612   return(self->f->endsWithS(self, string));
  28613 }
  28614 
  28615 bool endsWithCharSmallJsonG(smallJsont *self, char c) {
  28616 
  28617   return(self->f->endsWithChar(self,c));
  28618 }
  28619 
  28620 bool endsWithSmallStringSmallJsonG(smallJsont *self, smallStringt *string) {
  28621 
  28622   return(self->f->endsWithSmallString(self,string));
  28623 }
  28624 
  28625 bool endsWithJsonSmallJsonG(smallJsont *self, smallJsont *string) {
  28626 
  28627   return(self->f->endsWithJson(self,string));
  28628 }
  28629 
  28630 ssize_t countSSmallJsonG    (smallJsont *self, const char *string) {
  28631 
  28632   return(self->f->countS(self, string));
  28633 }
  28634 
  28635 ssize_t countCharSmallJsonG(smallJsont *self, char c) {
  28636 
  28637   return(self->f->countChar(self,c));
  28638 }
  28639 
  28640 ssize_t countSmallStringSmallJsonG(smallJsont *self, smallStringt *string) {
  28641 
  28642   return(self->f->countSmallString(self,string));
  28643 }
  28644 
  28645 ssize_t countJsonSmallJsonG(smallJsont *self, smallJsont *string) {
  28646 
  28647   return(self->f->countJson(self,string));
  28648 }
  28649 
  28650 bool icStartsWithSSmallJsonG  (smallJsont *self, const char *string) {
  28651 
  28652   return(self->f->icStartsWithS(self, string));
  28653 }
  28654 
  28655 bool icStartsWithCharSmallJsonG(smallJsont *self, char c) {
  28656 
  28657   return(self->f->icStartsWithChar(self,c));
  28658 }
  28659 
  28660 bool icStartsWithSmallStringSmallJsonG(smallJsont *self, smallStringt *string) {
  28661 
  28662   return(self->f->icStartsWithSmallString(self,string));
  28663 }
  28664 
  28665 bool icStartsWithJsonSmallJsonG(smallJsont *self, smallJsont *string) {
  28666 
  28667   return(self->f->icStartsWithJson(self,string));
  28668 }
  28669 
  28670 bool icEndsWithSSmallJsonG    (smallJsont *self, const char *string) {
  28671 
  28672   return(self->f->icEndsWithS(self, string));
  28673 }
  28674 
  28675 bool icEndsWithCharSmallJsonG(smallJsont *self, char c) {
  28676 
  28677   return(self->f->icEndsWithChar(self,c));
  28678 }
  28679 
  28680 bool icEndsWithSmallStringSmallJsonG(smallJsont *self, smallStringt *string) {
  28681 
  28682   return(self->f->icEndsWithSmallString(self,string));
  28683 }
  28684 
  28685 bool icEndsWithJsonSmallJsonG(smallJsont *self, smallJsont *string) {
  28686 
  28687   return(self->f->icEndsWithJson(self,string));
  28688 }
  28689 
  28690 ssize_t icCountSSmallJsonG    (smallJsont *self, const char *string) {
  28691 
  28692   return(self->f->icCountS(self, string));
  28693 }
  28694 
  28695 ssize_t icCountCharSmallJsonG(smallJsont *self, char c) {
  28696 
  28697   return(self->f->icCountChar(self,c));
  28698 }
  28699 
  28700 ssize_t icCountSmallStringSmallJsonG(smallJsont *self, smallStringt *string) {
  28701 
  28702   return(self->f->icCountSmallString(self,string));
  28703 }
  28704 
  28705 ssize_t icCountJsonSmallJsonG(smallJsont *self, smallJsont *string) {
  28706 
  28707   return(self->f->icCountJson(self,string));
  28708 }
  28709 
  28710 bool isNumberSmallJsonG(smallJsont *self) {
  28711 
  28712   return(self->f->isNumber(self));
  28713 }
  28714 
  28715 bool isIntSmallJsonG(smallJsont *self) {
  28716 
  28717   return(self->f->isInt(self));
  28718 }
  28719 
  28720 int64_t parseIntSmallJsonG (smallJsont *self) {
  28721 
  28722   return(self->f->parseInt(self));
  28723 }
  28724 
  28725 double parseDoubleSmallJsonG (smallJsont *self) {
  28726 
  28727   return(self->f->parseDouble(self));
  28728 }
  28729 
  28730 smallJsont* intToSmallJsonG        (smallJsont *self, int64_t n) {
  28731 
  28732   return(self->f->intTo(self, n));
  28733 }
  28734 
  28735 smallJsont* doubleToSmallJsonG     (smallJsont *self, double n) {
  28736 
  28737   return(self->f->doubleTo(self, n));
  28738 }
  28739 
  28740 size_t      lenSmallJsonG       (smallJsont *self) {
  28741 
  28742   return(self->f->len(self));
  28743 }
  28744 
  28745 smallJsont*    upperSmallJsonG      (smallJsont *self) {
  28746 
  28747   return(self->f->upper(self));
  28748 }
  28749 
  28750 smallJsont*    lowerSmallJsonG      (smallJsont *self) {
  28751 
  28752   return(self->f->lower(self));
  28753 }
  28754 
  28755 smallJsont*    trimSmallJsonG       (smallJsont *self) {
  28756 
  28757   return(self->f->trim(self));
  28758 }
  28759 
  28760 smallJsont*    lTrimSmallJsonG       (smallJsont *self) {
  28761 
  28762   return(self->f->lTrim(self));
  28763 }
  28764 
  28765 smallJsont*    rTrimSmallJsonG       (smallJsont *self) {
  28766 
  28767   return(self->f->rTrim(self));
  28768 }
  28769 
  28770 smallJsont* compactSmallJsonG       (smallJsont *self) {
  28771 
  28772   return(self->f->compact(self));
  28773 }
  28774 
  28775 smallJsont* emptySmallJsonG     (smallJsont *self) {
  28776 
  28777   return(self->f->empty(self));
  28778 }
  28779 
  28780 bool        isEmptySmallJsonG   (smallJsont *self) {
  28781 
  28782   return(self->f->isEmpty(self));
  28783 }
  28784 
  28785 bool isBlankSmallJsonG      (smallJsont *self) {
  28786 
  28787   return(self->f->isBlank(self));
  28788 }
  28789 
  28790 smallStringt* joinSmallJsonG(smallJsont *self, const char* delim) {
  28791 
  28792   return(self->f->join(self, delim));
  28793 }
  28794 
  28795 smallStringt* joinCharSmallJsonG(smallJsont *self, char c) {
  28796 
  28797   return(self->f->joinChar(self,c));
  28798 }
  28799 
  28800 smallStringt* joinSmallJsonSmallJsonG  (smallJsont *self, smallJsont* delim) {
  28801 
  28802   return(self->f->joinSmallJson(self,delim));
  28803 }
  28804 
  28805 smallStringt* joinSmallStringSmallJsonG(smallJsont *self, smallStringt* delim) {
  28806 
  28807   return(self->f->joinSmallString(self,delim));
  28808 }
  28809 
  28810 char* joinSSmallJsonG(smallJsont *self, const char* delim) {
  28811 
  28812   return(self->f->joinS(self,delim));
  28813 }
  28814 
  28815 char* joinCharSSmallJsonG(smallJsont *self, char c) {
  28816 
  28817   return(self->f->joinCharS(self,c));
  28818 }
  28819 
  28820 char* joinSmallJsonSSmallJsonG  (smallJsont *self, smallJsont* delim) {
  28821 
  28822   return(self->f->joinSmallJsonS(self,delim));
  28823 }
  28824 
  28825 char* joinSmallStringSSmallJsonG(smallJsont *self, smallStringt* delim) {
  28826 
  28827   return(self->f->joinSmallStringS(self,delim));
  28828 }
  28829 
  28830 smallJsont* splitSmallJsonG(smallJsont *self, const char *delim) {
  28831 
  28832   return(self->f->split(self, delim));
  28833 }
  28834 
  28835 smallJsont* splitCharSmallJsonG(smallJsont *self, char c) {
  28836 
  28837   return(self->f->splitChar(self,c));
  28838 }
  28839 
  28840 smallJsont* splitSmallJsonSmallJsonG  (smallJsont *self, smallJsont *delim) {
  28841 
  28842   return(self->f->splitSmallJson(self,delim));
  28843 }
  28844 
  28845 smallJsont* splitSmallStringSmallJsonG(smallJsont *self, smallStringt *delim) {
  28846 
  28847   return(self->f->splitSmallString(self,delim));
  28848 }
  28849 
  28850 char** splitSSmallJsonG(smallJsont *self, char* delim) {
  28851 
  28852   return(self->f->splitS(self,delim));
  28853 }
  28854 
  28855 char** splitCharSSmallJsonG(smallJsont *self, char c) {
  28856 
  28857   return(self->f->splitCharS(self,c));
  28858 }
  28859 
  28860 char** splitSmallJsonSSmallJsonG  (smallJsont *self, smallJsont *delim) {
  28861 
  28862   return(self->f->splitSmallJsonS(self,delim));
  28863 }
  28864 
  28865 char** splitSmallStringSSmallJsonG(smallJsont *self, smallStringt *delim) {
  28866 
  28867   return(self->f->splitSmallStringS(self,delim));
  28868 }
  28869 
  28870 smallJsont* extractSmallJsonG(smallJsont *self, const char* delim1, const char* delim2) {
  28871 
  28872   return(self->f->extract(self, delim1, delim2));
  28873 }
  28874 
  28875 smallJsont* extractCharSSmallJsonG(smallJsont *self, char delim1, const char* delim2) {
  28876 
  28877   return(self->f->extractCharS(self,delim1,delim2));
  28878 }
  28879 
  28880 smallJsont* extractSCharSmallJsonG(smallJsont *self, const char* delim1, char delim2) {
  28881 
  28882   return(self->f->extractSChar(self,delim1,delim2));
  28883 }
  28884 
  28885 smallJsont* extractCharCharSmallJsonG(smallJsont *self, char delim1, char delim2) {
  28886 
  28887   return(self->f->extractCharChar(self,delim1,delim2));
  28888 }
  28889 
  28890 smallJsont* extractSmallJsonSmallJsonSmallJsonG(smallJsont *self, smallJsont* delim1, smallJsont* delim2) {
  28891 
  28892   return(self->f->extractSmallJsonSmallJson(self,delim1,delim2));
  28893 }
  28894 
  28895 smallJsont* extractSmallJsonSmallStringSmallJsonG(smallJsont *self, smallJsont* delim1, smallStringt* delim2) {
  28896 
  28897   return(self->f->extractSmallJsonSmallString(self,delim1,delim2));
  28898 }
  28899 
  28900 smallJsont* extractSmallJsonSSmallJsonG(smallJsont *self, smallJsont* delim1, const char* delim2) {
  28901 
  28902   return(self->f->extractSmallJsonS(self,delim1,delim2));
  28903 }
  28904 
  28905 smallJsont* extractSmallJsonCharSmallJsonG(smallJsont *self, smallJsont* delim1, char delim2) {
  28906 
  28907   return(self->f->extractSmallJsonChar(self,delim1,delim2));
  28908 }
  28909 
  28910 smallJsont* extractSmallStringSmallJsonSmallJsonG(smallJsont *self, smallStringt* delim1, smallJsont* delim2) {
  28911 
  28912   return(self->f->extractSmallStringSmallJson(self,delim1,delim2));
  28913 }
  28914 
  28915 smallJsont* extractSmallStringSmallStringSmallJsonG(smallJsont *self, smallStringt* delim1, smallStringt* delim2) {
  28916 
  28917   return(self->f->extractSmallStringSmallString(self,delim1,delim2));
  28918 }
  28919 
  28920 smallJsont* extractSmallStringSSmallJsonG(smallJsont *self, smallStringt* delim1, const char* delim2) {
  28921 
  28922   return(self->f->extractSmallStringS(self,delim1,delim2));
  28923 }
  28924 
  28925 smallJsont* extractSmallStringCharSmallJsonG(smallJsont *self, smallStringt* delim1, char delim2) {
  28926 
  28927   return(self->f->extractSmallStringChar(self,delim1,delim2));
  28928 }
  28929 
  28930 smallJsont* extractSSmallJsonSmallJsonG(smallJsont *self, const char* delim1, smallJsont* delim2) {
  28931 
  28932   return(self->f->extractSSmallJson(self,delim1,delim2));
  28933 }
  28934 
  28935 smallJsont* extractSSmallStringSmallJsonG(smallJsont *self, const char* delim1, smallStringt* delim2) {
  28936 
  28937   return(self->f->extractSSmallString(self,delim1,delim2));
  28938 }
  28939 
  28940 smallJsont* extractCharSmallJsonSmallJsonG(smallJsont *self, char delim1, smallJsont* delim2) {
  28941 
  28942   return(self->f->extractCharSmallJson(self,delim1,delim2));
  28943 }
  28944 
  28945 smallJsont* extractCharSmallStringSmallJsonG(smallJsont *self, char delim1, smallStringt* delim2) {
  28946 
  28947   return(self->f->extractCharSmallString(self,delim1,delim2));
  28948 }
  28949 
  28950 smallJsont* icSplitSmallJsonG(smallJsont *self, const char *delim) {
  28951 
  28952   return(self->f->icSplit(self, delim));
  28953 }
  28954 
  28955 smallJsont* icSplitCharSmallJsonG(smallJsont *self, char c) {
  28956 
  28957   return(self->f->icSplitChar(self,c));
  28958 }
  28959 
  28960 smallJsont* icSplitSmallJsonSmallJsonG  (smallJsont *self, smallJsont *delim) {
  28961 
  28962   return(self->f->icSplitSmallJson(self,delim));
  28963 }
  28964 
  28965 smallJsont* icSplitSmallStringSmallJsonG(smallJsont *self, smallStringt *delim) {
  28966 
  28967   return(self->f->icSplitSmallString(self,delim));
  28968 }
  28969 
  28970 char** icSplitSSmallJsonG(smallJsont *self, char* delim) {
  28971 
  28972   return(self->f->icSplitS(self,delim));
  28973 }
  28974 
  28975 char** icSplitCharSSmallJsonG(smallJsont *self, char c) {
  28976 
  28977   return(self->f->icSplitCharS(self,c));
  28978 }
  28979 
  28980 char** icSplitSmallJsonSSmallJsonG(smallJsont *self, smallJsont *delim) {
  28981 
  28982   return(self->f->icSplitSmallJsonS(self,delim));
  28983 }
  28984 
  28985 char** icSplitSmallStringSSmallJsonG(smallJsont *self, smallStringt *delim) {
  28986 
  28987   return(self->f->icSplitSmallStringS(self,delim));
  28988 }
  28989 
  28990 smallJsont* icExtractSmallJsonG(smallJsont *self, const char* delim1, const char* delim2) {
  28991 
  28992   return(self->f->icExtract(self, delim1, delim2));
  28993 }
  28994 
  28995 smallJsont* icExtractCharSSmallJsonG(smallJsont *self, char delim1, const char* delim2) {
  28996 
  28997   return(self->f->icExtractCharS(self,delim1,delim2));
  28998 }
  28999 
  29000 smallJsont* icExtractSCharSmallJsonG(smallJsont *self, const char* delim1, char delim2) {
  29001 
  29002   return(self->f->icExtractSChar(self,delim1,delim2));
  29003 }
  29004 
  29005 smallJsont* icExtractCharCharSmallJsonG(smallJsont *self, char delim1, char delim2) {
  29006 
  29007   return(self->f->icExtractCharChar(self,delim1,delim2));
  29008 }
  29009 
  29010 smallJsont* icExtractSmallJsonSmallJsonSmallJsonG(smallJsont *self, smallJsont* delim1, smallJsont* delim2) {
  29011 
  29012   return(self->f->icExtractSmallJsonSmallJson(self,delim1,delim2));
  29013 }
  29014 
  29015 smallJsont* icExtractSmallJsonSmallStringSmallJsonG(smallJsont *self, smallJsont* delim1, smallStringt* delim2) {
  29016 
  29017   return(self->f->icExtractSmallJsonSmallString(self,delim1,delim2));
  29018 }
  29019 
  29020 smallJsont* icExtractSmallJsonSSmallJsonG(smallJsont *self, smallJsont* delim1, const char* delim2) {
  29021 
  29022   return(self->f->icExtractSmallJsonS(self,delim1,delim2));
  29023 }
  29024 
  29025 smallJsont* icExtractSmallJsonCharSmallJsonG(smallJsont *self, smallJsont* delim1, char delim2) {
  29026 
  29027   return(self->f->icExtractSmallJsonChar(self,delim1,delim2));
  29028 }
  29029 
  29030 smallJsont* icExtractSmallStringSmallJsonSmallJsonG(smallJsont *self, smallStringt* delim1, smallJsont* delim2) {
  29031 
  29032   return(self->f->icExtractSmallStringSmallJson(self,delim1,delim2));
  29033 }
  29034 
  29035 smallJsont* icExtractSmallStringSmallStringSmallJsonG(smallJsont *self, smallStringt* delim1, smallStringt* delim2) {
  29036 
  29037   return(self->f->icExtractSmallStringSmallString(self,delim1,delim2));
  29038 }
  29039 
  29040 smallJsont* icExtractSmallStringSSmallJsonG(smallJsont *self, smallStringt* delim1, const char* delim2) {
  29041 
  29042   return(self->f->icExtractSmallStringS(self,delim1,delim2));
  29043 }
  29044 
  29045 smallJsont* icExtractSmallStringCharSmallJsonG(smallJsont *self, smallStringt* delim1, char delim2) {
  29046 
  29047   return(self->f->icExtractSmallStringChar(self,delim1,delim2));
  29048 }
  29049 
  29050 smallJsont* icExtractSSmallJsonSmallJsonG(smallJsont *self, const char* delim1, smallJsont* delim2) {
  29051 
  29052   return(self->f->icExtractSSmallJson(self,delim1,delim2));
  29053 }
  29054 
  29055 smallJsont* icExtractSSmallStringSmallJsonG(smallJsont *self, const char* delim1, smallStringt* delim2) {
  29056 
  29057   return(self->f->icExtractSSmallString(self,delim1,delim2));
  29058 }
  29059 
  29060 smallJsont* icExtractCharSmallJsonSmallJsonG(smallJsont *self, char delim1, smallJsont* delim2) {
  29061 
  29062   return(self->f->icExtractCharSmallJson(self,delim1,delim2));
  29063 }
  29064 
  29065 smallJsont* icExtractCharSmallStringSmallJsonG(smallJsont *self, char delim1, smallStringt* delim2) {
  29066 
  29067   return(self->f->icExtractCharSmallString(self,delim1,delim2));
  29068 }
  29069 
  29070 smallJsont* zipSmallJsonG(smallJsont *self, smallArrayt *array1, smallArrayt *array2) {
  29071 
  29072   return(self->f->zip(self,array1,array2));
  29073 }
  29074 
  29075 smallJsont* zipArraySmallJsonG(smallJsont *self, char** array1, smallArrayt *array2) {
  29076 
  29077   return(self->f->zipArray(self,array1,array2));
  29078 }
  29079 
  29080 smallJsont* zipCArraySmallJsonG(smallJsont *self, const char** array1, smallArrayt *array2) {
  29081 
  29082   return(self->f->zipCArray(self,array1,array2));
  29083 }
  29084 
  29085 smallJsont* zipCharSmallJsonG(smallJsont *self, smallArrayt *array1, char** array2) {
  29086 
  29087   return(self->f->zipChar(self,array1,array2));
  29088 }
  29089 
  29090 smallJsont* zipCCharSmallJsonG(smallJsont *self, smallArrayt *array1, const char** array2) {
  29091 
  29092   return(self->f->zipCChar(self,array1,array2));
  29093 }
  29094 
  29095 smallJsont* zipArrayCharSmallJsonG(smallJsont *self, char** array1, char** array2) {
  29096 
  29097   return(self->f->zipArrayChar(self,array1,array2));
  29098 }
  29099 
  29100 smallJsont* zipArrayCCharSmallJsonG(smallJsont *self, char** array1, const char** array2) {
  29101 
  29102   return(self->f->zipArrayCChar(self,array1,array2));
  29103 }
  29104 
  29105 smallJsont* zipCArrayCharSmallJsonG(smallJsont *self, const char** array1, char** array2) {
  29106 
  29107   return(self->f->zipCArrayChar(self,array1,array2));
  29108 }
  29109 
  29110 smallJsont* zipCArrayCCharSmallJsonG(smallJsont *self, const char** array1, const char** array2) {
  29111 
  29112   return(self->f->zipCArrayCChar(self,array1,array2));
  29113 }
  29114 
  29115 smallJsont* zipJsonSmallJsonG          (smallJsont *self, smallJsont *array1, smallJsont *array2) {
  29116 
  29117   return(self->f->zipJson(self,array1,array2));
  29118 }
  29119 
  29120 smallJsont* zipJsonSmallArraySmallJsonG(smallJsont *self, smallJsont *array1, smallArrayt *array2) {
  29121 
  29122   return(self->f->zipJsonSmallArray(self,array1,array2));
  29123 }
  29124 
  29125 smallJsont* zipJsonArraySmallJsonG     (smallJsont *self, smallJsont *array1, char** array2) {
  29126 
  29127   return(self->f->zipJsonArray(self,array1,array2));
  29128 }
  29129 
  29130 smallJsont* zipJsonCArraySmallJsonG    (smallJsont *self, smallJsont *array1, const char** array2) {
  29131 
  29132   return(self->f->zipJsonCArray(self,array1,array2));
  29133 }
  29134 
  29135 smallJsont* zipSmallArrayJsonSmallJsonG(smallJsont *self, smallArrayt *array1, smallJsont *array2) {
  29136 
  29137   return(self->f->zipSmallArrayJson(self,array1,array2));
  29138 }
  29139 
  29140 smallJsont* zipArrayJsonSmallJsonG     (smallJsont *self, char** array1, smallJsont *array2) {
  29141 
  29142   return(self->f->zipArrayJson(self,array1,array2));
  29143 }
  29144 
  29145 smallJsont* zipCArrayJsonSmallJsonG    (smallJsont *self, const char** array1, smallJsont *array2) {
  29146 
  29147   return(self->f->zipCArrayJson(self,array1,array2));
  29148 }
  29149 
  29150 
  29151 smallStringt* stringifySmallStringSmallJsonG(smallJsont *self, int indent) {
  29152 
  29153   return(self->f->stringifySmallString(self,indent)); {
  29154   // cg c bug
  29155 }
  29156   }
  29157 
  29158 smallStringt* toYMLSmallStringSmallJsonG(smallJsont *self, int indent) {
  29159 
  29160   return(self->f->toYMLSmallString(self,indent));
  29161 }
  29162 
  29163 bool parseSmallJsonG            (smallJsont *self, const char *input) {
  29164 
  29165   return(self->f->parse(self, input));
  29166 }
  29167 
  29168 bool parseSmallJsonSmallJsonG(smallJsont *self, smallJsont *input) {
  29169 
  29170   return(self->f->parseSmallJson(self, input));
  29171 }
  29172 
  29173 bool parseSmallStringSmallJsonG(smallJsont *self, smallStringt *input) {
  29174 
  29175   return(self->f->parseSmallString(self, input));
  29176 }
  29177 
  29178 bool parseYMLSmallJsonG            (smallJsont *self, const char *input) {
  29179 
  29180   return(self->f->parseYML(self, input));
  29181 }
  29182 
  29183 bool parseYMLSmallJsonSmallJsonG(smallJsont *self, smallJsont *input) {
  29184 
  29185   return(self->f->parseYMLSmallJson(self, input));
  29186 }
  29187 
  29188 bool parseYMLSmallStringSmallJsonG(smallJsont *self, smallStringt *input) {
  29189 
  29190   return(self->f->parseYMLSmallString(self, input));
  29191 }
  29192 
  29193 void logSmallJsonG(smallJsont *self) {
  29194 
  29195   self->f->log(self);
  29196 }
  29197 
  29198 smallJsont* readFileSmallJsonG(smallJsont *self, const char *filePath) {
  29199 
  29200   return(self->f->readFile(self, filePath));
  29201 }
  29202 
  29203 smallJsont* readFileSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath) {
  29204 
  29205   return(self->f->readFileSmallString(self, filePath));
  29206 }
  29207 
  29208 smallJsont* readFileJsonSmallJsonG(smallJsont *self, smallJsont *filePath) {
  29209 
  29210   return(self->f->readFileJson(self, filePath));
  29211 }
  29212 
  29213 smallJsont* readStreamSmallJsonG  (smallJsont *self, FILE *fp) {
  29214 
  29215   return(self->f->readStream(self, fp));
  29216 }
  29217 
  29218 int writeFileSmallJsonG(smallJsont *self, const char *filePath) {
  29219 
  29220   return(self->f->writeFile(self, filePath));
  29221 }
  29222 
  29223 int writeFileSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath) {
  29224 
  29225   return(self->f->writeFileSmallString(self, filePath));
  29226 }
  29227 
  29228 int writeFileJsonSmallJsonG(smallJsont *self, smallJsont *filePath) {
  29229 
  29230   return(self->f->writeFileJson(self, filePath));
  29231 }
  29232 
  29233 int writeStreamSmallJsonG         (smallJsont *self, FILE *fp) {
  29234 
  29235   return(self->f->writeStream(self, fp));
  29236 }
  29237 
  29238 int appendFileSmallJsonG           (smallJsont *self, const char *filePath) {
  29239 
  29240   return(self->f->appendFile(self, filePath));
  29241 }
  29242 
  29243 int appendFileSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath) {
  29244 
  29245   return(self->f->appendFileSmallString(self, filePath));
  29246 }
  29247 
  29248 int appendFileJsonSmallJsonG(smallJsont *self, smallJsont *filePath) {
  29249 
  29250   return(self->f->appendFileJson(self, filePath));
  29251 }
  29252 
  29253 smallJsont* readTextSmallJsonG     (smallJsont *self, const char *filePath) {
  29254 
  29255   return(self->f->readText(self, filePath));
  29256 }
  29257 
  29258 smallJsont* readTextSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath) {
  29259 
  29260   return(self->f->readTextSmallString(self,filePath));
  29261 }
  29262 
  29263 smallJsont* readTextJsonSmallJsonG(smallJsont *self, smallJsont *filePath) {
  29264 
  29265   return(self->f->readTextJson(self,filePath));
  29266 }
  29267 
  29268 smallJsont* readTextStreamSmallJsonG   (smallJsont *self, FILE *fp) {
  29269 
  29270   return(self->f->readTextStream(self, fp));
  29271 }
  29272 
  29273 bool writeTextSmallJsonG    (smallJsont *self, const char *filePath) {
  29274 
  29275   return(self->f->writeText(self, filePath));
  29276 }
  29277 
  29278 bool writeTextSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath) {
  29279 
  29280   return(self->f->writeTextSmallString(self,filePath));
  29281 }
  29282 
  29283 bool writeTextJsonSmallJsonG(smallJsont *self, smallJsont *filePath) {
  29284 
  29285   return(self->f->writeTextJson(self,filePath));
  29286 }
  29287 
  29288 bool writeTextStreamSmallJsonG      (smallJsont *self, FILE *fp) {
  29289 
  29290   return(self->f->writeTextStream(self, fp));
  29291 }
  29292 
  29293 bool appendTextSmallStringSmallJsonG(smallJsont *self, smallStringt *filePath) {
  29294 
  29295   return(self->f->appendTextSmallString(self,filePath));
  29296 }
  29297 
  29298 bool appendTextJsonSmallJsonG(smallJsont *self, smallJsont *filePath) {
  29299 
  29300   return(self->f->appendTextJson(self,filePath));
  29301 }
  29302