1
0
Эх сурвалжийг харах

Reuse code for error clearing

Dmitry-Me 9 жил өмнө
parent
commit
0d2cef0cba
2 өөрчлөгдсөн 6 нэмэгдсэн , 4 устгасан
  1. 2 4
      tinyxml2.cpp
  2. 4 0
      tinyxml2.h

+ 2 - 4
tinyxml2.cpp

@@ -1955,9 +1955,7 @@ void XMLDocument::Clear()
 #ifdef DEBUG
 #ifdef DEBUG
     const bool hadError = Error();
     const bool hadError = Error();
 #endif
 #endif
-    _errorID = XML_SUCCESS;
-	_errorStr1.Reset();
-	_errorStr2.Reset();
+    ClearError();
 
 
     delete [] _charBuffer;
     delete [] _charBuffer;
     _charBuffer = 0;
     _charBuffer = 0;
@@ -2162,7 +2160,7 @@ XMLError XMLDocument::SaveFile( FILE* fp, bool compact )
 {
 {
     // Clear any error from the last save, otherwise it will get reported
     // Clear any error from the last save, otherwise it will get reported
     // for *this* call.
     // for *this* call.
-	SetError(XML_SUCCESS, 0, 0);
+    ClearError();
     XMLPrinter stream( fp, compact );
     XMLPrinter stream( fp, compact );
     Print( &stream );
     Print( &stream );
     return _errorID;
     return _errorID;

+ 4 - 0
tinyxml2.h

@@ -1740,6 +1740,10 @@ public:
 
 
     void SetError( XMLError error, const char* str1, const char* str2 );
     void SetError( XMLError error, const char* str1, const char* str2 );
 
 
+    void ClearError() {
+        SetError(XML_SUCCESS, 0, 0);
+    }
+
     /// Return true if there was an error parsing the document.
     /// Return true if there was an error parsing the document.
     bool Error() const {
     bool Error() const {
         return _errorID != XML_SUCCESS;
         return _errorID != XML_SUCCESS;