fix: function returns by const value

This commit is contained in:
MihailRis
2024-06-07 15:17:32 +03:00
parent d292ef130c
commit a5dc187481
14 changed files with 41 additions and 28 deletions
+3 -3
View File
@@ -42,10 +42,10 @@ const std::string& GLSLExtension::getHeader(const std::string& name) const {
return found->second;
}
const std::string GLSLExtension::getDefine(const std::string& name) const {
const std::string& GLSLExtension::getDefine(const std::string& name) const {
auto found = defines.find(name);
if (found == defines.end()) {
return "";
throw std::runtime_error("name '"+name+"' is not defined");
}
return found->second;
}
@@ -84,7 +84,7 @@ inline void source_line(std::stringstream& ss, uint linenum) {
ss << "#line " << linenum << "\n";
}
const std::string GLSLExtension::process(const fs::path& file, const std::string& source) {
std::string GLSLExtension::process(const fs::path& file, const std::string& source) {
std::stringstream ss;
size_t pos = 0;
uint linenum = 1;
+2 -2
View File
@@ -24,12 +24,12 @@ public:
void addHeader(const std::string& name, std::string source);
const std::string& getHeader(const std::string& name) const;
const std::string getDefine(const std::string& name) const;
const std::string& getDefine(const std::string& name) const;
bool hasHeader(const std::string& name) const;
bool hasDefine(const std::string& name) const;
const std::string process(
std::string process(
const std::filesystem::path& file,
const std::string& source
);
+2 -2
View File
@@ -120,7 +120,7 @@ const std::string& Node::getTag() const {
return tag;
}
const xmlattribute Node::attr(const std::string& name) const {
const xmlattribute& Node::attr(const std::string& name) const {
auto found = attrs.find(name);
if (found == attrs.end()) {
throw std::runtime_error("element <"+tag+" ...> missing attribute "+name);
@@ -128,7 +128,7 @@ const xmlattribute Node::attr(const std::string& name) const {
return found->second;
}
const xmlattribute Node::attr(const std::string& name, const std::string& def) const {
xmlattribute Node::attr(const std::string& name, const std::string& def) const {
auto found = attrs.find(name);
if (found == attrs.end()) {
return Attribute(name, def);
+2 -2
View File
@@ -68,14 +68,14 @@ namespace xml {
/// @param name attribute name
/// @throws std::runtime_error if element has no attribute
/// @return xmlattribute - {name, value}
const xmlattribute attr(const std::string& name) const;
const xmlattribute& attr(const std::string& name) const;
/// @brief Get attribute by name
/// @param name attribute name
/// @param def default value will be returned wrapped in xmlattribute
/// if element has no attribute
/// @return xmlattribute - {name, value} or {name, def} if not found*/
const xmlattribute attr(const std::string& name, const std::string& def) const;
xmlattribute attr(const std::string& name, const std::string& def) const;
/// @brief Check if element has attribute
/// @param name attribute name