Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MODMED
modmedLog
Commits
d23e244c
Commit
d23e244c
authored
Mar 11, 2019
by
EXT Arnaud Clère
Browse files
minor changes
parent
593cac6c
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/QBind/QVariant_impl.h
View file @
d23e244c
...
...
@@ -133,11 +133,11 @@ private:
// TODO BindNative other QVariant-supported types?
// //////////////////////////////////////////////////////////////////////////
// QBind<_,QVariant&> example support for the fixed set of
QVariantBuilder
's BindNative types + other convenient types
// QBind<_,QVariant&> example support for the fixed set of
IBind
's BindNative types + other convenient types
template
<
class
TResult
>
struct
QBind
<
TResult
,
QVariant
>
{
static
TResult
bind
(
Val
<
TResult
>&&
v
,
QVariant
&&
src
)
{
template
<
>
struct
QBind
<
Cursor
,
QVariant
>
{
static
Cursor
bind
(
Val
<
Cursor
>&&
v
,
QVariant
&&
src
)
{
if
(
v
->
mode
()
==
Write
)
{
if
(
src
.
type
()
==
QVariant
::
List
)
return
v
.
bind
(
src
.
value
<
QVariantList
>
());
// TODO QSequentialIterable ?
if
(
src
.
type
()
==
QVariant
::
Map
)
return
v
.
bind
(
src
.
value
<
QVariantMap
>
());
// TODO QAssociativeIterable ?
...
...
@@ -161,7 +161,7 @@ struct QBind<TResult, QVariant> {
}
else
{
Q_ASSERT_X
(
false
,
Q_FUNC_INFO
,
"Unsupported v->mode()"
);
return
v
.
null
();
}
}
static
TResult
bind
(
Val
<
TResult
>&&
v
,
QVariant
&
dst
)
{
static
Cursor
bind
(
Val
<
Cursor
>&&
v
,
QVariant
&
dst
)
{
if
(
v
->
mode
()
==
Write
)
{
return
bind
(
std
::
move
(
v
),
std
::
move
(
dst
));
}
...
...
@@ -169,11 +169,11 @@ struct QBind<TResult, QVariant> {
}
};
//template<
class TResult
>
//struct QBind<
TResult
, QVariant&, IsReader<
TResult
>> { static
TResult
bind(Val<
TResult
>&& v, QVariant& dst) {
//
TResult
r;
//template<>
//struct QBind<
Cursor
, QVariant&, IsReader<
Cursor
>> { static
Cursor
bind(Val<
Cursor
>&& v, QVariant& dst) {
//
Cursor
r;
// {
// QScopedChoice<Val<
TResult
>> choice(src);
// QScopedChoice<Val<
Cursor
>> choice(src);
// QVariantList a; if ((r = src.bind(a))) { dst = a ; return r; } // NB We cannot try QStringList before QVariantList as it will always work with our logical model...
// QVariantMap o; if ((r = src.bind(o))) { dst = o ; return r; }
// bool b; if ((r = src.bind(b))) { dst = QVariant(b); return r; }
...
...
tests/QBind/main.cpp
View file @
d23e244c
...
...
@@ -95,6 +95,15 @@ QDataStream &operator<<(QDataStream &out, const Person &p)
<<
p
.
phones
<<
p
.
comments
;
}
QDataStream
&
operator
>>
(
QDataStream
&
in
,
Person
&
p
)
{
return
in
>>
p
.
firstName
>>
p
.
lastName
// sequence is implicit
>>
p
.
height
>>
p
.
age
>>
p
.
phones
>>
p
.
comments
;
}
// //////////////////////////////////////////////////////////////////////////
// IBind basic implementation example
...
...
@@ -128,11 +137,11 @@ private:
#include <QtCore/qbuffer.h>
class
Text
:
public
TextWriter
class
Text
{
QBuffer
result
;
public:
template
<
typename
T
>
Text
(
T
&&
t
)
:
TextWriter
(
&
result
)
{
result
.
open
(
QIODevice
::
WriteOnly
);
bind
(
std
::
forward
<
T
>
(
t
));
}
template
<
typename
T
>
Text
(
T
&&
t
)
{
result
.
open
(
QIODevice
::
WriteOnly
);
TextWriter
(
&
result
).
bind
(
std
::
forward
<
T
>
(
t
));
}
operator
QUtf8String
()
const
{
return
result
.
buffer
();
}
};
...
...
Write
Preview
Supports
Markdown
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