00001 // ----------------------------------------------------------------------^ 00002 // Copyright (C) 2004, 2005, 2006, 2007, 2008 Giorgio Calderone 00003 // (mailto: <gcalderone@ifc.inaf.it>) 00004 // 00005 // This file is part of MCS. 00006 // 00007 // MCS is free software; you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation; either version 2 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // MCS is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with MCS; if not, write to the Free Software 00019 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 // 00021 // ----------------------------------------------------------------------$ 00022 #include "mcs.hh" 00023 using namespace mcs; 00024 00025 00026 00027 //-------------------------------------------------------------------- 00028 mcs::Buffer::Buffer(enum BufferFreeOnDestroy freeBuffer) 00029 { 00030 buf = NULL; 00031 extbuffer = false; 00032 free(); 00033 00034 this->freebuffer = freeBuffer; 00035 } 00036 00037 00038 mcs::Buffer::Buffer(void* extbuf, unsigned int size, 00039 enum BufferFreeOnDestroy freeBuffer) 00040 { 00041 buf = NULL; 00042 extbuffer = false; 00043 free(); 00044 00045 buf = (char*) extbuf; 00046 bufsize = size; 00047 this->freebuffer = freeBuffer; 00048 extbuffer = true; 00049 } 00050 00051 00052 void mcs::Buffer::set(void* extbuf, unsigned int size, 00053 enum BufferFreeOnDestroy freeBuffer) 00054 { 00055 free(); 00056 00057 buf = (char*) extbuf; 00058 bufsize = size; 00059 this->freebuffer = freeBuffer; 00060 extbuffer = true; 00061 } 00062 00063 00064 mcs::Buffer::~Buffer() 00065 { free(); } 00066 00067 00068 void mcs::Buffer::free() 00069 { 00070 if ((freebuffer == AUTO_FREE) && buf) 00071 std::free(buf); 00072 00073 bufsize = 0; 00074 select = false; 00075 wstart = 0; 00076 wlen = 0; 00077 } 00078 00079 00080 00081 void mcs::Buffer::resize(unsigned int size) 00082 { 00083 if (extbuffer) 00084 if (bufsize < size) 00085 throw MCS_FATAL(MSG_NOT_ENOUGH_SPACE, size, bufsize); 00086 00087 select = false; 00088 if (bufsize == 0) { 00089 buf = (char*) malloc(size); 00090 bufsize = size; 00091 } 00092 else if (bufsize < size) { 00093 buf = (char*) realloc(buf, size); 00094 bufsize = size; 00095 } 00096 } 00097 00098 00099 00100 00101 Buffer& mcs::Buffer::operator()(unsigned int len) 00102 { 00103 wstart = -1; 00104 wlen = len; 00105 select = true; 00106 return *this; 00107 } 00108 00109 Buffer& mcs::Buffer::operator()(unsigned int start, unsigned int len) 00110 { 00111 wstart = start; 00112 wlen = len; 00113 select = true; 00114 return *this; 00115 } 00116 00117 00118 Buffer& mcs::Buffer::operator<<(const void* extbuf) 00119 { 00120 if (select) { 00121 if (wstart == (unsigned int) -1) { //Append to the end of the buffer 00122 unsigned int tt = bufsize; 00123 resize(bufsize + wlen); 00124 char* p = buf + tt; 00125 memcpy(p, extbuf, wlen); 00126 } 00127 else { //Write in the selected window 00128 resize(wstart + wlen); 00129 memcpy(buf + wstart, extbuf, wlen); 00130 } 00131 select = false; 00132 } 00133 else 00134 throw MCS_ERROR( MSG_NO_WINDOWS_SELECTED ); 00135 00136 return *this; 00137 } 00138 00139 00140 Buffer& mcs::Buffer::operator<<(istream& stream) 00141 { 00142 if (select) { 00143 if (wstart == (unsigned int) -1) 00144 wstart = 0; 00145 00146 stream.read(buf + wstart, wlen); 00147 select = false; 00148 } 00149 else { 00150 char tmp[2048]; 00151 while (! stream.eof()) { 00152 stream.read(tmp, 2048); 00153 int n = stream.gcount(); //Bytes read 00154 (*this)(n) << tmp; //Fill the buffer 00155 } 00156 } 00157 00158 return *this; 00159 } 00160 00161 00162 00163 00164 00165 Buffer& mcs::Buffer::operator>>(void* extbuf) 00166 { 00167 if (select) { 00168 if (wstart == (unsigned int) -1) 00169 wstart = 0; 00170 00171 memcpy(extbuf, buf + wstart, wlen); 00172 select = false; 00173 } 00174 else { 00175 memcpy(extbuf, buf, bufsize); 00176 } 00177 00178 return *this; 00179 } 00180 00181 00182 Buffer& mcs::Buffer::operator>>(ostream& stream) 00183 { 00184 if (select) { 00185 if (wstart == (unsigned int) -1) 00186 wstart = 0; 00187 00188 stream.write(buf + wstart, wlen); 00189 select = false; 00190 } 00191 else { 00192 stream.write(buf, bufsize); 00193 } 00194 00195 return *this; 00196 } 00197 00198 00199 char* mcs::Buffer::operator[](unsigned int pos) 00200 { 00201 if (pos > bufsize-1) 00202 throw MCS_ERROR( MSG_INVALID_POSITION, pos ); 00203 00204 return buf + pos; 00205 } 00206 00207 00208 unsigned int mcs::Buffer::size() 00209 { 00210 select = false; 00211 return bufsize; 00212 } 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 //-------------------------------------------------------------------- 00227 mcs::Record::Record(bool synchro) : 00228 Serializable(MCS_SERIAL_BUFFER), Synchro(), array(false), lmap(false) 00229 { 00230 synchronize(synchro); 00231 } 00232 00233 00234 mcs::Record::~Record() 00235 {} 00236 00237 00238 mcs::Record::Record(void* llbuf, bool synchro) : 00239 Serializable(MCS_SERIAL_BUFFER), Synchro(), array(false), lmap(false) 00240 { 00241 int i; 00242 char* lbuf = (char*) llbuf; 00243 unsigned short int count; 00244 00245 synchronize(synchro); 00246 00247 memcpy(&count, lbuf, sizeof(unsigned short int)); 00248 lbuf += sizeof(unsigned short int); 00249 00250 for (i=0; i<count; i++) { 00251 Data d(lbuf); 00252 addField(d); 00253 lbuf += d.objSize(); 00254 } 00255 } 00256 00257 00258 00259 mcs::Record::Record(Record& from) : 00260 Serializable(MCS_SERIAL_BUFFER), Synchro(), array(false), lmap(false) 00261 { 00262 for (int i=0; i<from.count(); i++) 00263 addField(from[i]); 00264 00265 setFieldMap(from); 00266 } 00267 00268 00269 Record& mcs::Record::operator=(Record& from) 00270 { 00271 clear(); 00272 for (int i=0; i<from.count(); i++) 00273 addField(from[i]); 00274 00275 setFieldMap(from); 00276 return *this; 00277 } 00278 00279 00280 00281 unsigned int mcs::Record::objSize() 00282 { 00283 unsigned int size = 0; 00284 int i; 00285 00286 size += sizeof(unsigned short int); //array.count() 00287 00288 for (i=0; i<count(); i++) { 00289 size += array[i].objSize(); //Data objects 00290 } 00291 00292 return size; 00293 } 00294 00295 00296 00297 00298 00299 bool mcs::Record::serialize_buffer(char*& buf, unsigned int& size) 00300 { 00301 unsigned short int lcount = count(), i; 00302 unsigned int chunk; 00303 Buffer abuf(DONT_FREE); //* 00304 00305 abuf(sizeof(lcount)) << &lcount; 00306 for (i=0; i< lcount; i++) { 00307 void* tmp = array[i].getEntireBuffer(chunk); 00308 abuf(chunk) << tmp; 00309 free(tmp); 00310 } 00311 00312 size = abuf.size(); 00313 buf = abuf[0]; 00314 return true; //* = will be freed when not needed anymore 00315 } 00316 00317 00318 00319 00320 //unsigned int mcs::Record::prepareBuffer(void** lbuf, unsigned int bufsize) 00321 //{ 00322 // unsigned int size = objSize(); 00323 // int i; 00324 // 00325 // MCS_CRITICAL_SECTION_BEGIN; 00326 // 00327 // if (*lbuf == NULL) //Allocate the buffer 00328 // *lbuf = malloc(size); 00329 // else 00330 // if (bufsize < size) 00331 // throw MCS_ERROR(MSG_NOT_ENOUGH_SPACE, bufsize, size); 00332 // 00333 // void* p = *lbuf; 00334 // unsigned short int lcount = count(); 00335 // p = my_mempcpy(p, &lcount, sizeof(unsigned short int)); 00336 // 00337 // unsigned int left = size - (((char*) p) - ((char*) *lbuf)); 00338 // for (i=0; i<lcount; i++) { 00339 // unsigned int s = array[i].prepareBuffer(&p, left); 00340 // (char*) p += s; 00341 // left -= s; 00342 // } 00343 // 00344 // MCS_CRITICAL_SECTION_END; 00345 // return size; 00346 //} 00347 00348 00349 00350 void mcs::Record::clear() 00351 { 00352 MCS_CRITICAL_SECTION_BEGIN; 00353 array.clear(); 00354 lmap.clear(); 00355 MCS_CRITICAL_SECTION_END; 00356 } 00357 00358 00359 int mcs::Record::count() 00360 { 00361 return array.count(); 00362 } 00363 00364 void mcs::Record::addField(Data* d) 00365 { 00366 MCS_CRITICAL_SECTION_BEGIN; 00367 int i = array.count(); lmap.push(i); 00368 array.push(d); 00369 MCS_CRITICAL_SECTION_END; 00370 } 00371 00372 void mcs::Record::addField(Data& d) 00373 { 00374 MCS_CRITICAL_SECTION_BEGIN; 00375 int i = array.count(); lmap.push(i); 00376 array.push(d); 00377 MCS_CRITICAL_SECTION_END; 00378 } 00379 00380 void mcs::Record::addField(string v, char tag) 00381 { 00382 Data d(v, tag); 00383 addField(d); 00384 } 00385 00386 void mcs::Record::addField(int v, char tag) 00387 { 00388 Data d(v, tag); 00389 addField(d); 00390 } 00391 00392 void mcs::Record::addField(long long int v, char tag) 00393 { 00394 Data d(v, tag); 00395 addField(d); 00396 } 00397 00398 void mcs::Record::addField(double v, char tag) 00399 { 00400 Data d(v, tag); 00401 addField(d); 00402 } 00403 00404 00405 Data mcs::Record::pop(int x) 00406 { 00407 MCS_CRITICAL_SECTION_BEGIN; 00408 00409 for (int i=x; i<lmap.count(); i++) 00410 lmap[i] = lmap[i] - 1; 00411 lmap.pop(x); 00412 Data d = array.pop(x); 00413 00414 MCS_CRITICAL_SECTION_END_RETURN(d); 00415 } 00416 00417 00418 00419 Data mcs::Record::field(string name) 00420 { 00421 MCS_CRITICAL_SECTION_BEGIN; 00422 00423 Data d = array.peek( posWhoseNameIs(name) ); 00424 00425 MCS_CRITICAL_SECTION_END_RETURN(d); 00426 } 00427 00428 00429 Data mcs::Record::field(int pos) 00430 { 00431 MCS_CRITICAL_SECTION_BEGIN; 00432 00433 Data d = array.peek( lmap[ pos ] ); 00434 00435 MCS_CRITICAL_SECTION_END_RETURN(d); 00436 } 00437 00438 00439 Data& mcs::Record::operator[](string name) 00440 { 00441 int pos = posWhoseNameIs(name); 00442 return array[ pos ]; 00443 } 00444 00445 00446 Data& mcs::Record::operator[](int pos) 00447 { 00448 pos = lmap[ pos ]; 00449 return array[ pos ]; 00450 } 00451 00452 00453 00454 00455 00456 00457 int mcs::Record::posWhoseNameIs(string name, enum ThrowExceptions throwexc) 00458 { 00459 int i; 00460 bool found = false; 00461 00462 for (i=0; i<count(); i++) 00463 if (array[i].name() == name) { 00464 found = true; 00465 break; 00466 } 00467 00468 if (found) 00469 return i; 00470 else 00471 if (throwexc) 00472 throw MCS_ERROR(MSG_MISSING_FIELD, name.csz); 00473 else 00474 return -1; 00475 } 00476 00477 00478 00479 00480 void mcs::Record::setFieldMap(string s) 00481 { 00482 unsigned int ui; 00483 s = trim(s); 00484 smap = s; 00485 00486 if (s.empty()) { 00487 for (ui=0; ui< (unsigned int) array.count(); ui++) 00488 lmap[ui] = ui; 00489 } 00490 else { 00491 s += " "; 00492 vector<string> vmap = split(s); 00493 00494 for (ui=0; ui<vmap.size(); ui++) 00495 lmap[ui] = posWhoseNameIs(vmap[ui]); 00496 } 00497 } 00498 00499 00500 void mcs::Record::setFieldMap(Record& rec) 00501 { 00502 int i; 00503 for (i=0; i<lmap.count(); i++) 00504 lmap[i] = rec.lmap[i]; 00505 } 00506 00507 00508 void mcs::Record::emptyName() 00509 { 00510 for (int i=0; i<count(); i++) 00511 operator[](i).emptyName(); 00512 } 00513 00514 00515 00516 void mcs::Record::setNull() 00517 { 00518 for (int i=0; i<count(); i++) 00519 operator[](i).setNull(); 00520 } 00521 00522 00523 00524 string mcs::Record::asString(string sep) 00525 { 00526 string ret; 00527 00528 for (int i=0; i<count(); i++) { 00529 ret += field(i).sval(); 00530 00531 if (i < count()-1) 00532 ret += sep; 00533 } 00534 00535 return ret; 00536 } 00537 00538 string mcs::Record::asStringNames(string sep) 00539 { 00540 string ret; 00541 00542 for (int i=0; i<count(); i++) { 00543 ret += field(i).name(); 00544 00545 if (i < count()-1) 00546 ret += sep; 00547 } 00548 00549 return ret; 00550 } 00551 00552 00553 string mcs::Record::asStringTypes(string sep) 00554 { 00555 string ret; 00556 00557 for (int i=0; i<count(); i++) { 00558 ret += Types2Str(field(i).type(), field(i).isUnsigned()); 00559 00560 if (i < count()-1) 00561 ret += sep; 00562 } 00563 00564 return ret; 00565 } 00566 00567 00568 00569 00570 00571 00572 00573 00574 00575 00576 //-------------------------------------------------------- 00577 mcs::RecordSet::RecordSet() : 00578 lmetarec(false), rs(false) 00579 { 00580 clear(); 00581 init(MCS_RS_INSERT); 00582 } 00583 00584 00585 mcs::RecordSet::~RecordSet() { 00586 clear(); 00587 } 00588 00589 00590 void mcs::RecordSet::setFieldMap(string s) 00591 { 00592 if (lusemetarec) 00593 lmetarec.setFieldMap(s); 00594 else 00595 throw; //ERROR 00596 } 00597 00598 00599 00600 00601 Record* mcs::RecordSet::newRecord() 00602 { 00603 Record* rec = new Record(false); 00604 00605 if (lusemetarec) { 00606 for (int i=0; i<lmetarec.count(); i++) { 00607 rec->addField( lmetarec[i] ); 00608 (*rec)[i].setNull(); 00609 (*rec)[i].emptyName(); 00610 } 00611 } 00612 00613 return rec; 00614 } 00615 00616 00617 void mcs::RecordSet::clear() 00618 { 00619 lid = 0; 00620 lknow_nrows = false; 00621 laccum = false; 00622 lrandom = false; 00623 lnrows = 0; 00624 00625 //Because the meta record will be filled before calling init() 00626 lusemetarec = true; 00627 00628 leof = true; 00629 lpos = 0; 00630 current = 0; 00631 00632 lmetarec.clear(); 00633 rs.clear(); 00634 } 00635 00636 00637 00638 void mcs::RecordSet::init(unsigned char code, unsigned int nrows, 00639 Record* meta, short int id) 00640 { 00641 clear(); 00642 00643 lid = id; 00644 00645 this->code = code; 00646 lknow_nrows = code & MCS_RS_KNOW_NROWS; 00647 laccum = code & MCS_RS_ACCUM; 00648 lrandom = code & MCS_RS_RANDOM; 00649 lusemetarec = code & MCS_RS_USEMETAREC; 00650 linsert = code & MCS_RS_INSERT; 00651 lfetch = ! linsert; 00652 00653 lnrows = nrows; 00654 00655 if (meta) 00656 lmetarec = *meta; 00657 00658 if (laccum) { 00659 lrandom = true; 00660 lknow_nrows = true; 00661 } 00662 00663 if (linsert) { 00664 laccum = true; //We always have all records 00665 lrandom = true; 00666 lknow_nrows = true; 00667 lnrows = 0; 00668 } 00669 } 00670 00671 00672 00673 void mcs::RecordSet::insert(Record* rec) { 00674 if (lfetch) 00675 throw MCS_ERROR( MSG_INSERT_NOT_ALLOWED ); 00676 00677 rs.push(rec); 00678 lnrows++; 00679 leof = false; 00680 } 00681 00682 00683 void mcs::RecordSet::insert(Record& rec) { 00684 if (lfetch) 00685 throw MCS_ERROR( MSG_INSERT_NOT_ALLOWED ); 00686 00687 rs.push(rec); 00688 lnrows++; 00689 leof = false; 00690 } 00691 00692 00693 void mcs::RecordSet::startFetch() { 00694 if ((lfetch) && (rs.count() == 0)) { //First time 00695 rs.push(newRecord()); //At least one record is needed 00696 00697 if (laccum) { 00698 lnrows = 0; 00699 leof = false; //See note in the startFetch() method 00700 while (fetch(lnrows, false)) { 00701 rs.push(newRecord()); 00702 lnrows++; 00703 leof = false; 00704 } 00705 00706 //laccum true implies lrandom=true and lknow_nrows=true 00707 //lrandom = true; 00708 //lknow_nrows = true; 00709 setFirst(); 00710 } 00711 else { 00712 leof = false; //This is because inside fetch() a derived class 00713 //must use the rec() method to access current 00714 //record. If leof is true the rec() method would 00715 //throw an exception. Anyway leof is not 00716 //accessible in derived classes. 00717 leof = ! fetch(0, false); 00718 } 00719 } 00720 } 00721 00722 00723 bool mcs::RecordSet::internal_fetch(unsigned int newpos) { 00724 if (lpos != newpos) { 00725 if (lusemetarec) 00726 rs[current].emptyName(); 00727 00728 if (laccum) { 00729 current = lpos = newpos; 00730 leof = (lpos == lnrows); //(lpos == (lnrows-1)); 00731 } 00732 else { 00733 leof = false; //See note in the startFetch() method 00734 leof = ! fetch(newpos, ( newpos == (lpos+1) ? false : true) ); 00735 lpos = newpos; 00736 } 00737 } 00738 00739 return ! leof; 00740 } 00741 00742 00743 bool mcs::RecordSet::fetch(unsigned int newpos, bool random) { 00744 if (lfetch) 00745 throw MCS_ERROR(MSG_METHOD_MUST_BE_OVERLOADED, "RecordSet::fetch"); 00746 00747 return false; 00748 } 00749 00750 00751 00752 00753 bool mcs::RecordSet::know_nRows() { return lknow_nrows; } 00754 00755 unsigned int mcs::RecordSet::nRows() { 00756 if (! lknow_nrows) 00757 throw MCS_ERROR( MSG_DONT_KNOW_NROWS ); 00758 00759 return lnrows; 00760 } 00761 00762 00763 00764 00765 int mcs::RecordSet::nFields() { 00766 if (rs.count() > 0) 00767 return rs[current].count(); 00768 else if (lusemetarec) 00769 return lmetarec.count(); 00770 else 00771 return 0; 00772 } 00773 00774 00775 unsigned int mcs::RecordSet::pos() { return lpos; } 00776 00777 bool mcs::RecordSet::eof() { return leof; } 00778 00779 bool mcs::RecordSet::alwaysSameStructure() { return lusemetarec; } 00780 00781 00782 Record& mcs::RecordSet::metarec() 00783 { 00784 if (! lusemetarec) 00785 throw MCS_ERROR( MSG_NO_METAREC ); 00786 00787 return lmetarec; 00788 } 00789 00790 00791 Record& RecordSet::rec() { 00792 if (leof) 00793 throw MCS_ERROR( MSG_ALREADY_AT_END_OF_FILE ); 00794 00795 if (lusemetarec) { 00796 for (int i=0; i<lmetarec.count(); i++) 00797 rs[current][i].setName( lmetarec[i].name() ); 00798 00799 rs[current].setFieldMap( lmetarec); 00800 } 00801 00802 return rs[current]; 00803 } 00804 00805 00806 00807 00808 00809 bool mcs::RecordSet::setNext() { 00810 if (leof) 00811 throw MCS_ERROR( MSG_ALREADY_AT_END_OF_FILE ); 00812 00813 return internal_fetch( lpos + 1 ); 00814 } 00815 00816 00817 bool mcs::RecordSet::setPrev() 00818 { 00819 if (! lrandom) 00820 throw MCS_ERROR( MSG_NOT_A_RANDOM_ACCESS_RECORDSET, "setPrev()" ); 00821 00822 if (lpos == 0) 00823 throw MCS_ERROR( MSG_ALREADY_AT_BEGIN_OF_FILE ); 00824 00825 return internal_fetch( lpos - 1 ); 00826 } 00827 00828 00829 bool mcs::RecordSet::setFirst() 00830 { 00831 if (! lrandom) 00832 throw MCS_ERROR( MSG_NOT_A_RANDOM_ACCESS_RECORDSET, "setFirst()" ); 00833 00834 return internal_fetch( 0 ); 00835 } 00836 00837 00838 00839 bool mcs::RecordSet::setLast() { 00840 if (! lrandom) 00841 throw MCS_ERROR( MSG_NOT_A_RANDOM_ACCESS_RECORDSET, "setLast()" ); 00842 00843 if (! lknow_nrows) 00844 throw MCS_ERROR( MSG_DONT_KNOW_NROWS ); 00845 00846 return internal_fetch( lnrows - 1 ); 00847 } 00848 00849 00850 bool mcs::RecordSet::setPos(unsigned int newpos) 00851 { 00852 if (! lrandom) 00853 throw MCS_ERROR( MSG_NOT_A_RANDOM_ACCESS_RECORDSET, "setPos()" ); 00854 00855 if (! lknow_nrows) 00856 throw MCS_ERROR( MSG_DONT_KNOW_NROWS ); 00857 00858 if (newpos >= lnrows) 00859 throw MCS_ERROR( MSG_INDEX_OUT_RANGE, newpos, lnrows ); 00860 00861 return internal_fetch( newpos ); 00862 } 00863 00864 00865 bool mcs::RecordSet::setWhere(int field, string equalTo) 00866 { 00867 if (field < 0) 00868 throw MCS_ERROR(MSG_INVALID_POSITION, field); 00869 00870 if (field >= nFields()) 00871 throw MCS_ERROR(MSG_INDEX_OUT_RANGE, field, nFields()); 00872 00873 if (! alwaysSameStructure()) 00874 throw MCS_ERROR( MSG_NO_SAME_META_INFO ); 00875 00876 bool found = false; 00877 00878 if (lrandom) 00879 setFirst(); 00880 00881 do { 00882 if (rec()[field].sval() == equalTo) { 00883 found = true; 00884 break; 00885 } 00886 } 00887 while (setNext()); 00888 00889 return found; 00890 } 00891 00892 00893 00894 bool mcs::RecordSet::setWhere(int field, int equalTo) 00895 { 00896 if (field < 0) 00897 throw MCS_ERROR(MSG_INVALID_POSITION, field); 00898 00899 if (field >= nFields()) 00900 throw MCS_ERROR(MSG_INDEX_OUT_RANGE, field, nFields()); 00901 00902 if (! alwaysSameStructure()) 00903 throw MCS_ERROR( MSG_NO_SAME_META_INFO ); 00904 00905 bool found = false; 00906 00907 if (lrandom) 00908 setFirst(); 00909 00910 do { 00911 if (rec()[field].ival() == equalTo) { 00912 found = true; 00913 break; 00914 } 00915 } 00916 while (setNext()); 00917 00918 return found; 00919 } 00920 00921 00922 00923 00924 void mcs::RecordSet::dump(string fn) { 00925 hk_dump(fn); 00926 } 00927 00928 void mcs::RecordSet::hk_dump(string fn) {} 00929 00930 00931 Record* mcs::RecordSet::prepRecToSend() 00932 { 00933 Record* ret = new Record(false); 00934 long int nrows = (long int) lnrows; 00935 00936 Data d(nrows); 00937 d.setTag(code); 00938 00939 ret->addField(d); 00940 00941 if (lusemetarec) 00942 for (int i=0; i<lmetarec.count(); i++) 00943 ret->addField(lmetarec[i]); 00944 00945 return ret; 00946 } 00947 00948
![]() |
MCS (My Customizable Server) ver. 0.3.3-alpha3
|