@@ -27,78 +27,117 @@ interface MongoDBCAPI extends Library {
2727
2828 // CHECKSTYLE.OFF: MethodName
2929 /**
30- * Initializes the mongodbcapi library, required before any other call. Cannot be called again
31- * without libmongodbcapi_fini() being called first.
30+ * Creates a status pointer
3231 *
33- * @param initParams the embedded mongod initialization parameters.
32+ * @return the status pointer from which to get an associated status code / error information.
33+ */
34+ Pointer libmongodbcapi_status_create ();
3435
35- * @note This function is not thread safe.
36- * @return the error, or 0 if success
36+ /**
37+ * Destroys a valid status pointer object.
38+ *
39+ * @param status the `libmongodbcapi_status` pointer to release.
3740 */
38- int libmongodbcapi_init (Structure initParams );
41+
42+ void libmongodbcapi_status_destroy (Pointer status );
3943
4044 /**
41- * Tears down the state of the library, all databases must be closed before calling this.
45+ * Gets an error code from a status pointer.
46+ *
47+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
48+ * @return The error code associated with the `status` parameter or 0 if successful.
4249 *
43- * @return the error, or 0 if success
4450 */
45- int libmongodbcapi_fini ( );
51+ int libmongodbcapi_status_get_error ( Pointer status );
4652
4753 /**
48- * Create a new db instance .
54+ * Gets a descriptive error message from a status pointer .
4955 *
50- * @param yamlConfig null-terminated YAML formatted MongoDB configuration string
51- * @return the db pointer
56+ * @param status the `libmongodbcapi_status` pointer from which to get an associated error message.
57+ *
58+ * @return A null-terminated string containing an error message.
5259 */
53- Pointer libmongodbcapi_db_new ( String yamlConfig );
60+ String libmongodbcapi_status_get_explanation ( Pointer status );
5461
5562 /**
56- * Destroy a db instance .
63+ * Gets a status code from a status pointer .
5764 *
58- * @param db the db pointer
65+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
66+ * @return A numeric status code associated with the `status` parameter which indicates a
67+ * sub-category of failure.
5968 */
60- void libmongodbcapi_db_destroy (Pointer db );
69+ int libmongodbcapi_status_get_code (Pointer status );
6170
6271 /**
63- * Pump the message queue.
72+ * Initializes the mongodbcapi library, required before any other call.
73+ *
74+ * <p>Cannot be called again without {@link #libmongodbcapi_lib_fini(Pointer, Pointer)} being called first.</p>
6475 *
65- * @param db the db pointer
66- * @return the error, or 0 if success
76+ * @param initParams the embedded mongod initialization parameters.
77+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
78+ * @return the lib pointer or null if there was a failure. Modifies the status on failure.
6779 */
68- int libmongodbcapi_db_pump ( Pointer db );
80+ Pointer libmongodbcapi_lib_init ( Structure initParams , Pointer status );
6981
7082 /**
71- * Create a new client instance .
83+ * Tears down the state of the library, all databases must be closed before calling this .
7284 *
73- * @param db the db pointer
74- * @return the client pointer
85+ * @param lib the `libmongodbcapi_lib` pointer
86+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
87+ * @return the error code or 0 if successful. Modifies the status on failure.
7588 */
76- Pointer libmongodbcapi_db_client_new (Pointer db );
89+ int libmongodbcapi_lib_fini (Pointer lib , Pointer status );
7790
7891 /**
79- * Destroy a client instance.
92+ * Creates an embedded MongoDB instance and returns a handle with the service context .
8093 *
81- * @param client the client pointer
94+ * @param lib the `libmongodbcapi_lib` pointer
95+ * @param yamlConfig null-terminated YAML formatted MongoDB configuration string
96+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
97+ * @return the instance pointer or null if there was a failure. Modifies the status on failure.
8298 */
83- void libmongodbcapi_db_client_destroy (Pointer client );
99+ Pointer libmongodbcapi_instance_create (Pointer lib , String yamlConfig , Pointer status );
100+
101+ /**
102+ * Shuts down an embedded MongoDB instance.
103+ *
104+ * @param instance the `libmongodbcapi_instance` pointer to be destroyed.
105+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
106+ * @return the error code or 0 if successful. Modifies the status on failure.
107+ */
108+ int libmongodbcapi_instance_destroy (Pointer instance , Pointer status );
109+
110+ /**
111+ * Create a new embedded client instance.
112+ *
113+ * @param instance the `libmongodbcapi_instance` pointer.
114+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
115+ * @return the client pointer or null if there was a failure. Modifies the status on failure.
116+ */
117+ Pointer libmongodbcapi_client_create (Pointer instance , Pointer status );
118+
119+ /**
120+ * Destroys an embedded client instance.
121+ *
122+ * @param client the `libmongodbcapi_client` pointer.
123+ * @param status the `libmongodbcapi_status` pointer from which to get an associated status code.
124+ * @return the error code or 0 if successful. Modifies the status on failure.
125+ */
126+ int libmongodbcapi_client_destroy (Pointer client , Pointer status );
84127
85128 /**
86129 * Make an RPC call. Not clear yet on whether this is the correct signature.
87130 *
88- * @param client the client pointer
131+ * @param client the `libmongodbcapi_client` pointer
89132 * @param input the RPC input
90133 * @param inputSize the RPC input size
91134 * @param output the RPC output
92135 * @param outputSize the RPC output size
93- * @return the error, or 0 if success
136+ * @param status status the `libmongodbcapi_status` pointer from which to get an associated status code.
137+ * @return the error code or 0 if successful. Modifies the status on failure.
94138 */
95- int libmongodbcapi_db_client_wire_protocol_rpc (Pointer client , byte [] input , int inputSize , PointerByReference output ,
96- IntByReference outputSize );
139+ int libmongodbcapi_client_invoke (Pointer client , byte [] input , int inputSize , PointerByReference output , IntByReference outputSize ,
140+ Pointer status );
141+
97142
98- /**
99- * Gets the last error.
100- *
101- * @return the last error
102- */
103- int libmongodbcapi_get_last_error ();
104143}
0 commit comments