Daniele Bartolini 12 лет назад
Родитель
Сommit
19f371876a
2 измененных файлов с 20 добавлено и 0 удалено
  1. 13 0
      engine/core/json/JSONParser.cpp
  2. 7 0
      engine/core/json/JSONParser.h

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

@@ -271,6 +271,19 @@ float JSONParser::float_value() const
 	return JSONParser::parse_float(m_at);
 }
 
+//--------------------------------------------------------------------------
+const char* JSONParser::string_value() const
+{
+	static TempAllocator1024 alloc;
+	static List<char> string(alloc);
+
+	string.clear();
+
+	JSONParser::parse_string(m_at, string);
+
+	return string.begin();
+}
+
 //--------------------------------------------------------------------------
 bool JSONParser::is_nil() const
 {

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

@@ -107,6 +107,13 @@ public:
 	/// Returns the float value of the current element.
 	float				float_value() const;
 
+	/// Returns the string value of the current element.
+	/// @warning
+	/// The returned string is kept internally until the next call to
+	/// this function, so it is highly unsafe to just keep the pointer
+	/// instead of copying its content somewhere else.
+	const char*			string_value() const;
+
 public:
 
 	/// Returns the type of the @a s JSON text.