diff --git a/src/oatpp/algorithm/CRC.hpp b/src/oatpp/algorithm/CRC.hpp index 5b606aa1..86635a38 100644 --- a/src/oatpp/algorithm/CRC.hpp +++ b/src/oatpp/algorithm/CRC.hpp @@ -30,9 +30,16 @@ #include "oatpp/encoding/Hex.hpp" namespace oatpp { namespace algorithm { - + +/** + * Implementation of CRC-32. Cyclic redundancy check algorithm. + */ class CRC32 { public: + + /** + * Precalculated table + */ static const p_word32 TABLE_04C11DB7; public: @@ -42,7 +49,17 @@ public: * Generates v_word32 table[256] for polynomial */ static p_word32 generateTable(v_word32 poly); - + + /** + * Calculate CRC32 value for buffer of defined size + * @param buffer + * @param size + * @param crc + * @param initValue + * @param xorOut + * @param table + * @return - CRC32 value (v_word32) + */ static v_word32 calc(const void *buffer, v_int32 size, v_word32 crc = 0, v_word32 initValue = 0xFFFFFFFF, v_word32 xorOut = 0xFFFFFFFF, p_word32 table = TABLE_04C11DB7); }; diff --git a/src/oatpp/codegen/codegen_define_ApiClient_.hpp b/src/oatpp/codegen/codegen_define_ApiClient_.hpp index 585e8c2a..ba5ff24e 100644 --- a/src/oatpp/codegen/codegen_define_ApiClient_.hpp +++ b/src/oatpp/codegen/codegen_define_ApiClient_.hpp @@ -176,6 +176,13 @@ OATPP_MACRO_FOREACH(OATPP_MACRO_API_CLIENT_PARAM_DECL, LIST) \ #define OATPP_API_CALL__(X, NAME, METHOD, PATH, LIST) OATPP_API_CALL_(X, NAME, METHOD, PATH, LIST) #define OATPP_API_CALL___(NAME, METHOD, PATH, LIST) OATPP_API_CALL__(OATPP_MACRO_HAS_ARGS LIST, NAME, METHOD, PATH, LIST) +/** + * Codegen macoro to be used in `oatpp::web::client::ApiClient` to generate REST API-Calls. + * @METHOD - Http method ("GET", "POST", "PUT", etc.) + * @PATH - Path to endpoint (without host) + * @NAME - Name of the generated method + * @return - std::shared_ptr + */ #define API_CALL(METHOD, PATH, NAME, ...) \ OATPP_API_CALL___(NAME, METHOD, PATH, (__VA_ARGS__)) @@ -239,5 +246,12 @@ oatpp::async::Action NAME(\ #define OATPP_API_CALL_ASYNC__(X, NAME, METHOD, PATH, LIST) OATPP_API_CALL_ASYNC_(X, NAME, METHOD, PATH, LIST) #define OATPP_API_CALL_ASYNC___(NAME, METHOD, PATH, LIST) OATPP_API_CALL_ASYNC__(OATPP_MACRO_HAS_ARGS LIST, NAME, METHOD, PATH, LIST) +/** + * Codegen macoro to be used in `oatpp::web::client::ApiClient` to generate Asynchronous REST API-Calls. + * @METHOD - Http method ("GET", "POST", "PUT", etc.) + * @PATH - Path to endpoint (without host) + * @NAME - Name of the generated method + * @return - oatpp::async::Action + */ #define API_CALL_ASYNC(METHOD, PATH, NAME, ...) \ OATPP_API_CALL_ASYNC___(NAME, METHOD, PATH, (__VA_ARGS__)) diff --git a/src/oatpp/codegen/codegen_define_ApiController_.hpp b/src/oatpp/codegen/codegen_define_ApiController_.hpp index 6e060574..7e250c4e 100644 --- a/src/oatpp/codegen/codegen_define_ApiController_.hpp +++ b/src/oatpp/codegen/codegen_define_ApiController_.hpp @@ -390,12 +390,19 @@ OATPP_MACRO_API_CONTROLLER_ENDPOINT_(X, NAME, METHOD, PATH, LIST) #define OATPP_MACRO_API_CONTROLLER_ENDPOINT___(NAME, METHOD, PATH, LIST) \ OATPP_MACRO_API_CONTROLLER_ENDPOINT__(OATPP_MACRO_HAS_ARGS LIST, NAME, METHOD, PATH, LIST) +/** + * Codegen macoro to be used in `oatpp::web::server::api::ApiController` to generate Endpoint. + * @METHOD - Http method ("GET", "POST", "PUT", etc.) + * @PATH - Path to endpoint (without host) + * @NAME - Name of the generated method + * @return - std::shared_ptr + */ #define ENDPOINT(METHOD, PATH, NAME, ...) \ OATPP_MACRO_API_CONTROLLER_ENDPOINT___(NAME, METHOD, PATH, (__VA_ARGS__)) // ENDPOINT ASYNC MACRO // ------------------------------------------------------ -/** +/* * 1 - Method to obtain endpoint call function ptr * 2 - Endpoint info singleton */ @@ -414,7 +421,7 @@ std::shared_ptr Z__EDNPOINT_INFO_GET_INSTANCE_##NAME() { \ return info; \ } -/** +/* * 1 - Endpoint info instance * 2 - Endpoint instance */ @@ -434,7 +441,13 @@ const std::shared_ptr Z__ENDPOINT_##NAME = createEndpoint(m_endpoints, Z__ENDPOINT_METHOD_##NAME(this), \ Z__CREATE_ENDPOINT_INFO_##NAME()); - +/** + * Codegen macoro to be used in `oatpp::web::server::api::ApiController` to generate Asynchronous Endpoint. + * @METHOD - Http method ("GET", "POST", "PUT", etc.) + * @PATH - Path to endpoint (without host) + * @NAME - Name of the generated method + * @return - oatpp::async::Action + */ #define ENDPOINT_ASYNC(METHOD, PATH, NAME) \ OATPP_MACRO_API_CONTROLLER_ENDPOINT_ASYNC_DECL_DEFAULTS(NAME, METHOD, PATH) \ OATPP_MACRO_API_CONTROLLER_ENDPOINT_ASYNC_DECL(NAME, METHOD, PATH) \ @@ -448,6 +461,10 @@ oatpp::async::Action Z__PROXY_METHOD_##NAME(oatpp::async::AbstractCoroutine* par \ class NAME : public HandlerCoroutine +/** + * Auxiliary codegen macro for `ENDPOINT_ASYNC` to generate correct constructor for Asynchronous Endpoint Coroutine. + * @NAME - Name of the endpoint. Exact the same name as was passed to `ENDPOINT_ASYNC` macro. + */ #define ENDPOINT_ASYNC_INIT(NAME) \ public: \ \ diff --git a/src/oatpp/codegen/codegen_define_DTO_.hpp b/src/oatpp/codegen/codegen_define_DTO_.hpp index 54904f7c..b1bad9d2 100644 --- a/src/oatpp/codegen/codegen_define_DTO_.hpp +++ b/src/oatpp/codegen/codegen_define_DTO_.hpp @@ -27,6 +27,11 @@ // Defaults +/** + * Codegen macoro to be used in `oatpp::data::mapping::type::Object` to generate required fields/methods/constructors for DTO object. + * @TYPE_NAME - name of the DTO class. + * @TYPE_EXTEND - name of the parent DTO class. If DTO extends `oatpp::data::mapping::type::Object` TYPE_EXETENDS should be `Object`. + */ #define DTO_INIT(TYPE_NAME, TYPE_EXTEND) \ public: \ typedef TYPE_NAME Z__CLASS; \ @@ -113,6 +118,12 @@ TYPE NAME #define OATPP_MACRO_DTO_FIELD__(X, TYPE, NAME, LIST) OATPP_MACRO_DTO_FIELD_(X, TYPE, NAME, LIST) #define OATPP_MACRO_DTO_FIELD___(TYPE, NAME, LIST) OATPP_MACRO_DTO_FIELD__(OATPP_MACRO_HAS_ARGS LIST, TYPE, NAME, LIST) +/** + * Codegen macro to generate fields of DTO object. + * @TYPE - type of the field. + * @NAME - name of the field. + * @QUALIFIER_NAME - additional (optional) field to specify serialized name of the field. If not specified it will be same as NAME. + */ #define DTO_FIELD(TYPE, NAME, ...) \ OATPP_MACRO_DTO_FIELD___(TYPE, NAME, (__VA_ARGS__)) diff --git a/src/oatpp/core/Types.hpp b/src/oatpp/core/Types.hpp index 18cac5d1..5d55c7b4 100644 --- a/src/oatpp/core/Types.hpp +++ b/src/oatpp/core/Types.hpp @@ -29,14 +29,45 @@ #include "oatpp/core/data/mapping/type/Primitive.hpp" namespace oatpp { - + + /** + * Mapping-Enabled String type + */ typedef oatpp::data::mapping::type::String String; + + /** + * Mapping-Enabled 8-bits int. Can hold nullptr value. + */ typedef oatpp::data::mapping::type::Int8 Int8; + + /** + * Mapping-Enabled 16-bits int. Can hold nullptr value. + */ typedef oatpp::data::mapping::type::Int16 Int16; + + /** + * Mapping-Enabled 32-bits int. Can hold nullptr value. + */ typedef oatpp::data::mapping::type::Int32 Int32; + + /** + * Mapping-Enabled 64-bits int. Can hold nullptr value. + */ typedef oatpp::data::mapping::type::Int64 Int64; + + /** + * Mapping-Enabled 32-bits float. Can hold nullptr value. + */ typedef oatpp::data::mapping::type::Float32 Float32; + + /** + * Mapping-Enabled 64-bits float (double). Can hold nullptr value. + */ typedef oatpp::data::mapping::type::Float64 Float64; + + /** + * Mapping-Enabled Boolean. Can hold nullptr value. + */ typedef oatpp::data::mapping::type::Boolean Boolean; } diff --git a/src/oatpp/core/async/Coroutine.cpp b/src/oatpp/core/async/Coroutine.cpp index 64f2696c..dcf02e5e 100644 --- a/src/oatpp/core/async/Coroutine.cpp +++ b/src/oatpp/core/async/Coroutine.cpp @@ -25,12 +25,19 @@ #include "Coroutine.hpp" namespace oatpp { namespace async { - + const Action Action::_WAIT_RETRY(TYPE_WAIT_RETRY, nullptr, nullptr); const Action Action::_REPEAT(TYPE_REPEAT, nullptr, nullptr); const Action Action::_FINISH(TYPE_FINISH, nullptr, nullptr); const Action Action::_ABORT(TYPE_ABORT, nullptr, nullptr); - + +Error::Error(const char* pMessage, bool pIsExceptionThrown = false) + : message(pMessage) + , isExceptionThrown(pIsExceptionThrown) +{} + + + Action::Action(v_int32 type, AbstractCoroutine* coroutine, FunctionPtr functionPtr) diff --git a/src/oatpp/core/async/Coroutine.hpp b/src/oatpp/core/async/Coroutine.hpp index 541a757a..d515a0a1 100644 --- a/src/oatpp/core/async/Coroutine.hpp +++ b/src/oatpp/core/async/Coroutine.hpp @@ -33,32 +33,74 @@ namespace oatpp { namespace async { class AbstractCoroutine; // FWD class Processor; // FWD - + +/** + * Class to hold and communicate errors between Coroutines + */ class Error { public: - Error(const char* pMessage, bool pIsExceptionThrown = false) - : message(pMessage) - , isExceptionThrown(pIsExceptionThrown) - {} - + /** + * Constructor. + * @param pMessage - Error message. + * @param pIsExceptionThrown - Indicate that this error is a result of thrown exception. + */ + Error(const char* pMessage, bool pIsExceptionThrown = false); + + /** + * Error message + */ const char* message; + + /** + * Indicates that this error is a result of thrown exception. Re-throw if true to catch original exception. + */ bool isExceptionThrown; }; - + +/** + * Class Action represents an asynchronous action. + */ class Action { friend Processor; friend AbstractCoroutine; public: typedef Action (AbstractCoroutine::*FunctionPtr)(); public: + /** + * Indicate that Action is to start coroutine. Value = 0. + */ static constexpr const v_int32 TYPE_COROUTINE = 0; + + /** + * Indicate that Action is to YIELD control to other method of Coroutine. Value = 1. + */ static constexpr const v_int32 TYPE_YIELD_TO = 1; + + /** + * Indicate that Action is to WAIT and then RETRY call to current method of Coroutine. Value = 2. + */ static constexpr const v_int32 TYPE_WAIT_RETRY = 2; + + /** + * Indicate that Action is to REPEAT call to current method of Coroutine. Value = 3. + */ static constexpr const v_int32 TYPE_REPEAT = 3; + + /** + * Indicate that Action is to FINISH current Coroutine and return control to a caller-Coroutine. Value = 4. + */ static constexpr const v_int32 TYPE_FINISH = 4; + + /** + * Deprecated + */ static constexpr const v_int32 TYPE_ABORT = 5; + + /** + * Indicate that Error occurred + */ static constexpr const v_int32 TYPE_ERROR = 6; public: static const Action _WAIT_RETRY; diff --git a/src/oatpp/web/protocol/http/incoming/Request.hpp b/src/oatpp/web/protocol/http/incoming/Request.hpp index 7d2431a6..b7894deb 100644 --- a/src/oatpp/web/protocol/http/incoming/Request.hpp +++ b/src/oatpp/web/protocol/http/incoming/Request.hpp @@ -86,7 +86,7 @@ public: oatpp::String getQueryParameter(const oatpp::data::share::StringKeyLabel& name) const; /** - * + * Get query parameter value by name with defaultValue * @param name * @param defaultValue * @return query parameter value or defaultValue if no such parameter found @@ -100,8 +100,8 @@ public: const http::RequestStartingLine& getStartingLine() const; /** - * Get path variables according to path-pattern. - * Ex. given request path="/sum/19/1" for path-pattern="/sum/{a}/{b}" + * Get path variables according to path-pattern.
+ * Ex. given request path="/sum/19/1" for path-pattern="/sum/{a}/{b}"
* getPathVariables().getVariable("a") == 19, getPathVariables().getVariable("b") == 1. * * @return url MatchMap