refactor: use new string type part 1#705
Open
nickvunen wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's done
Foundation (compile-time safety + helpers)
__attribute__((format(printf,...)))toCDBDebug,CDBError,CDBWarning,CT::printf, etc. — compiler now rejects%sagainst astd::stringat build timenamespace CT::operating onstd::string(split,trim,replace,printf,startsWith,endsWith,indexOf,toFloat,isFloat,encodeXml,basename, ...)CT::fromCStr(const char*)for null-safeconst char*→std::stringconversion (replacesCT::string's null-pointer-tolerant constructor)CT::string ↔ std::stringinterop (constructor + explicit cast)Migrated to
std::stringFields:
GeoParameters::crsProjectionMapKey::{sourceCRS, destCRS}PointDV::idCRectangleText::{text, fontFile}CServerParams::{responceCrs, mapTitle, mapSubTitle, BGColor, JSONP, queryStrURLParam, datasetLocation}CRequest::{Version, Exceptions}COpenDAPHandler::httpHeaderContentTypeCNetCDFDataWriter::tempFileNameCXMLGen::serviceInfoCReporter::_filenameFunction signatures:
isLonLatProjection,isMercatorProjectionfindReaderByFileNamecheckIfFileMatchesLayerfindLayerConfigForRequestedLayerCSLD::{parameterIsSld, processSLDUrl}CReporter::filenameNull-safety:
.copy(rawCharPtr)→= CT::fromCStr(rawCharPtr)acrossCCDFDataModel/Bug fixes uncovered by the format attribute
CXMLSerializerInterface.cpp:102—CT::stringpassed via%svarargsCCDFNetCDFIO.cpp:552—CT::string *passed via%svarargsCOpenDAPHandler.cpp:423—getenv()null-pointer crash post-migrationDocs
NEWS.mdupdateddoc/developing/string-migration.md— patterns + risks for future PRsStats
What's left
CDF::Variable::name,CDF::Attribute::name,CDF::Dimension::namestillCT::string. Touched by every reader/converter; needs a dedicated PR.CDataSourcemembers —nativeProj4,nativeEPSG,headerFilename,meaning, etc. High ripple, needs dedicated PR.adagucserverEC/CServerConfig_CPPXSD.h(hundreds ofCT::stringattribute fields) and the field renameCXMLObjectInterface::value→elementValue. PR Improve cfg parsing #700 has a proposed mechanical rewrite for this.LayerMetadataType.h,CKeyValuePair,COGCDims,CXMLParser::XMLElement,CTime,CDBStore::Record,CXMLGen::*(CT::string *XMLDocbuilder pattern).hclasses/—CXMLParser,CDirReader,CHTTPTools,CReportMessage.CT::string,CT::stringref,CT::StackListoperator const char *()(currently catches printf misuse via the format attribute, but should ultimately be replaced by all callers using.c_str()explicitly)