bool IsGeographic(OWConnection* connection, long srid) { std::ostringstream oss; char* kind = (char* ) malloc (OWNAME * sizeof(char)); oss << "SELECT COORD_REF_SYS_KIND from MDSYS.SDO_COORD_REF_SYSTEM WHERE SRID = :1"; OWStatement* statement = 0; statement = connection->CreateStatement(oss.str().c_str()); long* p_srid = (long*) malloc( 1 * sizeof(long)); p_srid[0] = srid; statement->Bind(p_srid); statement->Define(kind); try { statement->Execute(); } catch (std::runtime_error const& e) { delete statement; std::ostringstream oss; oss << "Failed to fetch geographicness of srid " << srid << std::endl << e.what() << std::endl; throw std::runtime_error(oss.str()); } if (compare_no_case(kind, "GEOGRAPHIC2D",12) == 0) { delete statement; free(kind); free(p_srid); return true; } if (compare_no_case(kind, "GEOGRAPHIC3D",12) == 0) { delete statement; free(kind); free(p_srid); return true; } free(kind); free(p_srid); return false; }
bool is_executable(tstring const& name, std::vector<std::string> const& extensions) { // check existence if( !tinfra::fs::exists(name) ) return false; // check correct extension const size_t name_len = name.size(); for( std::vector<std::string>::const_iterator iext = extensions.begin(); iext != extensions.end(); ++iext) { const std::string& ext = *iext; const size_t extlen = ext.size(); if( name_len < extlen ) continue; const tstring actual_ext = name.substr(name_len-extlen, extlen); if( compare_no_case(actual_ext.data(), ext.data(), extlen) == 0 ) { return true; } } return false; }