소스 검색

Merge pull request #502 from Dmitry-Me/reuseClearError

Reuse code for error clearing
Lee Thomason 9 년 전
부모
커밋
156bc1b99f
2개의 변경된 파일6개의 추가작업 그리고 4개의 파일을 삭제
  1. 2 4
      tinyxml2.cpp
  2. 4 0
      tinyxml2.h

+ 2 - 4
tinyxml2.cpp

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

+ 4 - 0
tinyxml2.h

@@ -1741,6 +1741,10 @@ public:
 
     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.
     bool Error() const {
         return _errorID != XML_SUCCESS;