Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TSQLTableInfo.cxx
Go to the documentation of this file.
1// @(#)root/net:$Id$
2// Author: Sergey Linev 31/05/2006
3
4/*************************************************************************
5 * Copyright (C) 1995-2006, 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// TSQLTableInfo
15//
16// Contains information about table and table columns.
17// For MySQL additional information like engine type,
18// creation and last update time is provided
19//
20////////////////////////////////////////////////////////////////////////////////
21
22#include "TSQLTableInfo.h"
23
24#include "TSQLColumnInfo.h"
25#include "TList.h"
26#include "TROOT.h"
27
28#include <iostream>
29
30////////////////////////////////////////////////////////////////////////////////
31/// default constructor
32
34 TNamed(),
35 fColumns(0),
36 fEngine(),
37 fCreateTime(),
38 fUpdateTime()
39{
40}
41
42////////////////////////////////////////////////////////////////////////////////
43/// normal constructor
44
47 const char* comment,
48 const char* engine,
49 const char* create_time,
50 const char* update_time) :
51 TNamed(tablename, comment),
52 fColumns(columns),
53 fEngine(engine),
54 fCreateTime(create_time),
55 fUpdateTime(update_time)
56{
57}
58
59////////////////////////////////////////////////////////////////////////////////
60/// destructor
61
63{
64 if (fColumns!=0) {
66 delete fColumns;
67 fColumns = 0;
68 }
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Prints table and table columns info
73
75{
77 std::cout << "Table:" << GetName();
78
79 if ((GetTitle()!=0) && (strlen(GetTitle())!=0))
80 std::cout << " comm:'" << GetTitle() << "'";
81
82 if (fEngine.Length()>0)
83 std::cout << " engine:" << fEngine;
84
85 if (fCreateTime.Length()>0)
86 std::cout << " create:" << fCreateTime;
87
88 if (fUpdateTime.Length()>0)
89 std::cout << " update:" << fUpdateTime;
90
91 std::cout << std::endl;
92
94 if (fColumns!=0)
95 fColumns->Print("*");
97}
98
99////////////////////////////////////////////////////////////////////////////////
100/// Return column info object of given name
101
103{
104 if ((columnname==0) || (fColumns==0)) return 0;
105
106 return dynamic_cast<TSQLColumnInfo*> (fColumns->FindObject(columnname));
107
108}
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Print(Option_t *option="") const override
Default print for collections, calls Print(option, 1).
A doubly linked list.
Definition TList.h:38
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:708
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:600
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition TROOT.cxx:3059
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:3067
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition TROOT.cxx:2916
TSQLColumnInfo * FindColumn(const char *columnname)
Return column info object of given name.
TList * fColumns
! list of TSQLColumnInfo objects, describing each table column
TSQLTableInfo()
default constructor
void Print(Option_t *option="") const override
Prints table and table columns info.
TString fCreateTime
! table creation time
TString fEngine
! SQL tables engine name
virtual ~TSQLTableInfo()
destructor
TString fUpdateTime
! table update time
Ssiz_t Length() const
Definition TString.h:426