Module XmlRPCTypes


module XmlRPCTypes: sig  end
Mapping XML-RPC types to ocaml types



Interfacing XML-RPC and ocaml types




XML-RPC structs


type xrs 
An XML-RPC struct consists of zero or more key/value pairs, where the key is a string and the value is a t. You don't need to know how the structs are implemented internally (But if you're curious, as (string, t) Hashtbl.t at the moment), just use the functions described below to get at and access pairs.


XML-RPC types


type t = [ `Array of t array
| `Base64 of string
| `Boolean of bool
| `DateTime of string
| `Double of float
| `Int of int32
| `RawBase64 of string
| `String of string
| `Struct of xrs
| `Unit ]
This type includes all the possible XML-RPC types, and the ocaml type they corespond to. Functions listed below allow for easy extraction of the the ocaml type, or creation of the XML-RPC type.

Note that for `Base64, the string argument should not be actually base64-encoded by you. Use '`RawBase64 to hold data that's already thus encoded.


type fault = {
   desc : string;
   code : int;
}
Type of XML-RPC error information


Structs again



These functions can be used to create new structs, and manipulate existing ones -- like, say, one returned by a remote function.

val make_struct : unit -> xrs
Create a new struct.
val add_elem : xrs -> string -> t -> unit
Insert a new key/data pair into the struct
val find_elem : xrs -> string -> t
Return the data for a key. Raises Not_found if the element isn't present


Miscellanous routines


exception Bad_type
This exception is thrown by many of the conversion functions in this module when passed a different type than what they're expecting
val escape_cdata : string -> string
escape_cdata string turns <, > and & into XML/HTML entities


Converting types




Ocaml to XML-RPC


val xr_of_int : int -> t
These functions take an argument of an ocaml type and return it stored in the corresponding XML-RPC type.
val xr_of_int32 : int32 -> t
val xr_of_string : string -> t
val xr_of_bool : bool -> t
val xr_of_float : float -> t
val xr_of_base64 : string -> t
xr_of_base64 will store data that's not already base-64 encoded.
val xr_of_rawbase64 : string -> t
But xr_of_rawbase64 does expect its argument to already be encoded.
val xr_of_array : t array -> t
val xr_of_struct : xrs -> t
val skip : t


XML-RPC to Ocaml


val ml_of_int : t -> int
These functions convert Ocaml reps of XML-RPC types into native Ocaml types. If passed a XmlRPCTypes.t of the wrong type for what you want to convert it to, they will raise XmlRPCTypes.Bad_type in revenge.
val ml_of_int32 : t -> int32
val ml_of_string : t -> string
val ml_of_float : t -> float
val ml_of_bool : t -> bool
val ml_of_base64 : t -> string
ml_of_base64 will return the decoded data
val ml_of_rawbase64 : t -> string
And ml_of_rawbase64 will return the data still base64-encoded
val ml_of_struct : t -> xrs
val ml_of_datetime : t -> string
val ml_of_fault : t -> fault
val ml_of_array : t -> t array
val ml_of_intarray : t -> int array
val ml_of_int32array : t -> int32 array
val ml_of_floatarray : t -> float array
val ml_of_datetimearray : t -> string array
val ml_of_base64array : t -> string array
val ml_of_rawbase64array : t -> string array
val ml_of_stringarray : t -> string array
val ml_of_boolarray : t -> bool array
val ml_of_structarray : t -> xrs array


XML conversion



These functions are used to convert to and from XML

val print_type : t -> string
print_type t returns its argument as an XML-RPC value string
val parse_value : ('a Pxp_document.node #Pxp_document.extension as 'a) Pxp_document.node ->
t
parse_value node takes a PXP value node and returns its XML-RPC value. The node must be a <value>.