diff --git a/trick_source/data_products/DPX/APPS/FXPLOT/plot_view_node.cpp b/trick_source/data_products/DPX/APPS/FXPLOT/plot_view_node.cpp index df3d7640..da3d68c0 100644 --- a/trick_source/data_products/DPX/APPS/FXPLOT/plot_view_node.cpp +++ b/trick_source/data_products/DPX/APPS/FXPLOT/plot_view_node.cpp @@ -200,19 +200,11 @@ PlotViewNode::PlotViewNode( Widget Toplevel, Widget Parent_form, DPC_plot* Plot curves = new XYCurve[n_curves]; // X Axis label. - if ((const_temp_str = plot->getXLabel()) != NULL) { - snprintf( charbuf, sizeof(charbuf), "%s", const_temp_str ); - } else { - charbuf[0] = '\0'; - } + snprintf( charbuf, sizeof(charbuf), "%s", const_temp_str ); X_label = XmStringCreateLocalized( charbuf); // Y Axis label. - if ((const_temp_str = plot->getYLabel()) != NULL) { - snprintf( charbuf, sizeof(charbuf), "%s", const_temp_str ); - } else { - charbuf[0] = '\0'; - } + snprintf( charbuf, sizeof(charbuf), "%s", const_temp_str ); Y_label = XmStringCreateLocalized( charbuf); // --------------------------- diff --git a/trick_source/data_products/DPX/APPS/FXPLOT/table_view_node.cpp b/trick_source/data_products/DPX/APPS/FXPLOT/table_view_node.cpp index 03f8b818..94b89a39 100644 --- a/trick_source/data_products/DPX/APPS/FXPLOT/table_view_node.cpp +++ b/trick_source/data_products/DPX/APPS/FXPLOT/table_view_node.cpp @@ -319,15 +319,14 @@ TableViewNode::TableViewNode( Widget Toplevel, DPC_table* Table, int Xpos, int Y // Print out the column heading labels. // ---------------------------------------------------------------- for (colix=0; colix < n_columns ; colix++) { - const char *column_label = table->getColumnLabel( colix); - - if (!column_label) { + std::string column_label = table->getColumnLabel(colix); + if (column_label.empty()) { snprintf( charbuf, sizeof(charbuf), "Column_%d", colix); table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos, column_heading_format[colix], charbuf); } else { table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos, - column_heading_format[colix], column_label); + column_heading_format[colix], column_label.c_str()); } } table_text_buf = twprint( table_text_buf, &table_buf_size, &table_insertion_pos, (char *)"\n"); diff --git a/trick_source/data_products/DPX/APPS/GXPLOT/gp_view_plot_node.cpp b/trick_source/data_products/DPX/APPS/GXPLOT/gp_view_plot_node.cpp index 5a84d332..07c3f661 100644 --- a/trick_source/data_products/DPX/APPS/GXPLOT/gp_view_plot_node.cpp +++ b/trick_source/data_products/DPX/APPS/GXPLOT/gp_view_plot_node.cpp @@ -124,11 +124,11 @@ void GPViewPlotNode::finalize() { * So, check the return value before making the assignment. */ plot_title = (plot->getTitle()) ? plot->getTitle() : tmp_stream.str(); - plot_x_label = (plot->getXLabel()) ? plot->getXLabel() : ""; + plot_x_label = plot->getXLabel(); plot_x_scale = (plot->getAttribute("x_scale")) ? plot->getAttribute("x_scale") : ""; plot_x_min_rng = (plot->getAttribute("xmin")) ? plot->getAttribute("xmin") : ""; plot_x_max_rng = (plot->getAttribute("xmax")) ? plot->getAttribute("xmax") : ""; - plot_y_label = (plot->getYLabel()) ? plot->getYLabel() : ""; + plot_y_label = plot->getYLabel(); plot_y_format = (plot->getAttribute("format")) ? plot->getAttribute("format") : ""; plot_y_scale = (plot->getAttribute("y_scale")) ? plot->getAttribute("y_scale") : ""; plot_y_min_rng = (plot->getAttribute("ymin")) ? plot->getAttribute("ymin") : ""; diff --git a/trick_source/data_products/DPX/DPC/DPC_UnitConvDataStream.cpp b/trick_source/data_products/DPX/DPC/DPC_UnitConvDataStream.cpp index 8bd1a540..a339632d 100644 --- a/trick_source/data_products/DPX/DPC/DPC_UnitConvDataStream.cpp +++ b/trick_source/data_products/DPX/DPC/DPC_UnitConvDataStream.cpp @@ -11,8 +11,8 @@ DPC_UnitConvDataStream::DPC_UnitConvDataStream(DataStream* ds, const char *ToUni ut_unit * to = NULL ; ut_unit * from = NULL ; - - const char * recorded_units = ds->getUnit().c_str(); + + std::string recorded_units = ds->getUnit(); source_ds = ds; @@ -24,7 +24,7 @@ DPC_UnitConvDataStream::DPC_UnitConvDataStream(DataStream* ds, const char *ToUni // If the user has specified a units conversion and those units are valid ... if ( to != NULL ) { // If the recorded data file doesn't contain the units in which the data is recorded ... - if ((recorded_units == NULL) || (strcmp(recorded_units,"") == 0)) { + if (recorded_units.empty()) { // If the user didn't give us a hint as to what the units are (using var@from_units) ... if ((FromUnitsHint == NULL) || (strcmp(FromUnitsHint,"") == 0)) { // set the from units to the same as the to units. @@ -47,7 +47,7 @@ DPC_UnitConvDataStream::DPC_UnitConvDataStream(DataStream* ds, const char *ToUni } } else { // the recorded data file does "know" the units in which the data was recorded, // so those will be the units that we convert from. - from = ut_parse(u_system, recorded_units, UT_ASCII) ; + from = ut_parse(u_system, recorded_units.c_str(), UT_ASCII) ; if ( !from ) { std::cerr << "ERROR: Unable to to perform units conversion because the" << " units in the data recording file appear to be corrupt." @@ -72,7 +72,7 @@ DPC_UnitConvDataStream::DPC_UnitConvDataStream(DataStream* ds, const char *ToUni } } else { // The user has not specified a units conversion or the units were not valid. // If the recorded data file doesn't contain the units in which the data is recorded ... - if ((recorded_units == NULL) || (strcmp(recorded_units,"") == 0)) { + if (recorded_units.empty()) { // If the user didn't give us a hint as to what the units are (using var@from_units) ... if ((FromUnitsHint == NULL) || (strcmp(FromUnitsHint,"") == 0)) { cf = cv_get_trivial() ; diff --git a/trick_source/data_products/DPX/DPC/DPC_curve.hh b/trick_source/data_products/DPX/DPC/DPC_curve.hh index d37687ed..86b9bafa 100644 --- a/trick_source/data_products/DPX/DPC/DPC_curve.hh +++ b/trick_source/data_products/DPX/DPC/DPC_curve.hh @@ -39,7 +39,7 @@ public: /** * Return the name of the X variable. */ - const char *getXVarShortName() { + std::string getXVarShortName() { return( x_var->getShortName() ); }; @@ -53,7 +53,7 @@ public: /** * Return the name of the Y variable. */ - const char *getYVarShortName() { + std::string getYVarShortName() { return( y_var->getShortName() ); }; diff --git a/trick_source/data_products/DPX/DPC/DPC_plot.hh b/trick_source/data_products/DPX/DPC/DPC_plot.hh index 0486a798..0759c404 100644 --- a/trick_source/data_products/DPX/DPC/DPC_plot.hh +++ b/trick_source/data_products/DPX/DPC/DPC_plot.hh @@ -78,16 +78,16 @@ public: } /** - * Return the X-axis label of the plot, which may be NULL. + * Return the X-axis label of the plot, which may be empty. */ - const char *getXLabel() { + std::string getXLabel() { return( relation->getXAxisLabel()); } /** - * Return the Y-axis label of the plot, which may be NULL. + * Return the Y-axis label of the plot, which may be empty. */ - const char *getYLabel() { + std::string getYLabel() { return( relation->getYAxisLabel()); } diff --git a/trick_source/data_products/DPX/DPC/DPC_std_curve.cpp b/trick_source/data_products/DPX/DPC/DPC_std_curve.cpp index 112e4465..55d37bf4 100644 --- a/trick_source/data_products/DPX/DPC/DPC_std_curve.cpp +++ b/trick_source/data_products/DPX/DPC/DPC_std_curve.cpp @@ -106,9 +106,9 @@ DPC_std_curve::DPC_std_curve( Time_constraints ); if (ds[0] != NULL) { - const char* ds_units = ds[0]->getUnit().c_str(); + std::string ds_units = ds[0]->getUnit(); - y_actual_units = strdup(ds_units); + y_actual_units = strdup(ds_units.c_str()); // Tell our DataStream to start at the beginning. ds[0]->begin(); diff --git a/trick_source/data_products/DPX/DPC/DPC_table.cpp b/trick_source/data_products/DPX/DPC/DPC_table.cpp index 14900cd9..9615d488 100644 --- a/trick_source/data_products/DPX/DPC/DPC_table.cpp +++ b/trick_source/data_products/DPX/DPC/DPC_table.cpp @@ -194,12 +194,12 @@ int DPC_table::getNumColumns() { } // MEMBER FUNCTION -const char *DPC_table::getColumnLabel(unsigned int index) { +std::string DPC_table::getColumnLabel(unsigned int index) { DPM_column *column = table_spec->getColumn( index ); if ( column->getLabel() != NULL) { return( column->getLabel()); } else { - return( column->getVar()->getShortName()); + return( column->getVar()->getShortName() ); } } diff --git a/trick_source/data_products/DPX/DPC/DPC_table.hh b/trick_source/data_products/DPX/DPC/DPC_table.hh index 3a431266..c00efebe 100644 --- a/trick_source/data_products/DPX/DPC/DPC_table.hh +++ b/trick_source/data_products/DPX/DPC/DPC_table.hh @@ -53,9 +53,9 @@ public: int getNumColumns(); /** - * Return the Label (which may be NULL) of the of the indicated column. + * Return the Label (which may be empty) of the of the indicated column. */ - const char *getColumnLabel(unsigned int index); + std::string getColumnLabel(unsigned int index); /** * Return the name of the variable for the indicated column. diff --git a/trick_source/data_products/DPX/DPM/DPM_curve.cpp b/trick_source/data_products/DPX/DPM/DPM_curve.cpp index 0e5006d6..d524fc10 100644 --- a/trick_source/data_products/DPX/DPM/DPM_curve.cpp +++ b/trick_source/data_products/DPX/DPM/DPM_curve.cpp @@ -231,57 +231,54 @@ const char * DPM_curve::getZVarName(unsigned int case_index) { } // MEMBER FUNCTION -const char * DPM_curve::getXCommonName() { +std::string DPM_curve::getXCommonName() { - const char *candidate_label; - const char *short_name; + std::string candidate_label; + int n_vars, i; candidate_label = x_varcase_list[0]->getShortName(); n_vars = (int)x_varcase_list.size(); for (i=1; igetShortName(); - if (strcmp( candidate_label, short_name) != 0 ) { - return (NULL); + if (candidate_label != x_varcase_list[i]->getShortName()) { + return (""); } } - return ( candidate_label); + return (candidate_label); } // MEMBER FUNCTION -const char * DPM_curve::getYCommonName() { +std::string DPM_curve::getYCommonName() { - const char *candidate_label; - const char *short_name; + std::string candidate_label; + int n_vars, i; candidate_label = y_varcase_list[0]->getShortName(); n_vars = (int)y_varcase_list.size(); for (i=1; igetShortName(); - if (strcmp( candidate_label, short_name) != 0 ) { - return (NULL); + if (candidate_label != y_varcase_list[i]->getShortName()) { + return (""); } } return ( candidate_label); } // MEMBER FUNCTION -const char * DPM_curve::getZCommonName() { +std::string DPM_curve::getZCommonName() { - const char *candidate_label; - const char *short_name; + std::string candidate_label; + int n_vars, i; candidate_label = z_varcase_list[0]->getShortName(); n_vars = (int)z_varcase_list.size(); for (i=1; igetShortName(); - if (strcmp( candidate_label, short_name) != 0 ) { - return (NULL); + if (candidate_label != z_varcase_list[i]->getShortName()) { + return (""); } } - return ( candidate_label); + return (candidate_label); } // MEMBER FUNCTION diff --git a/trick_source/data_products/DPX/DPM/DPM_curve.hh b/trick_source/data_products/DPX/DPM/DPM_curve.hh index 434f4bbb..8f7c2a8d 100644 --- a/trick_source/data_products/DPX/DPM/DPM_curve.hh +++ b/trick_source/data_products/DPX/DPM/DPM_curve.hh @@ -69,17 +69,17 @@ public: /** * */ - const char * getXCommonName(); + std::string getXCommonName(); /** * */ - const char * getYCommonName(); + std::string getYCommonName(); /** * */ - const char * getZCommonName(); + std::string getZCommonName(); /** * Output an xml representation of DPM_curve. diff --git a/trick_source/data_products/DPX/DPM/DPM_relation.cpp b/trick_source/data_products/DPX/DPM/DPM_relation.cpp index 0af39c8e..3ea7788f 100644 --- a/trick_source/data_products/DPX/DPM/DPM_relation.cpp +++ b/trick_source/data_products/DPX/DPM/DPM_relation.cpp @@ -148,90 +148,81 @@ int DPM_relation::NumberOfAxes() { } // MEMBER FUNCTION -const char * DPM_relation::getXAxisLabel() { - const char * candidate_label; - const char * short_name; +std::string DPM_relation::getXAxisLabel() { + std::string candidate_label; + int n_curves, i; if (xaxis) { candidate_label = xaxis->getLabel(); } else { - candidate_label = NULL; + candidate_label = ""; } // If an Y-Axis label wasn't supplied, see if there is a common // variable name that will serve as a label. - if (candidate_label == NULL) { - if (( candidate_label = curve_list[0]->getXCommonName() ) == NULL) { - return (NULL); + if (candidate_label == "") { + if (( candidate_label = curve_list[0]->getXCommonName() ) == "") { + return (""); } n_curves = (int)curve_list.size(); for (i=1; igetXCommonName() ) == NULL ) { - return (NULL); - } - if (strcmp( candidate_label, short_name) != 0 ) { - return (NULL); - } + if ( curve_list[i]->getXCommonName().empty() || candidate_label != curve_list[i]->getXCommonName()) { + return (""); + } } } return (candidate_label); } // MEMBER FUNCTION -const char * DPM_relation::getYAxisLabel() { - const char * candidate_label; - const char * short_name; +std::string DPM_relation::getYAxisLabel() { + std::string candidate_label; + int n_curves, i; if (yaxis) { candidate_label = yaxis->getLabel(); } else { - candidate_label = NULL; + candidate_label = ""; } // If an Y-Axis label wasn't supplied, see if there is a common // variable name that will serve as a label. - if (candidate_label == NULL) { - if (( candidate_label = curve_list[0]->getYCommonName() ) == NULL) { - return (NULL); + if (candidate_label == "") { + if (( candidate_label = curve_list[0]->getYCommonName() ) == "") { + return (""); } n_curves = (int)curve_list.size(); for (i=1; igetYCommonName() ) == NULL ) { - return (NULL); - } - if (strcmp( candidate_label, short_name) != 0 ) { - return (NULL); - } + if (curve_list[i]->getYCommonName().empty() || candidate_label != curve_list[i]->getYCommonName()) { + return (""); + } } } return (candidate_label); } // MEMBER FUNCTION -const char * DPM_relation::getZAxisLabel() { - const char * candidate_label; - const char * short_name; +std::string DPM_relation::getZAxisLabel() { + std::string candidate_label; + int n_curves, i; if (zaxis) { candidate_label = zaxis->getLabel(); } else { - candidate_label = NULL; + candidate_label = ""; } // If an Z-Axis label wasn't supplied, see if there is a common // variable name that will serve as a label. - if (candidate_label == NULL) { - if (( candidate_label = curve_list[0]->getZCommonName() ) == NULL) { - return (NULL); + if (candidate_label == "") { + if (( candidate_label = curve_list[0]->getZCommonName() ) == "") { + return (""); } n_curves = (int)curve_list.size(); for (i=1; igetZCommonName() ) == NULL ) { - return (NULL); - } - if (strcmp( candidate_label, short_name) != 0 ) { - return (NULL); - } + if (curve_list[i]->getZCommonName().empty() || candidate_label != curve_list[i]->getZCommonName()) { + return (""); + } } } return (candidate_label); diff --git a/trick_source/data_products/DPX/DPM/DPM_relation.hh b/trick_source/data_products/DPX/DPM/DPM_relation.hh index 7da18ba4..d6daaf61 100644 --- a/trick_source/data_products/DPX/DPM/DPM_relation.hh +++ b/trick_source/data_products/DPX/DPM/DPM_relation.hh @@ -53,9 +53,9 @@ public: /** * */ - const char * getXAxisLabel(); - const char * getYAxisLabel(); - const char * getZAxisLabel(); + std::string getXAxisLabel(); + std::string getYAxisLabel(); + std::string getZAxisLabel(); /** * diff --git a/trick_source/data_products/DPX/DPM/DPM_var.cpp b/trick_source/data_products/DPX/DPM/DPM_var.cpp index 1f102591..a7e8440f 100644 --- a/trick_source/data_products/DPX/DPM/DPM_var.cpp +++ b/trick_source/data_products/DPX/DPM/DPM_var.cpp @@ -40,7 +40,7 @@ const char* DPM_var::getName() { return ( (const char*)name ); } -const char* DPM_var::getShortName() { +std::string DPM_var::getShortName() { char *p; std::string::size_type idx ; @@ -103,7 +103,7 @@ const char* DPM_var::getShortName() { } else { combinedName += " - " + paramName2; } - return combinedName.c_str(); + return combinedName; } } diff --git a/trick_source/data_products/DPX/DPM/DPM_var.hh b/trick_source/data_products/DPX/DPM/DPM_var.hh index 61b07a61..1c4409a4 100644 --- a/trick_source/data_products/DPX/DPM/DPM_var.hh +++ b/trick_source/data_products/DPX/DPM/DPM_var.hh @@ -43,7 +43,7 @@ class DPM_var:public DPM_component { * Return the part of the variable name right of the last * period or the name if there are no periods. */ - const char *getShortName(); + std::string getShortName(); /** * Output an xml representation of DPM_var. diff --git a/trick_source/data_products/DPX/TESTING/DPC_TEST/test_view.cpp b/trick_source/data_products/DPX/TESTING/DPC_TEST/test_view.cpp index 0147fef2..7fc3f1f2 100644 --- a/trick_source/data_products/DPX/TESTING/DPC_TEST/test_view.cpp +++ b/trick_source/data_products/DPX/TESTING/DPC_TEST/test_view.cpp @@ -93,7 +93,7 @@ DPV_pointer test_view::create_table_view( DPV_pointer parent_data, cout << "Number of Columns : " << n_columns << endl; for (colix=0; colix < n_columns ; colix++) { - const char *col_label = table->getColumnLabel( colix); + const char *col_label = table->getColumnLabel( colix).c_str(); const char *var_name = table->getColumnVarName( colix); const char *col_units = table->getColumnUnits( colix); const char *format = table->getColumnAttribute( colix,"format"); diff --git a/trick_source/data_products/DPX/test/unit_test/test_view.cpp b/trick_source/data_products/DPX/test/unit_test/test_view.cpp index 3449d90e..31577ec7 100644 --- a/trick_source/data_products/DPX/test/unit_test/test_view.cpp +++ b/trick_source/data_products/DPX/test/unit_test/test_view.cpp @@ -138,7 +138,7 @@ DPV_pointer Test_view::render_table( DPV_pointer parent_data, DPC_table *table) s << "Number of Columns: " << n_columns << std::endl; for (colix=0; colix < n_columns ; colix++) { - if ((temp_cstr = table->getColumnLabel(colix)) != NULL) { + if ((temp_cstr = table->getColumnLabel(colix).c_str())[0] != '\0') { s << "Column Label [" << colix << "]: " << temp_cstr << std::endl; } if ((temp_cstr = table->getColumnVarName(colix)) != NULL) {