curl :: CURLSList :: defaultinit
core :: Pointer :: address_is_null
Is the address behind this Object at NULL?core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Pointer :: defaultinit
curl :: CURLSList :: defaultinit
core :: Object :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).
# Extern Type of the Linked list type of CURL
extern class CURLSList `{ struct curl_slist * `}
# Empty constructor which allow us to avoid the use of Nit NULLABLE type
private new `{ return NULL; `}
# Constructor allow us to get list instancied by appending an element inside.
new with_str(s: String) import String.to_cstring `{
struct curl_slist *l = NULL;
l = curl_slist_append(l, String_to_cstring(s));
return l;
`}
# Check for initialization
fun is_init: Bool `{ return (self != NULL); `}
# Append an element in the linked list
fun append(key: String) import String.to_cstring `{
char *k = String_to_cstring(key);
curl_slist_append(self, (char*)k);
`}
# Internal method to check for reachability of current data
private fun native_data_reachable(c: CURLSList): Bool `{ return (c != NULL && c->data != NULL); `}
# Internal method to check for reachability of next element
private fun native_next_reachable(c: CURLSList): Bool `{ return (c != NULL && c->next != NULL); `}
# Internal method to get current data
private fun native_data(c: CURLSList): String import CString.to_s `{ return CString_to_s(c->data); `}
# Internal method to get next element
private fun native_next(c: CURLSList): CURLSList `{ return c->next; `}
# Convert current low level List to an Array[String] object
fun to_a: Array[String]
do
var r = new Array[String]
var cursor = self
loop
if not native_data_reachable(cursor) then break
r.add(native_data(cursor))
cursor = native_next(cursor)
end
return r
end
# Release allocated memory
fun destroy `{ curl_slist_free_all(self); `}
end
lib/curl/native_curl.nit:287,1--335,3