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
23
24#include "TSQLTableInfo.h"
25
26#include "TSQLColumnInfo.h"
27#include "TList.h"
28#include "TROOT.h"
29#include "Riostream.h"
30
31
32////////////////////////////////////////////////////////////////////////////////
33/// default constructor
34
43
44////////////////////////////////////////////////////////////////////////////////
45/// normal constructor
46
47TSQLTableInfo::TSQLTableInfo(const char* tablename,
48 TList* columns,
49 const char* comment,
50 const char* engine,
51 const char* create_time,
52 const char* update_time) :
53 TNamed(tablename, comment),
54 fColumns(columns),
55 fEngine(engine),
56 fCreateTime(create_time),
57 fUpdateTime(update_time)
58{
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// destructor
63
65{
66 if (fColumns!=0) {
67 fColumns->Delete();
68 delete fColumns;
69 fColumns = 0;
70 }
71}
72
73////////////////////////////////////////////////////////////////////////////////
74/// Prints table and table columns info
75
77{
79 std::cout << "Table:" << GetName();
80
81 if ((GetTitle()!=0) && (strlen(GetTitle())!=0))
82 std::cout << " comm:'" << GetTitle() << "'";
83
84 if (fEngine.Length()>0)
85 std::cout << " engine:" << fEngine;
86
87 if (fCreateTime.Length()>0)
88 std::cout << " create:" << fCreateTime;
89
90 if (fUpdateTime.Length()>0)
91 std::cout << " update:" << fUpdateTime;
92
93 std::cout << std::endl;
94
96 if (fColumns!=0)
97 fColumns->Print("*");
99}
100
101////////////////////////////////////////////////////////////////////////////////
102/// Return column info object of given name
103
105{
106 if ((columnname==0) || (fColumns==0)) return 0;
107
108 return dynamic_cast<TSQLColumnInfo*> (fColumns->FindObject(columnname));
109
110}
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
A doubly linked list.
Definition TList.h:38
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
TNamed()
Definition TNamed.h:38
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition TROOT.cxx:3044
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:3052
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition TROOT.cxx:2901
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