diff options
Diffstat (limited to 'cpp/src/Slice/FileTracker.cpp')
-rw-r--r-- | cpp/src/Slice/FileTracker.cpp | 101 |
1 files changed, 25 insertions, 76 deletions
diff --git a/cpp/src/Slice/FileTracker.cpp b/cpp/src/Slice/FileTracker.cpp index d974b2a8d8d..20dfc7ae93c 100644 --- a/cpp/src/Slice/FileTracker.cpp +++ b/cpp/src/Slice/FileTracker.cpp @@ -7,14 +7,12 @@ // // ********************************************************************** -#include <Slice/FileTracker.h> -#ifdef _WIN32 -# include <direct.h> -#else -# include <unistd.h> -#endif +#include <Slice/FileTracker.h> +#include <IceUtil/ConsoleUtil.h> +#include <IceUtil/FileUtil.h> +using namespace IceUtilInternal; using namespace std; Slice::FileException::FileException(const char* file, int line, const string& r) : @@ -23,16 +21,16 @@ Slice::FileException::FileException(const char* file, int line, const string& r) { } +#ifndef ICE_CPP11_COMPILER Slice::FileException::~FileException() throw() { } - -const char* Slice::FileException::_name = "Slice::FileException"; +#endif string -Slice::FileException::ice_name() const +Slice::FileException::ice_id() const { - return _name; + return "::Slice::FileException"; } void @@ -42,11 +40,13 @@ Slice::FileException::ice_print(ostream& out) const out << ": " << _reason; } +#ifndef ICE_CPP11_MAPPING Slice::FileException* Slice::FileException::ice_clone() const { return new FileException(*this); } +#endif void Slice::FileException::ice_throw() const @@ -93,15 +93,11 @@ Slice::FileTracker::setSource(const string& source) } void -Slice::FileTracker::setOutput(const string& output, bool error) +Slice::FileTracker::error() { - assert(!_source.empty()); - _errors.insert(make_pair(_source, output)); - if(error) - { - _generated.erase(_curr); - _curr = _generated.end(); - } + assert(_curr != _generated.end()); + _generated.erase(_curr); + _curr = _generated.end(); } void @@ -127,19 +123,11 @@ Slice::FileTracker::cleanup() { if(!p->second) { -#ifdef _WIN32 - _unlink(p->first.c_str()); -#else - unlink(p->first.c_str()); -#endif + IceUtilInternal::unlink(p->first); } else { -#ifdef _WIN32 - _rmdir(p->first.c_str()); -#else - rmdir(p->first.c_str()); -#endif + IceUtilInternal::rmdir(p->first); } } } @@ -147,58 +135,19 @@ 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) + consoleOut << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; + consoleOut << "<generated>"; + for(map<string, list<string> >::const_iterator p = _generated.begin(); p != _generated.end(); ++p) { - cout << " <source name=\"" << p->first << "\""; - - map<string, list<string> >::const_iterator q = _generated.find(p->first); - if(q == _generated.end()) + if(!p->second.empty()) { - cout << " error=\"true\">" << endl; - } - else - { - cout << ">" << endl; - for(list<string>::const_iterator r = q->second.begin(); r != q->second.end(); ++r) + consoleOut << endl << " <source name=\"" << p->first << "\">"; + for(list<string>::const_iterator q = p->second.begin(); q != p->second.end(); ++q) { - cout << " <file name=\"" << *r << "\"/>" << endl; + consoleOut << endl << " <file name=\"" << *q << "\"/>"; } - } - 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 << "<"; - break; - case '>': - ostr << ">"; - break; - case '&': - ostr << "&"; - break; - case '"': - ostr << """; - break; - default: - ostr << *p; - break; + consoleOut << endl << " </source>"; } } - - return ostr.str(); + consoleOut << endl << "</generated>" << endl; } |