1 /**********************************************************
2 * This file has been automatically created by "typemaker2"
3 * from the file "security.xml".
4 * Please do not edit this file, all changes will be lost.
5 * Better edit the mentioned source file instead.
6 **********************************************************/
7
8 #ifdef HAVE_CONFIG_H
9 # include <config.h>
10 #endif
11
12 #include "./security_p.h"
13
14 #include <gwenhywfar/misc.h>
15 #include <gwenhywfar/debug.h>
16
17 /* code headers */
18
19 /* macro functions */
GWEN_LIST_FUNCTIONS(AB_SECURITY,AB_Security)20 GWEN_LIST_FUNCTIONS(AB_SECURITY, AB_Security)
21 GWEN_LIST2_FUNCTIONS(AB_SECURITY, AB_Security)
22
23
24 AB_SECURITY *AB_Security_new(void)
25 {
26 AB_SECURITY *p_struct;
27
28 GWEN_NEW_OBJECT(AB_SECURITY, p_struct)
29 p_struct->_refCount=1;
30 GWEN_LIST_INIT(AB_SECURITY, p_struct)
31 /* members */
32 p_struct->name=NULL;
33 p_struct->uniqueId=NULL;
34 p_struct->nameSpace=NULL;
35 p_struct->tickerSymbol=NULL;
36 p_struct->units=AB_Value_new();
37 p_struct->unitPriceValue=AB_Value_new();
38 p_struct->unitPriceDate=NULL;
39 /* virtual functions */
40
41 return p_struct;
42 }
43
AB_Security_free(AB_SECURITY * p_struct)44 void AB_Security_free(AB_SECURITY *p_struct)
45 {
46 if (p_struct) {
47 assert(p_struct->_refCount);
48 if (p_struct->_refCount==1) {
49 GWEN_LIST_FINI(AB_SECURITY, p_struct)
50 /* members */
51 free(p_struct->name);
52 p_struct->name=NULL;
53 free(p_struct->uniqueId);
54 p_struct->uniqueId=NULL;
55 free(p_struct->nameSpace);
56 p_struct->nameSpace=NULL;
57 free(p_struct->tickerSymbol);
58 p_struct->tickerSymbol=NULL;
59 AB_Value_free(p_struct->units);
60 AB_Value_free(p_struct->unitPriceValue);
61 GWEN_Time_free(p_struct->unitPriceDate);
62 p_struct->unitPriceDate=NULL;
63 p_struct->_refCount=0;
64 GWEN_FREE_OBJECT(p_struct);
65 }
66 else
67 p_struct->_refCount--;
68 }
69 }
70
AB_Security_Attach(AB_SECURITY * p_struct)71 void AB_Security_Attach(AB_SECURITY *p_struct)
72 {
73 assert(p_struct);
74 assert(p_struct->_refCount);
75 p_struct->_refCount++;
76 }
77
AB_Security_dup(const AB_SECURITY * p_src)78 AB_SECURITY *AB_Security_dup(const AB_SECURITY *p_src)
79 {
80 AB_SECURITY *p_struct;
81
82 assert(p_src);
83 p_struct=AB_Security_new();
84 /* member "name" */
85 if (p_struct->name) {
86 free(p_struct->name);
87 p_struct->name=NULL;
88 p_struct->name=NULL;
89 }
90 if (p_src->name) {
91 p_struct->name=strdup(p_src->name);
92 }
93
94 /* member "uniqueId" */
95 if (p_struct->uniqueId) {
96 free(p_struct->uniqueId);
97 p_struct->uniqueId=NULL;
98 p_struct->uniqueId=NULL;
99 }
100 if (p_src->uniqueId) {
101 p_struct->uniqueId=strdup(p_src->uniqueId);
102 }
103
104 /* member "nameSpace" */
105 if (p_struct->nameSpace) {
106 free(p_struct->nameSpace);
107 p_struct->nameSpace=NULL;
108 p_struct->nameSpace=NULL;
109 }
110 if (p_src->nameSpace) {
111 p_struct->nameSpace=strdup(p_src->nameSpace);
112 }
113
114 /* member "tickerSymbol" */
115 if (p_struct->tickerSymbol) {
116 free(p_struct->tickerSymbol);
117 p_struct->tickerSymbol=NULL;
118 p_struct->tickerSymbol=NULL;
119 }
120 if (p_src->tickerSymbol) {
121 p_struct->tickerSymbol=strdup(p_src->tickerSymbol);
122 }
123
124 /* member "units" */
125 if (p_struct->units) {
126 AB_Value_free(p_struct->units);
127 p_struct->units=NULL;
128 }
129 if (p_src->units) {
130 p_struct->units=AB_Value_dup(p_src->units);
131 }
132
133 /* member "unitPriceValue" */
134 if (p_struct->unitPriceValue) {
135 AB_Value_free(p_struct->unitPriceValue);
136 p_struct->unitPriceValue=NULL;
137 }
138 if (p_src->unitPriceValue) {
139 p_struct->unitPriceValue=AB_Value_dup(p_src->unitPriceValue);
140 }
141
142 /* member "unitPriceDate" */
143 if (p_struct->unitPriceDate) {
144 GWEN_Time_free(p_struct->unitPriceDate);
145 p_struct->unitPriceDate=NULL;
146 p_struct->unitPriceDate=NULL;
147 }
148 if (p_src->unitPriceDate) {
149 p_struct->unitPriceDate=GWEN_Time_dup(p_src->unitPriceDate);
150 }
151
152 return p_struct;
153 }
154
AB_Security_copy(AB_SECURITY * p_struct,const AB_SECURITY * p_src)155 AB_SECURITY *AB_Security_copy(AB_SECURITY *p_struct, const AB_SECURITY *p_src)
156 {
157 assert(p_struct);
158 assert(p_src);
159 /* member "name" */
160 if (p_struct->name) {
161 free(p_struct->name);
162 p_struct->name=NULL;
163 p_struct->name=NULL;
164 }
165 if (p_src->name) {
166 p_struct->name=strdup(p_src->name);
167 }
168
169 /* member "uniqueId" */
170 if (p_struct->uniqueId) {
171 free(p_struct->uniqueId);
172 p_struct->uniqueId=NULL;
173 p_struct->uniqueId=NULL;
174 }
175 if (p_src->uniqueId) {
176 p_struct->uniqueId=strdup(p_src->uniqueId);
177 }
178
179 /* member "nameSpace" */
180 if (p_struct->nameSpace) {
181 free(p_struct->nameSpace);
182 p_struct->nameSpace=NULL;
183 p_struct->nameSpace=NULL;
184 }
185 if (p_src->nameSpace) {
186 p_struct->nameSpace=strdup(p_src->nameSpace);
187 }
188
189 /* member "tickerSymbol" */
190 if (p_struct->tickerSymbol) {
191 free(p_struct->tickerSymbol);
192 p_struct->tickerSymbol=NULL;
193 p_struct->tickerSymbol=NULL;
194 }
195 if (p_src->tickerSymbol) {
196 p_struct->tickerSymbol=strdup(p_src->tickerSymbol);
197 }
198
199 /* member "units" */
200 if (p_struct->units) {
201 AB_Value_free(p_struct->units);
202 p_struct->units=NULL;
203 }
204 if (p_src->units) {
205 p_struct->units=AB_Value_dup(p_src->units);
206 }
207
208 /* member "unitPriceValue" */
209 if (p_struct->unitPriceValue) {
210 AB_Value_free(p_struct->unitPriceValue);
211 p_struct->unitPriceValue=NULL;
212 }
213 if (p_src->unitPriceValue) {
214 p_struct->unitPriceValue=AB_Value_dup(p_src->unitPriceValue);
215 }
216
217 /* member "unitPriceDate" */
218 if (p_struct->unitPriceDate) {
219 GWEN_Time_free(p_struct->unitPriceDate);
220 p_struct->unitPriceDate=NULL;
221 p_struct->unitPriceDate=NULL;
222 }
223 if (p_src->unitPriceDate) {
224 p_struct->unitPriceDate=GWEN_Time_dup(p_src->unitPriceDate);
225 }
226
227 return p_struct;
228 }
229
AB_Security_GetName(const AB_SECURITY * p_struct)230 const char *AB_Security_GetName(const AB_SECURITY *p_struct)
231 {
232 assert(p_struct);
233 return p_struct->name;
234 }
235
AB_Security_GetUniqueId(const AB_SECURITY * p_struct)236 const char *AB_Security_GetUniqueId(const AB_SECURITY *p_struct)
237 {
238 assert(p_struct);
239 return p_struct->uniqueId;
240 }
241
AB_Security_GetNameSpace(const AB_SECURITY * p_struct)242 const char *AB_Security_GetNameSpace(const AB_SECURITY *p_struct)
243 {
244 assert(p_struct);
245 return p_struct->nameSpace;
246 }
247
AB_Security_GetTickerSymbol(const AB_SECURITY * p_struct)248 const char *AB_Security_GetTickerSymbol(const AB_SECURITY *p_struct)
249 {
250 assert(p_struct);
251 return p_struct->tickerSymbol;
252 }
253
AB_Security_GetUnits(const AB_SECURITY * p_struct)254 const AB_VALUE *AB_Security_GetUnits(const AB_SECURITY *p_struct)
255 {
256 assert(p_struct);
257 return p_struct->units;
258 }
259
AB_Security_GetUnitPriceValue(const AB_SECURITY * p_struct)260 const AB_VALUE *AB_Security_GetUnitPriceValue(const AB_SECURITY *p_struct)
261 {
262 assert(p_struct);
263 return p_struct->unitPriceValue;
264 }
265
AB_Security_GetUnitPriceDate(const AB_SECURITY * p_struct)266 const GWEN_TIME *AB_Security_GetUnitPriceDate(const AB_SECURITY *p_struct)
267 {
268 assert(p_struct);
269 return p_struct->unitPriceDate;
270 }
271
AB_Security_SetName(AB_SECURITY * p_struct,const char * p_src)272 void AB_Security_SetName(AB_SECURITY *p_struct, const char *p_src)
273 {
274 assert(p_struct);
275 if (p_struct->name) {
276 free(p_struct->name);
277 p_struct->name=NULL;
278 }
279 if (p_src) {
280 p_struct->name=strdup(p_src);
281 }
282 else {
283 p_struct->name=NULL;
284 }
285 }
286
AB_Security_SetUniqueId(AB_SECURITY * p_struct,const char * p_src)287 void AB_Security_SetUniqueId(AB_SECURITY *p_struct, const char *p_src)
288 {
289 assert(p_struct);
290 if (p_struct->uniqueId) {
291 free(p_struct->uniqueId);
292 p_struct->uniqueId=NULL;
293 }
294 if (p_src) {
295 p_struct->uniqueId=strdup(p_src);
296 }
297 else {
298 p_struct->uniqueId=NULL;
299 }
300 }
301
AB_Security_SetNameSpace(AB_SECURITY * p_struct,const char * p_src)302 void AB_Security_SetNameSpace(AB_SECURITY *p_struct, const char *p_src)
303 {
304 assert(p_struct);
305 if (p_struct->nameSpace) {
306 free(p_struct->nameSpace);
307 p_struct->nameSpace=NULL;
308 }
309 if (p_src) {
310 p_struct->nameSpace=strdup(p_src);
311 }
312 else {
313 p_struct->nameSpace=NULL;
314 }
315 }
316
AB_Security_SetTickerSymbol(AB_SECURITY * p_struct,const char * p_src)317 void AB_Security_SetTickerSymbol(AB_SECURITY *p_struct, const char *p_src)
318 {
319 assert(p_struct);
320 if (p_struct->tickerSymbol) {
321 free(p_struct->tickerSymbol);
322 p_struct->tickerSymbol=NULL;
323 }
324 if (p_src) {
325 p_struct->tickerSymbol=strdup(p_src);
326 }
327 else {
328 p_struct->tickerSymbol=NULL;
329 }
330 }
331
AB_Security_SetUnits(AB_SECURITY * p_struct,const AB_VALUE * p_src)332 void AB_Security_SetUnits(AB_SECURITY *p_struct, const AB_VALUE *p_src)
333 {
334 assert(p_struct);
335 if (p_struct->units) {
336 AB_Value_free(p_struct->units);
337 }
338 if (p_src) {
339 p_struct->units=AB_Value_dup(p_src);
340 }
341 else {
342 p_struct->units=AB_Value_new();
343 }
344 }
345
AB_Security_SetUnitPriceValue(AB_SECURITY * p_struct,const AB_VALUE * p_src)346 void AB_Security_SetUnitPriceValue(AB_SECURITY *p_struct, const AB_VALUE *p_src)
347 {
348 assert(p_struct);
349 if (p_struct->unitPriceValue) {
350 AB_Value_free(p_struct->unitPriceValue);
351 }
352 if (p_src) {
353 p_struct->unitPriceValue=AB_Value_dup(p_src);
354 }
355 else {
356 p_struct->unitPriceValue=AB_Value_new();
357 }
358 }
359
AB_Security_SetUnitPriceDate(AB_SECURITY * p_struct,const GWEN_TIME * p_src)360 void AB_Security_SetUnitPriceDate(AB_SECURITY *p_struct, const GWEN_TIME *p_src)
361 {
362 assert(p_struct);
363 if (p_struct->unitPriceDate) {
364 GWEN_Time_free(p_struct->unitPriceDate);
365 p_struct->unitPriceDate=NULL;
366 }
367 if (p_src) {
368 p_struct->unitPriceDate=GWEN_Time_dup(p_src);
369 }
370 else {
371 p_struct->unitPriceDate=NULL;
372 }
373 }
374
375 /* list1 functions */
AB_Security_List_dup(const AB_SECURITY_LIST * p_src)376 AB_SECURITY_LIST *AB_Security_List_dup(const AB_SECURITY_LIST *p_src)
377 {
378 AB_SECURITY_LIST *p_dest;
379 AB_SECURITY *p_elem;
380
381 assert(p_src);
382 p_dest=AB_Security_List_new();
383 p_elem=AB_Security_List_First(p_src);
384 while (p_elem) {
385 AB_SECURITY *p_cpy;
386
387 p_cpy=AB_Security_dup(p_elem);
388 AB_Security_List_Add(p_cpy, p_dest);
389 p_elem=AB_Security_List_Next(p_elem);
390 }
391
392 return p_dest;
393 }
394
AB_Security_ReadDb(AB_SECURITY * p_struct,GWEN_DB_NODE * p_db)395 void AB_Security_ReadDb(AB_SECURITY *p_struct, GWEN_DB_NODE *p_db)
396 {
397 assert(p_struct);
398 /* member "name" */
399 if (p_struct->name) {
400 free(p_struct->name);
401 p_struct->name=NULL;
402 }
403 {
404 const char *s;
405 s=GWEN_DB_GetCharValue(p_db, "name", 0, NULL);
406 if (s)
407 p_struct->name=strdup(s);
408 }
409 if (p_struct->name==NULL) {
410 p_struct->name=NULL;
411 }
412
413 /* member "uniqueId" */
414 if (p_struct->uniqueId) {
415 free(p_struct->uniqueId);
416 p_struct->uniqueId=NULL;
417 }
418 {
419 const char *s;
420 s=GWEN_DB_GetCharValue(p_db, "uniqueId", 0, NULL);
421 if (s)
422 p_struct->uniqueId=strdup(s);
423 }
424 if (p_struct->uniqueId==NULL) {
425 p_struct->uniqueId=NULL;
426 }
427
428 /* member "nameSpace" */
429 if (p_struct->nameSpace) {
430 free(p_struct->nameSpace);
431 p_struct->nameSpace=NULL;
432 }
433 {
434 const char *s;
435 s=GWEN_DB_GetCharValue(p_db, "nameSpace", 0, NULL);
436 if (s)
437 p_struct->nameSpace=strdup(s);
438 }
439 if (p_struct->nameSpace==NULL) {
440 p_struct->nameSpace=NULL;
441 }
442
443 /* member "tickerSymbol" */
444 if (p_struct->tickerSymbol) {
445 free(p_struct->tickerSymbol);
446 p_struct->tickerSymbol=NULL;
447 }
448 {
449 const char *s;
450 s=GWEN_DB_GetCharValue(p_db, "tickerSymbol", 0, NULL);
451 if (s)
452 p_struct->tickerSymbol=strdup(s);
453 }
454 if (p_struct->tickerSymbol==NULL) {
455 p_struct->tickerSymbol=NULL;
456 }
457
458 /* member "units" */
459 if (p_struct->units) {
460 AB_Value_free(p_struct->units);
461 }
462 {
463 const char *s;
464 s=GWEN_DB_GetCharValue(p_db, "units", 0, NULL);
465 if (s)
466 p_struct->units=AB_Value_fromString(s);
467 else
468 p_struct->units=NULL;
469 }
470 if (p_struct->units==NULL) {
471 p_struct->units=AB_Value_new();
472 }
473
474 /* member "unitPriceValue" */
475 if (p_struct->unitPriceValue) {
476 AB_Value_free(p_struct->unitPriceValue);
477 }
478 {
479 const char *s;
480 s=GWEN_DB_GetCharValue(p_db, "unitPriceValue", 0, NULL);
481 if (s)
482 p_struct->unitPriceValue=AB_Value_fromString(s);
483 else
484 p_struct->unitPriceValue=NULL;
485 }
486 if (p_struct->unitPriceValue==NULL) {
487 p_struct->unitPriceValue=AB_Value_new();
488 }
489
490 /* member "unitPriceDate" */
491 if (p_struct->unitPriceDate) {
492 GWEN_Time_free(p_struct->unitPriceDate);
493 p_struct->unitPriceDate=NULL;
494 }
495 {
496 GWEN_DB_NODE *dbDest;
497 dbDest=GWEN_DB_GetGroup(p_db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "unitPriceDate");
498 if (dbDest)
499 p_struct->unitPriceDate=GWEN_Time_fromDb(dbDest);
500 }
501 if (p_struct->unitPriceDate==NULL) {
502 p_struct->unitPriceDate=NULL;
503 }
504
505 }
506
AB_Security_WriteDb(const AB_SECURITY * p_struct,GWEN_DB_NODE * p_db)507 int AB_Security_WriteDb(const AB_SECURITY *p_struct, GWEN_DB_NODE *p_db)
508 {
509 int p_rv;
510
511 assert(p_struct);
512 /* member "name" */
513 if (p_struct->name)
514 p_rv=GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "name", p_struct->name);
515 else {
516 GWEN_DB_DeleteVar(p_db, "name");
517 p_rv=0;
518 }
519 if (p_rv<0) {
520 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
521 return p_rv;
522 }
523
524 /* member "uniqueId" */
525 if (p_struct->uniqueId)
526 p_rv=GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "uniqueId", p_struct->uniqueId);
527 else {
528 GWEN_DB_DeleteVar(p_db, "uniqueId");
529 p_rv=0;
530 }
531 if (p_rv<0) {
532 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
533 return p_rv;
534 }
535
536 /* member "nameSpace" */
537 if (p_struct->nameSpace)
538 p_rv=GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "nameSpace", p_struct->nameSpace);
539 else {
540 GWEN_DB_DeleteVar(p_db, "nameSpace");
541 p_rv=0;
542 }
543 if (p_rv<0) {
544 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
545 return p_rv;
546 }
547
548 /* member "tickerSymbol" */
549 if (p_struct->tickerSymbol)
550 p_rv=GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "tickerSymbol", p_struct->tickerSymbol);
551 else {
552 GWEN_DB_DeleteVar(p_db, "tickerSymbol");
553 p_rv=0;
554 }
555 if (p_rv<0) {
556 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
557 return p_rv;
558 }
559
560 /* member "units" */
561 if (p_struct->units) {
562 GWEN_BUFFER *tbuf=GWEN_Buffer_new(0, 64, 0, 1);
563 AB_Value_toString(p_struct->units, tbuf);
564 p_rv=GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "units", GWEN_Buffer_GetStart(tbuf));
565 GWEN_Buffer_free(tbuf);
566 }
567 else {
568 GWEN_DB_DeleteVar(p_db, "units");
569 p_rv=0;
570 }
571 if (p_rv<0) {
572 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
573 return p_rv;
574 }
575
576 /* member "unitPriceValue" */
577 if (p_struct->unitPriceValue) {
578 GWEN_BUFFER *tbuf=GWEN_Buffer_new(0, 64, 0, 1);
579 AB_Value_toString(p_struct->unitPriceValue, tbuf);
580 p_rv=GWEN_DB_SetCharValue(p_db, GWEN_DB_FLAGS_OVERWRITE_VARS, "unitPriceValue", GWEN_Buffer_GetStart(tbuf));
581 GWEN_Buffer_free(tbuf);
582 }
583 else {
584 GWEN_DB_DeleteVar(p_db, "unitPriceValue");
585 p_rv=0;
586 }
587 if (p_rv<0) {
588 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
589 return p_rv;
590 }
591
592 /* member "unitPriceDate" */
593 if (p_struct->unitPriceDate) {
594 GWEN_DB_NODE *dbDest;
595 dbDest=GWEN_DB_GetGroup(p_db, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "unitPriceDate");
596 assert(dbDest);
597 p_rv=GWEN_Time_toDb(p_struct->unitPriceDate, dbDest);
598 }
599 else
600 p_rv=0;
601 if (p_rv<0) {
602 DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
603 return p_rv;
604 }
605
606 return 0;
607 }
608
AB_Security_fromDb(GWEN_DB_NODE * p_db)609 AB_SECURITY *AB_Security_fromDb(GWEN_DB_NODE *p_db)
610 {
611 AB_SECURITY *p_struct;
612 p_struct=AB_Security_new();
613 AB_Security_ReadDb(p_struct, p_db);
614 return p_struct;
615 }
616
AB_Security_toDb(const AB_SECURITY * p_struct,GWEN_DB_NODE * p_db)617 int AB_Security_toDb(const AB_SECURITY *p_struct, GWEN_DB_NODE *p_db)
618 {
619 return AB_Security_WriteDb(p_struct, p_db);
620 }
621
AB_Security_ReadXml(AB_SECURITY * p_struct,GWEN_XMLNODE * p_db)622 void AB_Security_ReadXml(AB_SECURITY *p_struct, GWEN_XMLNODE *p_db)
623 {
624 assert(p_struct);
625 /* member "name" */
626 if (p_struct->name) {
627 free(p_struct->name);
628 p_struct->name=NULL;
629 }
630 {
631 const char *s;
632 s=GWEN_XMLNode_GetCharValue(p_db, "name", NULL);
633 if (s)
634 p_struct->name=strdup(s);
635 }
636 if (p_struct->name==NULL) { /* preset member "name" if empty */
637 p_struct->name=NULL;
638 }
639
640 /* member "uniqueId" */
641 if (p_struct->uniqueId) {
642 free(p_struct->uniqueId);
643 p_struct->uniqueId=NULL;
644 }
645 {
646 const char *s;
647 s=GWEN_XMLNode_GetCharValue(p_db, "uniqueId", NULL);
648 if (s)
649 p_struct->uniqueId=strdup(s);
650 }
651 if (p_struct->uniqueId==NULL) { /* preset member "uniqueId" if empty */
652 p_struct->uniqueId=NULL;
653 }
654
655 /* member "nameSpace" */
656 if (p_struct->nameSpace) {
657 free(p_struct->nameSpace);
658 p_struct->nameSpace=NULL;
659 }
660 {
661 const char *s;
662 s=GWEN_XMLNode_GetCharValue(p_db, "nameSpace", NULL);
663 if (s)
664 p_struct->nameSpace=strdup(s);
665 }
666 if (p_struct->nameSpace==NULL) { /* preset member "nameSpace" if empty */
667 p_struct->nameSpace=NULL;
668 }
669
670 /* member "tickerSymbol" */
671 if (p_struct->tickerSymbol) {
672 free(p_struct->tickerSymbol);
673 p_struct->tickerSymbol=NULL;
674 }
675 {
676 const char *s;
677 s=GWEN_XMLNode_GetCharValue(p_db, "tickerSymbol", NULL);
678 if (s)
679 p_struct->tickerSymbol=strdup(s);
680 }
681 if (p_struct->tickerSymbol==NULL) { /* preset member "tickerSymbol" if empty */
682 p_struct->tickerSymbol=NULL;
683 }
684
685 /* member "units" */
686 if (p_struct->units) {
687 AB_Value_free(p_struct->units);
688 }
689 {
690 const char *s;
691 s=GWEN_XMLNode_GetCharValue(p_db, "units", NULL);
692 if (s)
693 p_struct->units=AB_Value_fromString(s);
694 else
695 p_struct->units=NULL;
696 }
697 if (p_struct->units==NULL) { /* preset member "units" if empty */
698 p_struct->units=AB_Value_new();
699 }
700
701 /* member "unitPriceValue" */
702 if (p_struct->unitPriceValue) {
703 AB_Value_free(p_struct->unitPriceValue);
704 }
705 {
706 const char *s;
707 s=GWEN_XMLNode_GetCharValue(p_db, "unitPriceValue", NULL);
708 if (s)
709 p_struct->unitPriceValue=AB_Value_fromString(s);
710 else
711 p_struct->unitPriceValue=NULL;
712 }
713 if (p_struct->unitPriceValue==NULL) { /* preset member "unitPriceValue" if empty */
714 p_struct->unitPriceValue=AB_Value_new();
715 }
716
717 /* member "unitPriceDate" */
718 if (p_struct->unitPriceDate) {
719 GWEN_Time_free(p_struct->unitPriceDate);
720 p_struct->unitPriceDate=NULL;
721 }
722 {
723 const char *s;
724 s=GWEN_XMLNode_GetCharValue(p_db, "unitPriceDate", NULL);
725 if (s && *s)
726 p_struct->unitPriceDate=GWEN_Time_fromString(s, "YYYY/MM/DD-hh:mm");
727 }
728 if (p_struct->unitPriceDate==NULL) { /* preset member "unitPriceDate" if empty */
729 p_struct->unitPriceDate=NULL;
730 }
731
732 }
733
AB_Security_WriteXml(const AB_SECURITY * p_struct,GWEN_XMLNODE * p_db)734 void AB_Security_WriteXml(const AB_SECURITY *p_struct, GWEN_XMLNODE *p_db)
735 {
736 assert(p_struct);
737 /* member "name" */
738 GWEN_XMLNode_SetCharValue(p_db, "name", p_struct->name);
739
740 /* member "uniqueId" */
741 GWEN_XMLNode_SetCharValue(p_db, "uniqueId", p_struct->uniqueId);
742
743 /* member "nameSpace" */
744 GWEN_XMLNode_SetCharValue(p_db, "nameSpace", p_struct->nameSpace);
745
746 /* member "tickerSymbol" */
747 GWEN_XMLNode_SetCharValue(p_db, "tickerSymbol", p_struct->tickerSymbol);
748
749 /* member "units" */
750 if (p_struct->units) {
751 GWEN_BUFFER *tbuf=GWEN_Buffer_new(0, 64, 0, 1);
752 AB_Value_toString(p_struct->units, tbuf);
753 GWEN_XMLNode_SetCharValue(p_db, "units", GWEN_Buffer_GetStart(tbuf));
754 GWEN_Buffer_free(tbuf);
755 }
756
757 /* member "unitPriceValue" */
758 if (p_struct->unitPriceValue) {
759 GWEN_BUFFER *tbuf=GWEN_Buffer_new(0, 64, 0, 1);
760 AB_Value_toString(p_struct->unitPriceValue, tbuf);
761 GWEN_XMLNode_SetCharValue(p_db, "unitPriceValue", GWEN_Buffer_GetStart(tbuf));
762 GWEN_Buffer_free(tbuf);
763 }
764
765 /* member "unitPriceDate" */
766 if (p_struct->unitPriceDate) {
767 GWEN_BUFFER *xbuf;
768 int rv;
769 xbuf=GWEN_Buffer_new(0, 32, 0, 1);
770 rv=GWEN_Time_toString(p_struct->unitPriceDate, "YYYY/MM/DD-hh:mm", xbuf);
771 if (rv>=0)
772 GWEN_XMLNode_SetCharValue(p_db, "unitPriceDate", GWEN_Buffer_GetStart(xbuf));
773 GWEN_Buffer_free(xbuf);
774 }
775
776 }
777
AB_Security_toXml(const AB_SECURITY * p_struct,GWEN_XMLNODE * p_db)778 void AB_Security_toXml(const AB_SECURITY *p_struct, GWEN_XMLNODE *p_db)
779 {
780 AB_Security_WriteXml(p_struct, p_db);
781 }
782
AB_Security_fromXml(GWEN_XMLNODE * p_db)783 AB_SECURITY *AB_Security_fromXml(GWEN_XMLNODE *p_db)
784 {
785 AB_SECURITY *p_struct;
786 p_struct=AB_Security_new();
787 AB_Security_ReadXml(p_struct, p_db);
788 return p_struct;
789 }
790
AB_Security_toHashString(const AB_SECURITY * p_struct,GWEN_BUFFER * p_buffer)791 void AB_Security_toHashString(const AB_SECURITY *p_struct, GWEN_BUFFER *p_buffer)
792 {
793 assert(p_struct);
794 /* member "name" */
795 if (p_struct->name)
796 GWEN_Buffer_AppendString(p_buffer, p_struct->name);
797 GWEN_Buffer_AppendByte(p_buffer, ':');
798 /* member "uniqueId" */
799 if (p_struct->uniqueId)
800 GWEN_Buffer_AppendString(p_buffer, p_struct->uniqueId);
801 GWEN_Buffer_AppendByte(p_buffer, ':');
802 /* member "nameSpace" */
803 if (p_struct->nameSpace)
804 GWEN_Buffer_AppendString(p_buffer, p_struct->nameSpace);
805 GWEN_Buffer_AppendByte(p_buffer, ':');
806 /* member "tickerSymbol" */
807 if (p_struct->tickerSymbol)
808 GWEN_Buffer_AppendString(p_buffer, p_struct->tickerSymbol);
809 GWEN_Buffer_AppendByte(p_buffer, ':');
810 /* member "units" */
811 if (p_struct->units) {
812 double d=AB_Value_GetValueAsDouble(p_struct->units);
813 char numbuf[32];
814 snprintf(numbuf, sizeof(numbuf)-1, "%.4f", d);
815 numbuf[sizeof(numbuf)-1]=0;
816 GWEN_Buffer_AppendString(p_buffer, numbuf);
817 }
818 GWEN_Buffer_AppendByte(p_buffer, ':');
819 /* member "unitPriceValue" */
820 if (p_struct->unitPriceValue) {
821 double d=AB_Value_GetValueAsDouble(p_struct->unitPriceValue);
822 char numbuf[32];
823 snprintf(numbuf, sizeof(numbuf)-1, "%.4f", d);
824 numbuf[sizeof(numbuf)-1]=0;
825 GWEN_Buffer_AppendString(p_buffer, numbuf);
826 }
827 GWEN_Buffer_AppendByte(p_buffer, ':');
828 /* member "unitPriceDate" */
829 if (p_struct->unitPriceDate)
830 GWEN_Time_toUtcString(p_struct->unitPriceDate, "YYYY/MM/DD-hh:mm", p_buffer);
831 GWEN_Buffer_AppendByte(p_buffer, ':');
832 }
833
AB_Security_List2__freeAll_cb(AB_SECURITY * t,void * user_data)834 static AB_SECURITY *AB_Security_List2__freeAll_cb(AB_SECURITY *t, void *user_data)
835 {
836 AB_Security_free(t);
837 return NULL;
838 }
AB_Security_List2_freeAll(AB_SECURITY_LIST2 * tl)839 int AB_Security_List2_freeAll(AB_SECURITY_LIST2 *tl)
840 {
841 if (tl) {
842 AB_Security_List2_ForEach(tl, AB_Security_List2__freeAll_cb, NULL);
843 AB_Security_List2_free(tl);
844 }
845 else {
846 DBG_ERROR(AQBANKING_LOGDOMAIN, "List missing");
847 return GWEN_ERROR_INVALID;
848 }
849 return 0;
850 }
851
852 /* code headers */
853
854