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@inra.fr>
37  */
38 
39 
40 #ifndef __OPENFLUID_TOOLS_QTHELPERS_HPP__
41 #define __OPENFLUID_TOOLS_QTHELPERS_HPP__
42 
43 
44 #include <string>
45 #include <list>
46 #include <vector>
47 #include <set>
48 
49 #include <QVariant>
50 #include <QString>
51 #include <QStringList>
52 #include <QDateTime>
53 
55 #include <openfluid/dllexport.hpp>
56 
57 
58 namespace openfluid { namespace tools {
59 
60 
61 /**
62  Transforms the given string to a string compatible with the INI files managed with QSettings.
63  @param[in] Str the string to transform
64  @return The transformed string
65 */
66 QString OPENFLUID_API toIniCompatible(const std::string& Str);
67 
68 
69 /**
70  Transforms the given variable from an INI file managed with QSettings to a string
71  @param[in] Var the variable to transform
72  @return The variable transformed into a string
73 */
74 std::string OPENFLUID_API fromIniCompatible(const QVariant& Var);
75 
76 
77 /**
78  Transforms a QStringList into a std::list of std::string
79  @param[in] StrList the QStringList to transform
80  @return The QStringList transformed into a std::list of std::string
81 */
82 std::list<std::string> OPENFLUID_API toStdStringList(const QStringList& StrList);
83 
84 
85 /**
86  Transforms a QStringList into a std::vector of std::string
87  @param[in] StrList the QStringList to transform
88  @return The QStringList transformed into a std::vector of std::string
89 */
90 std::vector<std::string> toStdStringVector(const QStringList& StrList);
91 
92 
93 /**
94  Transforms an OpenFLUID DateTime to a QDateTime
95  @param[in] DT The OpenFLUID DateTime to transform
96  @return The DT transformed into QDateTime
97 */
99 
100 
101 /**
102  Transforms a std::vector of std::string into a QStringList
103  @param[in] StrVect the std::vector of std::string to transform
104  @return The StrVect transformed into a QStringList
105 */
106 QStringList OPENFLUID_API toQStringList(const std::vector<std::string>& StrVect);
107 
108 
109 /**
110  Transforms a std::set of std::string into a QStringList
111  @param[in] StrSet the std::set of std::string to transform
112  @return The StrSet transformed into a QStringList
113 */
114 QStringList OPENFLUID_API toQStringList(const std::set<std::string>& StrSet);
115 
116 
117 /**
118  Transforms a std::list of std::string into a QStringList
119  @param[in] StrList the std::list of std::string to transform
120  @return The StrList transformed into a QStringList
121 */
122 QStringList OPENFLUID_API toQStringList(const std::list<std::string>& StrList);
123 
124 
125 /**
126  Transforms a std::set of int into a QStringList
127  @param[in] IntSet the std::set of int to transform
128  @return The intSet transformed into a QStringList
129 */
130 QStringList OPENFLUID_API toQStringList(const std::set<int>& IntSet);
131 
132 
133 /**
134  Escapes characters in the given string to be compatible with the XML format.
135  @param[in] Str the string to escape
136  @return The escaped string
137 */
138 QString OPENFLUID_API escapeXMLEntities(const QString& Str);
139 
140 
141 /**
142  Decodes XML entities to characters
143  @param[in] Str the string to decode
144  @return The decoded string
145 */
146 QString OPENFLUID_API decodeXMLEntities(const QString& Str);
147 
148 
149 } } // namespaces
150 
151 
152 #endif /* __OPENFLUID_TOOLS_QTHELPERS_HPP__ */
QString OPENFLUID_API decodeXMLEntities(const QString &Str)
QStringList OPENFLUID_API toQStringList(const std::vector< std::string > &StrVect)
std::string OPENFLUID_API fromIniCompatible(const QVariant &Var)
#define OPENFLUID_API
Definition: dllexport.hpp:87
std::vector< std::string > toStdStringVector(const QStringList &StrList)
QString OPENFLUID_API escapeXMLEntities(const QString &Str)
Definition: ApplicationException.hpp:47
QString OPENFLUID_API toIniCompatible(const std::string &Str)
Class for management of date and time information.
Definition: DateTime.hpp:132
QDateTime OPENFLUID_API toQDateTime(const openfluid::core::DateTime &DT)
std::list< std::string > OPENFLUID_API toStdStringList(const QStringList &StrList)