1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
////////////////////////////////////////////////////////////////////////////////
/*! @file DB_Link.h Classes sDB_Info, sDB_UUID and sDB_Link.
- Part of RANet - Research Assistant Net Library (based on ANSI C++).
- Uses Qt v.5.0 - http://qt-project.org/
- Copyright(C) 2013-2020, Viktor E. Bursian, St.Petersburg, Russia.
VBursian@gmail.com
*///////////////////////////////////////////////////////////////////////////////
#ifndef DB_Link_H
#define DB_Link_H
#include "Strings.h"
#include "Version.h"
#include <QString>
#include <QUuid>
namespace RA {
//------------------------------------------------------------------------------
ANNOUNCE_CLASS(sDB_Info)
ANNOUNCE_CLASS(sDB_UUID)
ANNOUNCE_CLASS(sDB_Link)
//----------------------------------------------------------------- sDB_Info ---
/*! RANet URL class.
*/
class RANet_EXPORT sDB_Info
{
public://types
enum eType {cSQLite,cMySQL,cPostgreSQL};
typedef bool fModifyInfo (psDB_Info);
public://static
static const sString TypeName [];
static const QString QtDriverName [];
static fModifyInfo * ModifyInfo;
public:
sDB_Info (rcsString partition_URL);
sDB_Info ();
sDB_Info (eType type);
sDB_Info (rcsDB_Info);
// virtual bool IsValid () const;
// virtual bool HasValidURL () const;
// virtual bool HasValidURN () const;
rsDB_Info operator = (rcsDB_Info);
void SetByURL (rcsString partition_URL);
void SetDefaults ();
sString URL (bool with_password = false) const;
sString TableFullName (literal table_name) const;
sString ColumnNotation (literal col_name) const;
public://fields
eType Type;
sString TableNamePrefix;
sString SchemaName;
sString DBName;
sString Host;
int Port; //!< -1 means unset
sString Login;
sString Password; //!< "___" means request user
sString ConnectOptions;
};
//----------------------------------------------------------------- sDB_UUID ---
/*!
*/
class RANet_EXPORT sDB_UUID : public QUuid
{
public://static
static sDB_UUID NewUUID ();
public:
sDB_UUID ()
:QUuid()
{}
sDB_UUID (const QUuid & uuid) :QUuid(uuid) {}
sDB_UUID (rcsDB_UUID other) :QUuid(other) {}
rsDB_UUID operator = (rcsDB_UUID);
bool Undefined () const
{ return *this == sDB_UUID(); }
explicit sDB_UUID (rcsString);
sString ToString () const;
};
//----------------------------------------------------------------- sDB_Link ---
/*!
*/
class RANet_EXPORT sDB_Link : public sDB_Info
{
// public://types
// typedef QByteArray tUUID;
public://static
static const sString MyselfNickname;
// static tUUID NewUUID ();
public:
sDB_Link ()
:sDB_Info()
{}
sDB_Link (rcsDB_Info);
sDB_Link (rcsDB_Link);
rsDB_Link operator = (rcsDB_Link);
public://fields
sDB_UUID Id; //!< could be moved into sDB_Info
// bool Broken;
sVersion Version; //!< Known after partition is loaded.
//!< Move to sDatabase?
};
//------------------------------------------------------------------------------
} //namespace RA
#endif
|