Pārlūkot izejas kodu

implement array_value for strings

mikymod 12 gadi atpakaļ
vecāks
revīzija
144f903916
2 mainītis faili ar 19 papildinājumiem un 0 dzēšanām
  1. 15 0
      engine/core/json/JSONParser.cpp
  2. 4 0
      engine/core/json/JSONParser.h

+ 15 - 0
engine/core/json/JSONParser.cpp

@@ -314,6 +314,21 @@ void JSONElement::array_value(List<float>& array) const
 	}
 }
 
+//--------------------------------------------------------------------------
+void JSONElement::array_value(Vector<DynamicString>& array) const
+{
+	List<const char*> temp(default_allocator());
+
+	json::parse_array(m_at, temp);
+
+	for (uint32_t i = 0; i < temp.size(); i++)
+	{
+		DynamicString str;
+		json::parse_string(temp[i], str);
+		array.push_back(str);
+	}
+}
+
 //--------------------------------------------------------------------------
 bool JSONElement::is_nil() const
 {

+ 4 - 0
engine/core/json/JSONParser.h

@@ -28,6 +28,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "List.h"
+#include "Vector.h"
 
 namespace crown
 {
@@ -144,6 +145,9 @@ public:
 	/// @copydoc JSONElement::array_value(List<bool>&)
 	void				array_value(List<float>& array) const;
 
+	/// @copydoc JSONElement::array_value(List<bool>&)
+	void				array_value(Vector<DynamicString>& array) const;
+
 private:
 
 	const char*			m_at;