From 1e0307934a84d81c7685fb0e9fae0d2a023fb211 Mon Sep 17 00:00:00 2001 From: Gilles DAVID Date: Thu, 1 Jun 2017 17:53:37 +0200 Subject: [PATCH] Python 3: creation of encode/decode functions --- idl/SALOMEDS.idl | 14 ++++----- src/Basics/Basics_Utils.cxx | 30 ++++++++++++++++++ src/Basics/Basics_Utils.hxx | 5 +++ src/KERNEL_PY/batchmode_salome.py | 2 +- src/KERNEL_PY/salome_study.py | 3 +- src/KernelHelpers/KernelHelpersUseCases.cxx | 2 +- .../Test/KernelHelpersUnitTests.cxx | 2 +- src/SALOMEDS/SALOMEDS_Client.cxx | 7 +++-- src/SALOMEDS/SALOMEDS_Study.cxx | 27 +++++++++++++--- src/SALOMEDS/SALOMEDS_StudyManager.cxx | 10 +++--- src/SALOMEDS/SALOMEDS_StudyManager_i.cxx | 31 ++++++++++--------- src/SALOMEDS/SALOMEDS_StudyManager_i.hxx | 8 ++--- src/SALOMEDS/SALOMEDS_Study_i.cxx | 20 ++++++------ src/SALOMEDS/SALOMEDS_Study_i.hxx | 8 ++--- .../Test/SALOMEDSTest_AttributeComment.cxx | 3 ++ 15 files changed, 116 insertions(+), 56 deletions(-) diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index f7fb5d260..87a4f2df2 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -41,7 +41,7 @@ module SALOMEDS { /*! \brief Name of the file in which the %Study is saved. */ - typedef string URL; + typedef wstring URL; /*! \brief Main identifier of an object in %SALOME application */ @@ -60,7 +60,7 @@ module SALOMEDS Since %SALOME is a multi-study application, it allows to open a lot of studies during each working session. */ - typedef sequence ListOfOpenStudies; + typedef sequence ListOfOpenStudies; //! List of file names typedef sequence ListOfFileNames; //! List of modification dates of a study @@ -146,7 +146,7 @@ during each working session. This is equivalent to the methods setName() & getName() */ - attribute string Name; // equivalent to setName() & getName() + attribute wstring Name; // equivalent to setName() & getName() /*! \brief The ID of the %Study This is equivalent to the methods setID() & getID() @@ -300,7 +300,7 @@ during each working session. /*! \brief Indicate the file where the %study has been saved */ - attribute string URL; + attribute wstring URL; /*! \brief List of %SObjects @@ -868,7 +868,7 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin See \ref example17 for an example of this method usage in batchmode of %SALOME application. */ - Study NewStudy(in string study_name) raises (SALOME::SALOME_Exception); + Study NewStudy(in wstring study_name) raises (SALOME::SALOME_Exception); /*! \brief Open a study @@ -878,7 +878,7 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin See \ref example1 for an example of this method usage in batchmode of %SALOME application. */ - Study Open (in wstring aStudyUrl) raises (SALOME::SALOME_Exception); + Study Open (in URL aStudyUrl) raises (SALOME::SALOME_Exception); /*! \brief Closing the study @@ -940,7 +940,7 @@ Gets the list of open studies among the session collection picking it by name. \param aStudyName The name of the study */ - Study GetStudyByName (in string aStudyName); + Study GetStudyByName (in URL aStudyName); /*! \brief Getting a particular %Study picked by ID diff --git a/src/Basics/Basics_Utils.cxx b/src/Basics/Basics_Utils.cxx index 73b4e800e..97d6c0b5f 100644 --- a/src/Basics/Basics_Utils.cxx +++ b/src/Basics/Basics_Utils.cxx @@ -106,6 +106,36 @@ namespace Kernel_Utils return guid; } + const wchar_t* decode(const char* encoded) + { + setlocale(LC_ALL, ""); + size_t length = strlen(encoded) + sizeof(char); + wchar_t* decoded = new wchar_t[length]; + memset( decoded, '\0', length); + mbstowcs(decoded, encoded, length); + return decoded; + } + + const wchar_t* decode_s(std::string encoded) + { + return decode(encoded.c_str()); + } + + const char* encode(const wchar_t* decoded) + { + setlocale(LC_ALL, ""); + size_t length = std::wcslen(decoded) + sizeof(wchar_t); + char* encoded = new char[length]; + memset( encoded, '\0', length); + wcstombs(encoded, decoded, length); + return encoded; + } + + std::string encode_s(const wchar_t* decoded) + { + return std::string(encode(decoded)); + } + #ifndef WIN32 void print_traceback() { diff --git a/src/Basics/Basics_Utils.hxx b/src/Basics/Basics_Utils.hxx index 5843afb75..cef9dc3fc 100644 --- a/src/Basics/Basics_Utils.hxx +++ b/src/Basics/Basics_Utils.hxx @@ -56,6 +56,11 @@ namespace Kernel_Utils ObjectdID //!< Global usage object identifier ID }; + const wchar_t* decode(const char* encoded); + const wchar_t* decode_s(std::string encoded); + const char* encode(const wchar_t* decoded); + std::string encode_s(const wchar_t* decoded); + //! Get predefined GUID BASICS_EXPORT std::string GetGUID( GUIDtype ); #ifndef WIN32 diff --git a/src/KERNEL_PY/batchmode_salome.py b/src/KERNEL_PY/batchmode_salome.py index 6cf554390..8e3613164 100755 --- a/src/KERNEL_PY/batchmode_salome.py +++ b/src/KERNEL_PY/batchmode_salome.py @@ -293,7 +293,7 @@ if myStudyManager is None: aListOfOpenStudies = myStudyManager.GetOpenStudies(); myStudy = None; if len(aListOfOpenStudies) == 0 : - myStudy = myStudyManager.NewStudy("Study1") + myStudy = myStudyManager.NewStudy("étude") else: myStudyName = aListOfOpenStudies[0] myStudy = myStudyManager.GetStudyByName(myStudyName) diff --git a/src/KERNEL_PY/salome_study.py b/src/KERNEL_PY/salome_study.py index 503dff8fd..4f62a4139 100755 --- a/src/KERNEL_PY/salome_study.py +++ b/src/KERNEL_PY/salome_study.py @@ -299,6 +299,7 @@ def getActiveStudy(*args): if len(listOpenStudies) == 0: return None else: + print(listOpenStudies[0]) s = myStudyManager.GetStudyByName(listOpenStudies[0]) salome_study_ID = s._get_StudyId() if verbose(): print("--- Study Id ", salome_study_ID) @@ -355,7 +356,7 @@ def setCurrentStudyId(*args): def createNewStudy(): global myStudyManager print("createNewStudy") - aStudyName = "extStudy" + aStudyName = "étudeExt" theStudy = myStudyManager.NewStudy(aStudyName) theStudyId = theStudy._get_StudyId() print(aStudyName, theStudyId) diff --git a/src/KernelHelpers/KernelHelpersUseCases.cxx b/src/KernelHelpers/KernelHelpersUseCases.cxx index 7feaf8a2d..030fd8ce1 100644 --- a/src/KernelHelpers/KernelHelpersUseCases.cxx +++ b/src/KernelHelpers/KernelHelpersUseCases.cxx @@ -61,7 +61,7 @@ bool TEST_getLifeCycleCORBA() { } bool TEST_getStudyManager() { - SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudyManager()->NewStudy("kerneltest"); + SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudyManager()->NewStudy(L"kerneltest"); if ( CORBA::is_nil(myTestStudy) ) { return false; } diff --git a/src/KernelHelpers/Test/KernelHelpersUnitTests.cxx b/src/KernelHelpers/Test/KernelHelpersUnitTests.cxx index a3aa4cbb7..ee92ec1e6 100644 --- a/src/KernelHelpers/Test/KernelHelpersUnitTests.cxx +++ b/src/KernelHelpers/Test/KernelHelpersUnitTests.cxx @@ -91,7 +91,7 @@ void KernelHelpersUnitTests::TEST_getStudyManager() { } #endif - SALOMEDS::Study_ptr myTestStudy = studyManager->NewStudy("kerneltest"); + SALOMEDS::Study_ptr myTestStudy = studyManager->NewStudy(L"kerneltest"); CPPUNIT_ASSERT(!CORBA::is_nil(myTestStudy)); // One can use the study to store some general properties diff --git a/src/SALOMEDS/SALOMEDS_Client.cxx b/src/SALOMEDS/SALOMEDS_Client.cxx index 2650e1d0a..31fe34be3 100644 --- a/src/SALOMEDS/SALOMEDS_Client.cxx +++ b/src/SALOMEDS/SALOMEDS_Client.cxx @@ -30,6 +30,7 @@ #include CORBA_SERVER_HEADER(SALOMEDS) #include "SALOMEDS_StudyManager_i.hxx" #include "SALOMEDS_AttributeName_i.hxx" +#include "Basics_Utils.hxx" #include "utilities.h" #include "HDFOI.hxx" @@ -90,7 +91,7 @@ static void Test(SALOMEDS::StudyManager_ptr myStudyMgr ) try { char* name; MESSAGE("Create New Study Study1"); - SALOMEDS::Study_var myStudy = myStudyMgr->NewStudy("Study1"); + SALOMEDS::Study_var myStudy = myStudyMgr->NewStudy(L"Study1"); MESSAGE("Create Builder "); SALOMEDS::StudyBuilder_var StudyBuild = myStudy->NewBuilder(); @@ -206,7 +207,7 @@ static void Test(SALOMEDS::StudyManager_ptr myStudyMgr ) for (unsigned int ind = 0; ind < _list_open_studies->length();ind++) { - MESSAGE("Open studies list : " << _list_open_studies[ind]); + MESSAGE("Open studies list : " << Kernel_Utils::encode(_list_open_studies[ind])); } @@ -215,7 +216,7 @@ static void Test(SALOMEDS::StudyManager_ptr myStudyMgr ) MESSAGE("GetStudyByName done"); // Save as - myStudyMgr->SaveAs("/home/edeville/Study1.hdf",myStudy1, false); + myStudyMgr->SaveAs(L"/home/edeville/Study1.hdf",myStudy1, false); // Get Persistent Reference of the study test name = myStudy1->GetPersistentReference(); diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 63d44b5ac..d8a537c95 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -442,7 +442,7 @@ std::string SALOMEDS_Study::Name() SALOMEDS::Locker lock; aName = _local_impl->Name(); } - else aName = _corba_impl->Name(); + else aName = Kernel_Utils::encode_s(_corba_impl->Name()); return aName; } @@ -452,7 +452,7 @@ void SALOMEDS_Study::Name(const std::string& theName) SALOMEDS::Locker lock; _local_impl->Name(theName); } - else _corba_impl->Name((char*)theName.c_str()); + else _corba_impl->Name(Kernel_Utils::decode_s(theName)); } bool SALOMEDS_Study::IsSaved() @@ -503,7 +503,18 @@ std::string SALOMEDS_Study::URL() SALOMEDS::Locker lock; aURL = _local_impl->URL(); } - else aURL = _corba_impl->URL(); + else { + wchar_t* wurl = _corba_impl->URL(); + + // Converts unicode url to encoded version + setlocale(LC_ALL, ""); + size_t urlLen = std::wcslen(wurl); + char url[urlLen+1]; + memset( url, 0, urlLen+1); + wcstombs(url, wurl, sizeof(url)); + + aURL = std::string(url); + } return aURL; } @@ -513,7 +524,15 @@ void SALOMEDS_Study::URL(const std::string& url) SALOMEDS::Locker lock; _local_impl->URL(url); } - else _corba_impl->URL((char*)url.c_str()); + else { + setlocale(LC_ALL, ""); + size_t urlLen = url.size(); + wchar_t wurl[urlLen+1]; + memset( wurl, 0, urlLen+1); + mbstowcs(wurl, url.c_str(), sizeof(wurl)); + + _corba_impl->URL(wurl); + } } int SALOMEDS_Study::StudyId() diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.cxx b/src/SALOMEDS/SALOMEDS_StudyManager.cxx index 4dc29e939..e584b39f8 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.cxx @@ -105,7 +105,7 @@ _PTR(Study) SALOMEDS_StudyManager::NewStudy(const std::string& study_name) //SRN: Pure CORBA NewStudy as it does more initialization than the local one SALOMEDSClient_Study* aStudy = NULL; - SALOMEDS::Study_var aStudy_impl = _corba_impl->NewStudy((char*)study_name.c_str()); + SALOMEDS::Study_var aStudy_impl = _corba_impl->NewStudy(Kernel_Utils::decode_s(study_name)); if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); aStudy = new SALOMEDS_Study(aStudy_impl); @@ -151,14 +151,14 @@ bool SALOMEDS_StudyManager::SaveAs(const std::string& theUrl, const _PTR(Study) { //SRN: Pure CORBA save as the save operation require CORBA in any case SALOMEDS::Study_var aStudy = _corba_impl->GetStudyByID(theStudy->StudyId()); - return _corba_impl->SaveAs((char*)theUrl.c_str(), aStudy, theMultiFile); + return _corba_impl->SaveAs(Kernel_Utils::decode_s(theUrl), aStudy, theMultiFile); } bool SALOMEDS_StudyManager::SaveAsASCII(const std::string& theUrl, const _PTR(Study)& theStudy, bool theMultiFile) { //SRN: Pure CORBA save as the save operation require CORBA in any case SALOMEDS::Study_var aStudy = _corba_impl->GetStudyByID(theStudy->StudyId()); - return _corba_impl->SaveAsASCII((char*)theUrl.c_str(), aStudy, theMultiFile); + return _corba_impl->SaveAsASCII(Kernel_Utils::decode_s(theUrl), aStudy, theMultiFile); } std::vector SALOMEDS_StudyManager::GetOpenStudies() @@ -178,7 +178,7 @@ std::vector SALOMEDS_StudyManager::GetOpenStudies() SALOMEDS::ListOfOpenStudies_var aSeq = _corba_impl->GetOpenStudies(); aLength = aSeq->length(); for(i = 0; i < aLength; i++) - aVector.push_back(aSeq[i].in()); + aVector.push_back(Kernel_Utils::encode_s(aSeq[i].in())); } return aVector; } @@ -194,7 +194,7 @@ _PTR(Study) SALOMEDS_StudyManager::GetStudyByName(const std::string& theStudyNam aStudy = new SALOMEDS_Study(aStudy_impl); } else { - SALOMEDS::Study_var aStudy_impl = _corba_impl->GetStudyByName((char*)theStudyName.c_str()); + SALOMEDS::Study_var aStudy_impl = _corba_impl->GetStudyByName(Kernel_Utils::decode_s(theStudyName)); if(CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); aStudy = new SALOMEDS_Study(aStudy_impl); } diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 58c7c5ea1..3de6dbcce 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -110,7 +110,7 @@ void SALOMEDS_StudyManager_i::register_name(const char * name) * Purpose : Create a New Study of name study_name */ //============================================================================ -SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) +SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const wchar_t* study_name) throw(SALOME::SALOME_Exception) { SALOMEDS::Locker lock; @@ -126,7 +126,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) } #endif // !ALLOW_MULTI_STUDIES - SALOMEDSImpl_Study* aStudyImpl = _impl->NewStudy(study_name); + SALOMEDSImpl_Study* aStudyImpl = _impl->NewStudy(Kernel_Utils::encode(study_name)); if(!aStudyImpl) { MESSAGE("NewStudy : Error : " << _impl->GetErrorCode()); return SALOMEDS::Study::_nil(); @@ -143,7 +143,7 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) if(!_name_service->Change_Directory("/Study")) MESSAGE( "Unable to access the study directory" ) else - _name_service->Register(Study, study_name); + _name_service->Register(Study, Kernel_Utils::encode(study_name)); // Assign the value of the IOR in the study->root CORBA::String_var IORStudy = _orb->object_to_string(Study); @@ -232,8 +232,8 @@ void SALOMEDS_StudyManager_i::Close(SALOMEDS::Study_ptr aStudy) // Destroy study name in the naming service if(_name_service->Change_Directory("/Study")){ - CORBA::String_var aString(aStudy->Name()); - _name_service->Destroy_Name(aString.in()); + CORBA::WString_var awString(aStudy->Name()); + _name_service->Destroy_Name(Kernel_Utils::encode(awString.in())); } SALOMEDS::unlock(); @@ -285,30 +285,30 @@ CORBA::Boolean SALOMEDS_StudyManager_i::SaveASCII(SALOMEDS::Study_ptr aStudy, CO * Purpose : Save a study to the persistent reference aUrl */ //============================================================================ -CORBA::Boolean SALOMEDS_StudyManager_i::SaveAs(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) +CORBA::Boolean SALOMEDS_StudyManager_i::SaveAs(const wchar_t* aWUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) { SALOMEDS::Locker lock; if(aStudy->_is_nil()) { - MESSAGE("SaveASCII error: Study is null"); + MESSAGE("SaveAs error: Study is null"); return false; } SALOMEDSImpl_Study* aStudyImpl = _impl->GetStudyByID(aStudy->StudyId()); - return _impl->SaveAs(std::string(aUrl), aStudyImpl, _factory, theMultiFile); + return _impl->SaveAs(std::string(Kernel_Utils::encode(aWUrl)), aStudyImpl, _factory, theMultiFile); } -CORBA::Boolean SALOMEDS_StudyManager_i::SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) +CORBA::Boolean SALOMEDS_StudyManager_i::SaveAsASCII(const wchar_t* aWUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) { SALOMEDS::Locker lock; if(aStudy->_is_nil()) { - MESSAGE("SaveASCII error: Study is null"); + MESSAGE("SaveAsASCII error: Study is null"); return false; } SALOMEDSImpl_Study* aStudyImpl = _impl->GetStudyByID(aStudy->StudyId()); - return _impl->SaveAsASCII(std::string(aUrl), aStudyImpl, _factory, theMultiFile); + return _impl->SaveAsASCII(std::string(Kernel_Utils::encode(aWUrl)), aStudyImpl, _factory, theMultiFile); } //============================================================================ @@ -334,8 +334,9 @@ SALOMEDS::ListOfOpenStudies* SALOMEDS_StudyManager_i::GetOpenStudies() { for (unsigned int ind=0; ind < aLength; ind++) { - _list_open_studies[ind] = CORBA::string_dup(anOpened[ind]->Name().c_str()); - SCRUTE(_list_open_studies[ind]) ; + SCRUTE(anOpened[ind]->Name()) ; + _list_open_studies[ind] = CORBA::wstring_dup(Kernel_Utils::decode_s(anOpened[ind]->Name())); + SCRUTE(Kernel_Utils::encode(_list_open_studies[ind])) ; } } return _list_open_studies._retn(); @@ -346,11 +347,11 @@ SALOMEDS::ListOfOpenStudies* SALOMEDS_StudyManager_i::GetOpenStudies() * Purpose : Get a study from its name */ //============================================================================ -SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::GetStudyByName(const char* aStudyName) +SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::GetStudyByName(const wchar_t* aStudyName) { SALOMEDS::Locker lock; - SALOMEDSImpl_Study* aStudyImpl = _impl->GetStudyByName(std::string(aStudyName)); + SALOMEDSImpl_Study* aStudyImpl = _impl->GetStudyByName(Kernel_Utils::encode_s(aStudyName)); if (!aStudyImpl) { diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx index 51830f941..c3ffa5a71 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx @@ -82,7 +82,7 @@ public: \param char* arguments, the new study name \return Study_ptr arguments */ - virtual SALOMEDS::Study_ptr NewStudy(const char* study_name) throw (SALOME::SALOME_Exception); + virtual SALOMEDS::Study_ptr NewStudy(const wchar_t* study_name) throw (SALOME::SALOME_Exception); //! method to Open a Study from it's persistent reference /*! @@ -111,8 +111,8 @@ public: \param char* arguments, the new URL of the study \param Study_ptr arguments */ - virtual CORBA::Boolean SaveAs(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); - virtual CORBA::Boolean SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); + virtual CORBA::Boolean SaveAs(const wchar_t* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); + virtual CORBA::Boolean SaveAsASCII(const wchar_t* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); //! method to Get name list of open studies in the session /*! @@ -125,7 +125,7 @@ public: \param char* arguments, the study name \return Study_ptr arguments */ - virtual SALOMEDS::Study_ptr GetStudyByName(const char* aStudyName) ; + virtual SALOMEDS::Study_ptr GetStudyByName(const wchar_t* aStudyName) ; //! method to get a Study from it's ID /*! diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 921c9b34b..8b23183ff 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -744,11 +744,11 @@ SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder() * Purpose : get study name */ //============================================================================ -char* SALOMEDS_Study_i::Name() +wchar_t* SALOMEDS_Study_i::Name() { SALOMEDS::Locker lock; // Name is specified as IDL attribute: user exception cannot be raised - return CORBA::string_dup(_impl->Name().c_str()); + return CORBA::wstring_dup(Kernel_Utils::decode_s(_impl->Name())); } //============================================================================ @@ -756,11 +756,11 @@ char* SALOMEDS_Study_i::Name() * Purpose : set study name */ //============================================================================ -void SALOMEDS_Study_i::Name(const char* name) +void SALOMEDS_Study_i::Name(const wchar_t* wname) { - SALOMEDS::Locker lock; + SALOMEDS::Locker lock; // Name is specified as IDL attribute: user exception cannot be raised - _impl->Name(std::string(name)); + _impl->Name(Kernel_Utils::encode_s(wname)); } //============================================================================ @@ -823,11 +823,11 @@ void SALOMEDS_Study_i::Modified() * Purpose : get URL of the study (persistent reference of the study) */ //============================================================================ -char* SALOMEDS_Study_i::URL() +wchar_t* SALOMEDS_Study_i::URL() { - SALOMEDS::Locker lock; + SALOMEDS::Locker lock; // URL is specified as IDL attribute: user exception cannot be raised - return CORBA::string_dup(_impl->URL().c_str()); + return CORBA::wstring_dup(Kernel_Utils::decode_s(_impl->URL())); } //============================================================================ @@ -835,11 +835,11 @@ char* SALOMEDS_Study_i::URL() * Purpose : set URL of the study (persistent reference of the study) */ //============================================================================ -void SALOMEDS_Study_i::URL(const char* url) +void SALOMEDS_Study_i::URL(const wchar_t* wurl) { SALOMEDS::Locker lock; // URL is specified as IDL attribute: user exception cannot be raised - _impl->URL(std::string((char*)url)); + _impl->URL(Kernel_Utils::encode_s(wurl)); } CORBA::Short SALOMEDS_Study_i::StudyId() diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index a767e6414..2edf83825 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -204,13 +204,13 @@ public: /*! \return char* arguments, the study name */ - virtual char* Name(); + virtual wchar_t* Name(); //! method to set study name /*! \param name char* arguments, the study name */ - virtual void Name(const char* name); + virtual void Name(const wchar_t* name); //! method to get if study has been saved /*! @@ -237,13 +237,13 @@ public: /*! \return char* arguments, the study URL */ - virtual char* URL(); + virtual wchar_t* URL(); //! method to set URL of the study /*! \param url char* arguments, the study URL */ - virtual void URL(const char* url); + virtual void URL(const wchar_t* url); virtual CORBA::Short StudyId(); virtual void StudyId(CORBA::Short id); diff --git a/src/SALOMEDS/Test/SALOMEDSTest_AttributeComment.cxx b/src/SALOMEDS/Test/SALOMEDSTest_AttributeComment.cxx index 6c93cd649..9c57a7d10 100755 --- a/src/SALOMEDS/Test/SALOMEDSTest_AttributeComment.cxx +++ b/src/SALOMEDS/Test/SALOMEDSTest_AttributeComment.cxx @@ -25,6 +25,8 @@ * Use code of SALOMEDS_AttributeComment.cxx */ +//#include "Basics_Utils.hxx" + void SALOMEDSTest::testAttributeComment() { //Create or find the Study manager @@ -39,6 +41,7 @@ void SALOMEDSTest::testAttributeComment() study = sm->NewStudy("Test"); else study = sm->GetStudyByName(ost[0]); +// study = sm->GetStudyByName(Kernel_Utils::decode_s(ost[0])); CPPUNIT_ASSERT(study); -- 2.39.2