1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "Events_InfoMessage.h"
23 // To support old types of GCC (less than 5.0), check the wide-string conversion is working
24 #if (__cplusplus >= 201103L || _MSVC_LANG >= 201103L) && \
25 (__cplusplus >= 201402L || !defined(__GLIBCXX__) || \
26 (defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE > 4))
27 #define HAVE_WORKING_WIDESTRING 1
29 #define HAVE_WORKING_WIDESTRING 0
32 #if HAVE_WORKING_WIDESTRING
36 void Events_InfoMessage::addParameter(double theParam)
38 std::stringstream aStream;
40 myParameters.push_back(aStream.str());
43 void Events_InfoMessage::addParameter(int theParam)
45 std::stringstream aStream;
47 myParameters.push_back(aStream.str());
50 void Events_InfoMessage::send()
52 std::shared_ptr<Events_Message> aMsg(new Events_InfoMessage(*this));
53 Events_Loop::loop()->send(aMsg);
56 Events_InfoMessage& Events_InfoMessage::arg(const std::wstring& theParam)
58 #if HAVE_WORKING_WIDESTRING
59 static std::wstring_convert<std::codecvt_utf8<wchar_t> > aConvertor;
60 addParameter(aConvertor.to_bytes(theParam));
62 char* aBuf = new char[2 * (theParam.size() + 1)];
63 size_t aNbChars = std::wcstombs(aBuf, theParam.c_str(), theParam.size());
64 if (aNbChars != (size_t)-1)
65 aBuf[aNbChars] = '\0';