Error.cpp

00001 #include "Error.h"
00002 
00003 #include <sstream>
00004 
00005 namespace xfltk {
00006 
00007 // Error
00008 
00009 std::ostream& operator<<(std::ostream& out_stream, const Error& error) {
00010         return out_stream << error.what();
00011 }
00012 
00013 Errors::size_type Errors::size() const {
00014         return errors.size();
00015 }
00016 
00017 // Errors
00018 
00019 bool Errors::empty() const {
00020         return errors.empty();
00021 }
00022 
00023 const Error& Errors::operator[](Errors::size_type n) const {
00024         return *errors[n];
00025 }
00026 
00027 void Errors::append(Error* error) {
00028         errors.push_back(error);
00029 }
00030 
00031 void Errors::clear() {
00032         for (error_vec::iterator i = errors.begin(); i != errors.end(); ++i)
00033                 delete *i;
00034         errors.clear();
00035 }
00036 
00037 std::ostream& operator<<(std::ostream& out_stream, const Errors& errors) {
00038         for (Errors::size_type i = 0; i < errors.size(); ++i)
00039                 out_stream << errors[i].line_nr() << ": " << errors[i] << std::endl;
00040         return out_stream;
00041 }
00042 
00043 // GeneralDynamicError
00044 
00045 GeneralDynamicError::GeneralDynamicError(const char* text, int line_nr, ParserAction parser_action)
00046 : Error(line_nr, parser_action), _dynamic_text(utils::strcopy(text))
00047 {}
00048 
00049 GeneralDynamicError::GeneralDynamicError(const GeneralDynamicError& to_copy) 
00050 : Error(to_copy._line_nr, to_copy._parser_action), _dynamic_text(utils::strcopy(to_copy._dynamic_text))
00051 {}
00052 
00053 // InvalidTagError
00054 
00055 const char* InvalidTagError::make_text(const char* tag_name) {
00056         std::stringstream s;
00057         s << "\"" << tag_name << "\" is not valid widget name";
00058         return utils::strcopy(s.str().c_str());
00059 }
00060 
00061 InvalidTagError::InvalidTagError(const char* tag_name, int line_nr, ParserAction parser_action)
00062 : GeneralDynamicError(make_text(tag_name), line_nr, parser_action) {}
00063 
00064 };

Generated on Tue Jan 3 14:32:36 2006 for xfltk by  doxygen 1.4.6-NO