diff --git a/src/sky/GSkyRegionCircle.cpp b/src/sky/GSkyRegionCircle.cpp index 3bf8705..2d380e1 100644 --- a/src/sky/GSkyRegionCircle.cpp +++ b/src/sky/GSkyRegionCircle.cpp @@ -347,18 +347,20 @@ void GSkyRegionCircle::read(const std::string& line) compute_solid_angle(); // Check if there is a given name for the region and set it - std::vectorcomments = gammalib::split(comment, " "); - for (int i = 0; i < comments.size(); i++) { - if (gammalib::contains(comments[i], "text")) { - std::vector attributes = gammalib::split(comments[i], "="); - if (attributes.size() < 2) { - std::string msg = - "Invalid character sequence encountered in provided" - " string \""+line+"\".\n" - "An attribute of the type \"text=Name\" is expected."; - throw GException::invalid_value(G_READ, msg); - } - m_name = attributes[1]; + std::vectorcomments = gammalib::split(comment, " "); + for (int i = 0; i < comments.size(); i++) { + if (gammalib::contains(comments[i], "text")) { + std::vector attributes = gammalib::split(comments[i], "="); + unsigned pos_text = attributes[1].find("{"); + unsigned length_text = attributes[1].find("}") - pos_text; + if (attributes.size() < 2) { + std::string msg = + "Invalid character sequence encountered in provided" + " string \""+line+"\".\n" + "An attribute of the type \"text=Name\" is expected."; + throw GException::invalid_value(G_READ, msg); + } + m_name = attributes[1].substr(pos_text+1, length_text-1); } } diff --git a/src/sky/GSkyRegionRing.cpp b/src/sky/GSkyRegionRing.cpp index c835486..6125103 100644 --- a/src/sky/GSkyRegionRing.cpp +++ b/src/sky/GSkyRegionRing.cpp @@ -372,18 +372,20 @@ void GSkyRegionRing::read(const std::string& line) compute_solid_angle(); // Check if there is a given name for the region and set it - std::vectorcomments = gammalib::split(comment, " "); - for (int i = 0; i < comments.size(); i++) { - if (gammalib::contains(comments[i], "text")) { - std::vector attributes = gammalib::split(comments[i], "="); - if (attributes.size() < 2) { - std::string msg = - "Invalid character sequence encountered in provided" - " string \""+line+"\".\n" - "An attribute of the type \"text=Name\" is expected."; - throw GException::invalid_value(G_READ, msg); - } - m_name = attributes[1]; + std::vectorcomments = gammalib::split(comment, " "); + for (int i = 0; i < comments.size(); i++) { + if (gammalib::contains(comments[i], "text")) { + std::vector attributes = gammalib::split(comments[i], "="); + unsigned pos_text = attributes[1].find("{"); + unsigned length_text = attributes[1].find("}") - pos_text; + if (attributes.size() < 2) { + std::string msg = + "Invalid character sequence encountered in provided" + " string \""+line+"\".\n" + "An attribute of the type \"text=Name\" is expected."; + throw GException::invalid_value(G_READ, msg); + } + m_name = attributes[1].substr(pos_text+1, length_text-1); } }