QtHelpers.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 /**
34  @file QtHelpers.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@supagro.inra.fr>
37  */
38 
39 
40 #ifndef __OPENFLUID_TOOLS_QTHELPERS_HPP__
41 #define __OPENFLUID_TOOLS_QTHELPERS_HPP__
42 
43 
45 
46 #include <string>
47 #include <list>
48 #include <vector>
49 #include <set>
50 
51 #include <QVariant>
52 #include <QString>
53 #include <QStringList>
54 #include <QDateTime>
55 #include <QColor>
56 
57 #include <openfluid/dllexport.hpp>
58 
59 
60 namespace openfluid { namespace tools {
61 
62 
63 /**
64  Transforms the given string to a string compatible with the INI files managed with QSettings.
65  @param[in] Str the string to transform
66  @return The transformed string
67 */
68 QString OPENFLUID_API toIniCompatible(const std::string& Str);
69 
70 
71 /**
72  Transforms the given variable from an INI file managed with QSettings to a string
73  @param[in] Var the variable to transform
74  @return The variable transformed into a string
75 */
76 std::string OPENFLUID_API fromIniCompatible(const QVariant& Var);
77 
78 
79 /**
80  Transforms a QStringList into a std::list of std::string
81  @param[in] StrList the QStringList to transform
82  @return The QStringList transformed into a std::list of std::string
83 */
84 std::list<std::string> OPENFLUID_API toStdStringList(const QStringList& StrList);
85 
86 
87 /**
88  Transforms a QStringList into a std::vector of std::string
89  @param[in] StrList the QStringList to transform
90  @return The QStringList transformed into a std::vector of std::string
91 */
92 std::vector<std::string> toStdStringVector(const QStringList& StrList);
93 
94 
95 /**
96  Transforms an OpenFLUID DateTime to a QDateTime
97  @param[in] DT The OpenFLUID DateTime to transform
98  @return The DT transformed into QDateTime
99 */
101 
102 
103 /**
104  Transforms a std::vector of std::string into a QStringList
105  @param[in] StrVect the std::vector of std::string to transform
106  @return The StrVect transformed into a QStringList
107 */
108 QStringList OPENFLUID_API toQStringList(const std::vector<std::string>& StrVect);
109 
110 
111 /**
112  Transforms a std::set of std::string into a QStringList
113  @param[in] StrSet the std::set of std::string to transform
114  @return The StrSet transformed into a QStringList
115 */
116 QStringList OPENFLUID_API toQStringList(const std::set<std::string>& StrSet);
117 
118 
119 /**
120  Transforms a std::list of std::string into a QStringList
121  @param[in] StrList the std::list of std::string to transform
122  @return The StrList transformed into a QStringList
123 */
124 QStringList OPENFLUID_API toQStringList(const std::list<std::string>& StrList);
125 
126 
127 /**
128  Transforms a std::set of int into a QStringList
129  @param[in] IntSet the std::set of int to transform
130  @return The intSet transformed into a QStringList
131 */
132 QStringList OPENFLUID_API toQStringList(const std::set<int>& IntSet);
133 
134 
135 /**
136  Escapes characters in the given string to be compatible with the XML format.
137  @param[in] Str the string to escape
138  @return The escaped string
139 */
140 QString OPENFLUID_API escapeXMLEntities(const QString& Str);
141 
142 
143 /**
144  Decodes XML entities to characters
145  @param[in] Str the string to decode
146  @return The decoded string
147 */
148 QString OPENFLUID_API decodeXMLEntities(const QString& Str);
149 
150 
151 } } // namespaces
152 
153 
154 #endif /* __OPENFLUID_TOOLS_QTHELPERS_HPP__ */
QString OPENFLUID_API decodeXMLEntities(const QString &Str)
QStringList OPENFLUID_API toQStringList(const std::vector< std::string > &StrVect)
std::list< std::string > OPENFLUID_API toStdStringList(const QStringList &StrList)
Definition: ApplicationException.hpp:47
std::vector< std::string > toStdStringVector(const QStringList &StrList)
QString OPENFLUID_API toIniCompatible(const std::string &Str)
#define OPENFLUID_API
Definition: dllexport.hpp:87
std::string OPENFLUID_API fromIniCompatible(const QVariant &Var)
QDateTime OPENFLUID_API toQDateTime(const openfluid::core::DateTime &DT)
QString OPENFLUID_API escapeXMLEntities(const QString &Str)
Class for management of date and time information.
Definition: DateTime.hpp:132