]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/sourcemap.cpp
Use default member initializers for simple types
[libs/gl.git] / source / glsl / sourcemap.cpp
index e74f1b67408367ab2ff2a3a28c6381b6aa54656e..6c4dd476289736e7778f2cc3d371f7980efd2f60 100644 (file)
@@ -9,11 +9,7 @@ namespace Msp {
 namespace GL {
 namespace SL {
 
-SourceMap::SourceMap():
-       base_index(0)
-{ }
-
-void SourceMap::set_name(unsigned i, const std::string &n)
+void SourceMap::set_name(unsigned i, const string &n)
 {
        if(source_names.empty())
                base_index = i;
@@ -29,6 +25,16 @@ void SourceMap::set_name(unsigned i, const std::string &n)
        source_names[i] = n;
 }
 
+const string &SourceMap::get_name(unsigned i) const
+{
+       i -= base_index;
+       if(i<source_names.size())
+               return source_names[i];
+
+       static string empty;
+       return empty;
+}
+
 void SourceMap::merge_from(const SourceMap &other)
 {
        if(other.base_index<base_index)
@@ -49,9 +55,9 @@ string SourceMap::translate_errors(const string &errors) const
        static const Regex r_message("^(([0-9]+)\\(([0-9]+)\\) :|ERROR: ([0-9]+):([0-9]+):) (.*)$");
        vector<string> lines = split(errors, '\n');
        string translated;
-       for(vector<string>::const_iterator i=lines.begin(); i!=lines.end(); ++i)
+       for(const string &l: lines)
        {
-               RegMatch m = r_message.match(*i);
+               RegMatch m = r_message.match(l);
                if(m)
                {
                        unsigned index = 0;
@@ -72,7 +78,7 @@ string SourceMap::translate_errors(const string &errors) const
                        translated += format("%s:%d: %s", src, line, m[6].str);
                }
                else
-                       translated += *i;
+                       translated += l;
                translated += '\n';
        }