Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
90
Issues
90
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
cf56b60f
Commit
cf56b60f
authored
Jul 08, 2017
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove all the empty “options” members in Column classes
By using SFINAE to use that member only when it exists.
parent
870d4629
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
42 deletions
+29
-42
src/database/database.hpp
src/database/database.hpp
+17
-40
src/database/table.hpp
src/database/table.hpp
+12
-2
No files found.
src/database/database.hpp
View file @
cf56b60f
...
...
@@ -20,79 +20,56 @@ class Database
public:
using
time_point
=
std
::
chrono
::
system_clock
::
time_point
;
struct
Uuid
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"uuid_"
;
static
constexpr
auto
options
=
""
;
};
struct
Uuid
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"uuid_"
;
};
struct
Owner
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"owner_"
;
static
constexpr
auto
options
=
""
;
};
struct
Owner
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"owner_"
;
};
struct
IrcChanName
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"ircChanName_"
;
static
constexpr
auto
options
=
""
;
};
struct
IrcChanName
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"ircChanName_"
;
};
struct
Channel
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"channel_"
;
static
constexpr
auto
options
=
""
;
};
struct
Channel
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"channel_"
;
};
struct
IrcServerName
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"ircServerName_"
;
static
constexpr
auto
options
=
""
;
};
struct
IrcServerName
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"ircServerName_"
;
};
struct
Server
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"server_"
;
static
constexpr
auto
options
=
""
;
};
struct
Server
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"server_"
;
};
struct
Date
:
Column
<
time_point
::
rep
>
{
static
constexpr
auto
name
=
"date_"
;
static
constexpr
auto
options
=
""
;
};
struct
Date
:
Column
<
time_point
::
rep
>
{
static
constexpr
auto
name
=
"date_"
;
};
struct
Body
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"body_"
;
static
constexpr
auto
options
=
""
;
};
struct
Body
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"body_"
;
};
struct
Nick
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"nick_"
;
static
constexpr
auto
options
=
""
;
};
struct
Nick
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"nick_"
;
};
struct
Pass
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"pass_"
;
static
constexpr
auto
options
=
""
;
};
struct
Pass
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"pass_"
;
};
struct
Ports
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"ports_"
;
static
constexpr
auto
options
=
""
;
Ports
()
:
Column
<
std
::
string
>
(
"6667"
)
{}
};
struct
TlsPorts
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"tlsPorts_"
;
static
constexpr
auto
options
=
""
;
TlsPorts
()
:
Column
<
std
::
string
>
(
"6697;6670"
)
{}
};
struct
Username
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"username_"
;
static
constexpr
auto
options
=
""
;
};
struct
Username
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"username_"
;
};
struct
Realname
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"realname_"
;
static
constexpr
auto
options
=
""
;
};
struct
Realname
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"realname_"
;
};
struct
AfterConnectionCommand
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"afterConnectionCommand_"
;
static
constexpr
auto
options
=
""
;
};
struct
AfterConnectionCommand
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"afterConnectionCommand_"
;
};
struct
TrustedFingerprint
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"trustedFingerprint_"
;
static
constexpr
auto
options
=
""
;
};
struct
TrustedFingerprint
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"trustedFingerprint_"
;
};
struct
EncodingOut
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"encodingOut_"
;
static
constexpr
auto
options
=
""
;
};
struct
EncodingOut
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"encodingOut_"
;
};
struct
EncodingIn
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"encodingIn_"
;
static
constexpr
auto
options
=
""
;
};
struct
EncodingIn
:
Column
<
std
::
string
>
{
static
constexpr
auto
name
=
"encodingIn_"
;
};
struct
MaxHistoryLength
:
Column
<
int
>
{
static
constexpr
auto
name
=
"maxHistoryLength_"
;
static
constexpr
auto
options
=
""
;
MaxHistoryLength
()
:
Column
<
int
>
(
20
)
{}
};
struct
RecordHistory
:
Column
<
bool
>
{
static
constexpr
auto
name
=
"recordHistory_"
;
static
constexpr
auto
options
=
""
;
RecordHistory
()
:
Column
<
bool
>
(
true
)
{}};
struct
RecordHistoryOptional
:
Column
<
OptionalBool
>
{
static
constexpr
auto
name
=
"recordHistory_"
;
static
constexpr
auto
options
=
""
;
};
struct
RecordHistoryOptional
:
Column
<
OptionalBool
>
{
static
constexpr
auto
name
=
"recordHistory_"
;
};
struct
VerifyCert
:
Column
<
bool
>
{
static
constexpr
auto
name
=
"verifyCert_"
;
static
constexpr
auto
options
=
""
;
VerifyCert
()
:
Column
<
bool
>
(
true
)
{}
};
struct
Persistent
:
Column
<
bool
>
{
static
constexpr
auto
name
=
"persistent_"
;
static
constexpr
auto
options
=
""
;
Persistent
()
:
Column
<
bool
>
(
false
)
{}
};
using
MucLogLineTable
=
Table
<
Id
,
Uuid
,
Owner
,
IrcChanName
,
IrcServerName
,
Date
,
Body
,
Nick
>
;
...
...
src/database/table.hpp
View file @
cf56b60f
...
...
@@ -28,6 +28,17 @@ void add_column_to_table(sqlite3* db, const std::string& table_name)
}
}
template
<
typename
ColumnType
,
decltype
(
ColumnType
::
options
)
=
nullptr
>
void
append_option
(
std
::
string
&
s
)
{
s
+=
" "
s
+
ColumnType
::
options
;
}
template
<
typename
>
void
append_option
(...)
{
}
template
<
typename
...
T
>
class
Table
{
...
...
@@ -110,14 +121,13 @@ class Table
str
+=
ColumnType
::
name
;
str
+=
" "
;
str
+=
TypeToSQLType
<
RealType
>::
type
;
str
+=
" "
s
+
ColumnType
::
options
;
append_option
<
ColumnType
>
(
str
)
;
if
(
N
!=
sizeof
...(
T
)
-
1
)
str
+=
","
;
str
+=
"
\n
"
;
add_column_create
<
N
+
1
>
(
str
);
}
template
<
std
::
size_t
N
=
0
>
typename
std
::
enable_if
<
N
==
sizeof
...(
T
),
void
>::
type
add_column_create
(
std
::
string
&
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment