libsheepy
libsheepyCSmallDouble.c
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2023 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 "libsheepyCSmallDouble.h"
26 
27 #define internal static
28 
29 #include <stdint.h>
30 #include <stdlib.h>
31 #include <stdbool.h>
32 #include <stdio.h>
33 
37 void finalizeRecycleSmallDouble(void *arg UNUSED);
38 void finalizeSmallDouble(void);
44 internal void freeSmallDouble(smallDoublet *self);
45 internal void terminateSmallDouble(smallDoublet **self);
46 internal char* toStringSmallDouble(smallDoublet *self);
48 internal void smashSmallDouble(smallDoublet **self);
49 #if (NFreeStackCheck)
50 internal void finishSmallDouble(smallDoublet **self);
51 #else
52 internal void finishSmallDouble(smallDoublet **self);
53 #endif
54 internal const char* helpSmallDouble(smallDoublet UNUSED *self);
55 internal double getSmallDouble(smallDoublet *self);
56 internal smallDoublet* setSmallDouble(smallDoublet *self, double value);
57 internal smallDoublet* setBoolSmallDouble(smallDoublet* self, bool p2);
58 internal smallDoublet* setInt64SmallDouble(smallDoublet* self, int64_t p2);
59 internal smallDoublet* setInt32SmallDouble(smallDoublet* self, int32_t p2);
60 internal smallDoublet* setUint32SmallDouble(smallDoublet* self, uint32_t p2);
61 internal smallDoublet* setUint64SmallDouble(smallDoublet* self, uint64_t p2);
62 internal smallDoublet* setSSmallDouble(smallDoublet* self, const char* p2);
68 internal double* getPSmallDouble(smallDoublet *self);
69 internal bool equalSmallDoubleCha(smallDoublet* self, char p2);
70 internal bool equalSmallDoubleChar(smallDoublet* self, const char * p2);
71 internal bool equalSmallDoubleBase(smallDoublet* self, baset* p2);
72 internal bool equalSmallDoubleBool(smallDoublet* self, bool p2);
73 internal bool equalSmallDoubleDouble(smallDoublet* self, double p2);
74 internal bool equalSmallDoubleInt64(smallDoublet* self, int64_t p2);
75 internal bool equalSmallDoubleInt32(smallDoublet* self, int32_t p2);
76 internal bool equalSmallDoubleUint32(smallDoublet* self, uint32_t p2);
77 internal bool equalSmallDoubleUint64(smallDoublet* self, uint64_t p2);
78 internal bool equalSmallDoubleSmallBool(smallDoublet* self, smallBoolt* p2);
79 internal bool equalSmallDoubleSmallBytes(smallDoublet* self, smallBytest* p2);
80 internal bool equalSmallDouble(smallDoublet* self, smallDoublet* p2);
81 internal bool equalSmallDoubleSmallInt(smallDoublet* self, smallIntt* p2);
82 internal bool equalSmallDoubleSmallJson(smallDoublet* self, smallJsont* p2);
83 internal bool equalSmallDoubleSmallString(smallDoublet* self, smallStringt* p2);
84 internal smallDoublet* readFileSmallDouble(smallDoublet *self, const char *filePath);
87 internal smallDoublet* readStreamSmallDouble(smallDoublet *self, FILE *fp);
88 internal int writeFileSmallDouble(smallDoublet *self, const char *filePath);
89 internal int writeFileSmallJsonSmallDouble(smallDoublet *self, smallJsont *filePath);
90 internal int writeFileSmallStringSmallDouble(smallDoublet *self, smallStringt *filePath);
91 internal int writeStreamSmallDouble(smallDoublet *self, FILE *fp);
92 internal int appendFileSmallDouble(smallDoublet *self, const char *filePath);
93 internal int appendFileSmallStringSmallDouble(smallDoublet *self, smallStringt *filePath);
95 double getDoubleSmallDoubleG (smallDoublet *self, double retType UNUSED, int64_t index UNUSED);
97 smallDoublet* setSmallDoubleG(smallDoublet* self, double p2);
100 smallDoublet* setUint32SmallDoubleG(smallDoublet* self, uint32_t p2);
101 smallDoublet* setUint64SmallDoubleG(smallDoublet* self, uint64_t p2);
102 smallDoublet* setSSmallDoubleG(smallDoublet* self, const char* p2);
108 double* getDoublePSmallDoubleG (smallDoublet *self, double* retType UNUSED, int64_t index UNUSED);
109 bool equalSmallDoubleChaG(smallDoublet* self, char p2);
110 bool equalSmallDoubleCharG(smallDoublet* self, const char * p2);
111 bool equalSmallDoubleBaseG(smallDoublet* self, baset* p2);
112 bool equalSmallDoubleBoolG(smallDoublet* self, bool p2);
113 bool equalSmallDoubleDoubleG(smallDoublet* self, double p2);
114 bool equalSmallDoubleInt64G(smallDoublet* self, int64_t p2);
115 bool equalSmallDoubleInt32G(smallDoublet* self, int32_t p2);
116 bool equalSmallDoubleUint32G(smallDoublet* self, uint32_t p2);
117 bool equalSmallDoubleUint64G(smallDoublet* self, uint64_t p2);
124 smallDoublet* readFileSmallDoubleG (smallDoublet *self, const char *filePath);
128 int writeFileSmallDoubleG (smallDoublet *self, const char *filePath);
131 int writeStreamSmallDoubleG (smallDoublet *self, FILE *fp);
132 int appendFileSmallDoubleFG (smallDoublet *self, const char *filePath);
134 
136 
137  self->type = "smallDouble";
138  if (!smallDoubleF) {
139  isError(smallDoubleF, malloc(sizeof(smallDoubleFunctionst))) {
140  self->f = NULL;
141  return;
142  }
143  registerMethodsSmallDouble(smallDoubleF);
144  }
145  self->f = smallDoubleF;;
146 
147  self->value = NULL;
148 }
149 
151 
152  f->free = freeSmallDouble;
156  f->smash = smashSmallDouble;
158  f->help = helpSmallDouble;
159  f->get = getSmallDouble;
160  f->set = setSmallDouble;
161  f->setBool = setBoolSmallDouble;
162  f->setInt64 = setInt64SmallDouble;
163  f->setInt32 = setInt32SmallDouble;
164  f->setUint32 = setUint32SmallDouble;
165  f->setUint64 = setUint64SmallDouble;
166  f->setS = setSSmallDouble;
167  f->setSmallBool = setSmallBoolSmallDouble;
168  f->setSmallDouble = setSmallDoubleSmallDouble;
169  f->setSmallInt = setSmallIntSmallDouble;
170  f->setSmallJson = setSmallJsonSmallDouble;
171  f->setSmallString = setSmallStringSmallDouble;
172  f->getP = getPSmallDouble;
173  f->equalCha = equalSmallDoubleCha;
174  f->equalChar = equalSmallDoubleChar;
175  f->equalBase = equalSmallDoubleBase;
176  f->equalBool = equalSmallDoubleBool;
177  f->equalDouble = equalSmallDoubleDouble;
178  f->equalInt64 = equalSmallDoubleInt64;
179  f->equalInt32 = equalSmallDoubleInt32;
180  f->equalUint32 = equalSmallDoubleUint32;
181  f->equalUint64 = equalSmallDoubleUint64;
182  f->equalSmallBool = equalSmallDoubleSmallBool;
183  f->equalSmallBytes = equalSmallDoubleSmallBytes;
184  f->equal = equalSmallDouble;
185  f->equalSmallInt = equalSmallDoubleSmallInt;
186  f->equalSmallJson = equalSmallDoubleSmallJson;
187  f->equalSmallString = equalSmallDoubleSmallString;
188  f->readFile = readFileSmallDouble;
189  f->readFileSmallJson = readFileSmallJsonSmallDouble;
190  f->readFileSmallString = readFileSmallStringSmallDouble;
191  f->readStream = readStreamSmallDouble;
192  f->writeFile = writeFileSmallDouble;
193  f->writeFileSmallJson = writeFileSmallJsonSmallDouble;
194  f->writeFileSmallString = writeFileSmallStringSmallDouble;
195  f->writeStream = writeStreamSmallDouble;
196  f->appendFile = appendFileSmallDouble;
197  f->appendFileSmallString = appendFileSmallStringSmallDouble;
198 }
199 
201 
202  if (self) {
203  #if (recycleContainers)
204  initAllocateRecycle(smallDoublet);
205  #else
206  isError(*self, malloc(sizeof(smallDoublet)))
207  return;
208  #endif
209  if (*self) {
210  initiateSmallDouble(*self);
211  if (!(*self)->f) {
212  finishSmallDouble(self);
213 }
214  }
215  }
216  }
217 
219 
220  #if (recycleContainers)
221  finalizeRecycle
222  #endif
223  // recycleContainers
224 }
225 
227 
228  if (smallDoubleF) {
229  free(smallDoubleF);
230  smallDoubleF = NULL;
231  }
233 }
234 
236  smallDoublet *r = NULL;
237 
239  if (!r) {
240  return(NULL);
241  }
242  isError(r->value, allocSDouble(value)) {
243  terminateO(r);
244  return(NULL);
245  }
246  return(r);
247 }
248 
250 
251  terminateO(*val);
252 }
253 
255 
256  freeO(val);
257 }
258 
260 
261  freeO(*val);
262 }
263 
265 
266  finishO(*val);
267 }
268 
269 internal void freeSmallDouble(smallDoublet *self) {
270 
271  if (self->value) {
272  free(self->value);
273  self->value = NULL;
274  }
275  return;
276 }
277 
278 internal void terminateSmallDouble(smallDoublet **self) {
279 
280  freeSmallDouble(*self);
281  finishSmallDouble(self);
282 }
283 
284 
285 internal char* toStringSmallDouble(smallDoublet *self) {
286  char *s = NULL;
287 
288  if (!self->value) {
289  return(NULL);
290  }
291  s = malloc(256*sizeof(char));
292  if (!s) {
293  return(NULL);
294  }
295  snprintf(s,256, "%e", self->value->value);
296 
297  return(s);
298 }
299 
301 
303  if (!dup) {
304  return(NULL);
305  }
306  if (self->value) {
307  isError(dup->value, allocSDouble(self->value->value)) {
308  terminateO(dup);
309  return(NULL);
310  }
311  }
312  return(dup);
313 }
314 
315 internal void smashSmallDouble(smallDoublet **self) {
316 
317  finishSmallDouble(self);
318 }
319 
320 #if (NFreeStackCheck)
321 internal void finishSmallDouble(smallDoublet **self) {
322 
323  register u64 rsp asm("rsp");
324  if ((u64)*self > rsp) {
325  logW("Probably trying to free a smallDouble on stack: "BLD PRIx64 RST" sp: "BLD PRIx64 RST, *self, rsp);
326  logBtrace;
327  }
328  else {
329  #if (recycleContainers)
330  finishRecycle
331  #else
332  free(*self);
333  #endif
334  // recycleContainers
335  *self = NULL;
336 }
337  }
338 
339 #else
340 // #if NFreeStackCheck
341 internal void finishSmallDouble(smallDoublet **self) {
342 
343  #if (recycleContainers)
344  finishRecycle
345  #else
346  free(*self);
347  #endif
348  // recycleContainers
349  *self = NULL;
350 }
351 
352 #endif
353 // #if NFreeStackCheck
354 
355 internal const char* helpSmallDouble(smallDoublet UNUSED *self) {
356 
357  return(helpTextSmallDouble);
358 }
359 
360 internal double getSmallDouble(smallDoublet *self) {
361 
362  if (!self->value) {
363  return(0);
364  }
365  return(self->value->value);
366 }
367 
368 internal smallDoublet* setSmallDouble(smallDoublet *self, double value) {
369 
370  if (!self->value) {
371  isError(self->value, allocSDouble(value)) return(NULL);
372  }
373  else {
374  self->value->value = value;
375  }
376  return(self);
377 }
378 
379 internal smallDoublet* setBoolSmallDouble(smallDoublet* self, bool p2) {
380 
381  if (!self->value) {
382  isError(self->value, allocSDouble((double)p2)) return(NULL);
383  }
384  else {
385  self->value->value = (double)p2;
386  }
387  return(self);
388 }
389 
390 internal smallDoublet* setInt64SmallDouble(smallDoublet* self, int64_t p2) {
391 
392  if (!self->value) {
393  isError(self->value, allocSDouble((double)p2)) return(NULL);
394  }
395  else {
396  self->value->value = (double)p2;
397  }
398  return(self);
399 }
400 
401 internal smallDoublet* setInt32SmallDouble(smallDoublet* self, int32_t p2) {
402 
403  if (!self->value) {
404  isError(self->value, allocSDouble((double)p2)) return(NULL);
405  }
406  else {
407  self->value->value = (double)p2;
408  }
409  return(self);
410 }
411 
412 internal smallDoublet* setUint32SmallDouble(smallDoublet* self, uint32_t p2) {
413 
414  if (!self->value) {
415  isError(self->value, allocSDouble((double)p2)) return(NULL);
416  }
417  else {
418  self->value->value = (double)p2;
419  }
420  return(self);
421 }
422 
423 internal smallDoublet* setUint64SmallDouble(smallDoublet* self, uint64_t p2) {
424 
425  if (!self->value) {
426  isError(self->value, allocSDouble((double)p2)) return(NULL);
427  }
428  else {
429  self->value->value = (double)p2;
430  }
431  return(self);
432 }
433 
434 internal smallDoublet* setSSmallDouble(smallDoublet* self, const char* p2) {
435 
436  if (!p2 || !isNumber(p2)) {
437  return(NULL);
438  }
439  if (!self->value) {
440  isError(self->value, allocSDouble(parseDouble(p2))) return(NULL);
441  }
442  else {
443  self->value->value = parseDouble(p2);
444  }
445  return(self);
446 }
447 
449  bool value;
450 
451  if (!p2) {
452  return(NULL);
453  }
454 
455  value = p2->f->get(p2);
456 
457  if (!self->value) {
458  isError(self->value, allocSDouble((double)value)) return(NULL);
459  }
460  else {
461  self->value->value = (double)value;
462  }
463  return(self);
464 }
465 
467 
468  if (!p2) {
469  return(NULL);
470  }
471 
472  if (!self->value) {
473  isError(self->value, allocSDouble(p2->f->get(p2))) return(NULL);
474  }
475  else {
476  self->value->value = p2->f->get(p2);
477  }
478  return(self);
479 }
480 
482 
483  if (!p2) {
484  return(NULL);
485  }
486 
487  if (!self->value) {
488  isError(self->value, allocSDouble((double)p2->f->get(p2))) return(NULL);
489  }
490  else {
491  self->value->value = (double)p2->f->get(p2);
492  }
493  return(self);
494 }
495 
497 
498  if (!p2) {
499  return(NULL);
500  }
501 
502  const char *type = getTopTypeO(p2);
503 
504  if (!type || eqS(type, "undefined") || eqS(type, "dict") || eqS(type, "array")) {
505  return(NULL);
506  }
507 
508  if (eqS(type, "bool")) {
509  return(setBoolSmallDouble(self, getTopBoolO(p2)));
510  }
511  else if (eqS(type, "double")) {
512  return(setSmallDouble(self, getTopDoubleO(p2)));
513  }
514  else if (eqS(type, "int")) {
515  return(setInt64SmallDouble(self, getTopIntO(p2)));
516  }
517  else if (eqS(type, "string")) {
518  return(setSSmallDouble(self, getTopSO(p2)));
519  }
520  return(NULL);
521 }
522 
523 
525 
526  if (!p2 || !isNumberO(p2)) {
527  return(NULL);
528  }
529  if (!self->value) {
530  isError(self->value, allocSDouble(parseDoubleO(p2))) return(NULL);
531  }
532  else {
533  self->value->value = parseDoubleO(p2);
534  }
535  return(self);
536 }
537 
538 internal double* getPSmallDouble(smallDoublet *self) {
539 
540  if (!self->value) {
541  return(NULL);
542  }
543  return(&(self->value->value));
544 }
545 
546 internal bool equalSmallDoubleCha(smallDoublet* self, char p2) {
547 
548  if (!self->value) {
549  return(false);
550  }
551 
552  charToS(s, p2);
553 
554  if (isInt(s) || !isNumber(s)) {
555  return(false);
556  }
557 
558  double value = parseDouble(s);
559 
560  return(self->value->value == value);;
561 }
562 
563 internal bool equalSmallDoubleChar(smallDoublet* self, const char * p2) {
564 
565  if (!self->value || !p2) {
566  return(false);
567  }
568 
569  if (isInt(p2) || !isNumber(p2)) {
570  return(false);
571  }
572 
573  double value = parseDouble(p2);
574 
575  return(self->value->value == value);;
576 }
577 
578 internal bool equalSmallDoubleBase(smallDoublet* self, baset* p2) {
579 
580  if (!self->value || !p2) {
581  return(false);
582  }
583 
584  char *s = toStringO(p2);
585 
586  if (isInt(s) || !isNumber(s)) {
587  free(s);
588  return(false);
589  }
590 
591  double value = parseDouble(s);
592 
593  bool r;
594  if (self->value->value == value) {
595  r = true;
596  }
597  else {
598  r = false;
599  }
600 
601  free(s);
602  return(r);
603 }
604 
605 internal bool equalSmallDoubleBool(smallDoublet* self, bool p2) {
606 
607  if (!self->value) {
608  return(false);
609  }
610 
611  return(self->value->value == p2);;
612 }
613 
614 internal bool equalSmallDoubleDouble(smallDoublet* self, double p2) {
615 
616  if (!self->value) {
617  return(false);
618  }
619 
620  return(self->value->value == p2);;
621 }
622 
623 internal bool equalSmallDoubleInt64(smallDoublet* self, int64_t p2) {
624 
625  if (!self->value) {
626  return(false);
627  }
628 
629  return(self->value->value == p2);;
630 }
631 
632 internal bool equalSmallDoubleInt32(smallDoublet* self, int32_t p2) {
633 
634  if (!self->value) {
635  return(false);
636  }
637 
638  return(self->value->value == p2);;
639 }
640 
641 internal bool equalSmallDoubleUint32(smallDoublet* self, uint32_t p2) {
642 
643  if (!self->value) {
644  return(false);
645  }
646 
647  return(self->value->value == p2);;
648 }
649 
650 internal bool equalSmallDoubleUint64(smallDoublet* self, uint64_t p2) {
651 
652  if (!self->value) {
653  return(false);
654  }
655 
656  return(self->value->value == p2);;
657 }
658 
660 
661  if (!self->value || !p2 || !p2->value) {
662  return(false);
663  }
664 
665  return(self->value->value == p2->value->value);;
666 }
667 
669 
670  if (!self->value || !p2 || !p2->B) {
671  return(false);
672  }
673 
674  char *s = sBytesGet(p2->B);
675 
676  bool has0 = false;
677  rangeDown(i, p2->B->count) {
678  if (s[i] == 0) {
679  has0 = true;
680  break;
681  }
682  }
683 
684  if (!has0) {
685  return(false);
686  }
687 
688  if (isInt(s) || !isNumber(s)) {
689  return(false);
690  }
691 
692  double p2Value = parseDouble(s);
693 
694  return(p2Value == self->value->value);;
695 }
696 
697 
698 internal bool equalSmallDouble(smallDoublet* self, smallDoublet* p2) {
699 
700  if (!self->value || !p2 || !p2->value) {
701  return(false);
702  }
703 
704  return(self->value->value == p2->value->value);;
705 }
706 
708 
709  if (!self->value || !p2 || !p2->value) {
710  return(false);
711  }
712 
713  return(self->value->value == p2->value->value);;
714 }
715 
717 
718  if (!p2) {
719  return(false);
720  }
721 
722  if (checkObjectTypes && !isOSmallJson(p2)) {
723  return(false);
724  }
725 
726  return(p2->f->equalSmallDouble(p2, self));
727 }
728 
730 
731  if (!self->value || !p2 || !p2->data) {
732  return(false);
733  }
734 
735  if (isIntO(p2) || !isNumberO(p2)) {
736  return(false);
737  }
738 
739  double value = parseDoubleO(p2);
740 
741  return(self->value->value == value);;
742 }
743 
744 internal smallDoublet* readFileSmallDouble(smallDoublet *self, const char *filePath) {
745  FILE *f = NULL;
746  size_t readStatus;
747 
748  // sanity checks
749  if (!filePath || isBlankS(filePath)) {
750  return(NULL);
751  }
752 
753  if (!self->value) {
754  isError(self->value, allocSDouble(0)) return(NULL);
755  }
756 
757  f = fopen(filePath, "r");
758  if (!f) {
759  pFuncError
760  shEPrintfS("The path was: \"%s\"\n", filePath);
761  return(NULL);
762  }
763  readStatus = fread(&self->value->value, 1, sizeof(double) , f);
764  fclose(f);
765 
766  if (readStatus != sizeof(double)) {
767  pFuncError
768  shEPrintfS("The path was: \"%s\"\n", filePath);
769  return(NULL);
770  }
771 
772  return(self);
773 }
774 
776 
777  if (!filePath) {
778  return(NULL);
779  }
780 
781  if (checkObjectTypes && !isOSmallJson(filePath)) {
782  return(NULL);
783  }
784 
785  const char *type = getTopTypeO(filePath);
786 
787  if (!eqS(type,"string")) {
788  return(NULL);
789  }
790 
791  return(readFileSmallDouble(self, getTopSO(filePath)));
792 }
793 
795 
796  if (!filePath) {
797  return(NULL);
798  }
799 
800  if (checkObjectTypes && !isOSmallString(filePath)) {
801  return(NULL);
802  }
803 
804  return(readFileSmallDouble(self, ssGet(filePath)));
805 }
806 
808  size_t readStatus;
809 
810  // sanity checks
811  if (!fp) {
812  return(NULL);
813  }
814 
815  if (!self->value) {
816  isError(self->value, allocSDouble(0)) return(NULL);
817  }
818 
819  readStatus = fread(&self->value->value, 1, sizeof(double) , fp);
820 
821  if (readStatus != sizeof(double)) {
822  pFuncError
823  return(NULL);
824  }
825 
826  return(self);
827 }
828 
829 internal int writeFileSmallDouble(smallDoublet *self, const char *filePath) {
830  FILE *f = NULL;
831  size_t writeStatus;
832 
833  // sanity checks
834  if (!filePath || isBlankS(filePath) || !self->value) {
835  return(0);
836  }
837 
838  f = fopen(filePath, "w");
839  if (!f) {
840  pFuncError
841  shEPrintfS("The path was: \"%s\"\n", filePath);
842  return(0);
843  }
844  writeStatus = fwrite(&self->value->value, 1, sizeof(double) , f);
845  fclose(f);
846 
847  if (writeStatus != sizeof(double)) {
848  pFuncError
849  shEPrintfS("The path was: \"%s\"\n", filePath);
850  return(0);
851  }
852 
853  return(1);
854 }
855 
856 internal int writeFileSmallJsonSmallDouble(smallDoublet *self, smallJsont *filePath) {
857 
858  if (!filePath) {
859  return(0);
860  }
861 
862  if (checkObjectTypes && !isOSmallJson(filePath)) {
863  return(0);
864  }
865 
866  const char *type = getTopTypeO(filePath);
867 
868  if (!eqS(type,"string")) {
869  return(0);
870  }
871 
872  return(writeFileSmallDouble(self, getTopSO(filePath)));
873 }
874 
876 
877  if (!filePath) {
878  return(0);
879  }
880 
881  if (checkObjectTypes && !isOSmallString(filePath)) {
882  return(0);
883  }
884 
885  return(writeFileSmallDouble(self, ssGet(filePath)));
886 }
887 
888 internal int writeStreamSmallDouble(smallDoublet *self, FILE *fp) {
889  size_t writeStatus;
890 
891  // sanity checks
892  if (!fp || !self->value) {
893  return(0);
894  }
895 
896  writeStatus = fwrite(&self->value->value, 1, sizeof(double) , fp);
897 
898  if (writeStatus != sizeof(double)) {
899  pFuncError
900  return(0);
901  }
902 
903  return(1);
904 }
905 
906 internal int appendFileSmallDouble(smallDoublet *self, const char *filePath) {
907  FILE *f = NULL;
908  size_t writeStatus;
909 
910  // sanity checks
911  if (!filePath || isBlankS(filePath) || !self->value) {
912  return(0);
913  }
914 
915  f = fopen(filePath, "a");
916  if (!f) {
917  pFuncError
918  shEPrintfS("The path was: \"%s\"\n", filePath);
919  return(0);
920  }
921  writeStatus = fwrite(&self->value->value, 1, sizeof(double) , f);
922  fclose(f);
923 
924  if (writeStatus != sizeof(double)) {
925  pFuncError
926  shEPrintfS("The path was: \"%s\"\n", filePath);
927  return(0);
928  }
929 
930  return(1);
931 }
932 
934 
935  if (!filePath) {
936  return(0);
937  }
938  return(appendFileSmallDouble(self, ssGet(filePath)));
939 }
940 
941 
942 
944 
945  return(self->f->duplicate(self));
946 }
947 
948 void freeSmallDoubleG (smallDoublet *self) {self->f->free(self);}
949 
950 double getDoubleSmallDoubleG (smallDoublet *self, double retType UNUSED, int64_t index UNUSED) {
951 
952  return(self->f->get(self));
953 }
954 
956 
957  return(self->f->setBool(self, p2));
958 }
959 
961 
962  return(self->f->set(self, p2));
963 }
964 
966 
967  return(self->f->setInt64(self, p2));
968 }
969 
971 
972  return(self->f->setInt32(self, p2));
973 }
974 
976 
977  return(self->f->setUint32(self, p2));
978 }
979 
981 
982  return(self->f->setUint64(self, p2));
983 }
984 
985 smallDoublet* setSSmallDoubleG(smallDoublet* self, const char* p2) {
986 
987  return(self->f->setS(self, p2));
988 }
989 
991 
992  return(self->f->setSmallBool(self, p2));
993 }
994 
996 
997  return(self->f->setSmallDouble(self, p2));
998 }
999 
1001 
1002  return(self->f->setSmallInt(self, p2));
1003 }
1004 
1006 
1007  return(self->f->setSmallJson(self, p2));
1008 }
1009 
1011 
1012  return(self->f->setSmallString(self, p2));
1013 }
1014 
1015 
1016 double* getDoublePSmallDoubleG (smallDoublet *self, double* retType UNUSED, int64_t index UNUSED) {
1017 
1018  return(self->f->getP(self));
1019 }
1020 
1021 bool equalSmallDoubleChaG(smallDoublet* self, char p2) {
1022 
1023  return(self->f->equalCha(self, p2));
1024 }
1025 
1026 bool equalSmallDoubleCharG(smallDoublet* self, const char * p2) {
1027 
1028  return(self->f->equalChar(self, p2));
1029 }
1030 
1032 
1033  return(self->f->equalBase(self, p2));
1034 }
1035 
1036 bool equalSmallDoubleBoolG(smallDoublet* self, bool p2) {
1037 
1038  return(self->f->equalBool(self, p2));
1039 }
1040 
1041 bool equalSmallDoubleDoubleG(smallDoublet* self, double p2) {
1042 
1043  return(self->f->equalDouble(self, p2));
1044 }
1045 
1046 bool equalSmallDoubleInt64G(smallDoublet* self, int64_t p2) {
1047 
1048  return(self->f->equalInt64(self, p2));
1049 }
1050 
1051 bool equalSmallDoubleInt32G(smallDoublet* self, int32_t p2) {
1052 
1053  return(self->f->equalInt32(self, p2));
1054 }
1055 
1056 bool equalSmallDoubleUint32G(smallDoublet* self, uint32_t p2) {
1057 
1058  return(self->f->equalUint32(self, p2));
1059 }
1060 
1061 bool equalSmallDoubleUint64G(smallDoublet* self, uint64_t p2) {
1062 
1063  return(self->f->equalUint64(self, p2));
1064 }
1065 
1067 
1068  return(self->f->equalSmallBool(self, p2));
1069 }
1070 
1072 
1073  return(self->f->equalSmallBytes(self, p2));
1074 }
1075 
1077 
1078  return(self->f->equal(self, p2));
1079 }
1080 
1082 
1083  return(self->f->equalSmallInt(self, p2));
1084 }
1085 
1087 
1088  return(self->f->equalSmallJson(self, p2));
1089 }
1090 
1092 
1093  return(self->f->equalSmallString(self, p2));
1094 }
1095 
1096 smallDoublet* readFileSmallDoubleG (smallDoublet *self, const char *filePath) {
1097 
1098  return(self->f->readFile(self, filePath));
1099 }
1100 
1102 
1103  return(self->f->readFileSmallJson(self,filePath));
1104 }
1105 
1107 
1108  return(self->f->readFileSmallString(self,filePath));
1109 }
1110 
1112 
1113  return(self->f->readStream(self, fp));
1114 }
1115 
1116 int writeFileSmallDoubleG (smallDoublet *self, const char *filePath) {
1117 
1118  return(self->f->writeFile(self, filePath));
1119 }
1120 
1122 
1123  return(self->f->writeFileSmallJson(self,filePath));
1124 }
1125 
1127 
1128  return(self->f->writeFileSmallString(self,filePath));
1129 }
1130 
1132 
1133  return(self->f->writeStream(self, fp));
1134 }
1135 
1136 int appendFileSmallDoubleFG (smallDoublet *self, const char *filePath) {
1137 
1138  return(self->f->appendFile(self, filePath));
1139 }
1140 
1142 
1143  return(self->f->appendFileSmallString(self,filePath));
1144 }
1145 
#define getTopDoubleO(self)
smallDoublet * readFileSmallDoubleG(smallDoublet *self, const char *filePath)
char * s
#define charToS(dst, c)
Definition: libsheepy.h:1862
internal bool equalSmallDoubleSmallBool(smallDoublet *self, smallBoolt *p2)
#define getTopBoolO(self)
bool eqS(const char *string1, const char *string2)
string Equal compare string1 to string2
Definition: libsheepy.c:9067
internal int appendFileSmallDouble(smallDoublet *self, const char *filePath)
bool isBlankS(const char *string)
is Blank String
Definition: libsheepy.c:50246
#define getTopSO(self)
bool equalSmallDoubleSmallBoolG(smallDoublet *self, smallBoolt *p2)
bool equalSmallDoubleBoolG(smallDoublet *self, bool p2)
internal smallDoublet * setBoolSmallDouble(smallDoublet *self, bool p2)
internal smallDoublet * setSmallDoubleSmallDouble(smallDoublet *self, smallDoublet *p2)
int writeFileSmallJsonSmallDoubleG(smallDoublet *self, smallJsont *filePath)
free(s)
#define ssGet(obj)
get a pointer to the string in the smallString object
#define rangeDown(index, maxCount)
range down loop, index is ssize_t
Definition: libsheepy.h:2786
internal bool equalSmallDoubleSmallString(smallDoublet *self, smallStringt *p2)
internal int writeFileSmallJsonSmallDouble(smallDoublet *self, smallJsont *filePath)
internal smallDoublet * setUint64SmallDouble(smallDoublet *self, uint64_t p2)
#define RST
reset for color function
Definition: libsheepy.h:763
#define getTopIntO(self)
int writeStreamSmallDoubleG(smallDoublet *self, FILE *fp)
#define u64
Definition: libsheepy.h:448
internal bool equalSmallDoubleInt64(smallDoublet *self, int64_t p2)
toStringSmallDoubleFt toString
internal smallDoublet * readFileSmallStringSmallDouble(smallDoublet *self, smallStringt *filePath)
internal bool equalSmallDoubleDouble(smallDoublet *self, double p2)
internal double getSmallDouble(smallDoublet *self)
duplicateSmallDoubleFt duplicate
bool equalSmallDoubleSmallJsonG(smallDoublet *self, smallJsont *p2)
smallt * i
void initiateAllocateSmallDouble(smallDoublet **self)
bool equalSmallDoubleFG(smallDoublet *self, smallDoublet *p2)
smallDoublet * readStreamSmallDoubleG(smallDoublet *self, FILE *fp)
int appendFileSmallStringSmallDoubleG(smallDoublet *self, smallStringt *filePath)
#define pFuncError
print function name and system error
Definition: libsheepy.h:306
internal smallDoublet * setInt32SmallDouble(smallDoublet *self, int32_t p2)
internal bool equalSmallDoubleUint32(smallDoublet *self, uint32_t p2)
smallDoublet * setSmallJsonSmallDoubleG(smallDoublet *self, smallJsont *p2)
double getDoubleSmallDoubleG(smallDoublet *self, double retType UNUSED, int64_t index UNUSED)
int appendFileSmallDoubleFG(smallDoublet *self, const char *filePath)
bool equalSmallDoubleSmallBytesG(smallDoublet *self, smallBytest *p2)
void cleanUpSmallDoubleFreeLocalG(smallDoublet *val)
internal smallDoublet * setSmallIntSmallDouble(smallDoublet *self, smallIntt *p2)
internal double * getPSmallDouble(smallDoublet *self)
bool equalSmallDoubleSmallIntG(smallDoublet *self, smallIntt *p2)
#define isError(assigned, left)
is Assigment Error catch error when assigned is false, 0 or NULL after being assigned with left ...
Definition: libsheepy.h:386
smallDoublet * setSmallStringSmallDoubleG(smallDoublet *self, smallStringt *p2)
internal bool equalSmallDoubleInt32(smallDoublet *self, int32_t p2)
internal void smashSmallDouble(smallDoublet **self)
sBoolt * value
bool value
void registerMethodsSmallDouble(smallDoubleFunctionst *f)
internal int appendFileSmallStringSmallDouble(smallDoublet *self, smallStringt *filePath)
internal void terminateSmallDouble(smallDoublet **self)
#define getTopTypeO(self)
#define isOSmallJson(obj)
test if obj type is smallJson
internal int writeFileSmallStringSmallDouble(smallDoublet *self, smallStringt *filePath)
smallDoublet * readFileSmallStringSmallDoubleG(smallDoublet *self, smallStringt *filePath)
smallDoublet * setSmallBoolSmallDoubleG(smallDoublet *self, smallBoolt *p2)
void finalizeSmallDouble(void)
#define terminateO(obj)
free buffers and obj itself
internal int writeFileSmallDouble(smallDoublet *self, const char *filePath)
bool equalSmallDoubleSmallStringG(smallDoublet *self, smallStringt *p2)
smallDoublet * setUint32SmallDoubleG(smallDoublet *self, uint32_t p2)
bool equalSmallDoubleInt32G(smallDoublet *self, int32_t p2)
internal smallDoublet * setSmallJsonSmallDouble(smallDoublet *self, smallJsont *p2)
smallDoublet * setBoolSmallDoubleG(smallDoublet *self, bool p2)
#define logBtrace
Definition: libsheepy.h:3249
void cleanUpSmallDoubleFreeG(smallDoublet **val)
void initiateSmallDouble(smallDoublet *self)
uint32_t count
smallDoublet * setSmallIntSmallDoubleG(smallDoublet *self, smallIntt *p2)
internal smallDoublet * setSmallStringSmallDouble(smallDoublet *self, smallStringt *p2)
internal int writeStreamSmallDouble(smallDoublet *self, FILE *fp)
internal bool equalSmallDoubleBool(smallDoublet *self, bool p2)
internal void freeSmallDouble(smallDoublet *self)
smallDoublet * setSSmallDoubleG(smallDoublet *self, const char *p2)
END_TEST FILE * fp
bool equalSmallDoubleCharG(smallDoublet *self, const char *p2)
void cleanUpSmallDoubleTerminateG(smallDoublet **val)
#define parseDoubleO(self)
internal smallDoublet * setSSmallDouble(smallDoublet *self, const char *p2)
smallDoublet * setInt64SmallDoubleG(smallDoublet *self, int64_t p2)
#define toStringO(obj)
convert data in obj to string
bool isNumber(const char *string)
is Number (integer or float) String
Definition: libsheepy.c:10749
internal void finishSmallDouble(smallDoublet **self)
internal smallDoublet * duplicateSmallDouble(smallDoublet *self)
smallDoublet * duplicateSmallDoubleG(smallDoublet *self)
internal const char * helpSmallDouble(smallDoublet UNUSED *self)
internal smallDoublet * readFileSmallJsonSmallDouble(smallDoublet *self, smallJsont *filePath)
smallDoublet * setSmallDoubleSmallDoubleG(smallDoublet *self, smallDoublet *p2)
bool equalSmallDoubleDoubleG(smallDoublet *self, double p2)
internal smallDoublet * setUint32SmallDouble(smallDoublet *self, uint32_t p2)
bool isInt(const char *string)
is Integer String
Definition: libsheepy.c:10811
fclose(fp)
finishSmallDoubleFt finish
int64_t value
bool equalSmallDoubleChaG(smallDoublet *self, char p2)
void * sBytesGet(sBytest *bytes)
get buffer in small bytes
double parseDouble(const char *string)
convert string to double
Definition: libsheepy.c:10914
sDoublet * allocSDouble(double value)
allocate a small double
internal bool equalSmallDoubleSmallInt(smallDoublet *self, smallIntt *p2)
#define BLD
bold for color function
Definition: libsheepy.h:765
smallDoublet * setUint64SmallDoubleG(smallDoublet *self, uint64_t p2)
void finalizeRecycleSmallDouble(void *arg UNUSED)
int writeFileSmallStringSmallDoubleG(smallDoublet *self, smallStringt *filePath)
#define isIntO(self)
in value value
bool equalSmallDoubleUint32G(smallDoublet *self, uint32_t p2)
double value
createAllocateSmallDouble(jDouble)
bool equalSmallDoubleUint64G(smallDoublet *self, uint64_t p2)
internal bool equalSmallDouble(smallDoublet *self, smallDoublet *p2)
internal bool equalSmallDoubleChar(smallDoublet *self, const char *p2)
internal bool equalSmallDoubleCha(smallDoublet *self, char p2)
smallJsonFunctionst * f
smallDoublet * setSmallDoubleG(smallDoublet *self, double p2)
#define UNUSED
Definition: libsheepy.h:8195
#define isNumberO(self)
internal smallDoublet * readStreamSmallDouble(smallDoublet *self, FILE *fp)
smallBoolFunctionst * f
internal bool equalSmallDoubleUint64(smallDoublet *self, uint64_t p2)
void freeSmallDoubleG(smallDoublet *self)
#define helpTextSmallDouble
help text for this class It is public declaration so that child classes can add their help text easil...
internal bool equalSmallDoubleBase(smallDoublet *self, baset *p2)
bool r
terminateSmallDoubleFt terminate
#define logW(...)
Definition: libsheepy.h:1061
smallDoublet * allocSmallDouble(double value)
void shEPrintfS(const char *fmt,...)
sheepy Error printf String print with logE
Definition: libsheepy.c:6589
base class
void cleanUpSmallDoubleFinishG(smallDoublet **val)
internal smallDoublet * setSmallDouble(smallDoublet *self, double value)
#define freeO(obj)
free buffers in obj
internal bool equalSmallDoubleSmallBytes(smallDoublet *self, smallBytest *p2)
internal bool equalSmallDoubleSmallJson(smallDoublet *self, smallJsont *p2)
internal smallDoublet * readFileSmallDouble(smallDoublet *self, const char *filePath)
internal smallDoublet * setInt64SmallDouble(smallDoublet *self, int64_t p2)
int writeFileSmallDoubleG(smallDoublet *self, const char *filePath)
smallDoublet * setInt32SmallDoubleG(smallDoublet *self, int32_t p2)
smallIntFunctionst * f
bool value
internal smallDoublet * setSmallBoolSmallDouble(smallDoublet *self, smallBoolt *p2)
bool equalSmallDoubleBaseG(smallDoublet *self, baset *p2)
smallDoublet * readFileSmallJsonSmallDoubleG(smallDoublet *self, smallJsont *filePath)
#define finishO(obj)
free container only
internal char * toStringSmallDouble(smallDoublet *self)
smallDoubleFunctionst * f
bool equalSmallDoubleInt64G(smallDoublet *self, int64_t p2)
double * getDoublePSmallDoubleG(smallDoublet *self, double *retType UNUSED, int64_t index UNUSED)
#define isOSmallString(obj)
test if obj type is smallString