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

DD4hep: Replace "const char*" with "const std::string&" #28384

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
3 changes: 0 additions & 3 deletions DetectorDescription/DDCMS/data/cms-geometry-2021.xml
Expand Up @@ -14,9 +14,6 @@
<debug_visattr/-->
</debug>

<!--DisabledAlgo name="track:DDCutTubsFromPoints"/>
<DisabledAlgo name="track:DDTOBRadCableAlgo"/-->

<open_geometry/>
<close_geometry/>

Expand Down
4 changes: 2 additions & 2 deletions DetectorDescription/DDCMS/interface/DDFilteredView.h
Expand Up @@ -147,11 +147,11 @@ namespace cms {

//! extract attribute value
template <typename T>
T get(const char*) const;
T get(const std::string&) const;

//! extract attribute value in SpecPar
template <typename T>
T get(const char*, const char*) const;
T get(const std::string&, const std::string&) const;

std::string_view getString(const std::string&) const;

Expand Down
8 changes: 4 additions & 4 deletions DetectorDescription/DDCMS/interface/DDSpecParRegistry.h
Expand Up @@ -12,12 +12,12 @@ namespace cms {
using DDVectorsMap = tbb::concurrent_unordered_map<std::string, tbb::concurrent_vector<double>>;

struct DDSpecPar {
std::string_view strValue(const char*) const;
bool hasValue(const char* key) const;
double dblValue(const char*) const;
std::string_view strValue(const std::string&) const;
bool hasValue(const std::string& key) const;
double dblValue(const std::string&) const;

template <typename T>
T value(const char*) const;
T value(const std::string&) const;

DDPaths paths;
DDPartSelectionMap spars;
Expand Down
10 changes: 5 additions & 5 deletions DetectorDescription/DDCMS/src/DDFilteredView.cc
Expand Up @@ -304,7 +304,7 @@ LegacySolidShape DDFilteredView::legacyShape(const cms::DDSolidShape shape) cons
}

template <>
std::string_view DDFilteredView::get<string_view>(const char* key) const {
std::string_view DDFilteredView::get<string_view>(const string& key) const {
std::string_view result;
DDSpecParRefs refs;
registry_->filter(refs, key);
Expand Down Expand Up @@ -333,7 +333,7 @@ std::string_view DDFilteredView::get<string_view>(const char* key) const {
}

template <>
double DDFilteredView::get<double>(const char* key) const {
double DDFilteredView::get<double>(const string& key) const {
double result(0.0);
std::string_view tmpStrV = get<std::string_view>(key);
if (!tmpStrV.empty())
Expand All @@ -342,15 +342,15 @@ double DDFilteredView::get<double>(const char* key) const {
}

template <>
std::vector<double> DDFilteredView::get<std::vector<double>>(const char* name, const char* key) const {
std::vector<double> DDFilteredView::get<std::vector<double>>(const string& name, const string& key) const {
if (registry_->hasSpecPar(name))
return registry_->specPar(name)->value<std::vector<double>>(key);
else
return std::vector<double>();
}

template <>
std::vector<std::string> DDFilteredView::get<std::vector<std::string>>(const char* name, const char* key) const {
std::vector<std::string> DDFilteredView::get<std::vector<std::string>>(const string& name, const string& key) const {
if (registry_->hasSpecPar(name))
return registry_->specPar(name)->value<std::vector<std::string>>(key);
else
Expand All @@ -360,7 +360,7 @@ std::vector<std::string> DDFilteredView::get<std::vector<std::string>>(const cha
std::string_view DDFilteredView::getString(const std::string& key) const {
assert(currentFilter_);
assert(currentFilter_->spec);
return currentFilter_->spec->strValue(key.c_str());
return currentFilter_->spec->strValue(key);
}

DDFilteredView::nav_type DDFilteredView::navPos() const {
Expand Down
10 changes: 5 additions & 5 deletions DetectorDescription/DDCMS/src/DDSpecparRegistry.cc
Expand Up @@ -7,22 +7,22 @@ using namespace std;
using namespace cms;
using namespace edm;

string_view DDSpecPar::strValue(const char* key) const {
string_view DDSpecPar::strValue(const string& key) const {
auto const& item = spars.find(key);
if (item == end(spars))
return string();
return *begin(item->second);
}

bool DDSpecPar::hasValue(const char* key) const {
bool DDSpecPar::hasValue(const string& key) const {
if (numpars.find(key) != end(numpars))
return true;
else
return false;
}

template <>
std::vector<double> DDSpecPar::value<std::vector<double>>(const char* key) const {
std::vector<double> DDSpecPar::value<std::vector<double>>(const string& key) const {
std::vector<double> result;

auto const& nitem = numpars.find(key);
Expand All @@ -41,7 +41,7 @@ std::vector<double> DDSpecPar::value<std::vector<double>>(const char* key) const
}

template <>
std::vector<std::string> DDSpecPar::value<std::vector<std::string>>(const char* key) const {
std::vector<std::string> DDSpecPar::value<std::vector<std::string>>(const string& key) const {
std::vector<std::string> result;

auto const& nitem = numpars.find(key);
Expand All @@ -61,7 +61,7 @@ std::vector<std::string> DDSpecPar::value<std::vector<std::string>>(const char*
return result;
}

double DDSpecPar::dblValue(const char* key) const {
double DDSpecPar::dblValue(const string& key) const {
auto const& item = numpars.find(key);
if (item == end(numpars))
return 0;
Expand Down