diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-05-31 20:16:23 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-05-31 20:16:23 +0200 |
commit | e297fb92c2c0e344d36e0aef57921f6b9b921a61 (patch) | |
tree | ab36c3a121f3f132235ed3eafb5eb5d767c77b3b /common/propertymapper.cpp | |
parent | 0815156ef93cb9f48073a777b888ed47b579d695 (diff) | |
download | sink-e297fb92c2c0e344d36e0aef57921f6b9b921a61.tar.gz sink-e297fb92c2c0e344d36e0aef57921f6b9b921a61.zip |
Moved default read/write property mapper to TypeImplementation
There is always exactly one default buffer that we can centralize
in TypeImplementation.
Diffstat (limited to 'common/propertymapper.cpp')
-rw-r--r-- | common/propertymapper.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/common/propertymapper.cpp b/common/propertymapper.cpp new file mode 100644 index 0000000..0896aa6 --- /dev/null +++ b/common/propertymapper.cpp | |||
@@ -0,0 +1,39 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #include "propertymapper.h" | ||
21 | |||
22 | template <> | ||
23 | flatbuffers::uoffset_t variantToProperty<QString>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | ||
24 | { | ||
25 | if (property.isValid()) { | ||
26 | return fbb.CreateString(property.toString().toStdString()).o; | ||
27 | } | ||
28 | return 0; | ||
29 | } | ||
30 | |||
31 | template <> | ||
32 | QVariant propertyToVariant<QString>(const flatbuffers::String *property) | ||
33 | { | ||
34 | if (property) { | ||
35 | return QString::fromStdString(property->c_str()); | ||
36 | } | ||
37 | return QVariant(); | ||
38 | } | ||
39 | |||