Pārlūkot izejas kodu

Add SetText() as analog to GetText().

Uli Kusterer 12 gadi atpakaļ
vecāks
revīzija
8fe342a872
2 mainītis faili ar 15 papildinājumiem un 3 dzēšanām
  1. 10 0
      tinyxml2.cpp
  2. 5 3
      tinyxml2.h

+ 10 - 0
tinyxml2.cpp

@@ -1260,6 +1260,16 @@ const char* XMLElement::GetText() const
 }
 
 
+void	XMLElement::SetText( const char* inText )
+{
+	if ( FirstChild() )
+		FirstChild()->SetValue( inText );
+	else {
+		XMLText*	theText = GetDocument()->NewText( inText );
+		InsertFirstChild( theText );
+	}
+}
+
 XMLError XMLElement::QueryIntText( int* ival ) const
 {
     if ( FirstChild() && FirstChild()->ToText() ) {

+ 5 - 3
tinyxml2.h

@@ -116,9 +116,9 @@ inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... )
 #define TIXML_SSCANF   sscanf
 #endif
 
-static const int TIXML2_MAJOR_VERSION = 1;
-static const int TIXML2_MINOR_VERSION = 0;
-static const int TIXML2_PATCH_VERSION = 13;
+static const int TIXML2_MAJOR_VERSION = 1;
+static const int TIXML2_MINOR_VERSION = 0;
+static const int TIXML2_PATCH_VERSION = 13;
 
 namespace tinyxml2
 {
@@ -1369,6 +1369,8 @@ public:
     */
     const char* GetText() const;
 
+	void	SetText( const char* inText );
+
     /**
     	Convenience method to query the value of a child text node. This is probably best
     	shown by example. Given you have a document is this form: