source: trunk/Mars/msql/MBufferSQL.cc@ 15510

Last change on this file since 15510 was 15439, checked in by tbretz, 12 years ago
Removed all obsolete code from the root copied classes; now everything is returned asa double (enough for plots) and as a bonus time columns are now returned as a root axis-time; as a sql server reference MSqlServer is now used and tree is a member of MSqlServer.
File size: 2.2 KB
Line 
1// @(#)root/tree:$Id: MBufferSQL.cxx 43518 2012-03-28 01:04:07Z pcanal $
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//////////////////////////////////////////////////////////////////////////
13// //
14// MBufferSQL //
15// //
16// Implement TBuffer for a SQL backend //
17// //
18//////////////////////////////////////////////////////////////////////////
19#include "MBufferSQL.h"
20
21#include <stdio.h>
22#include <stdlib.h>
23
24#include "TError.h"
25
26#include "TSQLResult.h"
27#include "TSQLRow.h"
28
29#include "MTime.h"
30
31using namespace std;
32
33ClassImp(MBufferSQL);
34
35//________________________________________________________________________
36MBufferSQL::MBufferSQL() : TBufferFile(), fRowPtr(0)
37{
38 // Constructor.
39}
40
41//________________________________________________________________________
42MBufferSQL::MBufferSQL(TSQLRow **r, Int_t index, TString type) :
43TBufferFile(TBufferFile::kRead), fRowPtr(r), fIndex(index), fIsDate(kFALSE)
44{
45 // Constructor.
46 if (type.BeginsWith("date", TString::kIgnoreCase) ||
47 type.BeginsWith("time", TString::kIgnoreCase))
48 fIsDate = kTRUE;
49}
50
51//________________________________________________________________________
52void MBufferSQL::ReadDouble(Double_t &d)
53{
54 // Operator>>
55 const char *ptr = (*fRowPtr)->GetField(fIndex);
56
57 if (ptr==0)
58 {
59 d = 0;
60 Error("operator>>(Double_t&)","NULL value found in cell");
61 return;
62 }
63
64 if (!fIsDate)
65 {
66 d = atof(ptr);
67 return;
68 }
69
70 d = MTime(ptr).GetAxisTime();
71}
Note: See TracBrowser for help on using the repository browser.