From 390751147ed355480def29a728ec0487048c5c6d Mon Sep 17 00:00:00 2001 From: Chris Bradley Date: Wed, 11 Dec 2024 17:32:18 +0000 Subject: [PATCH] Rename metkit_request to metkit_marsrequest --- src/metkit/api/metkit_c.cc | 34 +++++++++++++++++----------------- src/metkit/api/metkit_c.h | 32 ++++++++++++++++---------------- tests/test_c_api.cc | 24 ++++++++++++------------ 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/metkit/api/metkit_c.cc b/src/metkit/api/metkit_c.cc index 85bbe1e..271222e 100644 --- a/src/metkit/api/metkit_c.cc +++ b/src/metkit/api/metkit_c.cc @@ -13,9 +13,9 @@ extern "C" { // --------------------------------------------------------------------------------------------------------------------- -struct metkit_request_t : public metkit::mars::MarsRequest { +struct metkit_marsrequest_t : public metkit::mars::MarsRequest { using metkit::mars::MarsRequest::MarsRequest; - metkit_request_t(const metkit::mars::MarsRequest& k) : + metkit_marsrequest_t(const metkit::mars::MarsRequest& k) : metkit::mars::MarsRequest(k) {} }; @@ -152,7 +152,7 @@ int metkit_initialise() { // PARSING // ----------------------------------------------------------------------------- -int metkit_parse_mars_request(const char* str, metkit_requestiterator_t** requests, bool strict) { +int metkit_parse_marsrequest(const char* str, metkit_requestiterator_t** requests, bool strict) { return tryCatch([requests, str, strict] { ASSERT(requests); ASSERT(str); @@ -165,21 +165,21 @@ int metkit_parse_mars_request(const char* str, metkit_requestiterator_t** reques // REQUEST // ----------------------------------------------------------------------------- -int metkit_new_request(metkit_request_t** request) { +int metkit_new_marsrequest(metkit_marsrequest_t** request) { return tryCatch([request] { ASSERT(request); - *request = new metkit_request_t(); + *request = new metkit_marsrequest_t(); }); } -int metkit_free_request(const metkit_request_t* request) { +int metkit_free_marsrequest(const metkit_marsrequest_t* request) { return tryCatch([request] { ASSERT(request); delete request; }); } -int metkit_request_add(metkit_request_t* request, const char* param, const char* values[], int numValues) { +int metkit_marsrequest_add(metkit_marsrequest_t* request, const char* param, const char* values[], int numValues) { return tryCatch([request, param, values, numValues] { ASSERT(request); ASSERT(param); @@ -193,7 +193,7 @@ int metkit_request_add(metkit_request_t* request, const char* param, const char* }); } -int metkit_request_set_verb(metkit_request_t* request, const char* verb) { +int metkit_marsrequest_set_verb(metkit_marsrequest_t* request, const char* verb) { return tryCatch([request, verb] { ASSERT(request); ASSERT(verb); @@ -201,7 +201,7 @@ int metkit_request_set_verb(metkit_request_t* request, const char* verb) { }); } -int metkit_request_verb(const metkit_request_t* request, const char** verb) { +int metkit_marsrequest_verb(const metkit_marsrequest_t* request, const char** verb) { return tryCatch([request, verb] { ASSERT(request); ASSERT(verb); @@ -209,7 +209,7 @@ int metkit_request_verb(const metkit_request_t* request, const char** verb) { }); } -int metkit_request_has_param(const metkit_request_t* request, const char* param, bool* has) { +int metkit_marsrequest_has_param(const metkit_marsrequest_t* request, const char* param, bool* has) { return tryCatch([request, param, has] { ASSERT(request); ASSERT(param); @@ -218,7 +218,7 @@ int metkit_request_has_param(const metkit_request_t* request, const char* param, }); } -int metkit_request_params(const metkit_request_t* request, metkit_paramiterator_t** params) { +int metkit_marsrequest_params(const metkit_marsrequest_t* request, metkit_paramiterator_t** params) { return tryCatch([request, params] { ASSERT(request); ASSERT(params); @@ -226,7 +226,7 @@ int metkit_request_params(const metkit_request_t* request, metkit_paramiterator_ }); } -int metkit_request_count_values(const metkit_request_t* request, const char* param, size_t* count) { +int metkit_marsrequest_count_values(const metkit_marsrequest_t* request, const char* param, size_t* count) { return tryCatch([request, param, count] { ASSERT(request); ASSERT(param); @@ -235,7 +235,7 @@ int metkit_request_count_values(const metkit_request_t* request, const char* par }); } -int metkit_request_value(const metkit_request_t* request, const char* param, int index, const char** value) { +int metkit_marsrequest_value(const metkit_marsrequest_t* request, const char* param, int index, const char** value) { return tryCatch([request, param, index, value] { ASSERT(request); ASSERT(param); @@ -244,7 +244,7 @@ int metkit_request_value(const metkit_request_t* request, const char* param, int }); } -int metkit_request_values(const metkit_request_t* request, const char* param, const char** values[], size_t* numValues) { +int metkit_marsrequest_values(const metkit_marsrequest_t* request, const char* param, const char** values[], size_t* numValues) { return tryCatch([request, param, values, numValues] { ASSERT(request); ASSERT(param); @@ -259,7 +259,7 @@ int metkit_request_values(const metkit_request_t* request, const char* param, co }); } -int metkit_request_expand(const metkit_request_t* request, metkit_request_t* expandedRequest, bool inherit, bool strict) { +int metkit_marsrequest_expand(const metkit_marsrequest_t* request, metkit_marsrequest_t* expandedRequest, bool inherit, bool strict) { return tryCatch([request, expandedRequest, inherit, strict] { ASSERT(request); ASSERT(expandedRequest); @@ -269,7 +269,7 @@ int metkit_request_expand(const metkit_request_t* request, metkit_request_t* exp }); } -int metkit_request_merge(metkit_request_t* request, const metkit_request_t* otherRequest) { +int metkit_marsrequest_merge(metkit_marsrequest_t* request, const metkit_marsrequest_t* otherRequest) { return tryCatch([request, otherRequest] { ASSERT(request); ASSERT(otherRequest); @@ -295,7 +295,7 @@ int metkit_requestiterator_next(metkit_requestiterator_t* list) { }}); } -int metkit_requestiterator_request(const metkit_requestiterator_t* list, metkit_request_t* request) { +int metkit_requestiterator_request(const metkit_requestiterator_t* list, metkit_marsrequest_t* request) { return tryCatch([list, request] { ASSERT(list); ASSERT(request); diff --git a/src/metkit/api/metkit_c.h b/src/metkit/api/metkit_c.h index 6ccb75c..6a1249f 100644 --- a/src/metkit/api/metkit_c.h +++ b/src/metkit/api/metkit_c.h @@ -11,8 +11,8 @@ extern "C" { * TYPES * -----*/ -struct metkit_request_t; -typedef struct metkit_request_t metkit_request_t; +struct metkit_marsrequest_t; +typedef struct metkit_marsrequest_t metkit_marsrequest_t; struct metkit_requestiterator_t; /** RequestIterator for iterating over vector of Request instances */ @@ -78,7 +78,7 @@ int metkit_initialise(); * @param requests Allocates RequestIterator object * @return int Error code */ -int metkit_parse_mars_request(const char* str, metkit_requestiterator_t** requests, bool strict = false); +int metkit_parse_marsrequest(const char* str, metkit_requestiterator_t** requests, bool strict = false); /* --------------------------------------------------------------------------------------------------------------------- * REQUEST @@ -88,13 +88,13 @@ int metkit_parse_mars_request(const char* str, metkit_requestiterator_t** reques * @param request new Request instance * @return int Error code */ -int metkit_new_request(metkit_request_t** request); +int metkit_new_marsrequest(metkit_marsrequest_t** request); /** Deallocates Request object and associated resources. * @param request Request instance * @return int Error code */ -int metkit_free_request(const metkit_request_t* request); +int metkit_free_marsrequest(const metkit_marsrequest_t* request); /** Add parameter and values to request * @param request Request instance @@ -103,21 +103,21 @@ int metkit_free_request(const metkit_request_t* request); * @param numValues number of values * @return int Error code */ -int metkit_request_add(metkit_request_t* request, const char* param, const char* values[], int numValues); +int metkit_marsrequest_add(metkit_marsrequest_t* request, const char* param, const char* values[], int numValues); /** Set verb in Request object * @param request Request instance * @param verb verb to set * @return int Error code */ -int metkit_request_set_verb(metkit_request_t* request, const char* verb); +int metkit_marsrequest_set_verb(metkit_marsrequest_t* request, const char* verb); /** Returns the verb in Request object * @param request Request instance * @param verb verb in request * @return int Error code */ -int metkit_request_verb(const metkit_request_t* request, const char** verb); +int metkit_marsrequest_verb(const metkit_marsrequest_t* request, const char** verb); /** Returns whether parameter is in Request object * @param request Request instance @@ -125,7 +125,7 @@ int metkit_request_verb(const metkit_request_t* request, const char** verb); * @param has whether parameter exists in request * @return int Error code */ -int metkit_request_has_param(const metkit_request_t* request, const char* param, bool* has); +int metkit_marsrequest_has_param(const metkit_marsrequest_t* request, const char* param, bool* has); /** Returns ParamIterator of parameters in request. Resulting ParamIterator * must be deallocated with metkit_free_paramiterator @@ -133,7 +133,7 @@ int metkit_request_has_param(const metkit_request_t* request, const char* param, * @param params Allocates ParamIterator object for parameter names in request * @return int Error code */ -int metkit_request_params(const metkit_request_t* request, metkit_paramiterator_t** params); +int metkit_marsrequest_params(const metkit_marsrequest_t* request, metkit_paramiterator_t** params); /** Returns number of values for specific parameter in Request object * @param request Request instance @@ -141,7 +141,7 @@ int metkit_request_params(const metkit_request_t* request, metkit_paramiterator_ * @param count number of values for param in request * @return int Error code */ -int metkit_request_count_values(const metkit_request_t* request, const char* param, size_t* count); +int metkit_marsrequest_count_values(const metkit_marsrequest_t* request, const char* param, size_t* count); /** Returns value for specific parameter and index in Request object * @param request Request instance @@ -150,7 +150,7 @@ int metkit_request_count_values(const metkit_request_t* request, const char* par * @param value retrieved value * @return int Error code */ -int metkit_request_value(const metkit_request_t* request, const char* param, int index, const char** value); +int metkit_marsrequest_value(const metkit_marsrequest_t* request, const char* param, int index, const char** value); /** Returns values for specific parameter Request object * @param request Request instance @@ -159,7 +159,7 @@ int metkit_request_value(const metkit_request_t* request, const char* param, int * @param numValues number of values for param in request * @return int Error code */ -int metkit_request_values(const metkit_request_t* request, const char* param, const char** values[], size_t* numValues); +int metkit_marsrequest_values(const metkit_marsrequest_t* request, const char* param, const char** values[], size_t* numValues); /** Populates empty Request object by expanding existing request * @param request Request instance to be expanded @@ -168,14 +168,14 @@ int metkit_request_values(const metkit_request_t* request, const char* param, co * @param strict it true, raise error rather than warning on invalid values * @return int Error code */ -int metkit_request_expand(const metkit_request_t* request, metkit_request_t* expandedRequest, bool inherit = true, bool strict = false); +int metkit_marsrequest_expand(const metkit_marsrequest_t* request, metkit_marsrequest_t* expandedRequest, bool inherit = true, bool strict = false); /** Merges other Request object into existing request * @param request Request instance to contain result of merge * @param otherRequest other Request instance to merge * @return int Error code */ -int metkit_request_merge(metkit_request_t* request, const metkit_request_t* otherRequest); +int metkit_marsrequest_merge(metkit_marsrequest_t* request, const metkit_marsrequest_t* otherRequest); /* --------------------------------------------------------------------------------------------------------------------- * REQUEST ITERATOR @@ -198,7 +198,7 @@ int metkit_requestiterator_next(metkit_requestiterator_t* list); * @param request empty Request instance to populate with data * @return int Error code */ -int metkit_requestiterator_request(const metkit_requestiterator_t* list, metkit_request_t* request); +int metkit_requestiterator_request(const metkit_requestiterator_t* list, metkit_marsrequest_t* request); /* --------------------------------------------------------------------------------------------------------------------- * PARAM ITERATOR diff --git a/tests/test_c_api.cc b/tests/test_c_api.cc index f97db4e..bef7aa4 100644 --- a/tests/test_c_api.cc +++ b/tests/test_c_api.cc @@ -20,47 +20,47 @@ namespace metkit::test { CASE( "Request get/set" ) { - metkit_request_t* request = nullptr; + metkit_marsrequest_t* request = nullptr; - metkit_new_request(&request); + metkit_new_marsrequest(&request); EXPECT(request); // set/get verb - metkit_request_set_verb(request, "retrieve"); + metkit_marsrequest_set_verb(request, "retrieve"); const char* verb = nullptr; - metkit_request_verb(request, &verb); + metkit_marsrequest_verb(request, &verb); EXPECT(strcmp(verb, "retrieve") == 0); // set array of values const char* dates[] = {"20200101", "20200102", "20200103"}; - metkit_request_add(request, "date", dates, 3); + metkit_marsrequest_add(request, "date", dates, 3); // set single value const char* expver = "xxxx"; - metkit_request_add(request, "expver", &expver, 1); + metkit_marsrequest_add(request, "expver", &expver, 1); // check values bool has = false; - metkit_request_has_param(request, "date", &has); + metkit_marsrequest_has_param(request, "date", &has); EXPECT(has); - metkit_request_has_param(request, "random", &has); + metkit_marsrequest_has_param(request, "random", &has); EXPECT(!has); size_t count = 0; - metkit_request_count_values(request, "date", &count); + metkit_marsrequest_count_values(request, "date", &count); EXPECT_EQUAL(count, 3); for (size_t i = 0; i < count; i++) { const char* value = nullptr; - metkit_request_value(request, "date", i, &value); + metkit_marsrequest_value(request, "date", i, &value); EXPECT(strcmp(value, dates[i]) == 0); } // all values const char** values = nullptr; count = 0; - metkit_request_values(request, "date", &values, &count); + metkit_marsrequest_values(request, "date", &values, &count); EXPECT_EQUAL(count, 3); for (size_t i = 0; i < count; i++) { @@ -68,7 +68,7 @@ CASE( "Request get/set" ) { } // done - metkit_free_request(request); + metkit_free_marsrequest(request); } //-----------------------------------------------------------------------------