Objectively 1.0.0
Ultra-lightweight object oriented framework for GNU C.
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Macros | Functions
URLResponse.c File Reference
#include <assert.h>
#include "MutableDictionary.h"
#include "String.h"
#include "URLResponse.h"

Go to the source code of this file.

Macros

#define _Class   _URLResponse
 

Functions

Class_URLResponse (void)
 
static Objectcopy (const Object *self)
 
static void dealloc (Object *self)
 
static URLResponseinit (URLResponse *self)
 
static void initialize (Class *clazz)
 
static void setValueForHTTPHeaderField (URLResponse *self, const char *value, const char *field)
 

Macro Definition Documentation

◆ _Class

#define _Class   _URLResponse

Definition at line 30 of file URLResponse.c.

Function Documentation

◆ _URLResponse()

Class * _URLResponse ( void  )

Definition at line 111 of file URLResponse.c.

111 {
112 static Class *clazz;
113 static Once once;
114
115 do_once(&once, {
116 clazz = _initialize(&(const ClassDef) {
117 .name = "URLResponse",
118 .superclass = _Object(),
119 .instanceSize = sizeof(URLResponse),
120 .interfaceOffset = offsetof(URLResponse, interface),
121 .interfaceSize = sizeof(URLResponseInterface),
123 });
124 });
125
126 return clazz;
127}
Class * _initialize(const ClassDef *def)
Initializes the given Class.
Definition: Class.c:91
static void initialize(Class *clazz)
Definition: URLResponse.c:98
long Once
The Once type.
Definition: Once.h:37
#define do_once(once, block)
Executes the given block at most one time.
Definition: Once.h:43
ClassDefs are passed to _initialize via an archetype to initialize a Class.
Definition: Class.h:41
The runtime representation of a Class.
Definition: Class.h:95
Class * _Object(void)
The Object archetype.
Definition: Object.c:136
A protocol-agnostic abstraction for URLSessionTask responses.
Definition: URLResponse.h:42

◆ copy()

static Object * copy ( const Object self)
static
See also
Object::copy(const Object *)

Definition at line 37 of file URLResponse.c.

37 {
38
39 URLResponse *this = (URLResponse *) self;
40
41 URLResponse *that = $(alloc(URLResponse), init);
42
43 if (this->httpHeaders) {
44 that->httpHeaders = (Dictionary *) $((Object *) this->httpHeaders, copy);
45 }
46
47 that->httpStatusCode = this->httpStatusCode;
48
49 return (Object *) that;
50}
#define alloc(type)
Allocate and initialize and instance of type.
Definition: Class.h:159
Condition * init(Condition *self)
Initializes this Condition.
Definition: Condition.c:67
Immutable key-value stores.
Definition: Dictionary.h:60
Object is the root Class of The Objectively Class hierarchy.
Definition: Object.h:46
Object * copy(const Object *self)
Creates a shallow copy of this Object.
Definition: Array.c:40
Dictionary * httpHeaders
The HTTP response headers.
Definition: URLResponse.h:58
int httpStatusCode
The HTTP response status code.
Definition: URLResponse.h:63

◆ dealloc()

static void dealloc ( Object self)
static
See also
Object::dealloc(Object *)

Definition at line 55 of file URLResponse.c.

55 {
56
57 URLResponse *this = (URLResponse *) self;
58
59 release(this->httpHeaders);
60
61 super(Object, self, dealloc);
62}
ident release(ident obj)
Atomically decrement the given Object's reference count. If the resulting reference count is 0,...
Definition: Class.c:196
#define super(type, obj, method,...)
void dealloc(Object *self)
Frees all resources held by this Object.
Definition: Array.c:50

◆ init()

static URLResponse * init ( URLResponse self)
static

Definition at line 70 of file URLResponse.c.

70 {
71 return (URLResponse *) super(Object, self, init);
72}

◆ initialize()

static void initialize ( Class clazz)
static
See also
Class::initialize(Class *)

Definition at line 98 of file URLResponse.c.

98 {
99
100 ((ObjectInterface *) clazz->interface)->copy = copy;
101 ((ObjectInterface *) clazz->interface)->dealloc = dealloc;
102
103 ((URLResponseInterface *) clazz->interface)->init = init;
104 ((URLResponseInterface *) clazz->interface)->setValueForHTTPHeaderField = setValueForHTTPHeaderField;
105}
ident interface
The interface of the Class.
Definition: Class.h:105
void setValueForHTTPHeaderField(URLREquest *self, const char *value, const char *field)

◆ setValueForHTTPHeaderField()

static void setValueForHTTPHeaderField ( URLResponse self,
const char *  value,
const char *  field 
)
static

Definition at line 78 of file URLResponse.c.

78 {
79
80 if (self->httpHeaders == NULL) {
82 }
83
84 String *object = str(value);
85 String *key = str(field);
86
87 $((MutableDictionary *) self->httpHeaders, setObjectForKey, object, key);
88
89 release(object);
90 release(key);
91}
Mutable key-value stores.
void setObjectForKey(MutableDictionary *self, const ident obj, const ident key)
Sets a pair in this MutableDictionary.
Immutable UTF-8 strings.
Definition: String.h:69
OBJECTIVELY_EXPORT String * str(const char *fmt,...)
A convenience function for instantiating Strings.
Definition: String.c:739