replace char* by string

This commit is contained in:
Joachim Schöberl 2017-06-25 18:22:46 +02:00
parent 5d62946130
commit 4cb120047c
4 changed files with 17 additions and 16 deletions

View File

@ -308,7 +308,7 @@ extern "C" {
struct Ng_SolutionData struct Ng_SolutionData
{ {
const char * name; // name of gridfunction string name; // name of gridfunction
double * data; // solution values double * data; // solution values
int components; // relevant (double) components in solution vector int components; // relevant (double) components in solution vector
int dist; // # doubles per entry alignment! int dist; // # doubles per entry alignment!

View File

@ -79,8 +79,8 @@ namespace netgen
for (int i = 0; i < vssolution.soldata.Size(); i++) for (int i = 0; i < vssolution.soldata.Size(); i++)
{ {
if ( (strlen (vssolution.soldata[i]->name) == size_t(pointpos-1)) && if ( (strlen (vssolution.soldata[i]->name.c_str()) == size_t(pointpos-1)) &&
(strncmp (vssolution.soldata[i]->name, scalname, pointpos-1) == 0) ) (strncmp (vssolution.soldata[i]->name.c_str(), scalname, pointpos-1) == 0) )
{ {
vssolution.scalfunction = i; vssolution.scalfunction = i;
vssolution.scalcomp = atoi (scalname + pointpos); vssolution.scalcomp = atoi (scalname + pointpos);
@ -96,10 +96,10 @@ namespace netgen
Tcl_SetVar ( interp, "::visoptions.scalfunction", newscalname, TCL_GLOBAL_ONLY ); Tcl_SetVar ( interp, "::visoptions.scalfunction", newscalname, TCL_GLOBAL_ONLY );
scalname = Tcl_GetVar (interp, "::visoptions.scalfunction", TCL_GLOBAL_ONLY); scalname = Tcl_GetVar (interp, "::visoptions.scalfunction", TCL_GLOBAL_ONLY);
} }
if (strcmp (vssolution.soldata[i]->name, vecname) == 0) if (strcmp (vssolution.soldata[i]->name.c_str(), vecname) == 0)
vssolution.vecfunction = i; vssolution.vecfunction = i;
if (strcmp (vssolution.soldata[i]->name, fieldlines_vecname) == 0) if (strcmp (vssolution.soldata[i]->name.c_str(), fieldlines_vecname) == 0)
vssolution.fieldlines_vecfunction = i; vssolution.fieldlines_vecfunction = i;
} }
@ -315,7 +315,7 @@ namespace netgen
return TCL_ERROR; return TCL_ERROR;
for (i = 0; i < vssolution.GetNSolData(); i++) for (i = 0; i < vssolution.GetNSolData(); i++)
if (strcmp (vssolution.GetSolData(i)->name, argv[2]) == 0) if (strcmp (vssolution.GetSolData(i)->name.c_str(), argv[2]) == 0)
{ {
cout << "found soldata " << i << endl; cout << "found soldata " << i << endl;
} }
@ -328,7 +328,7 @@ namespace netgen
if (strcmp (argv[1], "getfieldname") == 0) if (strcmp (argv[1], "getfieldname") == 0)
{ {
sprintf (buf, "%s", vssolution.GetSolData(atoi(argv[2])-1)->name); sprintf (buf, "%s", vssolution.GetSolData(atoi(argv[2])-1)->name.c_str());
} }
if (strcmp (argv[1], "iscomplex") == 0) if (strcmp (argv[1], "iscomplex") == 0)
@ -346,7 +346,7 @@ namespace netgen
{ {
for (i = 0; i < vssolution.GetNSolData(); i++) for (i = 0; i < vssolution.GetNSolData(); i++)
{ {
strcat (buf, vssolution.GetSolData(i)->name); strcat (buf, vssolution.GetSolData(i)->name.c_str());
strcat (buf, " "); strcat (buf, " ");
} }
strcat (buf, "var1 var2 var3"); strcat (buf, "var1 var2 var3");

View File

@ -24,12 +24,12 @@ namespace netgen
VisualSceneSolution :: SolData :: SolData () VisualSceneSolution :: SolData :: SolData ()
: name (0), data (0), solclass(0) : data (0), solclass(0)
{ ; } { ; }
VisualSceneSolution :: SolData :: ~SolData () VisualSceneSolution :: SolData :: ~SolData ()
{ {
delete [] name; // delete [] name;
delete data; delete data;
delete solclass; delete solclass;
} }
@ -86,7 +86,8 @@ namespace netgen
int funcnr = -1; int funcnr = -1;
for (int i = 0; i < soldata.Size(); i++) for (int i = 0; i < soldata.Size(); i++)
{ {
if (strcmp (soldata[i]->name, sd->name) == 0) // if (strcmp (soldata[i]->name, sd->name) == 0)
if (soldata[i]->name == sd->name)
{ {
delete soldata[i]; delete soldata[i];
soldata[i] = sd; soldata[i] = sd;
@ -4778,7 +4779,7 @@ void Ng_ClearSolutionData ()
void Ng_InitSolutionData (Ng_SolutionData * soldata) void Ng_InitSolutionData (Ng_SolutionData * soldata)
{ {
soldata -> name = NULL; // soldata -> name = NULL;
soldata -> data = NULL; soldata -> data = NULL;
soldata -> components = 1; soldata -> components = 1;
soldata -> dist = 1; soldata -> dist = 1;
@ -4797,9 +4798,9 @@ void Ng_SetSolutionData (Ng_SolutionData * soldata)
// vssolution.ClearSolutionData (); // vssolution.ClearSolutionData ();
netgen::VisualSceneSolution::SolData * vss = new netgen::VisualSceneSolution::SolData; netgen::VisualSceneSolution::SolData * vss = new netgen::VisualSceneSolution::SolData;
vss->name = new char[strlen (soldata->name)+1]; // vss->name = new char[strlen (soldata->name)+1];
strcpy (vss->name, soldata->name); // strcpy (vss->name, soldata->name);
vss->name = soldata->name;
vss->data = soldata->data; vss->data = soldata->data;
vss->components = soldata->components; vss->components = soldata->components;
vss->dist = soldata->dist; vss->dist = soldata->dist;

View File

@ -136,7 +136,7 @@ public:
SolData (); SolData ();
~SolData (); ~SolData ();
char * name; string name;
double * data; double * data;
int components; int components;
int dist; int dist;