Add API docs

This commit is contained in:
lganzzzo 2019-03-16 14:20:20 +02:00
parent 606e055072
commit 9187370b78
8 changed files with 157 additions and 18 deletions

View File

@ -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);
};

View File

@ -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<oatpp::web::protocol::http::incoming::Response>
*/
#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__))

View File

@ -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<oatpp::web::protocol::http::outgoing::Response>
*/
#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<Endpoint::Info> Z__EDNPOINT_INFO_GET_INSTANCE_##NAME() { \
return info; \
}
/**
/*
* 1 - Endpoint info instance
* 2 - Endpoint instance
*/
@ -434,7 +441,13 @@ const std::shared_ptr<Endpoint> 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<NAME, __ControllerType>
/**
* 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: \
\

View File

@ -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__))

View File

@ -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;
}

View File

@ -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)

View File

@ -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;

View File

@ -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. <br>
* Ex. given request path="/sum/19/1" for path-pattern="/sum/{a}/{b}" <br>
* getPathVariables().getVariable("a") == 19, getPathVariables().getVariable("b") == 1.
*
* @return url MatchMap