OpenASIP  2.0
DOMBuilderErrorHandler.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file DOMBuilderErrorHandler.cc
26  *
27  * Implementation of DOMBuilderErrorHandler class.
28  *
29  * @author Lasse Laasonen 2004 (lasse.laasonen-no.spam-tut.fi)
30  */
31 
32 #include <xercesc/dom/DOMLocator.hpp>
33 
35 #include "Conversion.hh"
36 
37 using std::string;
38 
39 /**
40  * Constructor.
41  */
43  errorCount_(0), errorLog_("") {
44 }
45 
46 
47 /**
48  * Destructor.
49  */
51 }
52 
53 
54 /**
55  * Handler function to process errors that occur while building DOM
56  * documents.
57  *
58  * Stores information to locate the error (URI, line number, column,
59  * diagnostic message) passed by a DOM builder to an error log. Called by
60  * DOMBuilder::parseURI.
61  *
62  * @param domError Error generated by DOM builder.
63  * @return Always Boolean value 'true'.
64  */
65 bool
66 DOMBuilderErrorHandler::handleError(const DOMError& domError) {
67 
68  errorCount_++;
69  DOMLocator* locator = domError.getLocation();
70 
71  errorLog_ += "Error at file ";
72  errorLog_ += Conversion::XMLChToString(locator->getURI());
73  errorLog_ += ", line ";
74  errorLog_ += Conversion::toString(locator->getLineNumber());
75  errorLog_ += ", column ";
76  errorLog_ += Conversion::toString(locator->getColumnNumber());
77  errorLog_ += "\n Message: ";
78  errorLog_ += Conversion::XMLChToString(domError.getMessage());
79  errorLog_ += "\n";
80 
81  return true;
82 }
83 
84 
85 /**
86  * Returns the number of errors handled.
87  *
88  * @return Number of errors handled.
89  */
90 int
92  return errorCount_;
93 }
94 
95 
96 /**
97  * Returns the error log.
98  *
99  * @return The error log.
100  */
101 string
103  return errorLog_;
104 }
DOMBuilderErrorHandler::errorCount_
int errorCount_
Number of errors handled.
Definition: DOMBuilderErrorHandler.hh:58
DOMBuilderErrorHandler::errorLog_
std::string errorLog_
Error log.
Definition: DOMBuilderErrorHandler.hh:60
Conversion::toString
static std::string toString(const T &source)
DOMBuilderErrorHandler::~DOMBuilderErrorHandler
virtual ~DOMBuilderErrorHandler()
Definition: DOMBuilderErrorHandler.cc:50
Conversion.hh
DOMBuilderErrorHandler::errorLog
std::string errorLog() const
Definition: DOMBuilderErrorHandler.cc:102
DOMBuilderErrorHandler::handleError
bool handleError(const DOMError &domError)
Definition: DOMBuilderErrorHandler.cc:66
DOMBuilderErrorHandler.hh
Conversion::XMLChToString
static std::string XMLChToString(const XMLCh *source)
DOMBuilderErrorHandler::errorCount
int errorCount() const
Definition: DOMBuilderErrorHandler.cc:91
DOMBuilderErrorHandler::DOMBuilderErrorHandler
DOMBuilderErrorHandler()
Definition: DOMBuilderErrorHandler.cc:42