ObjFW  Check-in [e8e45975df]

Overview
Comment:Everything should be documented now.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e8e45975df994f067e71c8469dda970d9b6d09febd9df93d4ec978412a0abc66
User & Date: js on 2008-11-07 14:29:00
Other Links: manifest | tags
Context
2008-11-07
17:25
Implementation for OFBigArray. check-in: 59f16e8a3d user: js tags: trunk
14:29
Everything should be documented now. check-in: e8e45975df user: js tags: trunk
2008-11-06
16:06
Even more documentation. check-in: 89c545c3e9 user: js tags: trunk
Changes

Modified src/OFExceptions.h from [af7a34fc33] to [9d8efd0a46].

160
161
162
163
164
165
166
167

168
169
170
171
172
173
174
175
176

177
178
179
180
181
182
183
160
161
162
163
164
165
166

167
168
169
170
171
172
173
174
175

176
177
178
179
180
181
182
183







-
+








-
+







      andPointer: (void*)ptr;

/**
 * \return An error message for the exception as a C String
 */
- (char*)cString;

/***
/**
 * \return A pointer to the memory which is not part of the object
 */
- (void*)pointer;
@end

/**
 * An OFException indicating the given value is out of range. 
 */
@interface OFOutOfRangeException: OFException
@interface OFOutOfRangeException: OFException {}
/**
 * Creates a new out of range exception.
 *
 * \param obj The object which caused the exception
 * \return A new out of range exception
 */
+ newWithObject: (id)obj;
285
286
287
288
289
290
291
292

293
294
295
296
297
298
299
300
301
302

303
304
305
306
307
285
286
287
288
289
290
291

292
293
294
295
296
297
298
299
300
301

302
303
304
305
306
307







-
+









-
+





 */
- (size_t)requestedItems;
@end

/**
 * An OFException indicating a read to the file failed.
 */
@interface OFReadFailedException: OFReadOrWriteFailedException
@interface OFReadFailedException: OFReadOrWriteFailedException {}
/**
 * \return An error message for the exception as a C String
 */
- (char*)cString;
@end

/**
 * An OFException indicating a write to the file failed.
 */
@interface OFWriteFailedException: OFReadOrWriteFailedException
@interface OFWriteFailedException: OFReadOrWriteFailedException {}
/**
 * \return An error message for the exception as a C String
 */
- (char*)cString;
@end

Modified src/OFHashes.h from [5de5b91012] to [7296eed131].

12
13
14
15
16
17
18



19
20
21
22
23
24
25
26
27
28







29
30





31
32
33



34
35
36
37
38
39
40
41
42
43
44







45
46





47
48
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78







+
+
+










+
+
+
+
+
+
+


+
+
+
+
+



+
+
+











+
+
+
+
+
+
+


+
+
+
+
+


#import <stdint.h>

#import "OFObject.h"

#define MD5_DIGEST_SIZE	 16
#define SHA1_DIGEST_SIZE 20

/**
 * The OFMD5Hash class provides functions to create an MD5 hash.
 */
@interface OFMD5Hash: OFObject
{
	uint32_t buf[4];
	uint32_t bits[2];
	uint8_t	 in[64];

	BOOL	 calculated;
}

- init;

/**
 * Adds a buffer to the hash to be calculated.
 * 
 * \param buf The buffer which should be included into calculation.
 * \param size The size of the buffer
 */
- updateWithBuffer: (const uint8_t*)buf
	    ofSize: (size_t)size;

/**
 * \return A buffer containing the hash (MD5_DIGEST_SIZE = 16 bytes).
 *	   The buffer is part of object's memory pool.
 */
- (uint8_t*)digest;
@end

/**
 * The OFSHA1Hash class provides functions to create an SHA1 hash.
 */
@interface OFSHA1Hash: OFObject
{
	uint32_t    state[5];
	uint64_t    count;
	uint8_t	    buffer[64];
	uint8_t	    digest[SHA1_DIGEST_SIZE];

	BOOL	 calculated;
}

- init;

/**
 * Adds a buffer to the hash to be calculated.
 * 
 * \param buf The buffer which should be included into calculation.
 * \param size The size of the buffer
 */
- updateWithBuffer: (const uint8_t*)buf
	    ofSize: (size_t)size;

/**
 * \return A buffer containing the hash (SHA1_DIGEST_SIZE = 20 bytes).
 *	   The buffer is part of object's memory pool.
 */
- (uint8_t*)digest;
@end

Modified src/OFList.h from [71b17c2d3e] to [304e257df3].

8
9
10
11
12
13
14



15
16
17
18
19
20
21




22




23




24




25






26







27
28
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
58
59







+
+
+







+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+
+
+
-
+
+
+
+
+
+
+


 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"
#import "OFListObject.h"

/**
 * The OFList class provides easy to use double-linked lists.
 */
@interface OFList: OFObject
{
	OFListObject *first;
	OFListObject *last;
}

- init;

/**
 * Frees the OFList and all OFListObjects, but not the data they contian.
 */
- free;

/**
 * Frees the list and the data included in all OFListObjects it contains.
 */
- freeIncludingData;

/**
 * \returns The first OFListObject in the OFList
 */
- (OFListObject*)first;

/**
 * \returns The last OFListObject in the OFList
 */
- (OFListObject*)last;

/**
 * Adds a new OFListObject to the OFList.
 *
 * \param obj An OFListObject
 */
- add: (OFListObject*)ptr;
- add: (OFListObject*)obj;

/**
 * Creates a new OFListObject and adds it to the OFList.
 *
 * \param ptr Pointer to the data for the OFListObject which will be added
 */
- addNew: (void*)ptr;
@end

Modified src/OFList.m from [dffe6b716b] to [91a37e1146].

54
55
56
57
58
59
60
61

62
63
64

65
66
67
68
69


70
71

72
73
74
75
76
77
78
79
80
54
55
56
57
58
59
60

61
62
63

64
65
66
67


68
69
70

71
72
73
74
75
76
77
78
79
80







-
+


-
+



-
-
+
+

-
+









}

- (OFListObject*)last
{
	return last;
}

- add: (OFListObject*)ptr
- add: (OFListObject*)obj
{
	if (!first || !last) {
		first = last = ptr;
		first = last = obj;
		return self;
	}

	[ptr setPrev: last];
	[last setNext: ptr];
	[obj setPrev: last];
	[last setNext: obj];

	last = ptr;
	last = obj;

	return self;
}

- addNew: (void*)ptr
{
	return [self add: [OFListObject newWithData: ptr]];
}
@end

Modified src/OFListObject.h from [b3500fd953] to [a259bd4ceb].

1
2
3
4
5
6
7
8
9
10
11
12
13



14
15
16
17
18
19
20




21







22




23




24




25




26






27
28








29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62


63
64
65
66
67
68
69
70
71













+
+
+







+
+
+
+

+
+
+
+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+

+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+

/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"

/**
 * The OFListObject class is a class for objects to be stored in an OFObject.
 */
@interface OFListObject: OFObject
{
	void	     *data;
	OFListObject *next;
	OFListObject *prev;
}

/**
 * \param The data the OFListObject should contain
 * \return A new OFListObject.
 */
+ newWithData: (void*)ptr;

/**
 * Initializes an already allocated OFListObjeect.
 *
 * \param The data the OFListObject should contain
 * \return An initialized OFListObject.
 */
- initWithData: (void*)ptr;

/**
 * Free the OFListObject and the data it contains.
 */
- freeIncludingData;

/**
 * \return The data included in the OFListObject
 */
- (void*)data;

/**
 * \return The next OFListObject in the OFList
 */
- (OFListObject*)next;

/**
 * \return The previous OFListObject in the OFList
 */
- (OFListObject*)prev;

/**
 * Sets the next OFListObject in the OFList.
 *
 * \param obj An OFListObject
 */
- setNext: (OFListObject*)ptr;
- setPrev: (OFListObject*)ptr;
- setNext: (OFListObject*)obj;

/**
 * Sets the previous OFListObject in the OFList.
 *
 * \param obj An OFListObject
 */
- setPrev: (OFListObject*)obj;
@end

Modified src/OFListObject.m from [df0e83b386] to [69d0af82c6].

48
49
50
51
52
53
54
55

56
57

58
59
60
61

62
63

64
65
66
48
49
50
51
52
53
54

55
56

57
58
59
60

61
62

63
64
65
66







-
+

-
+



-
+

-
+



}

- (OFListObject*)prev
{
	return prev;
}

- setNext: (OFListObject*)ptr
- setNext: (OFListObject*)obj
{
	next = ptr;
	next = obj;
	return self;
}

- setPrev: (OFListObject*)ptr
- setPrev: (OFListObject*)obj
{
	prev = ptr;
	prev = obj;
	return self;
}
@end

Modified src/OFString.h from [6e7e01107f] to [74c6375e2f].

13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
13
14
15
16
17
18
19

20
21
22
23
24
25
26
27







-
+







#import <stddef.h>

#import "OFObject.h"

/**
 * The OFString class can store and modify string of different types.
 */
@interface OFString: OFObject
@interface OFString: OFObject {}
/**
 * \param str A constant C string from which the new OFConstCString will be
 *	  created
 * \return A new OFConstCString
 */
+ newAsConstCString: (const char*)str;

Modified src/OFXMLFactory.h from [49fd914643] to [f58903a5cd].

1
2
3
4
5
6
7
8
9
10
11
12
13



14








15














16
17
18









19
20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53













+
+
+
-
+
+
+
+
+
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+
+
+



+
+
+
+
+
+
+
+
+


/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "OFObject.h"

/**
 * The OFXMLFactory class provides an easy way to create XML stanzas.
 */
@interface OFXMLFactory: OFObject
@interface OFXMLFactory: OFObject {}
/**
 * XML-escapes a C string.
 *
 * \param s The C string to escape
 * \return The escaped C string.
 *	   You need to free it manually!
 */
+ (char*)escapeCString: (const char*)s;

/**
 * Creates an XML stanza.
 *
 * \param name The name of the tag as a C string
 * \param close A boolean whether the tag should be closed
 * \param data Data that should be inside the tag.
 *	  It will NOT be escaped, so you can also include other stanzas.
 * \param ... Field / value pairs for the tag in the form "field", "value".
 *	  Last element must be NULL.
 *	  Example: "field1", "value1", "field2", "value2", NULL
 * \return The created XML stanza as a C string.
 *	   You need to free it manually!
 */
+ (char*)createStanza: (const char*)name
	 withCloseTag: (BOOL)close
	      andData: (const char*)data, ...;

/**
 * Concats an array of C strings into one C string and frees the array of C
 * strings.
 *
 * \param strs An array of C strings
 * \return The concatenated C strings.
 *	   You need to free it manually!
 */
+ (char*)concatAndFreeCStrings: (char **)strs;
@end