{
/*! \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
*/
Since %SALOME is a multi-study application, it allows to open a lot of studies
during each working session.
*/
- typedef sequence<string> ListOfOpenStudies;
+ typedef sequence<URL> ListOfOpenStudies;
//! List of file names
typedef sequence<string> ListOfFileNames;
//! List of modification dates of a study
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()
/*! \brief Indicate the file where the %study has been saved
*/
- attribute string URL;
+ attribute wstring URL;
/*! \brief List of %SObjects
<em>See \ref example17 for an example of this method usage in batchmode of %SALOME application.</em>
*/
- Study NewStudy(in string study_name) raises (SALOME::SALOME_Exception);
+ Study NewStudy(in wstring study_name) raises (SALOME::SALOME_Exception);
/*! \brief Open a study
<em>See \ref example1 for an example of this method usage in batchmode of %SALOME application.</em>
*/
- Study Open (in wstring aStudyUrl) raises (SALOME::SALOME_Exception);
+ Study Open (in URL aStudyUrl) raises (SALOME::SALOME_Exception);
/*! \brief Closing the study
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
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()
{
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
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)
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)
def createNewStudy():
global myStudyManager
print("createNewStudy")
- aStudyName = "extStudy"
+ aStudyName = "étudeExt"
theStudy = myStudyManager.NewStudy(aStudyName)
theStudyId = theStudy._get_StudyId()
print(aStudyName, theStudyId)
}
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;
}
}
#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
#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"
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();
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]));
}
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();
SALOMEDS::Locker lock;
aName = _local_impl->Name();
}
- else aName = _corba_impl->Name();
+ else aName = Kernel_Utils::encode_s(_corba_impl->Name());
return aName;
}
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()
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;
}
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()
//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);
{
//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<std::string> 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;
}
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);
}
* 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;
}
#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();
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);
// 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();
* 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);
}
//============================================================================
{
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();
* 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)
{
\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
/*!
\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
/*!
\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
/*!
* 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()));
}
//============================================================================
* 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));
}
//============================================================================
* 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()));
}
//============================================================================
* 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()
/*!
\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
/*!
/*!
\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);
* Use code of SALOMEDS_AttributeComment.cxx
*/
+//#include "Basics_Utils.hxx"
+
void SALOMEDSTest::testAttributeComment()
{
//Create or find the Study manager
study = sm->NewStudy("Test");
else
study = sm->GetStudyByName(ost[0]);
+// study = sm->GetStudyByName(Kernel_Utils::decode_s(ost[0]));
CPPUNIT_ASSERT(study);