Rudiments
dictionarycollectioninlines.h
1// Copyright (c) 1999-2018 David Muse
2// See the COPYING file for more information.
3
4#include <rudiments/private/new.h>
5
6template< class keytype, class valuetype >
7inline
9 return "dictionary";
10}
11
12template< class keytype, class valuetype >
13inline
15 return write(&stdoutput);
16}
17
18template< class keytype, class valuetype >
19inline
21 return writeJson(out,true);
22}
23
24template< class keytype, class valuetype >
25inline
27 return writeJson(&stdoutput,true);
28}
29
30template< class keytype, class valuetype >
31inline
33 return writeJson(&stdoutput,indent);
34}
35
36template< class keytype, class valuetype >
37inline
39 return writeJson(out,true);
40}
41
42template< class keytype, class valuetype >
43inline
45 bool indent) {
46 ssize_t retval=0;
47 uint64_t i=0;
48 listnode<keytype> *node=getKeys()->getFirst();
49 incOrErr(&retval,out->write('{'),1);
50 while (node && retval>-1) {
51 ((i)?incOrErr(&retval,out->write(','),1):true) &&
52 ((indent)?incOrErr(&retval,out->write("\n ",2),2):true) &&
53 incOrErr(&retval,
54 this->writeJsonValue(out,node->getValue())) &&
55 incOrErr(&retval,out->write(':'),1) &&
56 incOrErr(&retval,
57 this->writeJsonValue(out,getValue(node->getValue())));
58 node=node->getNext();
59 i++;
60 }
61 ((indent)?incOrErr(&retval,out->write('\n'),1):true) &&
62 incOrErr(&retval,out->write('}'),1) &&
63 ((indent)?incOrErr(&retval,out->write('\n'),1):true);
64 return retval;
65}
Definition avltree.h:11
avltreenode(valuetype value)
Definition avltreeinlines.h:555
treenode< valuetype > * getNext()
Definition avltreeinlines.h:671
valuetype getValue()
Definition avltreeinlines.h:578
virtual ssize_t writeJson()
Definition dictionarycollectioninlines.h:26
virtual ssize_t write()
Definition dictionarycollectioninlines.h:14
virtual const char * getType()
Definition dictionarycollectioninlines.h:8
Definition output.h:11
virtual ssize_t write(const byte_t *string, size_t size)=0