Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
sqlitebrowser/src/sqlitetypes.h at master · Processoriented/sqlitebrowser · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Processoriented
sqlitebrowser
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
sqlitebrowser
/
src
/
sqlitetypes.h
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
188 lines (157 loc) · 5.5 KB
master
Breadcrumbs
sqlitebrowser
/
src
/
sqlitetypes.h
Copy path
Top
File metadata and controls
Code
Blame
188 lines (157 loc) · 5.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#
pragma
once
#
ifndef
SQLITETYPES_H
#
define
SQLITETYPES_H
#
include
"
antlr/ASTRefCount.hpp
"
#
include
<
QString
>
#
include
<
QSharedPointer
>
#
include
<
QVector
>
#
include
<
QStringList
>
#
include
<
QPair
>
namespace
sqlb
{
class
ForeignKeyClause
{
public:
ForeignKeyClause
(
const
QString& table = QString(),
const
QStringList& columns = QStringList(),
const
QString& constraint = QString())
: m_table(table),
m_columns
(columns),
m_constraint(constraint),
m_override(QString())
{
}
bool
isSet
()
const
;
QString
toString
()
const
;
void
setFromString
(
const
QString& fk);
void
setTable
(
const
QString& table) { m_override =
QString
(); m_table = table; }
const
QString&
table
()
const
{
return
m_table; }
void
setColumns
(
const
QStringList& columns) { m_columns = columns; }
const
QStringList&
columns
()
const
{
return
m_columns; }
void
setConstraint
(
const
QString& constraint) { m_constraint = constraint; }
const
QString&
constraint
()
const
{
return
m_constraint; }
private:
QString m_table;
QStringList m_columns;
QString m_constraint;
QString m_override;
};
class
Field
{
public:
Field
(
const
QString& name,
const
QString& type,
bool
notnull =
false
,
const
QString& defaultvalue =
"
"
,
const
QString& check =
"
"
,
bool
pk =
false
,
bool
unique =
false
)
: m_name(name)
, m_type(type)
, m_notnull(notnull)
, m_check(check)
, m_defaultvalue(defaultvalue)
, m_autoincrement(
false
)
, m_primaryKey(pk)
, m_unique(unique)
{}
QString
toString
(
const
QString& indent =
"
\t
"
,
const
QString& sep =
"
\t
"
)
const
;
void
setName
(
const
QString& name) { m_name = name; }
void
setType
(
const
QString& type) { m_type = type; }
void
setNotNull
(
bool
notnull =
true
) { m_notnull = notnull; }
void
setCheck
(
const
QString& check) { m_check = check; }
void
setDefaultValue
(
const
QString& defaultvalue) { m_defaultvalue = defaultvalue; }
void
setAutoIncrement
(
bool
autoinc) { m_autoincrement = autoinc; }
void
setPrimaryKey
(
bool
pk) { m_primaryKey = pk; }
void
setUnique
(
bool
u) { m_unique = u; }
void
setForeignKey
(
const
ForeignKeyClause& key) { m_foreignKey = key; }
bool
isText
()
const
;
bool
isInteger
()
const
;
const
QString&
name
()
const
{
return
m_name; }
const
QString&
type
()
const
{
return
m_type; }
bool
notnull
()
const
{
return
m_notnull; }
const
QString&
check
()
const
{
return
m_check; }
const
QString&
defaultValue
()
const
{
return
m_defaultvalue; }
bool
autoIncrement
()
const
{
return
m_autoincrement; }
bool
primaryKey
()
const
{
return
m_primaryKey; }
bool
unique
()
const
{
return
m_unique; }
const
ForeignKeyClause&
foreignKey
()
const
{
return
m_foreignKey; }
static
QStringList Datatypes;
private:
QString m_name;
QString m_type;
bool
m_notnull;
QString m_check;
QString m_defaultvalue;
ForeignKeyClause m_foreignKey;
//
Even though this information is a table constraint it's easier for accessing and processing to store it here
bool
m_autoincrement;
//
! this is stored here for simplification
bool
m_primaryKey;
bool
m_unique;
};
typedef
QSharedPointer<Field> FieldPtr;
typedef
QVector< FieldPtr > FieldVector;
class
Table
{
public:
explicit
Table
(
const
QString& name): m_name(name), m_rowidColumn(
"
_rowid_
"
) {}
virtual
~Table
();
void
setName
(
const
QString& name) { m_name = name; }
const
QString&
name
()
const
{
return
m_name; }
const
FieldVector&
fields
()
const
{
return
m_fields; }
/*
*
* @brief Returns the CREATE TABLE statement for this table object
* @return A QString with the CREATE TABLE object.
*/
QString
sql
()
const
;
void
addField
(
const
FieldPtr& f);
bool
removeField
(
const
QString&
sFieldName
);
void
setFields
(
const
FieldVector& fields);
void
setField
(
int
index, FieldPtr f) { m_fields[index] = f; }
QStringList
fieldNames
()
const
;
void
setRowidColumn
(
const
QString& rowid) { m_rowidColumn = rowid; }
const
QString&
rowidColumn
()
const
{
return
m_rowidColumn; }
bool
isWithoutRowidTable
()
const
{
return
m_rowidColumn !=
"
_rowid_
"
; }
void
clear
();
/*
*
* @brief findField Finds a field and returns the index.
* @param sname
* @return The field index if the field was found.
* -1 if field couldn't be found.
*/
int
findField
(
const
QString& sname);
int
findPk
()
const
;
/*
*
* @brief parseSQL Parses the create Table statement in sSQL.
* @param sSQL The create table statement.
* @return A pair first is a table object, second is a bool indicating
* if our modify dialog supports the table.
* The table object may be a empty table if parsing failed.
*/
static
QPair<Table,
bool
>
parseSQL
(
const
QString&
sSQL
);
private:
QStringList
fieldList
()
const
;
bool
hasAutoIncrement
()
const
;
private:
QString m_name;
FieldVector m_fields;
QString m_rowidColumn;
};
/*
*
* @brief The CreateTableWalker class
* Goes trough the createtable AST and returns
* Table object.
*/
class
CreateTableWalker
{
public:
explicit
CreateTableWalker
(antlr::RefAST r)
: m_root(r)
, m_bModifySupported(
true
)
{}
Table
table
();
bool
modifysupported
()
const
{
return
m_bModifySupported; }
private:
void
parsecolumn
(FieldPtr& f, antlr::RefAST c);
private:
antlr::RefAST m_root;
bool
m_bModifySupported;
};
}
//
namespace sqlb
#endif
//
SQLITETYPES_H
You can’t perform that action at this time.