From: apo Date: Fri, 13 Jul 2007 09:15:54 +0000 (+0000) Subject: To rerturn std::string or QString instead of "const char*" X-Git-Tag: T_MULTIPR_INDUS_Persistence~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3fceba995246b7ef9c068ec838dd821d8206d9fc;p=modules%2Fvisu.git To rerturn std::string or QString instead of "const char*" --- diff --git a/src/VISU_I/VISU_Table_i.cc b/src/VISU_I/VISU_Table_i.cc index 2d1854bc..ec88462d 100644 --- a/src/VISU_I/VISU_Table_i.cc +++ b/src/VISU_I/VISU_Table_i.cc @@ -57,7 +57,7 @@ const string VISU::Table_i::myComment = "TABLE"; /*! Generate unique name */ -const char* VISU::Table_i::GenerateName() +QString VISU::Table_i::GenerateName() { return VISU::GenerateName( "Table", ++myNbPresent ); } @@ -74,7 +74,7 @@ const char* VISU::Table_i::GetComment() const VISU::Table_i::Table_i( SALOMEDS::Study_ptr theStudy, const char* theObjectEntry ) : PrsObject_i(theStudy) { - mySObj = SALOMEDS::SObject::_duplicate((theStudy->FindObjectID(theObjectEntry))); + mySObj = theStudy->FindObjectID(theObjectEntry); myOrientation = VISU::Table::HORIZONTAL; } /*! @@ -126,11 +126,12 @@ VISU::Table_i } //---------------------------------------------------------------------------- -char* +std::string VISU::Table_i ::GetObjectEntry() { - return CORBA::string_dup( mySObj->GetID() ); + CORBA::String_var anEntry = mySObj->GetID(); + return anEntry.in(); } //---------------------------------------------------------------------------- @@ -180,7 +181,7 @@ CORBA::Long VISU::Table_i::GetNbColumns() VISU::Storable* VISU::Table_i::Create() { // generate name ... - SetName(GetTableTitle(), false); + SetName(GetTableTitle().latin1(), false); // mpv (PAL 5357): if name attribute already exist at this label, use it as name of table if ( GetName() == "" ) @@ -197,7 +198,7 @@ VISU::Storable* VISU::Table_i::Create() } if ( GetName() == "" ) - SetName(GenerateName(), false); + SetName(GenerateName().latin1(), false); // ... and build the object return Build( false ); } @@ -304,7 +305,7 @@ VISU::Storable* VISU::Table_i::StorableEngine(SALOMEDS::SObject_ptr theSObject, /*! Gets title for the original table object */ -const char* VISU::Table_i::GetTableTitle() +QString VISU::Table_i::GetTableTitle() { SALOMEDS::SObject_var SO = mySObj; SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); @@ -314,11 +315,13 @@ const char* VISU::Table_i::GetTableTitle() if ( !SO->_is_nil() ) { if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) { anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); - return anInt->GetTitle(); + CORBA::String_var aString = anInt->GetTitle(); + return aString.in(); } else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) { aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); - return aReal->GetTitle(); + CORBA::String_var aString = aReal->GetTitle(); + return aString.in(); } } return ""; @@ -367,7 +370,7 @@ const string VISU::Curve_i::myComment = "CURVE"; /*! Generate unique name */ -const char* VISU::Curve_i::GenerateName() +QString VISU::Curve_i::GenerateName() { return VISU::GenerateName( "Curve", ++myNbPresent ); } @@ -529,7 +532,7 @@ VISU::Storable* VISU::Curve_i::Build(int theRestoring ) CORBA::Boolean VISU::Curve_i::IsValid() { // getting table SObject by it's entry - SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry()); + SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str()); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; @@ -557,7 +560,7 @@ string VISU::Curve_i::GetHorTitle() { string title; // getting table SObject by it's entry - SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry()); + SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str()); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; @@ -587,7 +590,7 @@ string VISU::Curve_i::GetVerTitle() { string title; // getting table SObject by it's entry - SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry()); + SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str()); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; @@ -615,7 +618,7 @@ string VISU::Curve_i::GetHorUnits() { string units; // getting table SObject by it's entry - SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry()); + SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str()); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; @@ -643,7 +646,7 @@ string VISU::Curve_i::GetVerUnits() { string units; // getting table SObject by it's entry - SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry()); + SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str()); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; @@ -671,7 +674,7 @@ int VISU::Curve_i::GetData( double*& theHorList, double*& theVerList, QStringLis { theHorList = 0; theVerList = 0; // getting table SObject by it's entry - SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry()); + SALOMEDS::SObject_var SO = GetStudyDocument()->FindObjectID(myTable->GetObjectEntry().c_str()); SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder(); SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeTableOfInteger_var anInt; @@ -793,7 +796,7 @@ SPlot2d_Curve* VISU::Curve_i::CreatePresentation() CORBA::String_var aString = mySObj->GetID(); crv->setIO(new SALOME_InteractiveObject(aString.in(), "VISU", GetName().c_str())); if ( myTable ) - crv->setTableIO(new SALOME_InteractiveObject(myTable->GetObjectEntry(), "VISU", myTable->GetName().c_str())); + crv->setTableIO(new SALOME_InteractiveObject(myTable->GetObjectEntry().c_str(), "VISU", myTable->GetName().c_str())); return crv; } /*! @@ -839,7 +842,7 @@ void VISU::Curve_i::ToStream( std::ostringstream& theStr ) /*! Gets reference table's entry */ -const char* VISU::Curve_i::GetTableID() { +std::string VISU::Curve_i::GetTableID() { return myTable->GetObjectEntry(); } /*! @@ -893,7 +896,7 @@ const string VISU::Container_i::myComment = "CONTAINER"; /*! Generate unique name */ -const char* VISU::Container_i::GenerateName() +QString VISU::Container_i::GenerateName() { return VISU::GenerateName( "Plot2DView", ++myNbPresent ); } diff --git a/src/VISU_I/VISU_Table_i.hh b/src/VISU_I/VISU_Table_i.hh index 04806091..dcdecc6b 100644 --- a/src/VISU_I/VISU_Table_i.hh +++ b/src/VISU_I/VISU_Table_i.hh @@ -79,10 +79,10 @@ namespace VISU{ virtual void ToStream( std::ostringstream& theStr ); static const std::string myComment; virtual const char* GetComment() const; - virtual const char* GenerateName(); - virtual const char* GetTableTitle(); + virtual QString GenerateName(); + virtual QString GetTableTitle(); - virtual char* GetObjectEntry(); + virtual std::string GetObjectEntry(); }; SALOMEDS::SObject_var ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy); bool ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName); @@ -149,8 +149,8 @@ namespace VISU{ virtual void ToStream( std::ostringstream& theStr ); static const std::string myComment; virtual const char* GetComment() const; - virtual const char* GenerateName(); - virtual const char* GetTableID(); + virtual QString GenerateName(); + virtual std::string GetTableID(); virtual CORBA::Boolean IsAuto() { return myAuto; } virtual CORBA::Boolean IsValid(); @@ -204,7 +204,7 @@ namespace VISU{ virtual void ToStream( std::ostringstream& theStr ); static const std::string myComment; virtual const char* GetComment() const; - virtual const char* GenerateName(); + virtual QString GenerateName(); void Update(); VISU::Curve_i* GetCurve( CORBA::Long theIndex );