Develop and Download Open Source Software

Browse CVS Repository

Contents of /xoonips/AL/criteria.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Sat Nov 27 01:08:08 2004 UTC (19 years, 4 months ago) by youi
Branch: MAIN
CVS Tags: mv_to_sourceforge_20050217, demo20050128
Changes since 1.2: +5 -1 lines
File MIME type: text/x-c++src
clearAll:orderbyのインスタンスの解放を追加した.

1 /*
2 * SQL絎?茵?腟???????我??絎?鐚?筝??号?帥???>散??膊∞??????criteria?????鴻???臂?/span>
3 *
4 * $Revision: 1.2 $
5 * $Log: criteria.cc,v $
6 * Revision 1.2 2004/11/27 00:39:57 youi
7 * orderby???潟?潟?鴻???????水????olumn?<?潟??紊??違??????????????菴遵??.
8 *
9 * Revision 1.1 2004/11/24 06:54:31 youi
10 * initial version
11 *
12 *
13 */
14 #include <stdlib.h>
15 #include <string.h>
16
17 #include "common.h"
18 #include "criteria.h"
19
20 /**
21 * SQL??RDERBY??┃絎???荐??吟??????????/span>
22 *
23 * @param column ????????
24 * @param order ????鐚?????????絎?(????絎??? orderby::ASC)
25 * @ref orderby::ASC
26 * @ref orderby::DESC
27 *
28 */
29 orderby::orderby( const char* column = "", int order = orderby::ASC ){
30 this -> column = 0;
31 setValue( &this -> column, column );
32 this -> order = order;
33 this -> next = 0;
34 }
35
36 /**
37 *
38 * ???鴻????????/span>
39 *
40 * ???????????<?≪???????????障????
41 *
42 */
43 orderby::~orderby( ){
44 delete this -> column;
45 }
46
47 /**
48 *
49 * ??????????菴???
50 * @return ????????
51 *
52 */
53 const char* orderby::getColumn( ) const { return column; }
54
55 /**
56 *
57 * ????鐚??障??????????菴???
58 * @return ????鐚??障????????
59 * @ref orderby::ASC
60 * @ref orderby::DESC
61 *
62 */
63 order_t orderby::getOrder( ) const{ return order; }
64
65 /**
66 *
67 * SQL????我??絎?(LIMIT)??鐚??純?若????(??????????????????)??膊∞??????????/span>
68 * ??
69 *
70 */
71 criteria::criteria( )
72 {
73 start = 0;
74 rows = 0;
75 indexOfOrders = 0;
76 ordersLen = 0;
77 ordersMax = 16;
78 orders = new orderby*[ ordersMax ];
79 memset( orders, 0, sizeof( orderby* ) * ordersMax );
80 }
81
82 /**
83 *
84 * ???鴻????????/span>
85 *
86 * addOrderBy?ц申??????orderby?ゃ?潟?鴻?帥?潟?鴻??В?障??茵?????
87 *
88 * @ref addOrderBy
89 *
90 */
91 criteria::~criteria( )
92 {
93 if( orders != 0 ){
94 for( int i = 0; i < ordersLen; i++ ) delete orders[ i ];
95 delete[] orders;
96 }
97 }
98
99 /**
100 *
101 * SQL絎?茵?腟??????????阪??????膀??蚊??鐚???紮?茵?????違?ф??絎?????.
102 *
103 * @param start ??紮?茵?
104 * @param rows 茵???/span>
105 *
106 */
107 void criteria::setLimit( int start , int rows )
108 {
109 this -> start = start;
110 this -> rows = rows;
111 }
112
113 /**
114 *
115 * ???????????>散??菴遵??????鐚?QL絎?茵???????????申???????????????????純??/span>
116 * ???>散??????鐚?/span>
117 *
118 * @param order orderby???≪??????/span>
119 *
120 */
121 void criteria::addOrderBy( orderby *order )
122 {
123 if( ordersMax == ordersLen ){
124 //orders?????c?宴???障?с???若?帥?????????э??≦宍????
125 orderby** ptr = new orderby*[ ordersMax * 2 ];
126 memset( ptr, 0, sizeof( orderby* ) * ordersMax * 2 );
127 memcpy( ptr, orders, sizeof( orderby* ) * ordersMax );
128 delete[] orders;
129 ordersMax *= 2;
130 orders = ptr;
131 }
132 orders[ ordersLen ] = order;
133 ordersLen++;
134 }
135
136 /**
137 *
138 * ??????rderby???????冴??. 2????札????rderby??extOrderBy?у????冴??.<br>
139 * ?祉?????∽?違???鴻???????????????絎???unsafe)?с??
140 *
141 * @return ??????rderby
142 * @return 0 ????篁ヤ???rderby??????
143 * @ref nextOrderBy
144 *
145 */
146 const orderby* criteria::headOrderBy( )
147 {
148 indexOfOrders = 0;
149 if( indexOfOrders >= ordersLen ) return 0;
150 return orders[ indexOfOrders++ ];
151 }
152
153 /**
154 *
155 * orderby???????冴??.<br>
156 * ?祉?????∽?違???鴻???????????????絎???unsafe)?с??
157 *
158 * @return orderby???ゃ?潟?鴻?帥?潟??/span>
159 * @return 0 ????篁ヤ???rderby??????
160 * @ref headNextOrderBy
161 *
162 */
163 const orderby* criteria::nextOrderBy( )
164 {
165 if( indexOfOrders >= ordersLen ) return 0;
166 return orders[ indexOfOrders++ ];
167 }
168
169 /**
170 *
171 * LIMIT荐??鐚???????RDERBY荐???????ゃ???障??.
172 *
173 */
174 void criteria::clearAll( )
175 {
176 for( int i = 0; i < ordersLen; i++ ) delete orders[ i ];
177 memset( orders, 0, sizeof( orderby* ) * ordersMax );
178 ordersLen = 0;
179 start = rows = 0;
180 }
181
182 /**
183 *
184 * LIMIT????紮?茵?
185 *
186 * @return
187 *
188 */
189 int criteria::getLimitStart( ) const { return start; }
190
191 /**
192 *
193 * LIMIT?????/span>
194 *
195 * @return
196 *
197 */
198 int criteria::getLimitRows( ) const{ return rows; }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26