<commit_before>Rem
	bbdoc: XML-RPC Data Type exception
End Rem
Type TXMLRPC_Value_Exception Extends TXMLRPC_Exception   
End Type

Rem
	bbdoc: Base type for all XML-RPC data types
End Rem
Type TXMLRPC_Value_Abstract Abstract
	Field _type:Int

	Rem
		bbdoc: The name or id this value has been identified with in the response. read-only
	End Rem
	Field name:String
	
	Rem
		bbdoc: Convert a XMLRPC_VALUE from XMLRPC-EPI to a BlitzMax type
	End Rem
	Function XMLRPC_To_BlizMax:TXMLRPC_Value_Abstract(val:Byte Ptr) Final
		Local dataType:Int = XMLRPC_GetValueType(val)
		Local data:TXMLRPC_Value_Abstract
		Select dataType
			Case xmlrpc_none
				data = New TXMLRPC_Value_None
			Case xmlrpc_empty
				data = New TXMLRPC_Value_Empty
			Case xmlrpc_base64
				data = New TXMLRPC_Value_Base64
				Local cStr:Byte Ptr = XMLRPC_GetValueBase64(val)
				If cStr
					TXMLRPC_Value_Base64(data).value = String.FromCString(cStr)
					XMLRPC_Free(cStr)
				End If
			Case xmlrpc_boolean
				data = New TXMLRPC_Value_Boolean
				TXMLRPC_Value_Boolean(data).value = XMLRPC_GetValueBoolean(val)
			Case xmlrpc_datetime
				data = New TXMLRPC_Value_Datetime
				Local cStr:Byte Ptr = XMLRPC_GetValueDateTime_ISO8601(val)
				If cStr
					TXMLRPC_Value_Datetime(data).value = String.FromCString(cStr)
					XMLRPC_Free(cStr)
				End If
			Case xmlrpc_double
				data = New TXMLRPC_Value_Double
				TXMLRPC_Value_Double(data).value = XMLRPC_GetValueDouble(val)
			Case xmlrpc_int
				data = New TXMLRPC_Value_Int
				TXMLRPC_Value_Int(data).value = XMLRPC_GetValueInt(val)
			Case xmlrpc_string
				data = New TXMLRPC_Value_String
				Local cStr:Byte Ptr = XMLRPC_GetValueString(val)
				If cStr
					TXMLRPC_Value_String(data).value = String.FromCString(cStr)
					XMLRPC_Free(cStr)
				End If
			Case xmlrpc_vector
				Local vectorType:Int = XMLRPC_GetVectorType(val)
				Select vectorType
					Case xmlrpc_vector_array
						data = New TXMLRPC_Value_Array
					Case xmlrpc_vector_struct
						data = New TXMLRPC_Value_Struct
					Case xmlrpc_vector_mixed
						Throw New TXMLRPC_Value_Exception.Create("Not sure yet how to handle a xmlrpc_vector_mixed value")
				End Select
				
				If TXMLRPC_Value_Collection(data)
					TXMLRPC_Value_Collection(data).SetData(val)
				End If
			Default
				Throw New TXMLRPC_Value_Exception.Create("I don't know a XMLRPC_VALUE with number " + dataType)
		End Select
		
		If data
			data._type = dataType
			Local cStr:Byte Ptr = XMLRPC_GetValueID(val)
			If cStr
				data.name = String.FromCString(cStr)
				XMLRPC_Free(cStr)<commit_msg>All vector types have been added to the Select in TXMLRPC_Value_Abstract.XMLRPC_To_BlizMax()<commit_after>Rem
	bbdoc: XML-RPC Data Type exception
End Rem
Type TXMLRPC_Value_Exception Extends TXMLRPC_Exception   
End Type

Rem
	bbdoc: Base type for all XML-RPC data types
End Rem
Type TXMLRPC_Value_Abstract Abstract
	Field _type:Int

	Rem
		bbdoc: The name or id this value has been identified with in the response. read-only
	End Rem
	Field name:String
	
	Rem
		bbdoc: Convert a XMLRPC_VALUE from XMLRPC-EPI to a BlitzMax type
	End Rem
	Function XMLRPC_To_BlizMax:TXMLRPC_Value_Abstract(val:Byte Ptr) Final
		Local dataType:Int = XMLRPC_GetValueType(val)
		Local data:TXMLRPC_Value_Abstract
		Select dataType
			Case xmlrpc_none
				data = New TXMLRPC_Value_None
			Case xmlrpc_empty
				data = New TXMLRPC_Value_Empty
			Case xmlrpc_base64
				data = New TXMLRPC_Value_Base64
				Local cStr:Byte Ptr = XMLRPC_GetValueBase64(val)
				If cStr
					TXMLRPC_Value_Base64(data).value = String.FromCString(cStr)
					XMLRPC_Free(cStr)
				End If
			Case xmlrpc_boolean
				data = New TXMLRPC_Value_Boolean
				TXMLRPC_Value_Boolean(data).value = XMLRPC_GetValueBoolean(val)
			Case xmlrpc_datetime
				data = New TXMLRPC_Value_Datetime
				Local cStr:Byte Ptr = XMLRPC_GetValueDateTime_ISO8601(val)
				If cStr
					TXMLRPC_Value_Datetime(data).value = String.FromCString(cStr)
					XMLRPC_Free(cStr)
				End If
			Case xmlrpc_double
				data = New TXMLRPC_Value_Double
				TXMLRPC_Value_Double(data).value = XMLRPC_GetValueDouble(val)
			Case xmlrpc_int
				data = New TXMLRPC_Value_Int
				TXMLRPC_Value_Int(data).value = XMLRPC_GetValueInt(val)
			Case xmlrpc_string
				data = New TXMLRPC_Value_String
				Local cStr:Byte Ptr = XMLRPC_GetValueString(val)
				If cStr
					TXMLRPC_Value_String(data).value = String.FromCString(cStr)
					XMLRPC_Free(cStr)
				End If
			Case xmlrpc_vector
				Local vectorType:Int = XMLRPC_GetVectorType(val)
				Select vectorType
					Case xmlrpc_vector_array
						data = New TXMLRPC_Value_Array
					Case xmlrpc_vector_struct
						data = New TXMLRPC_Value_Struct
					Case xmlrpc_vector_mixed
						Throw New TXMLRPC_Value_Exception.Create("Not sure yet how to handle a xmlrpc_vector_mixed value")
					Case xmlrpc_vector_none
						Throw New TXMLRPC_Value_Exception.Create("Not sure yet how to handle a xmlrpc_vector_none value")
					Default
						Throw New TXMLRPC_Value_Exception.Create("Unknown vector type: " + vectorType)
				End Select
				
				If TXMLRPC_Value_Collection(data)
					TXMLRPC_Value_Collection(data).SetData(val)
				End If
			Default
				Throw New TXMLRPC_Value_Exception.Create("I don't know a XMLRPC_VALUE with number " + dataType)
		End Select
		
		If data
			data._type = dataType
			Local cStr:Byte Ptr = XMLRPC_GetValueID(val)
			If cStr
				data.name = String.FromCString(cStr)
				XMLRPC_Free(cStr)
{'fraction_non_alphanumeric': 0.04924382146809295, 'fraction_numerical': 0.004426410918480265, 'mean_word_length': 3.957038391224863, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 28}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5164686', 'n_tokens_mistral': 2223, 'n_tokens_neox': 1821, 'n_words': 461}