/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
5.1.1 by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen.
1
/*
5.2.7 by Gustav Hartvigsson
* Switched licence to a more permisive one.
2
Copyright (c) 2013-2014 Gustav Hartvigsson
3
4
Permission is hereby granted, free of charge, to any person obtaining a copy
5
of this software and associated documentation files (the "Software"), to deal
6
in the Software without restriction, including without limitation the rights
7
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
copies of the Software, and to permit persons to whom the Software is
9
furnished to do so, subject to the following conditions:
10
11
The above copyright notice and this permission notice shall be included in
12
all copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
THE SOFTWARE.
5.1.1 by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen.
21
*/
22
23
/** @file */
3 by Gustav Hartvigsson
Fixed a few things...
24
25
#ifndef __H_ERROR__
26
#define __H_ERROR__
27
28
#include "baseobject.h"
5.2.8 by Gustav Hartvigsson
* Copied over LinkedList and DynamicArray from c_sdl_js
29
#include "defs.h"
22 by Gustav Hartvigsson
* Made code compile
30
#include "utils.h"
31
#include "Func.h"
3 by Gustav Hartvigsson
Fixed a few things...
32
#include <limits.h>
33
#include <stdlib.h>
34
#include <stdio.h>
35
#include <string.h>
36
22 by Gustav Hartvigsson
* Made code compile
37
BEGIN_DECLS
38
5.1.1 by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen.
39
/**
62 by Gustav Hartvigsson
* General documentation clean up.
40
 * @defgroup SError SError
41
 * @addtogroup SError
42
 * @{
5.1.1 by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen.
43
 * An opaque datastructure that holds the SError's private data.
44
 */
39 by Gustav Hartvigsson
* Added "check" target for testing.
45
typedef struct SErrorPrivate SErrorPrivate;
3 by Gustav Hartvigsson
Fixed a few things...
46
5.1.1 by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen.
47
/**
19 by Gustav Hartvigsson
* Woops
48
 * An SError is a data structure that inherits from SBaseObjectInstance.
5.1.1 by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen.
49
 * 
50
 * An SError represents an error that can occur.
51
 */
61 by Gustav Hartvigsson
* Made the code more easy to read.
52
typedef struct
53
SError {
22 by Gustav Hartvigsson
* Made code compile
54
  SObject parent;
5.1.1 by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen.
55
  SErrorPrivate * priv; /** Pimple pointer to the private data. */
3 by Gustav Hartvigsson
Fixed a few things...
56
  
57
} SError;
58
59
/**
60
 * The error class is not changed, no extra methods are needed.
61
 */
61 by Gustav Hartvigsson
* Made the code more easy to read.
62
typedef struct
63
SErrorClass {
22 by Gustav Hartvigsson
* Made code compile
64
  SObjectClass parent_class;
3 by Gustav Hartvigsson
Fixed a few things...
65
  
66
} SErrorClass;
67
49 by Gustav Hartvigsson
* started work SBox (Untested).
68
#define S_ERROR(o) (SError *)(o)
69
#define S_ERROR_CLASS(k) (SErrorClass *)(k)
70
5.1.1 by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen.
71
/** @brief
72
 * The different error types.
73
 */
3 by Gustav Hartvigsson
Fixed a few things...
74
typedef enum {
8 by Gustav Hartvigsson
* Fixed a DoxyGen error documentation error of an enum.
75
  S_ERROR_NONE = 0, /**< Not on error */
43 by Gustav Hartvigsson
* Code cleanup
76
  S_ERROR_INPUT_OUTPUT,/**< An I/O error */
77
  S_ERROR_OVERFLOW, /**< An Overflow error */
62 by Gustav Hartvigsson
* General documentation clean up.
78
  S_ERROR_TYPE_ERROR, /** Some generic type error. */
43 by Gustav Hartvigsson
* Code cleanup
79
  S_ERROR_UNUSED_0,
80
  S_ERROR_UNUSED_1,
81
  S_ERROR_UNUSED_2,
82
  S_ERROR_OTHER, /**< Some unknowned error */
83
  S_ERROR_NULL /**< An NULL error */
3 by Gustav Hartvigsson
Fixed a few things...
84
} SErrorType;
85
39 by Gustav Hartvigsson
* Added "check" target for testing.
86
/**
62 by Gustav Hartvigsson
* General documentation clean up.
87
 * @var static char * SErrorTypeName[] __attribute__((unused))
88
 * @breif
39 by Gustav Hartvigsson
* Added "check" target for testing.
89
 * Holds the names of the string version of SErrorType.
90
 */
72 by Gustav Hartvigsson
* Added our own types for stability and shit and giggles.
91
static schar * SErrorTypeName[] UNUSED = {
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
92
  "NONE",
93
  "INPUT/OUTPUT",
94
  "OVERFLOW",
62 by Gustav Hartvigsson
* General documentation clean up.
95
  "TYPE_ERROR",
49 by Gustav Hartvigsson
* started work SBox (Untested).
96
  "UNUSED_0/INVALID",
97
  "UNUSED_1/INVALID",
98
  "UNUSED_2/INVALID",
46 by Gustav Hartvigsson
* Renamed DynamicArray to SDynamicArray.
99
  "OTHER",
100
  "NULL",
101
  0x0,
102
  0x0
103
};
39 by Gustav Hartvigsson
* Added "check" target for testing.
104
72 by Gustav Hartvigsson
* Added our own types for stability and shit and giggles.
105
106
49 by Gustav Hartvigsson
* started work SBox (Untested).
107
/**
108
 * @brief
109
 * Function to get the same of an error.
110
 * 
111
 * For use in bindings.
112
 *
113
 * @param k The key to look up.
114
 */
72 by Gustav Hartvigsson
* Added our own types for stability and shit and giggles.
115
schar *
61 by Gustav Hartvigsson
* Made the code more easy to read.
116
s_error_get_name (SErrorType k);
3 by Gustav Hartvigsson
Fixed a few things...
117
118
/**
5.1.1 by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen.
119
 * the constructor for the an SError
3 by Gustav Hartvigsson
Fixed a few things...
120
 */
61 by Gustav Hartvigsson
* Made the code more easy to read.
121
SError *
72 by Gustav Hartvigsson
* Added our own types for stability and shit and giggles.
122
s_error_new (SErrorType error, schar * message);
3 by Gustav Hartvigsson
Fixed a few things...
123
5.1.1 by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen.
124
/**
125
 * This function calles the deinitize method of the object.
126
 */
61 by Gustav Hartvigsson
* Made the code more easy to read.
127
void
128
s_error_free (SError * self);
3 by Gustav Hartvigsson
Fixed a few things...
129
5.1.1 by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen.
130
/**
131
 * This function returns the ErrorType of on object.
132
 */
61 by Gustav Hartvigsson
* Made the code more easy to read.
133
SErrorType
134
s_error_get_error_type (SError * self);
3 by Gustav Hartvigsson
Fixed a few things...
135
5.1.1 by Gustav Hartvigsson
* Started work on making the code more prasable by DoxyGen.
136
/**
137
 * This function prints the current error to stdout.
138
 */
61 by Gustav Hartvigsson
* Made the code more easy to read.
139
void
140
s_error_print_error (SError * self);
3 by Gustav Hartvigsson
Fixed a few things...
141
62 by Gustav Hartvigsson
* General documentation clean up.
142
/** @} */
143
22 by Gustav Hartvigsson
* Made code compile
144
END_DECLS
145
3 by Gustav Hartvigsson
Fixed a few things...
146
#endif