Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TBufferSQL.cxx
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Philippe Canal and al. 08/2004
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TBufferSQL
13 \ingroup tree
14 Implement TBuffer for a SQL backend.
15 */
16 
17 #include <stdio.h>
18 #include "Riostream.h"
19 #include "TError.h"
20 
21 #include "TBasketSQL.h"
22 #include "TBufferSQL.h"
23 #include "TSQLResult.h"
24 #include "TSQLRow.h"
25 #include <stdlib.h>
26 
27 ClassImp(TBufferSQL);
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// Constructor.
31 
32 TBufferSQL::TBufferSQL(TBuffer::EMode mode, std::vector<Int_t> *vc,
33  TString *insert_query, TSQLRow ** r) :
34  TBufferFile(mode),
35  fColumnVec(vc), fInsertQuery(insert_query), fRowPtr(r)
36 {
37  fIter = fColumnVec->begin();
38 }
39 
40 ////////////////////////////////////////////////////////////////////////////////
41 /// Constructor.
42 
43 TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsiz, std::vector<Int_t> *vc,
44  TString *insert_query, TSQLRow ** r) :
45  TBufferFile(mode,bufsiz),
46  fColumnVec(vc), fInsertQuery(insert_query), fRowPtr(r)
47 {
48  fIter = fColumnVec->begin();
49 }
50 
51 ////////////////////////////////////////////////////////////////////////////////
52 /// Constructor.
53 
54 TBufferSQL::TBufferSQL(TBuffer::EMode mode, Int_t bufsiz, std::vector<Int_t> *vc,
55  TString *insert_query, TSQLRow ** r,
56  void *buf, Bool_t adopt) :
57  TBufferFile(mode,bufsiz,buf,adopt),
58  fColumnVec(vc), fInsertQuery(insert_query), fRowPtr(r)
59 {
60  fIter = fColumnVec->begin();
61 }
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// Constructor.
65 
66 TBufferSQL::TBufferSQL() : TBufferFile(), fColumnVec(0),fInsertQuery(0),fRowPtr(0)
67 {
68 }
69 
70 ////////////////////////////////////////////////////////////////////////////////
71 /// Destructor.
72 
73 TBufferSQL::~TBufferSQL()
74 {
75  delete fColumnVec;
76 }
77 
78 ////////////////////////////////////////////////////////////////////////////////
79 /// Operator>>
80 
81 void TBufferSQL::ReadBool(Bool_t &b)
82 {
83  b = (Bool_t)atoi((*fRowPtr)->GetField(*fIter));
84 
85  if (fIter != fColumnVec->end()) ++fIter;
86 }
87 
88 ////////////////////////////////////////////////////////////////////////////////
89 /// Operator>>
90 
91 void TBufferSQL::ReadChar(Char_t &c)
92 {
93  c = (Char_t)atoi((*fRowPtr)->GetField(*fIter));
94 
95  if (fIter != fColumnVec->end()) ++fIter;
96 }
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// Operator>>
100 
101 void TBufferSQL::ReadShort(Short_t &h)
102 {
103  h = (Short_t)atoi((*fRowPtr)->GetField(*fIter));
104 
105  if (fIter != fColumnVec->end()) ++fIter;
106 }
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 /// Operator>>
110 
111 void TBufferSQL::ReadInt(Int_t &i)
112 {
113  i = atoi((*fRowPtr)->GetField(*fIter));
114 
115  if (fIter != fColumnVec->end()) ++fIter;
116 }
117 
118 ////////////////////////////////////////////////////////////////////////////////
119 /// Operator>>
120 
121 void TBufferSQL::ReadFloat(Float_t &f)
122 {
123  f = atof((*fRowPtr)->GetField(*fIter));
124 
125  if (fIter != fColumnVec->end()) ++fIter;
126 }
127 
128 ////////////////////////////////////////////////////////////////////////////////
129 /// Operator>>
130 
131 void TBufferSQL::ReadLong(Long_t &l)
132 {
133  l = atol((*fRowPtr)->GetField(*fIter));
134 
135  if (fIter != fColumnVec->end()) ++fIter;
136 }
137 
138 ////////////////////////////////////////////////////////////////////////////////
139 /// Operator>>
140 
141 void TBufferSQL::ReadDouble(Double_t &d)
142 {
143  d = atof((*fRowPtr)->GetField(*fIter));
144 
145  if (fIter != fColumnVec->end()) ++fIter;
146 }
147 
148 ////////////////////////////////////////////////////////////////////////////////
149 /// Operator<<
150 
151 void TBufferSQL::WriteBool(Bool_t b)
152 {
153  (*fInsertQuery) += b;
154  (*fInsertQuery) += ",";
155  if (fIter != fColumnVec->end()) ++fIter;
156 }
157 
158 ////////////////////////////////////////////////////////////////////////////////
159 /// Operator<<
160 
161 void TBufferSQL::WriteChar(Char_t c)
162 {
163  (*fInsertQuery) += c;
164  (*fInsertQuery) += ",";
165  if (fIter != fColumnVec->end()) ++fIter;
166 }
167 
168 ////////////////////////////////////////////////////////////////////////////////
169 /// Operator<<
170 
171 void TBufferSQL::WriteShort(Short_t h)
172 {
173  (*fInsertQuery) += h;
174  (*fInsertQuery) += ",";
175  if (fIter != fColumnVec->end()) ++fIter;
176 }
177 
178 ////////////////////////////////////////////////////////////////////////////////
179 /// Operator<<
180 
181 void TBufferSQL::WriteInt(Int_t i)
182 {
183  (*fInsertQuery) += i;
184  (*fInsertQuery) += ",";
185  if (fIter != fColumnVec->end()) ++fIter;
186 }
187 
188 ////////////////////////////////////////////////////////////////////////////////
189 /// Operator<<
190 
191 void TBufferSQL::WriteLong(Long_t l)
192 {
193  (*fInsertQuery) += l;
194  (*fInsertQuery) += ",";
195  if (fIter != fColumnVec->end()) ++fIter;
196 }
197 
198 ////////////////////////////////////////////////////////////////////////////////
199 /// Operator<<
200 
201 void TBufferSQL::WriteFloat(Float_t f)
202 {
203  (*fInsertQuery) += f;
204  (*fInsertQuery) += ",";
205  if (fIter != fColumnVec->end()) ++fIter;
206 }
207 
208 ////////////////////////////////////////////////////////////////////////////////
209 /// Operator<<
210 
211 void TBufferSQL::WriteDouble(Double_t d)
212 {
213  (*fInsertQuery) += d;
214  (*fInsertQuery) += ",";
215  if (fIter != fColumnVec->end()) ++fIter;
216 }
217 
218 ////////////////////////////////////////////////////////////////////////////////
219 /// Operator>>
220 
221 void TBufferSQL::ReadUChar(UChar_t& uc)
222 {
223  uc = (UChar_t)atoi((*fRowPtr)->GetField(*fIter));
224 
225  if (fIter != fColumnVec->end()) ++fIter;
226 }
227 
228 ////////////////////////////////////////////////////////////////////////////////
229 /// Operator>>
230 
231 void TBufferSQL::ReadUShort(UShort_t& us)
232 {
233  us = (UShort_t)atoi((*fRowPtr)->GetField(*fIter));
234 
235  if (fIter != fColumnVec->end()) ++fIter;
236 }
237 
238 ////////////////////////////////////////////////////////////////////////////////
239 /// Operator>>
240 
241 void TBufferSQL::ReadUInt(UInt_t& ui)
242 {
243  TString val = (*fRowPtr)->GetField(*fIter);
244  Int_t code = sscanf(val.Data(), "%u",&ui);
245  if(code == 0) Error("operator>>(UInt_t&)","Error reading UInt_t");
246 
247  if (fIter != fColumnVec->end()) ++fIter;
248 }
249 
250 ////////////////////////////////////////////////////////////////////////////////
251 /// Operator>>
252 
253 void TBufferSQL::ReadULong(ULong_t& ul)
254 {
255  TString val = (*fRowPtr)->GetField(*fIter);
256  Int_t code = sscanf(val.Data(), "%lu",&ul);
257  if(code == 0) Error("operator>>(ULong_t&)","Error reading ULong_t");
258 
259  if (fIter != fColumnVec->end()) ++fIter;
260 }
261 
262 ////////////////////////////////////////////////////////////////////////////////
263 /// Operator>>
264 
265 void TBufferSQL::ReadLong64(Long64_t &ll)
266 {
267  TString val = (*fRowPtr)->GetField(*fIter);
268  Int_t code = sscanf(val.Data(), "%lld",&ll);
269  if(code == 0) Error("operator>>(ULong_t&)","Error reading Long64_t");
270 
271  if (fIter != fColumnVec->end()) ++fIter;
272 }
273 
274 ////////////////////////////////////////////////////////////////////////////////
275 /// Operator>>
276 
277 void TBufferSQL::ReadULong64(ULong64_t &ull)
278 {
279  TString val = (*fRowPtr)->GetField(*fIter);
280  Int_t code = sscanf(val.Data(), "%llu",&ull);
281  if(code == 0) Error("operator>>(ULong_t&)","Error reading ULong64_t");
282 
283  if (fIter != fColumnVec->end()) ++fIter;
284 }
285 
286 ////////////////////////////////////////////////////////////////////////////////
287 /// Operator>>
288 
289 void TBufferSQL::ReadCharP(Char_t *str)
290 {
291  strcpy(str,(*fRowPtr)->GetField(*fIter)); // Legacy interface, we have no way to know the user's buffer size ....
292  if (fIter != fColumnVec->end()) ++fIter;
293 }
294 
295 ////////////////////////////////////////////////////////////////////////////////
296 /// Read a TString
297 
298 void TBufferSQL::ReadTString(TString &s)
299 {
300  s = (*fRowPtr)->GetField(*fIter);
301  if (fIter != fColumnVec->end()) ++fIter;
302 }
303 
304 ////////////////////////////////////////////////////////////////////////////////
305 /// Write a TString
306 
307 void TBufferSQL::WriteTString(const TString &s)
308 {
309  (*fInsertQuery) += s;
310  (*fInsertQuery) += ",";
311  if (fIter != fColumnVec->end()) ++fIter;
312 }
313 
314 
315 
316 ////////////////////////////////////////////////////////////////////////////////
317 /// Read a std::string
318 
319 void TBufferSQL::ReadStdString(std::string *s)
320 {
321  TBufferFile::ReadStdString(s);
322 }
323 
324 ////////////////////////////////////////////////////////////////////////////////
325 /// Write a std::string
326 
327 void TBufferSQL::WriteStdString(const std::string *s)
328 {
329  TBufferFile::WriteStdString(s);
330 }
331 
332 ////////////////////////////////////////////////////////////////////////////////
333 /// Read a char* string
334 
335 void TBufferSQL::ReadCharStar(char* &s)
336 {
337  TBufferFile::ReadCharStar(s);
338 }
339 
340 ////////////////////////////////////////////////////////////////////////////////
341 /// Write a char* string
342 
343 void TBufferSQL::WriteCharStar(char *s)
344 {
345  TBufferFile::WriteCharStar(s);
346 }
347 
348 
349 // Method to send to database.
350 
351 ////////////////////////////////////////////////////////////////////////////////
352 /// Operator<<
353 
354 void TBufferSQL::WriteUChar(UChar_t uc)
355 {
356  (*fInsertQuery) += uc;
357  (*fInsertQuery) += ",";
358  ++fIter;
359 }
360 
361 ////////////////////////////////////////////////////////////////////////////////
362 /// Operator<<
363 
364 void TBufferSQL::WriteUShort(UShort_t us)
365 {
366  (*fInsertQuery) += us;
367  (*fInsertQuery) += ",";
368  ++fIter;
369 }
370 
371 ////////////////////////////////////////////////////////////////////////////////
372 /// Operator<<
373 
374 void TBufferSQL::WriteUInt(UInt_t ui)
375 {
376  (*fInsertQuery) += ui;
377  (*fInsertQuery) += ",";
378  ++fIter;
379 }
380 
381 ////////////////////////////////////////////////////////////////////////////////
382 /// Operator<<
383 
384 void TBufferSQL::WriteULong(ULong_t ul)
385 {
386  (*fInsertQuery) += ul;
387  (*fInsertQuery) += ",";
388  ++fIter;
389 }
390 
391 ////////////////////////////////////////////////////////////////////////////////
392 /// Operator<<
393 
394 void TBufferSQL::WriteLong64(Long64_t ll)
395 {
396  (*fInsertQuery) += ll;
397  (*fInsertQuery) += ",";
398  ++fIter;
399 }
400 
401 ////////////////////////////////////////////////////////////////////////////////
402 /// Operator<<
403 
404 void TBufferSQL::WriteULong64(ULong64_t ull)
405 {
406  (*fInsertQuery) += ull;
407  (*fInsertQuery) += ",";
408  ++fIter;
409 }
410 
411 ////////////////////////////////////////////////////////////////////////////////
412 /// Operator<<
413 
414 void TBufferSQL::WriteCharP(const Char_t *str)
415 {
416  (*fInsertQuery) += "\"";
417  (*fInsertQuery) += str;
418  (*fInsertQuery) += "\",";
419  ++fIter;
420 }
421 
422 ////////////////////////////////////////////////////////////////////////////////
423 /// WriteFastArray SQL implementation.
424 
425 void TBufferSQL::WriteFastArray(const Bool_t *b, Int_t n)
426 {
427  for(int i=0; i<n; ++i) {
428  (*fInsertQuery) += b[i];
429  (*fInsertQuery) += ",";
430  ++fIter;
431  }
432 }
433 
434 ////////////////////////////////////////////////////////////////////////////////
435 /// WriteFastArray SQL implementation.
436 
437 void TBufferSQL::WriteFastArray(const Char_t *c, Int_t n)
438 {
439  for(int i=0; i<n; ++i) {
440  (*fInsertQuery) += (Short_t)c[i];
441  (*fInsertQuery) += ",";
442  ++fIter;
443  }
444 }
445 
446 ////////////////////////////////////////////////////////////////////////////////
447 /// WriteFastArray SQL implementation.
448 
449 void TBufferSQL::WriteFastArrayString(const Char_t *c, Int_t /* n */)
450 {
451  (*fInsertQuery) += "\"";
452  (*fInsertQuery) += c;
453  (*fInsertQuery) += "\",";
454  ++fIter;
455 }
456 
457 ////////////////////////////////////////////////////////////////////////////////
458 /// WriteFastArray SQL implementation.
459 
460 void TBufferSQL::WriteFastArray(const UChar_t *uc, Int_t n)
461 {
462  for(int i=0; i<n; ++i) {
463  (*fInsertQuery) += uc[i];
464  (*fInsertQuery) += ",";
465  ++fIter;
466  }
467 }
468 
469 ////////////////////////////////////////////////////////////////////////////////
470 /// WriteFastArray SQL implementation.
471 
472 void TBufferSQL::WriteFastArray(const Short_t *h, Int_t n)
473 {
474  for(int i=0; i<n; ++i) {
475  (*fInsertQuery) += h[i];
476  (*fInsertQuery) += ",";
477  ++fIter;
478  }
479 }
480 
481 ////////////////////////////////////////////////////////////////////////////////
482 /// WriteFastArray SQL implementation.
483 
484 void TBufferSQL::WriteFastArray(const UShort_t *us, Int_t n)
485 {
486  for(int i=0; i<n; ++i) {
487  (*fInsertQuery) += us[i];
488  (*fInsertQuery) += ",";
489  ++fIter;
490  }
491 }
492 
493 ////////////////////////////////////////////////////////////////////////////////
494 /// WriteFastArray SQL implementation.
495 
496 void TBufferSQL::WriteFastArray(const Int_t *ii, Int_t n)
497 {
498  // std::cerr << "Column: " <<*fIter << " i:" << *ii << std::endl;
499  for(int i=0; i<n; ++i) {
500  (*fInsertQuery) += ii[i];
501  (*fInsertQuery) += ",";
502  ++fIter;
503  }
504 }
505 
506 ////////////////////////////////////////////////////////////////////////////////
507 /// WriteFastArray SQL implementation.
508 
509 void TBufferSQL::WriteFastArray(const UInt_t *ui, Int_t n)
510 {
511  for(int i=0; i<n; ++i) {
512  (*fInsertQuery) += ui[i];
513  (*fInsertQuery) += ",";
514  ++fIter;
515  }
516 }
517 
518 ////////////////////////////////////////////////////////////////////////////////
519 /// WriteFastArray SQL implementation.
520 
521 void TBufferSQL::WriteFastArray(const Long_t *l, Int_t n)
522 {
523  for(int i=0; i<n; ++i) {
524  (*fInsertQuery)+= l[i];
525  (*fInsertQuery)+= ",";
526  ++fIter;
527  }
528 }
529 
530 ////////////////////////////////////////////////////////////////////////////////
531 /// WriteFastArray SQL implementation.
532 
533 void TBufferSQL::WriteFastArray(const ULong_t *ul, Int_t n)
534 {
535  for(int i=0; i<n; ++i) {
536  (*fInsertQuery) += ul[i];
537  (*fInsertQuery) += ",";
538  ++fIter;
539  }
540 }
541 
542 ////////////////////////////////////////////////////////////////////////////////
543 /// WriteFastArray SQL implementation.
544 
545 void TBufferSQL::WriteFastArray(const Long64_t *l, Int_t n)
546 {
547  for(int i=0; i<n; ++i) {
548  (*fInsertQuery) += l[i];
549  (*fInsertQuery) += ",";
550  ++fIter;
551  }
552 }
553 
554 ////////////////////////////////////////////////////////////////////////////////
555 /// WriteFastArray SQL implementation.
556 
557 void TBufferSQL::WriteFastArray(const ULong64_t *ul, Int_t n)
558 {
559  for(int i=0; i<n; ++i) {
560  (*fInsertQuery) += ul[i];
561  (*fInsertQuery) += ",";
562  ++fIter;
563  }
564 }
565 
566 ////////////////////////////////////////////////////////////////////////////////
567 /// WriteFastArray SQL implementation.
568 
569 void TBufferSQL::WriteFastArray(const Float_t *f, Int_t n)
570 {
571  for(int i=0; i<n; ++i) {
572  (*fInsertQuery) += f[i];
573  (*fInsertQuery) += ",";
574  ++fIter;
575  }
576 }
577 
578 ////////////////////////////////////////////////////////////////////////////////
579 /// WriteFastArray SQL implementation.
580 
581 void TBufferSQL::WriteFastArray(const Double_t *d, Int_t n)
582 {
583  for(int i=0; i<n; ++i) {
584  (*fInsertQuery) += d[i];
585  (*fInsertQuery )+= ",";
586  ++fIter;
587  }
588 }
589 
590 ////////////////////////////////////////////////////////////////////////////////
591 /// WriteFastArray SQL implementation.
592 
593 void TBufferSQL::WriteFastArray(void*, const TClass*, Int_t, TMemberStreamer *)
594 {
595  Fatal("WriteFastArray(void*, const TClass*, Int_t, TMemberStreamer *)","Not implemented yet");
596 }
597 
598 ////////////////////////////////////////////////////////////////////////////////
599 /// WriteFastArray SQL implementation.
600 
601 Int_t TBufferSQL::WriteFastArray(void **, const TClass*, Int_t, Bool_t, TMemberStreamer*)
602 {
603  Fatal("WriteFastArray(void **, const TClass*, Int_t, Bool_t, TMemberStreamer*)","Not implemented yet");
604  return 0;
605 }
606 
607 ////////////////////////////////////////////////////////////////////////////////
608 /// ReadFastArray SQL implementation.
609 
610 void TBufferSQL::ReadFastArray(Bool_t *b, Int_t n)
611 {
612  for(int i=0; i<n; ++i) {
613  b[i] = (Bool_t)atoi((*fRowPtr)->GetField(*fIter));
614  ++fIter;
615  }
616 }
617 
618 ////////////////////////////////////////////////////////////////////////////////
619 /// ReadFastArray SQL implementation.
620 
621 void TBufferSQL::ReadFastArray(Char_t *c, Int_t n)
622 {
623  for(int i=0; i<n; ++i) {
624  c[i] = (Char_t)atoi((*fRowPtr)->GetField(*fIter));
625  ++fIter;
626  }
627 }
628 
629 ////////////////////////////////////////////////////////////////////////////////
630 /// ReadFastArray SQL implementation.
631 
632 void TBufferSQL::ReadFastArrayString(Char_t *c, Int_t /* n */)
633 {
634  strcpy(c,((*fRowPtr)->GetField(*fIter)));
635  ++fIter;
636 }
637 
638 ////////////////////////////////////////////////////////////////////////////////
639 /// ReadFastArray SQL implementation.
640 
641 void TBufferSQL::ReadFastArray(UChar_t *uc, Int_t n)
642 {
643  for(int i=0; i<n; ++i) {
644  uc[i] = (UChar_t)atoi((*fRowPtr)->GetField(*fIter));
645  ++fIter;
646  }
647 }
648 
649 ////////////////////////////////////////////////////////////////////////////////
650 /// ReadFastArray SQL implementation.
651 
652 void TBufferSQL::ReadFastArray(Short_t *s, Int_t n)
653 {
654  for(int i=0; i<n; ++i) {
655  s[i] = (Short_t)atoi((*fRowPtr)->GetField(*fIter));
656  ++fIter;
657  }
658 }
659 
660 ////////////////////////////////////////////////////////////////////////////////
661 /// ReadFastArray SQL implementation.
662 
663 void TBufferSQL::ReadFastArray(UShort_t *us, Int_t n)
664 {
665  for(int i=0; i<n; ++i) {
666  us[i] = (UShort_t)atoi((*fRowPtr)->GetField(*fIter));
667  ++fIter;
668  }
669 }
670 
671 ////////////////////////////////////////////////////////////////////////////////
672 /// ReadFastArray SQL implementation.
673 
674 void TBufferSQL::ReadFastArray(Int_t *in, Int_t n)
675 {
676  for(int i=0; i<n; ++i) {
677  in[i] = atoi((*fRowPtr)->GetField(*fIter));
678  ++fIter;
679  }
680 }
681 
682 ////////////////////////////////////////////////////////////////////////////////
683 /// ReadFastArray SQL implementation.
684 
685 void TBufferSQL::ReadFastArray(UInt_t *ui, Int_t n)
686 {
687  for(int i=0; i<n; ++i) {
688  ui[i] = atoi((*fRowPtr)->GetField(*fIter));
689  ++fIter;
690  }
691 }
692 
693 ////////////////////////////////////////////////////////////////////////////////
694 /// ReadFastArray SQL implementation.
695 
696 void TBufferSQL::ReadFastArray(Long_t *l, Int_t n)
697 {
698  for(int i=0; i<n; ++i) {
699  l[i] = atol((*fRowPtr)->GetField(*fIter));
700  ++fIter;
701  }
702 }
703 
704 ////////////////////////////////////////////////////////////////////////////////
705 /// ReadFastArray SQL implementation.
706 
707 void TBufferSQL::ReadFastArray(ULong_t *ul, Int_t n)
708 {
709  for(int i=0; i<n; ++i) {
710  (*this) >> ul[i];
711  }
712 }
713 
714 ////////////////////////////////////////////////////////////////////////////////
715 /// ReadFastArray SQL implementation.
716 
717 void TBufferSQL::ReadFastArray(Long64_t *ll, Int_t n)
718 {
719  for(int i=0; i<n; ++i) {
720  (*this) >> ll[i];
721  }
722 }
723 
724 ////////////////////////////////////////////////////////////////////////////////
725 /// ReadFastArray SQL implementation.
726 
727 void TBufferSQL::ReadFastArray(ULong64_t *ull, Int_t n)
728 {
729  for(int i=0; i<n; ++i) {
730  (*this) >> ull[i];
731  }
732 }
733 
734 ////////////////////////////////////////////////////////////////////////////////
735 /// ReadFastArray SQL implementation.
736 
737 void TBufferSQL::ReadFastArray(Float_t *f, Int_t n)
738 {
739  for(int i=0; i<n; ++i) {
740  f[i] = atof((*fRowPtr)->GetField(*fIter));
741  ++fIter;
742  }
743 }
744 
745 ////////////////////////////////////////////////////////////////////////////////
746 /// ReadFastArray SQL implementation.
747 
748 void TBufferSQL::ReadFastArray(Double_t *d, Int_t n)
749 {
750  for(int i=0; i<n; ++i) {
751  d[i] = atof((*fRowPtr)->GetField(*fIter));
752  ++fIter;
753  }
754 }
755 
756 ////////////////////////////////////////////////////////////////////////////////
757 /// ReadFastArray SQL implementation.
758 
759 void TBufferSQL::ReadFastArrayFloat16(Float_t *, Int_t , TStreamerElement *)
760 {
761  Fatal("ReadFastArrayFloat16(Float_t *, Int_t , TStreamerElement *)","Not implemented yet");
762 }
763 
764 ////////////////////////////////////////////////////////////////////////////////
765 /// Read array of Float16_t from buffer
766 
767 void TBufferSQL::ReadFastArrayWithFactor(Float_t *, Int_t , Double_t /* factor */, Double_t /* minvalue */)
768 {
769  Fatal("ReadFastArrayWithFactor(Float_t *, Int_t, Double_t, Double_t)","Not implemented yet");
770 }
771 
772 ////////////////////////////////////////////////////////////////////////////////
773 /// Read array of Float16_t from buffer
774 
775 void TBufferSQL::ReadFastArrayWithNbits(Float_t *, Int_t , Int_t /*nbits*/)
776 {
777  Fatal("ReadFastArrayWithNbits(Float_t *, Int_t , Int_t )","Not implemented yet");
778 }
779 
780 ////////////////////////////////////////////////////////////////////////////////
781 /// Read array of Double32_t from buffer
782 
783 void TBufferSQL::ReadFastArrayWithFactor(Double_t *, Int_t , Double_t /* factor */, Double_t /* minvalue */)
784 {
785  Fatal("ReadFastArrayWithFactor(Double_t *, Int_t, Double_t, Double_t)","Not implemented yet");
786 }
787 
788 ////////////////////////////////////////////////////////////////////////////////
789 /// Read array of Double32_t from buffer
790 
791 void TBufferSQL::ReadFastArrayWithNbits(Double_t *, Int_t , Int_t /*nbits*/)
792 {
793  Fatal("ReadFastArrayWithNbits(Double_t *, Int_t , Int_t )","Not implemented yet");
794 }
795 
796 ////////////////////////////////////////////////////////////////////////////////
797 /// ReadFastArray SQL implementation.
798 
799 void TBufferSQL::ReadFastArrayDouble32(Double_t *, Int_t , TStreamerElement *)
800 {
801  Fatal("ReadFastArrayDouble32(Double_t *, Int_t , TStreamerElement *)","Not implemented yet");
802 }
803 
804 ////////////////////////////////////////////////////////////////////////////////
805 /// ReadFastArray SQL implementation.
806 
807 void TBufferSQL::ReadFastArray(void *, const TClass *, Int_t, TMemberStreamer *, const TClass *)
808 {
809  Fatal("ReadFastArray(void *, const TClass *, Int_t, TMemberStreamer *, const TClass *)","Not implemented yet");
810 }
811 
812 ////////////////////////////////////////////////////////////////////////////////
813 /// ReadFastArray SQL implementation.
814 
815 void TBufferSQL::ReadFastArray(void **, const TClass *, Int_t, Bool_t, TMemberStreamer *, const TClass *)
816 {
817  Fatal("ReadFastArray(void **, const TClass *, Int_t, Bool_t, TMemberStreamer *, const TClass *)","Not implemented yet");
818 }
819 
820 ////////////////////////////////////////////////////////////////////////////////
821 /// Reset Offset.
822 
823 void TBufferSQL::ResetOffset()
824 {
825  fIter = fColumnVec->begin();
826 }
827 
828 #if 0
829 ////////////////////////////////////////////////////////////////////////////////
830 
831 void TBufferSQL::insert_test(const char* dsn, const char* usr,
832  const char* pwd, const TString& tblname)
833 {
834  TString str;
835  TString select = "select * from ";
836  TString sql;
837  TSQLStatement* stmt;
838  sql = select + "ins";
839 
840  con = gSQLDriverManager->GetConnection(dsn,usr,pwd);
841 
842  if(!con)
843  printf("\n\n\nConnection NOT Successful\n\n\n");
844  else
845  printf("\n\n\nConnection Sucessful\n\n\n");
846 
847  stmt = con->CreateStatement(0, odbc::ResultSet::CONCUR_READ_ONLY);
848 
849  ptr = stmt->ExecuteQuery(sql.Data());
850  if(!ptr) printf("No recorSet found!");
851 
852  ptr->Next();
853  ptr->MoveToInsertRow();
854  std::cerr << "IsAfterLast(): " << ptr->IsAfterLast() << std::endl;
855  ptr->UpdateInt(1, 5555);
856  ptr->InsertRow();
857  con->Commit();
858 
859  ptr1 = stmt->ExecuteQuery(sql.Data());
860 
861 }
862 #endif