Rudiments
tablecollectioninlines.h
1// Copyright (c) 1999-2018 David Muse
2// See the COPYING file for more information
3
4template <class valuetype>
5inline
8 copycolumnnames(false) {
9}
10
11template <class valuetype>
12inline
15 copycolumnnames(c.copycolumnnames) {
16}
17
18template <class valuetype>
19inline
22 if (this!=&c) {
24 copycolumnnames=c.copycolumnnames;
25 }
26 return *this;
27}
28
29template <class valuetype>
30inline
33
34template <class valuetype>
35inline
37 return "table";
38}
39
40template <class valuetype>
41inline
43 return getRowCount()*getColumnCount();
44}
45
46template <class valuetype>
47inline
49 copycolumnnames=copy;
50}
51
52template <class valuetype>
53inline
55 return copycolumnnames;
56}
57
58template <class valuetype>
59inline
61 return write(&stdoutput);
62}
63
64template <class valuetype>
65inline
67 return writeJson(out,true);
68}
69
70template< class valuetype >
71inline
73 return writeJson(&stdoutput,true);
74}
75
76template< class valuetype >
77inline
79 return writeJson(&stdoutput,indent);
80}
81
82template< class valuetype >
83inline
85 return writeJson(out,true);
86}
87
88template< class valuetype >
89inline
91
92 ssize_t retval=0;
93
94 incOrErr(&retval,out->write('{'),1) &&
95 ((indent)?incOrErr(&retval,out->write("\n ",2),2):true) &&
96 incOrErr(&retval,out->write("\"c\":",4),4) &&
97 ((indent)?incOrErr(&retval,out->write(' '),1):true) &&
98 incOrErr(&retval,out->write('['),1);
99
100 for (uint64_t i=0; i<getColumnCount() && retval>-1; i++) {
101 ((i)?incOrErr(&retval,out->write(','),1):true) &&
102 ((indent)?incOrErr(&retval,
103 out->write("\n ",3),3):true) &&
104 incOrErr(&retval,this->writeJsonValue(out,getColumnName(i)));
105 }
106
107 ((indent)?incOrErr(&retval,out->write("\n ",2),2):true) &&
108 incOrErr(&retval,out->write("],",2),2) &&
109 ((indent)?incOrErr(&retval,out->write("\n ",2),2):true) &&
110 incOrErr(&retval,out->write("\"r\":",4),4) &&
111 ((indent)?incOrErr(&retval,out->write(' '),1):true) &&
112 incOrErr(&retval,out->write('['),1);
113
114 for (uint64_t i=0; i<getRowCount() && retval>-1; i++) {
115
116 ((i)?incOrErr(&retval,out->write(','),1):true) &&
117 ((indent)?incOrErr(&retval,
118 out->write("\n ",3),3):true) &&
119 incOrErr(&retval,out->write('['),1);
120
121 for (uint64_t j=0; j<getColumnCount() && retval>-1; j++) {
122 ((j)?incOrErr(&retval,out->write(','),1):true) &&
123 ((indent)?incOrErr(&retval,
124 out->write("\n ",4),4):true) &&
125 incOrErr(&retval,
126 this->writeJsonValue(out,getValue(i,j)));
127 }
128
129 ((indent)?incOrErr(&retval,
130 out->write("\n ",3),3):true) &&
131 incOrErr(&retval,out->write("]"),1);
132 }
133
134 ((indent)?incOrErr(&retval,out->write("\n ",2),2):true) &&
135 incOrErr(&retval,out->write("]"),1) &&
136 ((indent)?incOrErr(&retval,out->write('\n'),1):true);
137 incOrErr(&retval,out->write('}'),1) &&
138 ((indent)?incOrErr(&retval,out->write('\n'),1):true);
139
140 return retval;
141}
Definition avltree.h:11
avltreenode(valuetype value)
Definition avltreeinlines.h:555
valuetype getValue()
Definition avltreeinlines.h:578
Definition collection.h:11
collection & operator=(collection &c)
Definition collectioninlines.h:30
Definition output.h:11
virtual ssize_t write(const byte_t *string, size_t size)=0
Definition tablecollection.h:35
virtual ~tablecollection()
Definition tablecollectioninlines.h:31
virtual bool getCopyColumnNames()
Definition tablecollectioninlines.h:54
tablecollection & operator=(tablecollection &c)
Definition tablecollectioninlines.h:21
virtual const char * getType()
Definition tablecollectioninlines.h:36
virtual uint64_t getCount()
Definition tablecollectioninlines.h:42
virtual ssize_t writeJson()
Definition tablecollectioninlines.h:72
virtual void setCopyColumnNames(bool copy)
Definition tablecollectioninlines.h:48
tablecollection()
Definition tablecollectioninlines.h:6
virtual ssize_t write()
Definition tablecollectioninlines.h:60