ObjPgSQL  Diff

Differences From Artifact [4e80eb06d8]:

To Artifact [a79bf6e7f3]:


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
79
80
81
82
83
84

85
86
87


88
89
90
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
79
80
81
82
83

84
85


86
87
88
89
90







-
+








-
+


-
+



-
+















-
+


















-
+

-
+







-
+

-
-
+
+



 * PERFORMANCE OF THIS SOFTWARE.
 */

#include <libpq-fe.h>

#import <ObjFW/ObjFW.h>

#import "PGResult.h"
#import "PGSQLResult.h"

OF_ASSUME_NONNULL_BEGIN

/** @file */

/**
 * @brief A result row.
 */
typedef OFDictionary OF_GENERIC(OFString *, id) *PGRow;
typedef OFDictionary OF_GENERIC(OFString *, id) *PGSQLRow;

/**
 * @class PGConnection PGConnection.h ObjPgSQL/ObjPgSQL.h
 * @class PGSQLConnection PGSQLConnection.h ObjPgSQL/ObjPgSQL.h
 *
 * @brief A connection to a database.
 */
@interface PGConnection: OFObject
@interface PGSQLConnection: OFObject
{
	PGconn *_connection;
	OFDictionary OF_GENERIC(OFString *, OFString *) *_parameters;
}

/**
 * @brief The parameters for the database connection. See `PQconnectdb` in the
 *	  PostgreSQL documentation.
 */
@property (nonatomic, copy)
    OFDictionary OF_GENERIC(OFString *, OFString *) *parameters;

/**
 * @brief Connects to the database.
 *
 * @throw PGConnectionFailedException The connection failed
 * @throw PGSQLConnectionFailedException The connection failed
 */
- (void)connect;

/**
 * @brief Resets the connection to the database.
 */
- (void)reset;

/**
 * @brief Closes the connection to the database.
 */
- (void)close;

/**
 * @brief Executes the specified command.
 *
 * @param command The command to execute
 * @return The result of the command, if any
 * @throw PGCommandFailedException Executing the command failed.
 * @throw PGSQLCommandFailedException Executing the command failed.
 */
- (nullable PGResult *)executeCommand: (OFConstantString *)command;
- (nullable PGSQLResult *)executeCommand: (OFConstantString *)command;

/**
 * @brief Executes the specified command.
 *
 * @param command The command to execute
 * @param firstParameter First parameter for the command
 * @return The result of the command, if any
 * @throw PGCommandFailedException Executing the command failed.
 * @throw PGSQLCommandFailedException Executing the command failed.
 */
- (nullable PGResult *)executeCommand: (OFConstantString *)command
			   parameters: (id)firstParameter, ... OF_SENTINEL;
- (nullable PGSQLResult *)executeCommand: (OFConstantString *)command
			      parameters: (id)firstParameter, ... OF_SENTINEL;
@end

OF_ASSUME_NONNULL_END