Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use empty() instead of comparing against new string. #58

Merged
merged 1 commit into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/vw/BundleAdjustment/ControlNetwork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ namespace ba {
f << " EphemerisTime = " << m_ephemeris_time << "\n";
if ( m_diameter > 0 )
f << " Diameter = " << m_diameter << "\n";
if ( m_date_time != "" )
if ( !m_date_time.empty() )
f << " DateTime = " << m_date_time << "\n";
if ( m_chooserName != "" )
if ( !m_chooserName.empty() )
f << " ChooserName = " << m_chooserName << "\n";
if ( m_ignore )
f << " Ignore = True\n";
Expand Down Expand Up @@ -210,7 +210,7 @@ namespace ba {
// Cleaning out any tokens that are just ""
for(std::vector<std::string>::iterator iter = tokens.begin();
iter != tokens.end(); ++iter ) {
if ( (*iter) == "" ) {
if ( (*iter).empty() ) {
iter = tokens.erase(iter);
iter--;
}
Expand Down Expand Up @@ -446,7 +446,7 @@ namespace ba {
// Cleaning out any tokens that are just ""
for(std::vector<std::string>::iterator iter = tokens.begin();
iter != tokens.end(); ++iter ) {
if ( (*iter) == "" ) {
if ( (*iter).empty() ) {
iter = tokens.erase(iter);
iter--;
}
Expand Down Expand Up @@ -634,7 +634,7 @@ namespace ba {
// Making sure all the control points have unique IDs
size_t cpcount = 0;
BOOST_FOREACH( ControlPoint& cp, m_control_points ) {
if ( cp.id() == "Null" || cp.id() == "" ) {
if ( cp.id() == "Null" || cp.id().empty() ) {
std::ostringstream ostr;
ostr << std::setw(9) << std::setfill('0') << cpcount;
cp.set_id( ostr.str() );
Expand Down Expand Up @@ -698,7 +698,7 @@ namespace ba {
// Cleaning out any tokens that are just ""
for(std::vector<std::string>::iterator iter = tokens.begin();
iter != tokens.end(); ++iter ) {
if ( (*iter) == "" ) {
if ( (*iter).empty() ) {
iter = tokens.erase(iter);
iter--;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vw/Cartography/GeoReference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ double GeoReference::test_pixel_reprojection_error(Vector2 const& pixel) {

// Apply projcs override if it was specified
std::string projcs_name = this->get_projcs_name();
if (projcs_name != "")
if (!projcs_name.empty())
gdal_spatial_ref.SetProjCS(projcs_name.c_str());

// For perfect spheres, we set the inverse flattening to
Expand Down
2 changes: 1 addition & 1 deletion src/vw/FileIO/DiskImageResourceGDAL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ namespace vw {

m_options = user_options;

if (m_options["PREDICTOR"] == ""){
if (m_options["PREDICTOR"].empty()){
// Unless predictor was explicitly set, use predictor 3 for
// compression of float/double, and predictor 2 for integers,
// except whose size is one byte, as for those compression makes
Expand Down
2 changes: 1 addition & 1 deletion src/vw/FileIO/DiskImageResourceRaw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void DiskImageResourceRaw::close() {
// Factory functions required by DiskImageResource.cc
DiskImageResource* DiskImageResourceRaw::construct_open( std::string const& filename ) {
std::string dim_file = find_associated_spot5_dim_file(filename);
if (dim_file == "")
if (dim_file.empty())
vw_throw( ArgumentErr() << "Could not find .DIM file for: " << filename);

return DiskImageResourceRaw::construct(filename, image_format_from_spot5_DIM(dim_file));
Expand Down
2 changes: 1 addition & 1 deletion src/vw/FileIO/FileUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ bool vw::has_spot5_extension(std::string const& image_file, std::string const& c
if ((image_ext == ".bip") || (image_ext == ".bil") || (image_ext == ".bsq"))
return true;
// If no camera file was provided it cannot be a Spot5 file
if ((camera_file == "") || (camera_file == image_file))
if ((camera_file.empty()) || (camera_file == image_file))
return false;
// The Spot5 file is the last thing we check
const std::string camera_ext = vw::get_extension(camera_file);
Expand Down
24 changes: 12 additions & 12 deletions src/vw/FileIO/KML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ namespace vw {
void KMLFile::enter_folder( std::string name,
std::string desc ) {
open_bracket("Folder");
if ( name != "" )
if ( !name.empty() )
m_output_file << m_tab << "<name>"<< name <<"</name>\n";
if ( desc != "" )
if ( !desc.empty() )
m_output_file << m_tab << "<description>"<< desc <<"</description>\n";
}

Expand All @@ -104,12 +104,12 @@ namespace vw {
double altitude,
bool extrude ) {
open_bracket("Placemark");
if ( name != "" )
if ( !name.empty() )
m_output_file << m_tab << "<name>"<< name <<"</name>\n";
if ( description != "" )
if ( !description.empty() )
m_output_file << m_tab << "<description>"
<< description << "</description>\n";
if ( style != "")
if ( !style.empty())
m_output_file << m_tab << "<styleUrl>#"<<style<<"</styleUrl>\n";
open_bracket("Point");
if ( extrude )
Expand All @@ -125,9 +125,9 @@ namespace vw {
std::string name,
std::string style ) {
open_bracket("Placemark");
if ( name != "" )
if ( !name.empty() )
m_output_file << m_tab << "<name>"<< name <<"</name>\n";
if ( style != "")
if ( !style.empty())
m_output_file << m_tab << "<styleUrl>#"<<style<<"</styleUrl>\n";
open_bracket("LineString");
m_output_file << m_tab << "<altitudeMode>absolute</altitudeMode>\n";
Expand Down Expand Up @@ -157,9 +157,9 @@ namespace vw {
double heading = angles(0)*180/M_PI, tilt = angles(1)*180/M_PI, roll = angles(2)*180/M_PI;

open_bracket("Placemark");
if ( name != "" )
if ( !name.empty() )
m_output_file << m_tab << "<name>"<< name <<"</name>\n";
if ( description != "" )
if ( !description.empty() )
m_output_file << m_tab << "<description>"
<< description << "</description>\n";

Expand Down Expand Up @@ -228,7 +228,7 @@ namespace vw {
close_brackets(1);
}
open_bracket("IconStyle");
if (color_hex != "" )
if (!color_hex.empty() )
m_output_file << m_tab << "<color>" << color_hex << "</color>\n";
m_output_file << m_tab << "<scale>" << scale << "</scale>\n";
open_bracket("Icon");
Expand All @@ -243,7 +243,7 @@ namespace vw {
m_output_file << m_tab << "<Style id=\"" << id << "\">\n";
m_tab.count++;
open_bracket("LineStyle");
if (color_hex != "" )
if (!color_hex.empty() )
m_output_file << m_tab << "<color>" << color_hex << "</color>\n";
m_output_file << m_tab << "<width>" << width << "</width>\n";
close_brackets(1);
Expand Down Expand Up @@ -288,7 +288,7 @@ namespace vw {
// Open / Close Stuff
void KMLFile::open_kml() {
std::ostringstream path;
if ( m_directory != "" )
if ( !m_directory.empty() )
path << m_directory << "/";
path << m_filename;
fs::path kml_path( path.str() );
Expand Down
2 changes: 1 addition & 1 deletion src/vw/Geometry/dPoly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ void dPoly::writePoly(std::string filename, std::string defaultColor){

string layer = "";
if (pIter < (int)m_layers.size()) layer = m_layers[pIter];
if (layer != "") layer = " ; " + layer;
if (!layer.empty()) layer = " ; " + layer;

bool isPolyClosed = true;
if ( pIter < (int)m_colors.size() ) isPolyClosed = m_isPolyClosed[pIter];
Expand Down
2 changes: 1 addition & 1 deletion src/vw/Mosaic/DiskImagePyramid.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ namespace vw { namespace mosaic {
m_top_image_max_pix(top_image_max_pix),
m_nodata_val(std::numeric_limits<double>::quiet_NaN()) {

if (base_file == "")
if (base_file.empty())
return;

if (subsample < 2) {
Expand Down
4 changes: 2 additions & 2 deletions src/vw/tools/detect_water.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ int main(int argc, char **argv) {
return -1;
}

if ((dem_path != "") && (!radar_mode))
if ((!dem_path.empty()) && (!radar_mode))
std::cout << "Warning: DEM file is only used when mode is 'sentinel1'\n";

// If a DEM file was provided, make sure it actually exists before we start doing any processing.
if ((dem_path != "") && !boost::filesystem::exists(dem_path)) {
if ((!dem_path.empty()) && !boost::filesystem::exists(dem_path)) {
std::cout << "Error: Provided DEM file not found!\n";
return -2;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vw/tools/georef.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int main( int argc, char *argv[] ) {
read_georeference( georef, file_resource );
}

if ( georef.proj4_str() == "" ) georef.set_well_known_geogcs("WGS84");
if ( georef.proj4_str().empty() ) georef.set_well_known_geogcs("WGS84");
if( manual || georef.transform() == identity_matrix<3>() ) {
if( manual ) {
vw_out() << "Using manual Plate Carree coordinates: ";
Expand Down
4 changes: 2 additions & 2 deletions src/vw/tools/image2qtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ struct Options {
VW_ASSERT(input_files.size() == 1,
vw::tools::Usage() << "Non-georeferenced images cannot be composed");
if (mode == "CELESTIA" || mode == "UNIVIEW")
VW_ASSERT(module_name != "",
VW_ASSERT(!module_name.empty(),
vw::tools::Usage() << "Uniview and Celestia require --module-name");

if (proj.type == "NONE")
Expand Down Expand Up @@ -394,7 +394,7 @@ void do_mosaic(const Options& opt, const vw::ProgressCallback *progress) {

if (opt.tile_size > 0)
quadtree.set_tile_size(opt.tile_size);
if (opt.output_file_type != "")
if (!opt.output_file_type.empty())
quadtree.set_file_type(opt.output_file_type);

// This box represents the input data, shifted such that total_bbox.min() is
Expand Down
2 changes: 1 addition & 1 deletion src/vw/tools/image2toast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int main(int argc, char **argv) {
return 1;
}

if( output_file_name == "" )
if( output_file_name.empty() )
output_file_name = fs::path(image_files[0]).replace_extension("toast").string();

if( tile_size <= 0 || tile_size != pow(2.,floor(log((double)tile_size)/log(2.))) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/vw/tools/radar.h
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ void sar_martinis(std::string const& input_image_path, std::string const& output
}


if (dem_path == "") {
if (dem_path.empty()) {
// Handle the case where a DEM was not provided

std::cout << "No input DEM file provided, finishing calculations without one.\n";
Expand Down
4 changes: 2 additions & 2 deletions src/vw/tools/slopemap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ int main( int argc, char *argv[] ) {
return 1;
}

if( opt.output_prefix == "" )
if( opt.output_prefix.empty() )
opt.output_prefix=fs::path(opt.input_file_name).replace_extension().string();

//checking strings
Expand All @@ -355,7 +355,7 @@ int main( int argc, char *argv[] ) {
algorithm_string == "sa" ||
algorithm_string == "planefit" ||

algorithm_string == "" ) ) { //it's okay if it isn't set?
algorithm_string.empty() ) ) { //it's okay if it isn't set?
vw_out() << "Unknown opt.algorithm: " << algorithm_string << ". Options are : [ horn, fh, sa, planefit ]\n";
exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/vw/tools/undistort_image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ int main( int argc, char *argv[] ) {

output_nodata_value_was_set = vm.count("output-nodata-value");

if (input_file_name == "" || camera_file_name == "" || output_file_name == "")
if (input_file_name.empty() || camera_file_name.empty() || output_file_name.empty())
vw_throw(ArgumentErr() << "Not all inputs were specified.\n" << desc << "\n");

vw::create_out_dir(output_file_name);
Expand Down