summaryrefslogtreecommitdiff
path: root/cpp/src/Slice/FileTracker.cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2009-02-02 10:15:06 -0800
committerMark Spruiell <mes@zeroc.com>2009-02-02 10:15:06 -0800
commitc1ce7caa97b3dd6f7536d5c3b8b482d823c51891 (patch)
tree85be09ca58cee5a9dffa27cbcf3ce67a0d2b25f2 /cpp/src/Slice/FileTracker.cpp
parentRemoved old makedist scripts (diff)
downloadice-c1ce7caa97b3dd6f7536d5c3b8b482d823c51891.tar.bz2
ice-c1ce7caa97b3dd6f7536d5c3b8b482d823c51891.tar.xz
ice-c1ce7caa97b3dd6f7536d5c3b8b482d823c51891.zip
bug 3644 - improve integration between eclipse plugin and translator
bug 3657 - improve error reporting in translators
Diffstat (limited to 'cpp/src/Slice/FileTracker.cpp')
-rw-r--r--cpp/src/Slice/FileTracker.cpp83
1 files changed, 82 insertions, 1 deletions
diff --git a/cpp/src/Slice/FileTracker.cpp b/cpp/src/Slice/FileTracker.cpp
index 43d9632ad17..051fa6919d6 100644
--- a/cpp/src/Slice/FileTracker.cpp
+++ b/cpp/src/Slice/FileTracker.cpp
@@ -61,7 +61,8 @@ Slice::FileException::reason() const
static Slice::FileTrackerPtr Instance;
-Slice::FileTracker::FileTracker()
+Slice::FileTracker::FileTracker() :
+ _curr(_generated.end())
{
}
@@ -81,9 +82,30 @@ Slice::FileTracker::instance()
}
void
+Slice::FileTracker::setSource(const string& source, const string& output, bool error)
+{
+ _source = source;
+ _errors.insert(make_pair(source, output));
+ if(error)
+ {
+ _curr = _generated.end();
+ }
+ else
+ {
+ pair<map<string, list<string> >::iterator, bool> p = _generated.insert(make_pair(source, list<string>()));
+ assert(p.second);
+ _curr = p.first;
+ }
+}
+
+void
Slice::FileTracker::addFile(const string& file)
{
_files.push_front(make_pair(file, false));
+ if(_curr != _generated.end())
+ {
+ _curr->second.push_back(file);
+ }
}
void
@@ -115,3 +137,62 @@ Slice::FileTracker::cleanup()
}
}
}
+
+void
+Slice::FileTracker::dumpxml()
+{
+ cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
+
+ cout << "<generated>" << endl;
+ for(map<string, string>::const_iterator p = _errors.begin(); p != _errors.end(); ++p)
+ {
+ cout << " <source name=\"" << p->first << "\"";
+
+ map<string, list<string> >::const_iterator q = _generated.find(p->first);
+ if(q == _generated.end())
+ {
+ cout << " error=\"true\">" << endl;
+ }
+ else
+ {
+ cout << ">" << endl;
+ for(list<string>::const_iterator r = q->second.begin(); r != q->second.end(); ++r)
+ {
+ cout << " <file name=\"" << *r << "\"/>" << endl;
+ }
+ }
+ cout << " <output>" << escape(p->second) << "</output>" << endl;
+ cout << " </source>" << endl;
+ }
+ cout << "</generated>" << endl;
+}
+
+string
+Slice::FileTracker::escape(const string& str) const
+{
+ ostringstream ostr;
+
+ for(string::const_iterator p = str.begin(); p != str.end(); ++p)
+ {
+ switch(*p)
+ {
+ case '<':
+ ostr << "&lt;";
+ break;
+ case '>':
+ ostr << "&gt;";
+ break;
+ case '&':
+ ostr << "&amp;";
+ break;
+ case '"':
+ ostr << "&quot;";
+ break;
+ default:
+ ostr << *p;
+ break;
+ }
+ }
+
+ return ostr.str();
+}