diff --git a/include/odata/client/odata_client.h b/include/odata/client/odata_client.h
index 427a7ef..6342e0e 100644
--- a/include/odata/client/odata_client.h
+++ b/include/odata/client/odata_client.h
@@ -18,159 +18,274 @@
namespace odata { namespace client {
- class odata_client
- {
- public:
- ///
- /// Constructor
- ///
- /// The OData service endpoint used to create the client.
- odata_client(::utility::string_t baseAddress, client_options options = client_options()) :
- m_options(options), m_service_root_url(std::move(baseAddress))
- {
- m_client_proxy = std::make_shared<::odata::communication::http_client_proxy<::odata::communication::http_client_impl, ::odata::communication::http_client_response>>(m_service_root_url, options.get_credential_setting());
-
- if (m_service_root_url.back() == '/')
- {
- m_service_root_url.pop_back();
- }
- }
-
- ::web::http::client::http_client_config& get_client_config(){
- return m_client_proxy->get_client_config();
- }
-
- const ::utility::string_t& get_service_root_url() const
- {
- return m_service_root_url;
- }
-
- ::utility::string_t get_relative_path(const ::utility::string_t& full_path)
- {
- if (::odata::common::is_relative_path(m_service_root_url, full_path))
- {
- return full_path;
- }
-
- return full_path.substr(m_service_root_url.length() + 1, full_path.length() - m_service_root_url.length());
- }
-
- ///
- /// Retrieve the service's metadata (types, and other information).
- ///
- ODATACPP_CLIENT_API pplx::task> get_model();
-
- ///
- /// Get the elements of a given entity set.
- ///
- /// The entity set metadata record.
- /// The OData query string to use for the request.
- /// The result entities with annotation infomation, possibly empty.
- ODATACPP_CLIENT_API pplx::task>> get_entities(const ::utility::string_t& edm_entity_set);
-
- ///
- /// Add an entity to a given entity set.
- ///
- /// The entity set metadata record.
- /// The entity to add.
- /// An entity instance representing the new entity after it was inserted.
- ODATACPP_CLIENT_API pplx::task<::web::http::status_code> create_entity(const ::utility::string_t& entity_set_name, const std::shared_ptr<::odata::core::odata_entity_value>& entity_object);
-
- ///
- /// Update an existing entity of a given entity set.
- ///
- /// The entity set metadata record.
- /// The primary key of the record that should be modified.
- /// The entity value to write.
- /// An entity instance representing the new entity after it was modified.
- /// This does a surgical replacement of the record, modifying and adding properties found in the provided record.
- ODATACPP_CLIENT_API pplx::task<::web::http::status_code> patch_entity(const ::utility::string_t& entity_set_name, const std::shared_ptr<::odata::core::odata_entity_value>& entity_object);
-
- ///
- /// Replace existing entity of a given entity set.
- ///
- /// The entity set metadata record.
- /// The primary key of the record that should be modified.
- /// The entity value to write.
- /// An entity instance representing the new entity after it was modified.
- /// This does a total replacement of the existing entity with a given entity value.
- ODATACPP_CLIENT_API pplx::task<::web::http::status_code> put_entity(const ::utility::string_t& entity_set_name, const std::shared_ptr<::odata::core::odata_entity_value>& entity_object);
-
- ///
- /// Remove an entity from a given entity set.
- ///
- /// The entity set metadata record.
- /// The primary key of the record that should be deleted.
- ODATACPP_CLIENT_API pplx::task<::web::http::status_code> delete_entity(const ::utility::string_t& entity_set_name, const std::shared_ptr<::odata::core::odata_entity_value>& entity_object);
-
- ///
- /// Add a reference to a collection-valued navigation property.
- ///
- /// The path of the navigation property.
- /// The id of referenced entity.
- ODATACPP_CLIENT_API pplx::task<::web::http::status_code> add_reference(const ::utility::string_t& path, const ::utility::string_t& referenceEntityId);
-
- ///
- /// Remove reference to a collection-valued or single-valued navigation property.
- ///
- /// The path of the navigation property.
- /// The id of referenced entity if the navigation property is collection-values, or empty if it is single-valued.
- ODATACPP_CLIENT_API pplx::task<::web::http::status_code> remove_reference(const ::utility::string_t& path, const ::utility::string_t& referenceEntityId);
-
- ///
- /// Update reference to a single-valued navigation property.
- ///
- /// The path of the navigation property.
- /// The id of referenced entity.
- ODATACPP_CLIENT_API pplx::task<::web::http::status_code> update_reference(const ::utility::string_t& path, const ::utility::string_t& referenceEntityId);
-
- ///
- /// Get odata value of any odata type data defined in edm library including primitive, complex, entity type from server.
- ///
- /// The request path which can be set with select, filter, expand or even function or action options.
- ODATACPP_CLIENT_API pplx::task>> get_data_from_server(const ::utility::string_t& path);
-
- ///
- /// The size of result data of a request maybe too large for one http response, so the server may return the data one page after another
- ///
- /// The request path which can be set with select, filter, expand or even function or action options.
- /// The result data set.
- /// The odata_payload class containing next link url, if no more data next link url is empty.
- ODATACPP_CLIENT_API pplx::task> get_paged_data_from_server(const ::utility::string_t& path);
-
- ///
- /// Send odata value of any odata type data defined in edm library including primitive, complex, entity type to server.
- ///
- /// Path of OData value.
- /// OData value to be sent to the server.
- /// POST, PATCH or PUT options.
- ODATACPP_CLIENT_API pplx::task<::web::http::status_code> send_data_to_server(const ::utility::string_t& path, const std::shared_ptr<::odata::core::odata_value>& send_value, const ::utility::string_t& send_type = HTTP_POST);
-
- ///
- /// Send a vector of odata parameters to server.
- ///
- /// Path to send the parameters, could be function/action path.
- /// OData parameters to be sent to the server.
- /// POST, PATCH or PUT options.
- ODATACPP_CLIENT_API pplx::task<::web::http::status_code> send_data_to_server(const ::utility::string_t& path, const std::vector>& send_parameters, std::vector>& returnd_value, const ::utility::string_t& send_type = HTTP_POST);
-
- ///
- /// Send empty data to server.
- ///
- /// Path of OData value.
- /// POST, PATCH or PUT options.
- ODATACPP_CLIENT_API pplx::task<::web::http::status_code> send_data_to_server(const ::utility::string_t& path, const ::utility::string_t& send_type = HTTP_POST);
- private:
- std::shared_ptr<::odata::edm::edm_model> schema_from_response(const ::odata::communication::http_client_response& response);
- std::shared_ptr<::odata::core::odata_payload> entity_payload_from_response(const ::odata::communication::http_client_response&, const std::shared_ptr<::odata::edm::edm_entity_set>& set);
- std::shared_ptr<::odata::core::odata_payload> parse_payload_from_response(const ::odata::communication::http_client_response&);
- pplx::task>> get_entities(const std::shared_ptr<::odata::edm::edm_entity_set>& edm_entity_set, const ::utility::string_t& path = U(""));
-
- static std::unordered_map<::utility::string_t, std::shared_ptr<::odata::edm::edm_model>> m_model_cache;
- std::shared_ptr<::odata::communication::http_client_proxy<::odata::communication::http_client_impl, ::odata::communication::http_client_response>> m_client_proxy;
- client_options m_options;
- ::utility::string_t m_service_root_url;
- std::shared_ptr<::odata::edm::edm_model> m_model;
- };
+ struct http_result
+ {
+ http_result() = default;
+ http_result(http_result const&) = default;
+ http_result(http_result&&) = default;
+ http_result(::web::http::http_headers const &headers, ::web::http::status_code status) : headers_(headers), status_(status) {}
+ http_result(::web::http::http_response const &response) : headers_(response.headers()), status_(response.status_code()) {}
+ http_result& operator=(http_result const&) = default;
+ http_result& operator=(http_result&&) = default;
+ ::web::http::http_headers headers_;
+ ::web::http::status_code status_;
+ };
+
+ class odata_client
+ {
+ public:
+ ///
+ /// Constructor
+ ///
+ /// The OData service endpoint used to create the client.
+ odata_client(::odata::string_t baseAddress, client_options options = client_options()) :
+ m_client_proxy(), m_options(options), m_service_root_url(std::move(baseAddress)), m_model(), m_model_response_headers(), m_ShallLogCallback(), m_LogCallback()
+ {
+ m_client_proxy = ::odata::make_shared<::odata::communication::http_client_proxy<::odata::communication::http_client_impl, ::odata::communication::http_client_response>>(m_service_root_url, options.get_credential_setting());
+
+ if (m_service_root_url.back() == _XPLATSTR('/'))
+ {
+ m_service_root_url.pop_back();
+ }
+ }
+
+ ::web::http::client::http_client_config& get_client_config()
+ {
+ return m_client_proxy->get_client_config();
+ }
+
+ const ::odata::string_t& get_service_root_url() const
+ {
+ return m_service_root_url;
+ }
+
+ ::odata::string_t get_relative_path(const ::odata::string_t& full_path) const
+ {
+ if (::odata::common::is_relative_path(m_service_root_url, full_path))
+ {
+ return full_path;
+ }
+
+ return full_path.length() > m_service_root_url.length() ? full_path.substr(m_service_root_url.length() + 1, full_path.length() - m_service_root_url.length()) : _XPLATSTR(""); // Handles corner case of full_path = m_service_root_url!
+ }
+
+ const client_options& get_options() const { return m_options; }
+
+ ///
+ /// Retrieve the service's metadata (types, and other information).
+ ///
+ ODATACPP_CLIENT_API pplx::task, http_result>> get_model();
+
+ ///
+ /// Get the elements of a given entity set.
+ ///
+ /// The entity set metadata record.
+ /// The OData query string to use for the request.
+ /// The result entities with annotation infomation, possibly empty.
+ ODATACPP_CLIENT_API pplx::task>, http_result>> get_entities(const ::odata::string_t& edm_entity_set);
+
+ ///
+ /// Add an entity to a given entity set.
+ ///
+ /// The entity set metadata record.
+ /// The entity to add.
+ /// An entity instance representing the new entity after it was inserted.
+ ODATACPP_CLIENT_API pplx::task> create_entity(const ::odata::string_t& entity_set_name, const std::shared_ptr<::odata::core::odata_entity_value>& entity_object);
+
+ ///
+ /// Update an existing entity of a given entity set.
+ ///
+ /// The entity set metadata record.
+ /// The primary key of the record that should be modified.
+ /// The entity value to write.
+ /// An entity instance representing the new entity after it was modified.
+ /// This does a surgical replacement of the record, modifying and adding properties found in the provided record.
+ ODATACPP_CLIENT_API pplx::task> patch_entity(const ::odata::string_t& entity_set_name, const std::shared_ptr<::odata::core::odata_entity_value>& entity_object);
+
+ ///
+ /// Replace existing entity of a given entity set.
+ ///
+ /// The entity set metadata record.
+ /// The primary key of the record that should be modified.
+ /// The entity value to write.
+ /// An entity instance representing the new entity after it was modified.
+ /// This does a total replacement of the existing entity with a given entity value.
+ ODATACPP_CLIENT_API pplx::task> put_entity(const ::odata::string_t& entity_set_name, const std::shared_ptr<::odata::core::odata_entity_value>& entity_object);
+
+ ///
+ /// Remove an entity from a given entity set.
+ ///
+ /// The entity set metadata record.
+ /// The primary key of the record that should be deleted.
+ ODATACPP_CLIENT_API pplx::task> delete_entity(const ::odata::string_t& entity_set_name, const std::shared_ptr<::odata::core::odata_entity_value>& entity_object);
+
+ ///
+ /// Add a reference to a collection-valued navigation property.
+ ///
+ /// The path of the navigation property.
+ /// The id of referenced entity.
+ ODATACPP_CLIENT_API pplx::task> add_reference(const ::odata::string_t& path, const ::odata::string_t& referenceEntityId);
+
+ ///
+ /// Remove reference to a collection-valued or single-valued navigation property.
+ ///
+ /// The path of the navigation property.
+ /// The id of referenced entity if the navigation property is collection-values, or empty if it is single-valued.
+ ODATACPP_CLIENT_API pplx::task> remove_reference(const ::odata::string_t& path, const ::odata::string_t& referenceEntityId);
+
+ ///
+ /// Update reference to a single-valued navigation property.
+ ///
+ /// The path of the navigation property.
+ /// The id of referenced entity.
+ ODATACPP_CLIENT_API pplx::task> update_reference(const ::odata::string_t& path, const ::odata::string_t& referenceEntityId);
+
+ ///
+ /// Get odata value of any odata type data defined in edm library including primitive, complex, entity type from server.
+ ///
+ /// The request path which can be set with select, filter, expand or even function or action options.
+ ODATACPP_CLIENT_API pplx::task>, http_result>> get_data_from_server(const ::odata::string_t& path);
+
+ ///
+ /// The size of result data of a request maybe too large for one http response, so the server may return the data one page after another
+ ///
+ /// The request path which can be set with select, filter, expand or even function or action options.
+ /// The result data set.
+ /// The odata_payload class containing next link url, if no more data next link url is empty.
+ ODATACPP_CLIENT_API pplx::task, http_result>> get_paged_data_from_server(const ::odata::string_t& path);
+
+ ///
+ /// Send odata value of any odata type data defined in edm library including primitive, complex, entity type to server.
+ ///
+ /// Path of OData value.
+ /// OData value to be sent to the server.
+ /// POST, PATCH or PUT options.
+ ODATACPP_CLIENT_API pplx::task> send_data_to_server(const ::odata::string_t& path, const std::shared_ptr<::odata::core::odata_value>& send_value, const ::odata::string_t& send_type = HTTP_POST);
+
+ ///
+ /// Send a vector of odata parameters to server.
+ ///
+ /// Path to send the parameters, could be function/action path.
+ /// OData parameters to be sent to the server.
+ /// POST, PATCH or PUT options.
+ ODATACPP_CLIENT_API pplx::task> send_data_to_server(const ::odata::string_t& path, const std::vector>& send_parameters, std::vector>& returned_value, const ::odata::string_t& send_type = HTTP_POST);
+
+ ///
+ /// Send empty data to server.
+ ///
+ /// Path of OData value.
+ /// POST, PATCH or PUT options.
+ ODATACPP_CLIENT_API pplx::task> send_data_to_server(const ::odata::string_t& path, const ::odata::string_t& send_type = HTTP_POST);
+ private:
+ std::shared_ptr<::odata::edm::edm_model> schema_from_response(const ::odata::communication::http_client_response& response);
+ std::shared_ptr<::odata::core::odata_payload> entity_payload_from_response(const ::odata::communication::http_client_response&, const std::shared_ptr<::odata::edm::edm_entity_set>& set);
+ std::shared_ptr<::odata::core::odata_payload> parse_payload_from_response(const ::odata::communication::http_client_response&);
+ pplx::task>, http_result>> get_entities(const std::shared_ptr<::odata::edm::edm_entity_set>& edm_entity_set, const ::odata::string_t& path = _XPLATSTR(""));
+
+ static std::unordered_map<::odata::string_t, std::shared_ptr<::odata::edm::edm_model>> m_model_cache;
+ std::shared_ptr<::odata::communication::http_client_proxy<::odata::communication::http_client_impl, ::odata::communication::http_client_response>> m_client_proxy;
+ client_options m_options;
+ ::odata::string_t m_service_root_url;
+ std::shared_ptr<::odata::edm::edm_model> m_model;
+
+ web::http::http_headers m_model_response_headers; //!< The http headers from the query for the model. These are kept separately as every command used will automatically query the model.
+
+ public:
+ void clear_request_header()
+ {
+ m_client_proxy->clear_request_header();
+ }
+ bool has_request_header(const ::odata::string_t& name) const
+ {
+ return m_client_proxy->has_request_header(name);
+ }
+ void add_request_header(const ::odata::string_t& name, const ::odata::string_t& value)
+ {
+ m_client_proxy->add_request_header(name, value);
+ }
+ void remove_request_header(const ::odata::string_t& name)
+ {
+ m_client_proxy->remove_request_header(name);
+ }
+ ::odata::string_t match_request_header(const ::odata::string_t& name) const
+ {
+ return m_client_proxy->match_request_header(name);
+ }
+
+ web::http::http_headers const& get_model_response_header() const
+ {
+ return m_model_response_headers;
+ }
+ bool has_model_response_header(const ::odata::string_t& name) const
+ {
+ return m_model_response_headers.has(name);
+ }
+ ::odata::string_t match_model_response_header(const ::odata::string_t& name) const
+ {
+ ::odata::string_t value;
+ m_model_response_headers.match(name, value);
+ return value;
+ }
+
+ bool clear_metadata_model()
+ {
+ auto find_iter = m_model_cache.find(m_service_root_url);
+ if (find_iter == m_model_cache.end())
+ {
+ return false;
+ }
+
+ // Erase the model from the cache and from the instance itself
+ m_model_cache.erase(find_iter);
+ m_model.reset();
+ return true;
+ }
+
+ bool get_supress_odata_type() const
+ {
+ return m_options.get_suppress_odata_type();
+ }
+
+ void set_supress_odata_type(bool suppress_odata_type)
+ {
+ m_options.set_suppress_odata_type(suppress_odata_type);
+ }
+
+ // Logging capability for http responses. Be careful when using, this is a comment from
+ // the casablanca REST SDK method to_string():
+ // "Generates a string representation of the message, including the body when possible.
+ // Mainly this should be used for debugging purposes as it has to copy the message body
+ // and doesn't have excellent performance."
+ // Thus besides setting the callback itself we have a separate callback that needs to
+ // check in advance if any logging should happen, preventing th call to to_string()
+ // if logging is disabled by some means (e. g. logging level).
+ private:
+ std::function m_ShallLogCallback;
+ std::function m_LogCallback;
+
+ void doLog(wchar_t const* Function, wchar_t const *File, size_t Line, web::http::http_response const &response) const
+ {
+ if (m_LogCallback && m_ShallLogCallback && m_ShallLogCallback())
+ {
+ m_LogCallback(Function, File, Line, false, response.to_string()); // false == This is a response
+ }
+ }
+
+ public:
+ void SetLogCallbacks(std::function ShallLogCallback, std::function LogCallback)
+ {
+ if (ShallLogCallback && LogCallback)
+ {
+ m_ShallLogCallback = ShallLogCallback;
+ m_LogCallback = LogCallback;
+ }
+ else
+ {
+ m_ShallLogCallback = nullptr;
+ m_LogCallback = nullptr;
+ }
+ m_client_proxy->SetLogCallbacks(ShallLogCallback, LogCallback);
+ }
+ };
}}
diff --git a/include/odata/client/odata_client_options.h b/include/odata/client/odata_client_options.h
index e20dd05..c197864 100644
--- a/include/odata/client/odata_client_options.h
+++ b/include/odata/client/odata_client_options.h
@@ -13,24 +13,24 @@ namespace odata { namespace client {
class odata_client_credential
{
public:
- odata_client_credential(::utility::string_t username, ::utility::string_t password) :
+ odata_client_credential(::odata::string_t username, ::odata::string_t password) :
m_username(std::move(username)), m_password(std::move(password))
{
}
- const ::utility::string_t& get_username() const
+ const ::odata::string_t& get_username() const
{
return m_username;
}
- const ::utility::string_t& get_password() const
+ const ::odata::string_t& get_password() const
{
return m_password;
}
private:
- ::utility::string_t m_username;
- ::utility::string_t m_password;
+ ::odata::string_t m_username;
+ ::odata::string_t m_password;
};
///
@@ -41,45 +41,45 @@ class odata_client;
class client_options
{
public:
- ///
- /// Represents options used when creating an OData client instance.
- ///
- client_options() : m_prefer_json(true), m_verb_tunneling(false),m_json_mdlevel(U("minimal")), m_credential(nullptr)
- {
- }
-
- ///
- /// Sets the client to request responses formatted as JSON, when applicable
- ///
- client_options prefer_json(::utility::string_t mdlevel = U("minimal"))
- {
- m_prefer_json = true;
- m_json_mdlevel = mdlevel;
- return *this;
- }
-
- ///
- /// Sets the client to request responses formatted as an Atom feed, when applicable
- ///
- client_options prefer_atom()
- {
- m_prefer_json = false;
- m_json_mdlevel.clear();
- return *this;
- }
-
- ///
- /// Use verb tunneling when making non-GET/POST requests.
- ///
- client_options do_verb_tunneling()
- {
- m_verb_tunneling = true;
- return *this;
- }
-
- void enable_client_credential(::utility::string_t username, ::utility::string_t password)
+ ///
+ /// Represents options used when creating an OData client instance.
+ ///
+ client_options() : m_prefer_json(true), m_verb_tunneling(false), m_json_mdlevel(_XPLATSTR("minimal")), m_credential(nullptr), m_suppress_odata_type(false)
{
- m_credential = std::make_shared(std::move(username), std::move(password));
+ }
+
+ ///
+ /// Sets the client to request responses formatted as JSON, when applicable
+ ///
+ client_options prefer_json(::odata::string_t mdlevel = _XPLATSTR("minimal"))
+ {
+ m_prefer_json = true;
+ m_json_mdlevel = mdlevel;
+ return *this;
+ }
+
+ ///
+ /// Sets the client to request responses formatted as an Atom feed, when applicable
+ ///
+ client_options prefer_atom()
+ {
+ m_prefer_json = false;
+ m_json_mdlevel.clear();
+ return *this;
+ }
+
+ ///
+ /// Use verb tunneling when making non-GET/POST requests.
+ ///
+ client_options do_verb_tunneling()
+ {
+ m_verb_tunneling = true;
+ return *this;
+ }
+
+ void enable_client_credential(::odata::string_t username, ::odata::string_t password)
+ {
+ m_credential = ::odata::make_shared(std::move(username), std::move(password));
}
void disable_client_credential()
@@ -87,18 +87,29 @@ class client_options
m_credential = nullptr;
}
- const std::shared_ptr& get_credential_setting()
+ void set_suppress_odata_type(bool SuppressODataType)
+ {
+ m_suppress_odata_type = SuppressODataType;
+ }
+
+ const std::shared_ptr& get_credential_setting() const
{
return m_credential;
}
+ bool get_suppress_odata_type() const
+ {
+ return m_suppress_odata_type;
+ }
+
private:
friend class odata_client;
- bool m_prefer_json;
- bool m_verb_tunneling;
- ::utility::string_t m_json_mdlevel;
+ bool m_prefer_json;
+ bool m_verb_tunneling;
+ ::odata::string_t m_json_mdlevel;
std::shared_ptr m_credential;
+ bool m_suppress_odata_type;
};
-}}
\ No newline at end of file
+}}
diff --git a/include/odata/codegen/code_generation.h b/include/odata/codegen/code_generation.h
index bbfe933..b41ebab 100644
--- a/include/odata/codegen/code_generation.h
+++ b/include/odata/codegen/code_generation.h
@@ -15,111 +15,85 @@
#include "odata/core/odata_core.h"
#include "odata/core/odata_json_writer.h"
-namespace odata { namespace codegen {
+namespace odata { namespace codegen {
#define DECLARE_PRIMITIVE_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
public: \
- const type& get_##property_name() { return property_name; } const \
+ const type& get_##property_name() const { return property_name; } \
void set_##property_name(const type& property_value) { property_name = property_value; } \
protected: \
- type property_name; \
- void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
+ type property_name; \
+ void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
#define IMPLEMENT_PRIMITIVE_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name, edm_name, type) \
- void myclass::get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+ void myclass::get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
- std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pentity->get_property_value(U(#edm_name), property_value) || !property_value) \
- { \
- return ; \
+ std::shared_ptr<::odata::core::odata_value> property_value; \
+ if (!pentity->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
+ { \
+ return; \
} \
auto primitive_value = std::dynamic_pointer_cast(property_value); \
- if (primitive_value) \
- { \
- property_name = primitive_value->as(); \
- } \
- } \
+ if (primitive_value) \
+ { \
+ property_name = primitive_value->as(); \
+ } \
+ } \
void myclass::set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
- if (!pentity) \
- { \
- return ; \
- } \
- pentity->set_value(U(#edm_name), property_name); \
+ if (!pentity) \
+ { \
+ return; \
+ } \
+ pentity->set_value(_XPLATSTR(#edm_name), property_name); \
}
-// because we have to support derived complex type, so complex object in entity are all set with pointer type
-#define DECLARE_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
- DECLARE_NULLABLE_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type)
-
-#define IMPLEMENT_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name, edm_name, type) \
- IMPLEMENT_NULLABLE_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name, edm_name, type)
-
#define DECLARE_PRIMITIVE_PROPERTY_IN_COMPLEX_MAPPING(property_name, edm_name, type) \
public : \
- const type& get_##property_name() { return property_name; } const \
+ const type& get_##property_name() const { return property_name; } \
void set_##property_name(const type& property_value) { property_name = property_value; } \
protected: \
- type property_name; \
- void get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
+ type property_name; \
+ void get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
#define IMPLEMENT_PRIMITIVE_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name, edm_name, type) \
- void myclass::get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
+ void myclass::get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
- std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pcomplex->get_property_value(U(#edm_name), property_value) || !property_value) \
- { \
- return ; \
+ std::shared_ptr<::odata::core::odata_value> property_value; \
+ if (!pcomplex->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
+ { \
+ return; \
} \
auto primitive_value = std::dynamic_pointer_cast(property_value); \
- if (primitive_value) \
- { \
- property_name = primitive_value->as(); \
- } \
- }\
+ if (primitive_value) \
+ { \
+ property_name = primitive_value->as(); \
+ } \
+ }\
void myclass::set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
- if (!pcomplex) \
- { \
- return ; \
- } \
- pcomplex->set_value(U(#edm_name), property_name); \
- }
-
-#define IMPLEMENT_EDM_INFO(myclass, name_space, type_name) \
- ::utility::string_t myclass::m_namespace = U(#name_space); \
- ::utility::string_t myclass::m_typename = U(#type_name); \
- ::utility::string_t myclass::get_full_name() \
- { \
- return myclass::m_namespace + U(".") + myclass::m_typename; \
- } \
- ::utility::string_t myclass::get_type_name() \
- { \
- return m_typename; \
+ if (!pcomplex) \
+ { \
+ return; \
+ } \
+ pcomplex->set_value(_XPLATSTR(#edm_name), property_name); \
}
-#define DECLARE_ENTITY_CONSTRUCTOR(myclass) \
- public: \
- myclass(const std::shared_ptr& service_context); \
- ::utility::string_t get_root_url() { return m_service_context ? m_service_context->get_root_url() : U(""); } \
- static create_map_for_entity_type::value_type _init_creator_map_values[]; \
- static std::unordered_map<::utility::string_t, CREATE_CALL_FOR_ENTITY> _derived_entity_creator_map;
-
#define ENABLE_PROPERTY_IN_ENTITY_MAPPING() \
public: \
- void from_value(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
+ void from_value(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
virtual std::shared_ptr<::odata::core::odata_entity_value> to_value(); \
PROPMAP_ENTRY_IN_ENTITY* get_to_entity_map(); \
void set_to_entity_map(PROPMAP_ENTRY_IN_ENTITY* _map); \
protected: \
- static PROPMAP_ENTRY_IN_ENTITY _property_entrties[]; \
- PROPMAP_ENTRY_IN_ENTITY* get_mapping_map(); \
- static PROPMAP_ENTRY_IN_ENTITY _map_class_to_entity_entrties[]; \
+ static PROPMAP_ENTRY_IN_ENTITY _property_entries[]; \
+ PROPMAP_ENTRY_IN_ENTITY* get_mapping_map(); \
+ static PROPMAP_ENTRY_IN_ENTITY _map_class_to_entity_entries[]; \
PROPMAP_ENTRY_IN_ENTITY* m_to_entity_map; \
void map_entity_value_to_class_member(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
- void map_class_member_to_entity_value(const std::shared_ptr<::odata::core::odata_entity_value>& entity_value);
+ void map_class_member_to_entity_value(const std::shared_ptr<::odata::core::odata_entity_value>& entity_value);
#define ENABLE_PROPERTY_IN_COMPLEX_MAPPING() \
public: \
@@ -128,324 +102,466 @@ public: \
PROPMAP_ENTRY_IN_COMPLEX* get_to_complex_map(); \
void set_to_complex_map(PROPMAP_ENTRY_IN_COMPLEX* _map); \
protected: \
- static PROPMAP_ENTRY_IN_COMPLEX _property_entrties[]; \
- PROPMAP_ENTRY_IN_COMPLEX* get_mapping_map(); \
- static PROPMAP_ENTRY_IN_COMPLEX _map_class_to_complex_entrties[]; \
+ static PROPMAP_ENTRY_IN_COMPLEX _property_entries[]; \
+ PROPMAP_ENTRY_IN_COMPLEX* get_mapping_map(); \
+ static PROPMAP_ENTRY_IN_COMPLEX _map_class_to_complex_entries[]; \
PROPMAP_ENTRY_IN_COMPLEX* m_to_complex_map; \
void map_complex_value_to_class_member(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
- void map_class_member_to_complex_value(const std::shared_ptr<::odata::core::odata_complex_value>& complex_value);
+ void map_class_member_to_complex_value(const std::shared_ptr<::odata::core::odata_complex_value>& complex_value);
#define DECLARE_EDM_INFO() \
- protected: \
- static ::utility::string_t m_namespace; \
- static ::utility::string_t m_typename; \
+ protected: \
+ static ::odata::string_t m_namespace; \
+ static ::odata::string_t m_typename; \
public: \
- static ::utility::string_t get_full_name(); \
- static ::utility::string_t get_type_name(); \
+ static ::odata::string_t get_full_name(); \
+ static ::odata::string_t get_type_name();
+
+#define IMPLEMENT_EDM_INFO(myclass, name_space, type_name) \
+ ::odata::string_t myclass::m_namespace = _XPLATSTR(#name_space); \
+ ::odata::string_t myclass::m_typename = _XPLATSTR(#type_name); \
+ ::odata::string_t myclass::get_full_name() \
+ { \
+ return myclass::m_namespace + _XPLATSTR(".") + myclass::m_typename; \
+ } \
+ ::odata::string_t myclass::get_type_name() \
+ { \
+ return m_typename; \
+ }
#define BEGIN_PROPERTY_IN_ENTITY_MAPPING(myclass) \
- PROPMAP_ENTRY_IN_ENTITY* myclass::get_mapping_map() \
- { \
- return _property_entrties; \
- } \
+ PROPMAP_ENTRY_IN_ENTITY* myclass::get_mapping_map() \
+ { \
+ return _property_entries; \
+ } \
PROPMAP_ENTRY_IN_ENTITY* myclass::get_to_entity_map() \
{ \
- if (!m_to_entity_map) \
- m_to_entity_map = _map_class_to_entity_entrties; \
- return m_to_entity_map; \
+ if (!m_to_entity_map) \
+ m_to_entity_map = _map_class_to_entity_entries; \
+ return m_to_entity_map; \
} \
void myclass::set_to_entity_map(PROPMAP_ENTRY_IN_ENTITY* _map) \
{ \
- m_to_entity_map = _map; \
+ m_to_entity_map = _map; \
} \
- PROPMAP_ENTRY_IN_ENTITY myclass::_property_entrties[] = \
- {
+ PROPMAP_ENTRY_IN_ENTITY myclass::_property_entries[] = \
+ {
#define BEGIN_PROPERTY_IN_ENTITY_MAPPING_WITH_BASE_CLASS(myclass, parentclass) \
- BEGIN_PROPERTY_IN_ENTITY_MAPPING(myclass)
+ BEGIN_PROPERTY_IN_ENTITY_MAPPING(myclass)
#define END_PROPERTY_IN_ENTITY_MAPPING(myclass) \
- {(PROP_MAP_CALL_IN_ENTITY)0} \
- }; \
+ {(PROP_MAP_CALL_IN_ENTITY)0} \
+ }; \
std::shared_ptr<::odata::core::odata_entity_value> myclass::to_value() \
{ \
- if (!m_service_context || !m_service_context->get_edm_model()) { return nullptr; } \
- auto entity_type = m_service_context->get_edm_model()->find_entity_type(m_typename); \
- auto entity_value = std::make_shared<::odata::core::odata_entity_value>(entity_type); \
+ if (!m_service_context || !m_service_context->get_edm_model()) { return nullptr; } \
+ auto entity_type = m_service_context->get_edm_model()->find_entity_type(m_typename); \
+ auto entity_value = ::odata::make_shared<::odata::core::odata_entity_value>(entity_type); \
map_class_member_to_entity_value(entity_value); \
if (!m_namespace.empty() && !m_typename.empty()) \
- { \
- entity_value->set_value(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE, std::make_shared(std::make_shared<::odata::edm::edm_payload_annotation_type>(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE), U("#") + m_namespace + U(".") + m_typename)); \
- } \
+ { \
+ entity_value->set_value(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE, ::odata::make_shared(::odata::make_shared<::odata::edm::edm_payload_annotation_type>(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE), _XPLATSTR("#") + m_namespace + _XPLATSTR(".") + m_typename)); \
+ } \
return entity_value; \
} \
- void myclass::from_value(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+ void myclass::from_value(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
- map_entity_value_to_class_member(pentity); \
+ map_entity_value_to_class_member(pentity); \
}
#define END_PROPERTY_IN_ENTITY_MAPPING_WITH_BASE_CLASS(myclass, parentclass) \
- {(PROP_MAP_CALL_IN_ENTITY)0} \
- }; \
+ {(PROP_MAP_CALL_IN_ENTITY)0} \
+ }; \
std::shared_ptr<::odata::core::odata_entity_value> myclass::to_value() \
{ \
- if (!m_service_context || !m_service_context->get_edm_model()) { return nullptr; } \
+ if (!m_service_context || !m_service_context->get_edm_model()) { return nullptr; } \
auto entity_value = parentclass::to_value(); \
- auto entity_type = m_service_context->get_edm_model()->find_entity_type(m_typename); \
+ auto entity_type = m_service_context->get_edm_model()->find_entity_type(m_typename); \
entity_value->set_value_type(entity_type); \
map_class_member_to_entity_value(entity_value); \
if (!m_namespace.empty() && !m_typename.empty()) \
- { \
-entity_value->set_value(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE, std::make_shared(std::make_shared<::odata::edm::edm_payload_annotation_type>(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE), U("#") + m_namespace + U(".") + m_typename)); \
- } \
+ { \
+entity_value->set_value(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE, ::odata::make_shared(::odata::make_shared<::odata::edm::edm_payload_annotation_type>(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE), _XPLATSTR("#") + m_namespace + _XPLATSTR(".") + m_typename)); \
+ } \
return entity_value; \
} \
- void myclass::from_value(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+ void myclass::from_value(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
- parentclass::from_value(pentity); \
- map_entity_value_to_class_member(pentity); \
+ parentclass::from_value(pentity); \
+ map_entity_value_to_class_member(pentity); \
}
#define ON_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name) \
- {(PROP_MAP_CALL_IN_ENTITY)&myclass::get_##property_name##_from_entity},
+ {(PROP_MAP_CALL_IN_ENTITY)&myclass::get_##property_name##_from_entity},
+
+#define ON_OPEN_PROPERTY_IN_ENTITY_MAPPING(myclass) \
+ {(PROP_MAP_CALL_IN_ENTITY)&myclass::get_open_properties_from_entity},
#define BEGIN_PROPERTY_IN_COMPLEX_MAPPING(myclass) \
- PROPMAP_ENTRY_IN_COMPLEX* myclass::get_mapping_map() \
- { \
- return _property_entrties; \
- } \
+ PROPMAP_ENTRY_IN_COMPLEX* myclass::get_mapping_map() \
+ { \
+ return _property_entries; \
+ } \
PROPMAP_ENTRY_IN_COMPLEX* myclass::get_to_complex_map() \
{ \
- if (!m_to_complex_map) \
- m_to_complex_map = _map_class_to_complex_entrties; \
- return m_to_complex_map; \
+ if (!m_to_complex_map) \
+ m_to_complex_map = _map_class_to_complex_entries; \
+ return m_to_complex_map; \
} \
void myclass::set_to_complex_map(PROPMAP_ENTRY_IN_COMPLEX* _map) \
{ \
- m_to_complex_map = _map; \
+ m_to_complex_map = _map; \
} \
- PROPMAP_ENTRY_IN_COMPLEX myclass::_property_entrties[] = \
- {
+ PROPMAP_ENTRY_IN_COMPLEX myclass::_property_entries[] = \
+ {
#define BEGIN_PROPERTY_IN_COMPLEX_MAPPING_WITH_BASE_CLASS(myclass, parentclass) \
BEGIN_PROPERTY_IN_COMPLEX_MAPPING(myclass)
#define END_PROPERTY_IN_COMPLEX_MAPPING(myclass) \
- {(PROP_MAP_CALL_IN_COMPLEX)0 } \
- }; \
+ {(PROP_MAP_CALL_IN_COMPLEX)0 } \
+ }; \
std::shared_ptr<::odata::core::odata_complex_value> myclass::to_value() \
{ \
- if (!m_service_context || !m_service_context->get_edm_model()) { return nullptr; } \
- auto complex_type = m_service_context->get_edm_model()->find_complex_type(m_typename); \
- auto complex_value = std::make_shared<::odata::core::odata_complex_value>(complex_type); \
+ if (!m_service_context || !m_service_context->get_edm_model()) { return nullptr; } \
+ auto complex_type = m_service_context->get_edm_model()->find_complex_type(m_typename); \
+ auto complex_value = ::odata::make_shared<::odata::core::odata_complex_value>(complex_type); \
map_class_member_to_complex_value(complex_value); \
if (!m_namespace.empty() && !m_typename.empty()) \
- { \
- complex_value->set_value(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE, std::make_shared(std::make_shared<::odata::edm::edm_payload_annotation_type>(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE), U("#") + m_namespace + U(".") + m_typename)); \
- } \
+ { \
+ complex_value->set_value(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE, ::odata::make_shared(::odata::make_shared<::odata::edm::edm_payload_annotation_type>(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE), _XPLATSTR("#") + m_namespace + _XPLATSTR(".") + m_typename)); \
+ } \
return complex_value; \
} \
void myclass::from_value(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
- map_complex_value_to_class_member(pcomplex); \
+ map_complex_value_to_class_member(pcomplex); \
}
#define END_PROPERTY_IN_COMPLEX_MAPPING_WITH_BASE_CLASS(myclass, parentclass) \
- {(PROP_MAP_CALL_IN_COMPLEX)0 } \
- }; \
+ {(PROP_MAP_CALL_IN_COMPLEX)0 } \
+ }; \
std::shared_ptr<::odata::core::odata_complex_value> myclass::to_value() \
{ \
- if (!m_service_context || !m_service_context->get_edm_model()) { return nullptr; } \
- auto complex_type = m_service_context->get_edm_model()->find_complex_type(m_typename); \
+ if (!m_service_context || !m_service_context->get_edm_model()) { return nullptr; } \
+ auto complex_type = m_service_context->get_edm_model()->find_complex_type(m_typename); \
auto complex_value = parentclass::to_value(); \
complex_value->set_value_type(complex_type); \
map_class_member_to_complex_value(complex_value); \
if (!m_namespace.empty() && !m_typename.empty()) \
- { \
- complex_value->set_value(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE, std::make_shared(std::make_shared<::odata::edm::edm_payload_annotation_type>(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE), U("#") + m_namespace + U(".") + m_typename)); \
- } \
+ { \
+ complex_value->set_value(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE, ::odata::make_shared(::odata::make_shared<::odata::edm::edm_payload_annotation_type>(::odata::core::odata_json_constants::PAYLOAD_ANNOTATION_TYPE), _XPLATSTR("#") + m_namespace + _XPLATSTR(".") + m_typename)); \
+ } \
return complex_value; \
} \
void myclass::from_value(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
- parentclass::from_value(pcomplex); \
- map_complex_value_to_class_member(pcomplex); \
+ parentclass::from_value(pcomplex); \
+ map_complex_value_to_class_member(pcomplex); \
}
#define ON_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name) \
{(PROP_MAP_CALL_IN_COMPLEX)&myclass::get_##property_name##_from_complex}, \
+#define ON_OPEN_PROPERTY_IN_COMPLEX_MAPPING(myclass) \
+ {(PROP_MAP_CALL_IN_COMPLEX)&myclass::get_open_properties_from_complex}, \
+
+#define DECLARE_ENTITY_CONSTRUCTOR(myclass) \
+ public: \
+ myclass(const std::shared_ptr& service_context); \
+ ::odata::string_t get_root_url() { return m_service_context ? m_service_context->get_root_url() : _XPLATSTR(""); } \
+ static create_map_for_entity_type::value_type _init_creator_map_values[]; \
+ static std::unordered_map<::odata::string_t, CREATE_CALL_FOR_ENTITY> _derived_entity_creator_map;
+
#define BEGIN_ENTITY_CONSTRUCTOR(myclass, baseclass) \
myclass::myclass(const std::shared_ptr& service_context) \
: baseclass(service_context), m_to_entity_map(nullptr)
#define ON_PROPERTY_IN_ENTITY_CONSTRUCTOR(property_name, property_value) \
- , property_name(property_value)
+ , property_name(property_value)
+
+#define ON_OPEN_PROPERTY_IN_ENTITY_CONSTRUCTOR() \
+ , open_property_dictionary()
#define END_ENTITY_CONSTRUCTOR(myclass, baseclass) \
- { }
+ { }
#define DECLARE_COMPLEX_CONSTRUCTOR(myclass) \
public: \
myclass(const std::shared_ptr& service_context); \
- static create_map_for_complex_type::value_type _init_creator_map_values[]; \
- static std::unordered_map<::utility::string_t, CREATE_CALL_FOR_COMPLEX> _derived_complex_creator_map;
+ static create_map_for_complex_type::value_type _init_creator_map_values[]; \
+ static std::unordered_map<::odata::string_t, CREATE_CALL_FOR_COMPLEX> _derived_complex_creator_map;
#define BEGIN_COMPLEX_CONSTRUCTOR(myclass, baseclass) \
myclass::myclass(const std::shared_ptr& service_context) \
- : baseclass(service_context), m_to_complex_map(nullptr)
+ : baseclass(service_context), m_to_complex_map(nullptr)
#define ON_PROPERTY_IN_COMPLEX_CONSTRUCTOR(property_name, property_value) \
- , property_name(property_value)
+ , property_name(property_value)
+
+#define ON_OPEN_PROPERTY_IN_COMPLEX_CONSTRUCTOR() \
+ , open_property_dictionary()
#define END_COMPLEX_CONSTRUCTOR(myclass, baseclass) \
- { }
+ { }
-#define DECLARE_COMPLEX_DESTRUCTOR(myclass) \
+#define DECLARE_ENTITY_DESTRUCTOR(myclass) \
public: \
~myclass();
-#define BEGIN_COMPLEX_DESTRUCTOR(myclass) \
+#define BEGIN_ENTITY_DESTRUCTOR(myclass) \
myclass::~myclass() \
- {
+ {
-#define ON_PROPERTY_IN_COMPLEX_DESTRUCTOR(property_name)
+#define ON_PROPERTY_IN_ENTITY_DESTRUCTOR(property_name)
-#define END_COMPLEX_DESTRUCTOR(myclass) \
+#define ON_OPEN_PROPERTY_IN_ENTITY_DESTRUCTOR()
+
+#define END_ENTITY_DESTRUCTOR(myclass) \
}
-#define DECLARE_ENTITY_DESTRUCTOR(myclass) \
+#define DECLARE_COMPLEX_DESTRUCTOR(myclass) \
public: \
~myclass();
-#define BEGIN_ENTITY_DESTRUCTOR(myclass) \
+#define BEGIN_COMPLEX_DESTRUCTOR(myclass) \
myclass::~myclass() \
- {
+ {
-#define ON_PROPERTY_IN_ENTITY_DESTRUCTOR(property_name)
+#define ON_PROPERTY_IN_COMPLEX_DESTRUCTOR(property_name)
-#define END_ENTITY_DESTRUCTOR(myclass) \
+#define ON_OPEN_PROPERTY_IN_COMPLEX_DESTRUCTOR()
+
+#define END_COMPLEX_DESTRUCTOR(myclass) \
}
-#define BEGIN_SERIALIZE_PROPERTY_IN_COMPLEX_MAPPING(myclass) \
- PROPMAP_ENTRY_IN_COMPLEX myclass::_map_class_to_complex_entrties[] = \
- {
+#define BEGIN_SERIALIZE_PROPERTY_IN_ENTITY_MAPPING(myclass) \
+ PROPMAP_ENTRY_IN_ENTITY myclass::_map_class_to_entity_entries[] = \
+ {
-#define ON_SERIALIZE_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name) \
- {(PROP_MAP_CALL_IN_COMPLEX)&myclass::set_##property_name##_to_complex},
+#define ON_SERIALIZE_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name) \
+ {(PROP_MAP_CALL_IN_ENTITY)&myclass::set_##property_name##_to_entity},
-#define END_SERIALIZE_PROPERTY_IN_COMPLEX_MAPPING(myclass) \
- {(PROP_MAP_CALL_IN_COMPLEX)0} \
+#define ON_SERIALIZE_OPEN_PROPERTY_IN_ENTITY_MAPPING(myclass) \
+ {(PROP_MAP_CALL_IN_ENTITY)&myclass::set_open_properties_to_entity},
+
+#define END_SERIALIZE_PROPERTY_IN_ENTITY_MAPPING(myclass) \
+ {(PROP_MAP_CALL_IN_ENTITY)0} \
}; \
- void myclass::map_complex_value_to_class_member(const shared_ptr<::odata::core::odata_complex_value>& pentity) \
+ void myclass::map_entity_value_to_class_member(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
- for (int i = 0;; i++) \
+ if (m_edit_link.empty()) \
{ \
- PROPMAP_ENTRY_IN_COMPLEX pentry = get_mapping_map()[i]; \
+ m_edit_link = odata_entity_model_builder::compute_edit_link(get_root_url(), pentity, _XPLATSTR(""), false); \
+ } \
+ for (size_t i = 0;; ++i) \
+ { \
+ PROPMAP_ENTRY_IN_ENTITY pentry = get_mapping_map()[i]; \
if (pentry.pfn == 0) \
{ \
break; \
} \
- (this->*((PROP_MAP_CALL_IN_COMPLEX)pentry.pfn))(pentity); \
+ (this->*((PROP_MAP_CALL_IN_ENTITY)pentry.pfn))(pentity); \
} \
} \
- void myclass::map_class_member_to_complex_value(const std::shared_ptr<::odata::core::odata_complex_value>& complex_value) \
+ void myclass::map_class_member_to_entity_value(const std::shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
- for (int i = 0;; i++) \
+ for (size_t i = 0;; ++i) \
{ \
- PROPMAP_ENTRY_IN_COMPLEX pentry = get_to_complex_map()[i]; \
+ PROPMAP_ENTRY_IN_ENTITY pentry = get_to_entity_map()[i]; \
if (pentry.pfn == 0) \
{ \
break; \
} \
- (this->*((PROP_MAP_CALL_IN_COMPLEX)pentry.pfn))(complex_value); \
+ (this->*((PROP_MAP_CALL_IN_ENTITY)pentry.pfn))(pentity); \
} \
}
-#define BEGIN_SERIALIZE_PROPERTY_IN_ENTITY_MAPPING(myclass) \
- PROPMAP_ENTRY_IN_ENTITY myclass::_map_class_to_entity_entrties[] = \
- {
+#define BEGIN_SERIALIZE_PROPERTY_IN_COMPLEX_MAPPING(myclass) \
+ PROPMAP_ENTRY_IN_COMPLEX myclass::_map_class_to_complex_entries[] = \
+ {
-#define ON_SERIALIZE_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name) \
- {(PROP_MAP_CALL_IN_ENTITY)&myclass::set_##property_name##_to_entity},
+#define ON_SERIALIZE_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name) \
+ {(PROP_MAP_CALL_IN_COMPLEX)&myclass::set_##property_name##_to_complex},
-#define END_SERIALIZE_PROPERTY_IN_ENTITY_MAPPING(myclass) \
- {(PROP_MAP_CALL_IN_ENTITY)0} \
+#define ON_SERIALIZE_OPEN_PROPERTY_IN_COMPLEX_MAPPING(myclass) \
+ {(PROP_MAP_CALL_IN_COMPLEX)&myclass::set_open_properties_to_complex},
+
+#define END_SERIALIZE_PROPERTY_IN_COMPLEX_MAPPING(myclass) \
+ {(PROP_MAP_CALL_IN_COMPLEX)0} \
}; \
- void myclass::map_entity_value_to_class_member(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+ void myclass::map_complex_value_to_class_member(const shared_ptr<::odata::core::odata_complex_value>& pentity) \
{ \
- if (m_edit_link.empty()) \
- { \
- m_edit_link = odata_entity_model_builder::compute_edit_link(get_root_url(), pentity, U(""), false); \
- } \
- for (int i = 0;; i++) \
+ for (size_t i = 0;; ++i) \
{ \
- PROPMAP_ENTRY_IN_ENTITY pentry = get_mapping_map()[i]; \
+ PROPMAP_ENTRY_IN_COMPLEX pentry = get_mapping_map()[i]; \
if (pentry.pfn == 0) \
{ \
break; \
} \
- (this->*((PROP_MAP_CALL_IN_ENTITY)pentry.pfn))(pentity); \
+ (this->*((PROP_MAP_CALL_IN_COMPLEX)pentry.pfn))(pentity); \
} \
} \
- void myclass::map_class_member_to_entity_value(const std::shared_ptr<::odata::core::odata_entity_value>& pentity) \
+ void myclass::map_class_member_to_complex_value(const std::shared_ptr<::odata::core::odata_complex_value>& complex_value) \
{ \
- for (int i = 0;; i++) \
+ for (size_t i = 0;; ++i) \
{ \
- PROPMAP_ENTRY_IN_ENTITY pentry = get_to_entity_map()[i]; \
+ PROPMAP_ENTRY_IN_COMPLEX pentry = get_to_complex_map()[i]; \
if (pentry.pfn == 0) \
{ \
break; \
} \
- (this->*((PROP_MAP_CALL_IN_ENTITY)pentry.pfn))(pentity); \
+ (this->*((PROP_MAP_CALL_IN_COMPLEX)pentry.pfn))(complex_value); \
} \
}
#define DECLARE_NAVIGATION_PROPERTY_IN_ENTITY_MAPPING(navigation_property_name, edm_name, type) \
public: \
- const std::shared_ptr& get_##navigation_property_name() { return navigation_property_name; } const \
+ const std::shared_ptr& get_##navigation_property_name() const { return navigation_property_name; } \
void set_##navigation_property_name(const std::shared_ptr& navigation_value) { navigation_property_name = navigation_value; } \
- ::pplx::task load_##navigation_property_name(const std::shared_ptr& builder = nullptr); \
+ ::pplx::task, ::odata::client::http_result>> load_##navigation_property_name(const std::shared_ptr& builder = nullptr); \
protected: \
- std::shared_ptr navigation_property_name; \
- void get_##navigation_property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
+ std::shared_ptr navigation_property_name; \
+ void get_##navigation_property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
+ void set_##navigation_property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
#define IMPLEMENT_NAVIGATION_PROPERTY_IN_ENTITY_MAPPING(myclass, navigation_property_name, edm_name, type) \
void myclass::get_##navigation_property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
- std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pentity->get_property_value(U(#edm_name), property_value) || !property_value) \
- { \
- return ; \
+ std::shared_ptr<::odata::core::odata_value> property_value; \
+ if (!pentity->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
+ { \
+ return; \
} \
- if (property_value->get_value_type()->get_type_kind() == ::odata::edm::edm_type_kind_t::Entity) \
- { \
+ if (property_value->get_value_type()->get_type_kind() == ::odata::edm::edm_type_kind_t::Entity) \
+ { \
auto entity_value = std::dynamic_pointer_cast<::odata::core::odata_entity_value>(property_value); \
navigation_property_name = create_instance_from_entity(entity_value, m_service_context); \
- } \
- } \
- ::pplx::task myclass::load_##navigation_property_name(const std::shared_ptr& builder) \
+ } \
+ } \
+ ::pplx::task, ::odata::client::http_result>> myclass::load_##navigation_property_name(const std::shared_ptr& builder) \
{ \
- if (m_service_context) \
+ if (m_service_context) \
{\
- ::utility::string_t path = m_service_context->get_relative_path(m_edit_link) + U("/") + U(#edm_name); \
+ ::odata::string_t path = m_service_context->get_relative_path(m_edit_link) + _XPLATSTR("/") + _XPLATSTR(#edm_name); \
auto query = m_service_context->create_query, odata_query_builder>(path); \
if (builder) { query->set_query_builder(builder); } \
return query->execute_query().then( \
- [this] (const std::shared_ptr& ret_value) -> void \
- { \
- navigation_property_name = ret_value; \
- }); \
+ [this] (const std::pair, ::odata::client::http_result>& ret_value) -> std::pair, ::odata::client::http_result> \
+ { \
+ navigation_property_name = ret_value.first; \
+ return ret_value; \
+ }); \
}\
- return ::pplx::task_from_result(); \
- }
+ return ::pplx::task_from_result(std::make_pair(std::shared_ptr(), ::odata::client::http_result(::web::http::http_headers(), ::web::http::status_code(-1)))); \
+ } \
+ void myclass::set_##navigation_property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+ { \
+ if (!pentity || !navigation_property_name) \
+ { \
+ return; \
+ } \
+ auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pentity->get_value_type()); \
+ if (!entity_type) \
+ { \
+ return; \
+ } \
+ auto edm_property = entity_type->find_property(_XPLATSTR(#edm_name)); \
+ if (!edm_property) \
+ { \
+ return; \
+ } \
+ auto property_type = edm_property->get_property_type(); \
+ auto navigation_value_type = std::dynamic_pointer_cast<::odata::edm::edm_navigation_type>(property_type); \
+ if (!navigation_value_type) \
+ { \
+ return; \
+ } \
+ if (!navigation_value_type->is_contained()) \
+ { \
+ pentity->set_value(_XPLATSTR(#edm_name) + odata::core::odata_json_constants::PAYLOAD_ANNOTATION_BIND, m_service_context->get_relative_path(navigation_property_name->get_edit_link())); \
+ return; \
+ } \
+ pentity->set_value(_XPLATSTR(#edm_name), navigation_property_name->to_value()); \
+ }
+
+#define DECLARE_NAVIGATION_PROPERTY_IN_COMPLEX_MAPPING(navigation_property_name, edm_name, type) \
+public: \
+ const std::shared_ptr& get_##navigation_property_name() const { return navigation_property_name; } \
+ void set_##navigation_property_name(const std::shared_ptr& navigation_value) { navigation_property_name = navigation_value; } \
+ ::pplx::task, ::odata::client::http_result>> load_##navigation_property_name(const std::shared_ptr& builder = nullptr); \
+protected: \
+ std::shared_ptr navigation_property_name; \
+ void get_##navigation_property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
+ void set_##navigation_property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
+
+#define IMPLEMENT_NAVIGATION_PROPERTY_IN_COMPLEX_MAPPING(myclass, navigation_property_name, edm_name, type) \
+ void myclass::get_##navigation_property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
+ { \
+ std::shared_ptr<::odata::core::odata_value> property_value; \
+ if (!pcomplex->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
+ { \
+ return; \
+ } \
+ if (property_value->get_value_type()->get_type_kind() == ::odata::edm::edm_type_kind_t::Entity) \
+ { \
+ auto entity_value = std::dynamic_pointer_cast<::odata::core::odata_entity_value>(property_value); \
+ navigation_property_name = create_instance_from_entity(entity_value, m_service_context); \
+ } \
+ } \
+ ::pplx::task, ::odata::client::http_result>> myclass::load_##navigation_property_name(const std::shared_ptr& builder) \
+ { \
+ if (m_service_context) \
+ {\
+ ::odata::string_t path = m_service_context->get_relative_path(m_edit_link) + _XPLATSTR("/") + _XPLATSTR(#edm_name); \
+ auto query = m_service_context->create_query, odata_query_builder>(path); \
+ if (builder) { query->set_query_builder(builder); } \
+ return query->execute_query().then( \
+ [this] (const std::pair, ::odata::client::http_result>& ret_value) -> std::pair, ::odata::client::http_result> \
+ { \
+ navigation_property_name = ret_value.first; \
+ return ret_value; \
+ }); \
+ }\
+ return ::pplx::task_from_result(std::make_pair(std::shared_ptr(), ::odata::client::http_result(::web::http::http_headers(), ::web::http::status_code(-1)))); \
+ } \
+ void myclass::set_##navigation_property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
+ { \
+ if (!pcomplex || !navigation_property_name) \
+ { \
+ return; \
+ } \
+ auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pcomplex->get_value_type()); \
+ if (!entity_type) \
+ { \
+ return; \
+ } \
+ auto edm_property = entity_type->find_property(_XPLATSTR(#edm_name)); \
+ if (!edm_property) \
+ { \
+ return; \
+ } \
+ auto property_type = edm_property->get_property_type(); \
+ auto navigation_value_type = std::dynamic_pointer_cast<::odata::edm::edm_navigation_type>(property_type); \
+ if (!navigation_value_type) \
+ { \
+ return; \
+ } \
+ if (!navigation_value_type->is_contained()) \
+ { \
+ pcomplex->set_value(_XPLATSTR(#edm_name) + odata::core::odata_json_constants::PAYLOAD_ANNOTATION_BIND, m_service_context->get_relative_path(navigation_property_name->get_edit_link())); \
+ return; \
+ } \
+ pcomplex->set_value(_XPLATSTR(#edm_name), navigation_property_name->to_value()); \
+ }
#define DECLARE_COLLECTION_PRIMITIVE_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
public: \
- const std::vector& get_##property_name() { return property_name; } const \
+ const std::vector& get_##property_name() const { return property_name; } \
void set_##property_name(std::vector values) { property_name = std::move(values); } \
- void add_to_##property_name(const type& property_value) { property_name.push_back(property_value); } \
+ void add_to_##property_name(const type& property_value) { property_name.emplace_back(property_value); } \
protected: \
std::vector property_name; \
void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
@@ -455,127 +571,127 @@ protected: \
void myclass::get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pentity->get_property_value(U(#edm_name), property_value) || !property_value) \
+ if (!pentity->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
{ \
- return ; \
+ return; \
} \
auto property_collection_value = static_pointer_cast<::odata::core::odata_collection_value>(property_value); \
if (!property_collection_value) \
{ \
- return ; \
+ return; \
} \
- for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); iter++) \
+ for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); ++iter) \
{ \
- auto primitive_value = std::dynamic_pointer_cast(*iter); \
+ auto primitive_value = std::dynamic_pointer_cast(*iter); \
if (!primitive_value) \
- { \
- continue ; \
+ { \
+ continue; \
} \
- property_name.push_back(primitive_value->as()); \
+ property_name.emplace_back(primitive_value->as()); \
} \
} \
void myclass::set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
if (!pentity || !pentity->get_value_type()) \
{ \
- return ; \
+ return; \
} \
- auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pentity->get_value_type()); \
+ auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pentity->get_value_type()); \
if (!entity_type) \
{ \
- return ; \
+ return; \
} \
- auto edm_property = entity_type->find_property(U(#edm_name)); \
+ auto edm_property = entity_type->find_property(_XPLATSTR(#edm_name)); \
if (!edm_property) \
{ \
- return ; \
+ return; \
} \
auto property_type = edm_property->get_property_type(); \
auto collection_value_type = std::dynamic_pointer_cast<::odata::edm::edm_collection_type>(property_type); \
if (!collection_value_type) \
{ \
- return ; \
+ return; \
} \
- std::shared_ptr<::odata::core::odata_collection_value> collection_value = std::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
- for (size_t i = 0; i < property_name.size(); i++) \
+ std::shared_ptr<::odata::core::odata_collection_value> collection_value = ::odata::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
+ for (size_t i = 0; i < property_name.size(); ++i) \
{ \
collection_value->add_collection_value(odata_primitive_value::make_primitive_value(property_name[i])); \
} \
- pentity->set_value(U(#edm_name), collection_value); \
+ pentity->set_value(_XPLATSTR(#edm_name), collection_value); \
}
#define DECLARE_COLLECTION_PRIMITIVE_PROPERTY_IN_COMPLEX_MAPPING(property_name, edm_name, type) \
public: \
- const std::vector& get_##property_name() { return property_name; } const \
+ const std::vector& get_##property_name() const { return property_name; } \
void set_##property_name(const std::vector& values) { property_name = values; } \
- void add_to_##property_name(const type& property_value) { property_name.push_back(property_value); } \
+ void add_to_##property_name(const type& property_value) { property_name.emplace_back(property_value); } \
protected: \
std::vector property_name; \
void get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
- void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
+ void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
#define IMPLEMENT_COLLECTION_PRIMITIVE_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name, edm_name, type) \
void myclass::get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pcomplex->get_property_value(U(#edm_name), property_value) || !property_value) \
+ if (!pcomplex->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
{ \
- return ; \
+ return; \
} \
auto property_collection_value = static_pointer_cast<::odata::core::odata_collection_value>(property_value); \
if (!property_collection_value) \
{ \
- return ; \
+ return; \
} \
- for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); iter++) \
+ for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); ++iter) \
{ \
- auto primitive_value = std::dynamic_pointer_cast(*iter); \
+ auto primitive_value = std::dynamic_pointer_cast(*iter); \
if (!primitive_value) \
- { \
- continue ; \
+ { \
+ continue; \
} \
- property_name.push_back(primitive_value->as()); \
+ property_name.emplace_back(primitive_value->as()); \
} \
} \
void myclass::set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
if (!pcomplex || !pcomplex->get_value_type()) \
{ \
- return ; \
+ return; \
} \
- auto complex_type = std::dynamic_pointer_cast<::odata::edm::edm_complex_type>(pcomplex->get_value_type()); \
+ auto complex_type = std::dynamic_pointer_cast<::odata::edm::edm_complex_type>(pcomplex->get_value_type()); \
if (!complex_type) \
{ \
- return ; \
+ return; \
} \
- auto edm_property = complex_type->find_property(U(#edm_name)); \
+ auto edm_property = complex_type->find_property(_XPLATSTR(#edm_name)); \
if (!edm_property) \
{ \
- return ; \
+ return; \
} \
auto property_type = edm_property->get_property_type(); \
auto collection_value_type = std::dynamic_pointer_cast<::odata::edm::edm_collection_type>(property_type); \
if (!collection_value_type) \
{ \
- return ; \
+ return; \
} \
- std::shared_ptr<::odata::core::odata_collection_value> collection_value = std::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
- for (size_t i = 0; i < property_name.size(); i++) \
+ std::shared_ptr<::odata::core::odata_collection_value> collection_value = ::odata::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
+ for (size_t i = 0; i < property_name.size(); ++i) \
{ \
collection_value->add_collection_value(odata_primitive_value::make_primitive_value(property_name[i])); \
} \
- pcomplex->set_value(U(#edm_name), collection_value); \
+ pcomplex->set_value(_XPLATSTR(#edm_name), collection_value); \
}
#define DECLARE_NULLABLE_PRIMITIVE_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
public: \
- type* get_##property_name() { return property_name.get(); } const \
+ type* get_##property_name() const { return property_name.get(); } \
void set_##property_name(type property_value) \
{\
- property_name = std::make_shared(property_value); \
+ property_name = ::odata::make_shared(property_value); \
} \
protected: \
- std::shared_ptr property_name; \
+ std::shared_ptr property_name; \
void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
@@ -583,66 +699,66 @@ protected: \
void myclass::get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pentity->get_property_value(U(#edm_name), property_value) || !property_value) \
+ if (!pentity->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
{ \
- return ; \
+ return; \
} \
auto primitive_value = std::dynamic_pointer_cast(property_value); \
if (primitive_value) \
{ \
- property_name = std::make_shared(primitive_value->as()); \
+ property_name = ::odata::make_shared(primitive_value->as()); \
} \
} \
void myclass::set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
- if (!pentity || !property_name) \
- { \
- return ; \
- } \
- pentity->set_value(U(#edm_name), *property_name); \
+ if (!pentity || !property_name) \
+ { \
+ return; \
+ } \
+ pentity->set_value(_XPLATSTR(#edm_name), *property_name); \
}
#define DECLARE_NULLABLE_PRIMITIVE_PROPERTY_IN_COMPLEX_MAPPING(property_name, edm_name, type) \
public: \
- type* get_##property_name() { return property_name.get(); } const \
- void set_##property_name(type property_value) \
- { \
- property_name = std::make_shared(property_value); \
+ type* get_##property_name() const { return property_name.get(); } \
+ void set_##property_name(type property_value) \
+ { \
+ property_name = ::odata::make_shared(property_value); \
} \
protected: \
- std::shared_ptr property_name; \
+ std::shared_ptr property_name; \
void get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
- void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
+ void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
#define IMPLEMENT_NULLABLE_PRIMITIVE_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name, edm_name, type) \
void myclass::get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pcomplex->get_property_value(U(#edm_name), property_value) || !property_value) \
+ if (!pcomplex->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
{ \
- return ; \
+ return; \
} \
auto primitive_value = std::dynamic_pointer_cast(property_value); \
if (primitive_value) \
{ \
- property_name = std::make_shared(primitive_value->as()); \
+ property_name = ::odata::make_shared(primitive_value->as()); \
} \
} \
void myclass::set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
- if (!pcomplex || !property_name) \
- { \
- return ; \
- } \
- pcomplex->set_value(U(#edm_name), *property_name); \
+ if (!pcomplex || !property_name) \
+ { \
+ return; \
+ } \
+ pcomplex->set_value(_XPLATSTR(#edm_name), *property_name); \
}
#define DECLARE_NULLABLE_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
public: \
- type* get_##property_name() { return property_name.get(); } const \
+ type* get_##property_name() const { return property_name.get(); } \
void set_##property_name(const std::shared_ptr& property_value) { property_name = property_value; } \
protected: \
- std::shared_ptr property_name; \
+ std::shared_ptr property_name; \
void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
@@ -650,9 +766,9 @@ protected: \
void myclass::get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pentity->get_property_value(U(#edm_name), property_value) || !property_value) \
+ if (!pentity->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
{ \
- return ; \
+ return; \
} \
if (property_value->get_value_type()->get_type_kind() == ::odata::edm::edm_type_kind_t::Complex) \
{ \
@@ -661,19 +777,19 @@ protected: \
} \
void myclass::set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
- if (!pentity || !property_name) \
- { \
- return ; \
- } \
- pentity->set_value(U(#edm_name), property_name->to_value()); \
+ if (!pentity || !property_name) \
+ { \
+ return; \
+ } \
+ pentity->set_value(_XPLATSTR(#edm_name), property_name->to_value()); \
}
#define DECLARE_NULLABLE_COMPLEX_PROPERTY_IN_COMPLEX_MAPPING(property_name, edm_name, type) \
public: \
- type* get_##property_name() { return property_name.get(); } const \
+ type* get_##property_name() const { return property_name.get(); } \
void set_##property_name(const std::shared_ptr& property_value) { property_name = property_value; } \
protected: \
- std::shared_ptr property_name; \
+ std::shared_ptr property_name; \
void get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
@@ -681,9 +797,9 @@ protected: \
void myclass::get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pcomplex->get_property_value(U(#edm_name), property_value) || !property_value) \
+ if (!pcomplex->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
{ \
- return ; \
+ return; \
} \
if (property_value->get_value_type()->get_type_kind() == ::odata::edm::edm_type_kind_t::Complex) \
{ \
@@ -692,407 +808,895 @@ protected: \
} \
void myclass::set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
- if (!pcomplex || !property_name) \
- { \
- return ; \
- } \
- pcomplex->set_value(U(#edm_name), property_name->to_value()); \
+ if (!pcomplex || !property_name) \
+ { \
+ return; \
+ } \
+ pcomplex->set_value(_XPLATSTR(#edm_name), property_name->to_value()); \
}
+// because we have to support derived complex type, so complex object in entity are all set with pointer type
+#define DECLARE_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
+ DECLARE_NULLABLE_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type)
+
+#define IMPLEMENT_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name, edm_name, type) \
+ IMPLEMENT_NULLABLE_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name, edm_name, type)
+
#define DECLARE_COMPLEX_PROPERTY_IN_COMPLEX_MAPPING(property_name, edm_name, type) \
DECLARE_NULLABLE_COMPLEX_PROPERTY_IN_COMPLEX_MAPPING(property_name, edm_name, type)
#define IMPLEMENT_COMPLEX_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name, edm_name, type) \
IMPLEMENT_NULLABLE_COMPLEX_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name, edm_name, type)
+#define DECLARE_OPEN_PROPERTY_DICTIONARY_IN_ENTITY_MAPPING() \
+public: \
+ std::unordered_map<::odata::string_t, shared_ptr<::odata::string_t>> const& get_open_properties() const \
+ { \
+ return open_property_dictionary; \
+ } \
+ void set_open_properties(std::unordered_map<::odata::string_t, shared_ptr<::odata::string_t>> const& properties) \
+ { \
+ open_property_dictionary = properties; \
+ } \
+ shared_ptr<::odata::string_t> const get_open_property_from_dictionary(const ::odata::string_t& property_name) const; \
+ void set_open_property_to_dictionary(const ::odata::string_t& property_name, const ::odata::string_t& property_value) \
+ {\
+ open_property_dictionary[property_name] = ::odata::make_shared<::odata::string_t>(property_value); \
+ } \
+ size_t delete_open_property_from_dictionary(const ::odata::string_t& property_name) \
+ { \
+ return open_property_dictionary.erase(property_name); \
+ } \
+protected: \
+ std::unordered_map<::odata::string_t, shared_ptr<::odata::string_t>> open_property_dictionary; \
+ void get_open_properties_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
+ void set_open_properties_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
+
+#define IMPLEMENT_OPEN_PROPERTY_DICTIONARY_IN_ENTITY_MAPPING(myclass) \
+shared_ptr<::odata::string_t> const myclass::get_open_property_from_dictionary(const ::odata::string_t& property_name) const \
+{ \
+ auto iter = open_property_dictionary.find(property_name); \
+ return iter != open_property_dictionary.end() ? iter->second : nullptr; \
+} \
+void myclass::get_open_properties_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+{ \
+ if (pentity->is_open()) \
+ { \
+ for (auto const &open_property_value : pentity->open_properties()) \
+ { \
+ if (!open_property_value.second || pentity->has_property(open_property_value.first)) \
+ { \
+ continue; \
+ } \
+ auto primitive_value = std::dynamic_pointer_cast(open_property_value.second); \
+ if (primitive_value) \
+ { \
+ open_property_dictionary[open_property_value.first] = ::odata::make_shared<::odata::string_t>(primitive_value->as<::odata::string_t>()); \
+ } \
+ } \
+ } \
+} \
+void myclass::set_open_properties_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+{ \
+ if (pentity->is_open()) \
+ { \
+ for (auto const &open_property_value : open_property_dictionary) \
+ { \
+ if (!open_property_value.second || pentity->has_property(open_property_value.first)) \
+ { \
+ continue; \
+ } \
+ pentity->set_open_value(open_property_value.first, *open_property_value.second); \
+ } \
+ } \
+} \
+
+#define DECLARE_OPEN_PROPERTY_DICTIONARY_IN_COMPLEX_MAPPING() \
+public: \
+ std::unordered_map<::odata::string_t, shared_ptr<::odata::string_t>> const& get_open_properties() const \
+ { \
+ return open_property_dictionary; \
+ } \
+ void set_open_properties(std::unordered_map<::odata::string_t, shared_ptr<::odata::string_t>> const& properties) \
+ { \
+ open_property_dictionary = properties; \
+ } \
+ shared_ptr<::odata::string_t> const get_open_property_from_dictionary(const ::odata::string_t& property_name) const; \
+ void set_open_property_to_dictionary(const ::odata::string_t& property_name, const ::odata::string_t& property_value) \
+ { \
+ open_property_dictionary[property_name] = ::odata::make_shared<::odata::string_t>(property_value); \
+ } \
+ size_t delete_open_property_from_dictionary(const ::odata::string_t& property_name) \
+ { \
+ return open_property_dictionary.erase(property_name); \
+ } \
+protected: \
+ std::unordered_map<::odata::string_t, shared_ptr<::odata::string_t>> open_property_dictionary; \
+ void get_open_properties_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
+ void set_open_properties_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
+
+#define IMPLEMENT_OPEN_PROPERTY_DICTIONARY_IN_COMPLEX_MAPPING(myclass) \
+shared_ptr<::odata::string_t> const myclass::get_open_property_from_dictionary(const ::odata::string_t& property_name) const \
+{ \
+ auto iter = open_property_dictionary.find(property_name); \
+ return iter != open_property_dictionary.end() ? iter->second : nullptr; \
+} \
+void myclass::get_open_properties_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
+{ \
+ if (pcomplex->is_open()) \
+ { \
+ for (auto const &open_property_value : pcomplex->open_properties()) \
+ { \
+ if (!open_property_value.second || pcomplex->has_property(open_property_value.first)) \
+ { \
+ continue; \
+ } \
+ auto primitive_value = std::dynamic_pointer_cast(open_property_value.second); \
+ if (primitive_value) \
+ { \
+ open_property_dictionary[open_property_value.first] = ::odata::make_shared<::odata::string_t>(primitive_value->as<::odata::string_t>()); \
+ } \
+ } \
+ } \
+} \
+void myclass::set_open_properties_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
+{ \
+ if (pcomplex->is_open()) \
+ { \
+ for (auto const &open_property_value : open_property_dictionary) \
+ { \
+ if (!open_property_value.second || pcomplex->has_property(open_property_value.first)) \
+ { \
+ continue; \
+ } \
+ pcomplex->set_open_value(open_property_value.first, *open_property_value.second); \
+ } \
+ } \
+}
+
#define DECLARE_COLLECTION_NAVIGATION_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
public: \
- const std::vector>& get_##property_name() { return property_name; } const \
+ const std::vector>& get_##property_name() const { return property_name; } \
void set_##property_name(const std::vector>& property_values) { property_name = property_values; } \
- void add_to_##property_name(const std::shared_ptr& property_value) { property_name.push_back(property_value); } \
- ::pplx::task load_##property_name(const std::shared_ptr& builder = nullptr); \
+ void add_to_##property_name(const std::shared_ptr& property_value) { property_name.emplace_back(property_value); } \
+ ::pplx::task>, ::odata::client::http_result>> load_##property_name(const std::shared_ptr& builder = nullptr); \
protected: \
std::vector> property_name; \
- void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
+ void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
+ void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
#define IMPLEMENT_COLLECTION_NAVIGATION_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name, edm_name, type) \
void myclass::get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
- std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pentity->get_property_value(U(#edm_name), property_value) || !property_value) \
+ std::shared_ptr<::odata::core::odata_value> property_value; \
+ if (!pentity->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
+ { \
+ return; \
+ } \
+ auto property_collection_value = static_pointer_cast<::odata::core::odata_collection_value>(property_value); \
+ if (!property_collection_value) \
+ { \
+ return; \
+ } \
+ for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); ++iter) \
+ { \
+ auto entity_value = std::dynamic_pointer_cast<::odata::core::odata_entity_value>(*iter); \
+ if (!entity_value) \
+ { \
+ continue; \
+ } \
+ std::shared_ptr p_entity = create_instance_from_entity(entity_value, m_service_context); \
+ property_name.emplace_back(std::dynamic_pointer_cast(p_entity)); \
+ } \
+ } \
+ ::pplx::task>, ::odata::client::http_result>> myclass::load_##property_name(const std::shared_ptr& builder) \
+ { \
+ if (m_service_context)\
+ {\
+ ::odata::string_t path = m_service_context->get_relative_path(m_edit_link) + _XPLATSTR("/") + _XPLATSTR(#edm_name);\
+ auto query = m_service_context->create_query, odata_query_builder>(path);\
+ if (builder) { query->set_query_builder(builder); } \
+ return query->execute_query().then( \
+ [this] (const std::pair>, ::odata::client::http_result>& ret_values) -> std::pair>, ::odata::client::http_result> \
+ { \
+ property_name = ret_values.first; \
+ return ret_values; \
+ }); \
+ } \
+ return ::pplx::task_from_result(std::make_pair(std::vector>(), ::odata::client::http_result(::web::http::http_headers(), ::web::http::status_code(-1)))); \
+ } \
+ void myclass::set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+ { \
+ if (!pentity || !pentity->get_value_type()) \
+ { \
+ return; \
+ } \
+ auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pentity->get_value_type()); \
+ if (!entity_type) \
+ { \
+ return; \
+ } \
+ auto edm_property = entity_type->find_property(_XPLATSTR(#edm_name)); \
+ if (!edm_property) \
+ { \
+ return; \
+ } \
+ auto property_type = edm_property->get_property_type(); \
+ auto navigation_value_type = std::dynamic_pointer_cast<::odata::edm::edm_navigation_type>(property_type); \
+ if (!navigation_value_type) \
+ { \
+ return; \
+ } \
+ if (!navigation_value_type->is_contained()) \
+ { \
+ ::odata::string_t const BindName = _XPLATSTR(#edm_name) + odata::core::odata_json_constants::PAYLOAD_ANNOTATION_BIND; \
+ auto PrimitiveType = ::odata::make_shared<::odata::edm::edm_named_type>(BindName, entity_type->get_namespace(), odata::edm::edm_type_kind_t::Primitive); \
+ auto collection_value_type = ::odata::make_shared<::odata::edm::edm_collection_type>(BindName, PrimitiveType); \
+ if (!collection_value_type) \
+ { \
+ return; \
+ } \
+ std::shared_ptr<::odata::core::odata_collection_value> collection_value = ::odata::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
+ for (size_t i = 0; i < property_name.size(); ++i) \
+ { \
+ if (property_name[i]) collection_value->add_collection_value(std::dynamic_pointer_cast<::odata::core::odata_value>(odata::core::odata_primitive_value::make_primitive_value(m_service_context->get_relative_path(property_name[i]->get_edit_link())))); \
+ } \
+ pentity->set_value(BindName, collection_value); \
+ return; \
+ } \
+ auto navigation_type = std::dynamic_pointer_cast<::odata::edm::edm_named_type>(navigation_value_type->get_navigation_type()); \
+ if (!navigation_type) \
+ { \
+ return; \
+ } \
+ auto collection_value_type = std::dynamic_pointer_cast<::odata::edm::edm_collection_type>(navigation_type); \
+ if (!collection_value_type) \
+ { \
+ return; \
+ } \
+ std::shared_ptr<::odata::core::odata_collection_value> collection_value = ::odata::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
+ for (size_t i = 0; i < property_name.size(); ++i) \
+ { \
+ if (property_name[i]) collection_value->add_collection_value(std::dynamic_pointer_cast<::odata::core::odata_value>(property_name[i]->to_value())); \
+ } \
+ pentity->set_value(_XPLATSTR(#edm_name), collection_value); \
+ }
+
+#define DECLARE_COLLECTION_NAVIGATION_PROPERTY_IN_COMPLEX_MAPPING(property_name, edm_name, type) \
+public: \
+ const std::vector>& get_##property_name() const { return property_name; } \
+ void set_##property_name(const std::vector>& property_values) { property_name = property_values; } \
+ void add_to_##property_name(const std::shared_ptr& property_value) { property_name.emplace_back(property_value); } \
+ ::pplx::task>, ::odata::client::http_result>> load_##property_name(const std::shared_ptr& builder = nullptr); \
+protected: \
+ std::vector> property_name; \
+ void get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
+ void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
+
+#define IMPLEMENT_COLLECTION_NAVIGATION_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name, edm_name, type) \
+ void myclass::get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
+ { \
+ std::shared_ptr<::odata::core::odata_value> property_value; \
+ if (!pcomplex->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
+ { \
+ return; \
+ } \
+ auto property_collection_value = static_pointer_cast<::odata::core::odata_collection_value>(property_value); \
+ if (!property_collection_value) \
+ { \
+ return; \
+ } \
+ for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); ++iter) \
+ { \
+ auto entity_value = std::dynamic_pointer_cast<::odata::core::odata_entity_value>(*iter); \
+ if (!entity_value) \
+ { \
+ continue; \
+ } \
+ std::shared_ptr p_entity = create_instance_from_entity(entity_value, m_service_context); \
+ property_name.emplace_back(std::dynamic_pointer_cast(p_entity)); \
+ } \
+ } \
+ ::pplx::task>, ::odata::client::http_result>> myclass::load_##property_name(const std::shared_ptr& builder) \
+ { \
+ if (m_service_context)\
+ {\
+ ::odata::string_t path = m_service_context->get_relative_path(m_edit_link) + _XPLATSTR("/") + _XPLATSTR(#edm_name);\
+ auto query = m_service_context->create_query, odata_query_builder>(path);\
+ if (builder) { query->set_query_builder(builder); } \
+ return query->execute_query().then( \
+ [this] (const std::pair>, ::odata::client::http_result>& ret_values) -> std::pair>, ::odata::client::http_result> \
+ { \
+ property_name = ret_values.first; \
+ return ret_values; \
+ }); \
+ } \
+ return ::pplx::task_from_result(std::make_pair(std::vector>(), ::odata::client::http_result(::web::http::http_headers(), ::web::http::status_code(-1)))); \
+ } \
+ void myclass::set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
+ { \
+ if (!pcomplex || !pcomplex->get_value_type()) \
+ { \
+ return; \
+ } \
+ auto complex_type = std::dynamic_pointer_cast<::odata::edm::edm_complex_type>(pcomplex->get_value_type()); \
+ if (!complex_type) \
+ { \
+ return; \
+ } \
+ auto edm_property = complex_type->find_property(_XPLATSTR(#edm_name)); \
+ if (!edm_property) \
+ { \
+ return; \
+ } \
+ auto property_type = edm_property->get_property_type(); \
+ auto navigation_value_type = std::dynamic_pointer_cast<::odata::edm::edm_navigation_type>(property_type); \
+ if (!navigation_value_type) \
+ { \
+ return; \
+ } \
+ if (!navigation_value_type->is_contained()) \
+ { \
+ ::odata::string_t const BindName = _XPLATSTR(#edm_name) + odata::core::odata_json_constants::PAYLOAD_ANNOTATION_BIND; \
+ auto PrimitiveType = ::odata::make_shared<::odata::edm::edm_named_type>(BindName, complex_type->get_namespace(), odata::edm::edm_type_kind_t::Primitive); \
+ auto collection_value_type = ::odata::make_shared<::odata::edm::edm_collection_type>(BindName, PrimitiveType); \
+ if (!collection_value_type) \
+ { \
+ return; \
+ } \
+ std::shared_ptr<::odata::core::odata_collection_value> collection_value = ::odata::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
+ for (size_t i = 0; i < property_name.size(); ++i) \
+ { \
+ if (property_name[i]) collection_value->add_collection_value(std::dynamic_pointer_cast<::odata::core::odata_value>(odata::core::odata_primitive_value::make_primitive_value(m_service_context->get_relative_path(property_name[i]->get_edit_link())))); \
+ } \
+ pcomplex->set_value(BindName, collection_value); \
+ return; \
+ } \
+ auto navigation_type = std::dynamic_pointer_cast<::odata::edm::edm_named_type>(navigation_value_type->get_navigation_type()); \
+ if (!navigation_type) \
+ { \
+ return; \
+ } \
+ auto collection_value_type = std::dynamic_pointer_cast<::odata::edm::edm_collection_type>(navigation_type); \
+ if (!collection_value_type) \
+ { \
+ return; \
+ } \
+ std::shared_ptr<::odata::core::odata_collection_value> collection_value = ::odata::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
+ for (size_t i = 0; i < property_name.size(); ++i) \
+ { \
+ if (property_name[i]) collection_value->add_collection_value(std::dynamic_pointer_cast(property_name[i]->to_value())); \
+ } \
+ pcomplex->set_value(_XPLATSTR(#edm_name), collection_value); \
+ }
+
+#define DECLARE_COLLECTION_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
+public: \
+ const std::vector>& get_##property_name() const { return property_name; } \
+ void set_##property_name(std::vector> property_values) { property_name = std::move(property_values); } \
+ void add_to_##property_name(const std::shared_ptr& property_value) { property_name.emplace_back(property_value); } \
+protected: \
+ std::vector> property_name; \
+ void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
+ void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
+
+#define IMPLEMENT_COLLECTION_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name, edm_name, type) \
+ void myclass::get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+ { \
+ std::shared_ptr<::odata::core::odata_value> property_value; \
+ if (!pentity->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
+ { \
+ return; \
+ } \
+ auto property_collection_value = static_pointer_cast<::odata::core::odata_collection_value>(property_value); \
+ if (!property_collection_value) \
+ { \
+ return; \
+ } \
+ for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); ++iter) \
+ { \
+ auto complex_value = std::dynamic_pointer_cast<::odata::core::odata_complex_value>(*iter); \
+ if (!complex_value) \
+ { \
+ continue; \
+ } \
+ property_name.emplace_back(create_instance_from_complex(complex_value, m_service_context)); \
+ } \
+ } \
+ void myclass::set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+ { \
+ if (!pentity || !pentity->get_value_type()) \
+ { \
+ return; \
+ } \
+ auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pentity->get_value_type()); \
+ if (!entity_type) \
+ { \
+ return; \
+ } \
+ auto edm_property = entity_type->find_property(_XPLATSTR(#edm_name)); \
+ if (!edm_property) \
+ { \
+ return; \
+ } \
+ auto property_type = edm_property->get_property_type(); \
+ auto collection_value_type = std::dynamic_pointer_cast<::odata::edm::edm_collection_type>(property_type); \
+ if (!collection_value_type) \
+ { \
+ return; \
+ } \
+ std::shared_ptr<::odata::core::odata_collection_value> collection_value = ::odata::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
+ for (size_t i = 0; i < property_name.size(); ++i) \
+ { \
+ if (property_name[i]) collection_value->add_collection_value(std::dynamic_pointer_cast<::odata::core::odata_value>(property_name[i]->to_value())); \
+ } \
+ pentity->set_value(_XPLATSTR(#edm_name), collection_value); \
+ }
+
+#define DECLARE_COLLECTION_COMPLEX_PROPERTY_IN_COMPLEX_MAPPING(property_name, edm_name, type) \
+public: \
+ const std::vector>& get_##property_name() const { return property_name; } \
+ void set_##property_name(std::vector> property_values) { property_name = std::move(property_values); } \
+ void add_to_##property_name(const std::shared_ptr& property_value) { property_name.emplace_back(property_value); } \
+protected: \
+ std::vector> property_name; \
+ void get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
+ void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
+
+#define IMPLEMENT_COLLECTION_COMPLEX_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name, edm_name, type) \
+ void myclass::get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
+ { \
+ std::shared_ptr<::odata::core::odata_value> property_value; \
+ if (!pcomplex->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
+ { \
+ return; \
+ } \
+ auto property_collection_value = static_pointer_cast<::odata::core::odata_collection_value>(property_value); \
+ if (!property_collection_value) \
+ { \
+ return; \
+ } \
+ for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); ++iter) \
+ { \
+ auto complex_value = std::dynamic_pointer_cast<::odata::core::odata_complex_value>(*iter); \
+ if (!complex_value) \
+ { \
+ continue; \
+ } \
+ property_name.emplace_back(create_instance_from_complex(complex_value, m_service_context)); \
+ } \
+ } \
+ void myclass::set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
+ { \
+ if (!pcomplex || !pcomplex->get_value_type()) \
+ { \
+ return; \
+ } \
+ auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pcomplex->get_value_type()); \
+ if (!entity_type) \
+ { \
+ return; \
+ } \
+ auto edm_property = entity_type->find_property(_XPLATSTR(#edm_name)); \
+ if (!edm_property) \
+ { \
+ return; \
+ } \
+ auto property_type = edm_property->get_property_type(); \
+ auto collection_value_type = std::dynamic_pointer_cast<::odata::edm::edm_collection_type>(property_type); \
+ if (!collection_value_type) \
+ { \
+ return; \
+ } \
+ std::shared_ptr<::odata::core::odata_collection_value> collection_value = ::odata::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
+ for (size_t i = 0; i < property_name.size(); ++i) \
+ { \
+ if (property_name[i]) collection_value->add_collection_value(std::dynamic_pointer_cast<::odata::core::odata_value>(property_name[i]->to_value())); \
+ } \
+ pcomplex->set_value(_XPLATSTR(#edm_name), collection_value); \
+ }
+
+#define DECLARE_COLLECTION_ENTITY_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
+public: \
+ const std::vector>& get_##property_name() const { return property_name; } \
+ void set_##property_name(std::vector> property_values) { property_name = std::move(property_values); } \
+ void add_to_##property_name(const std::shared_ptr& property_value) { property_name.emplace_back(property_value); } \
+protected: \
+ std::vector> property_name; \
+ void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
+ void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
+
+#define IMPLEMENT_COLLECTION_ENTITY_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name, edm_name, type) \
+ void myclass::get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+ { \
+ std::shared_ptr<::odata::core::odata_value> property_value; \
+ if (!pentity->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
+ { \
+ return; \
+ } \
+ auto property_collection_value = static_pointer_cast<::odata::core::odata_collection_value>(property_value); \
+ if (!property_collection_value) \
+ { \
+ return; \
+ } \
+ for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); ++iter) \
+ { \
+ auto entity_value = std::dynamic_pointer_cast<::odata::core::odata_entity_value>(*iter); \
+ if (!entity_value) \
+ { \
+ continue; \
+ } \
+ property_name.emplace_back(create_instance_from_entity(entity_value, m_service_context)); \
+ } \
+ } \
+ void myclass::set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+ { \
+ if (!pentity || !pentity->get_value_type()) \
+ { \
+ return; \
+ } \
+ auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pentity->get_value_type()); \
+ if (!entity_type) \
{ \
- return ; \
+ return; \
} \
- auto property_collection_value = static_pointer_cast<::odata::core::odata_collection_value>(property_value); \
- if (!property_collection_value) \
+ auto edm_property = entity_type->find_property(_XPLATSTR(#edm_name)); \
+ if (!edm_property) \
{ \
- return ; \
+ return; \
} \
- for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); iter++) \
+ auto property_type = edm_property->get_property_type(); \
+ auto collection_value_type = std::dynamic_pointer_cast<::odata::edm::edm_collection_type>(property_type); \
+ if (!collection_value_type) \
{ \
- auto entity_value = std::dynamic_pointer_cast<::odata::core::odata_entity_value>(*iter); \
- if (!entity_value) \
- { \
- continue ; \
- } \
- std::shared_ptr p_entity = create_instance_from_entity(entity_value, m_service_context); \
- property_name.push_back(std::dynamic_pointer_cast(p_entity)); \
+ return; \
} \
- } \
- ::pplx::task myclass::load_##property_name(const std::shared_ptr& builder) \
- { \
- if (m_service_context)\
- {\
- ::utility::string_t path = m_service_context->get_relative_path(m_edit_link) + U("/") + U(#edm_name);\
- auto query = m_service_context->create_query, odata_query_builder>(path);\
- if (builder) { query->set_query_builder(builder); } \
- return query->execute_query().then( \
- [this] (const std::vector>& ret_values) -> void \
- { \
- property_name = ret_values; \
- }); \
- }\
- return ::pplx::task_from_result(); \
+ std::shared_ptr<::odata::core::odata_collection_value> collection_value = ::odata::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
+ for (size_t i = 0; i < property_name.size(); ++i) \
+ { \
+ if (property_name[i]) collection_value->add_collection_value(std::dynamic_pointer_cast<::odata::core::odata_value>(property_name[i]->to_value())); \
+ } \
+ pentity->set_value(_XPLATSTR(#edm_name), collection_value); \
}
-#define DECLARE_COLLECTION_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
+#define DECLARE_COLLECTION_ENTITY_PROPERTY_IN_COMPLEX_MAPPING(property_name, edm_name, type) \
public: \
- const std::vector>& get_##property_name() { return property_name; } const\
+ const std::vector>& get_##property_name() const { return property_name; } \
void set_##property_name(std::vector> property_values) { property_name = std::move(property_values); } \
- void add_to_##property_name(const std::shared_ptr& property_value) { property_name.push_back(property_value); } \
+ void add_to_##property_name(const std::shared_ptr& property_value) { property_name.emplace_back(property_value); } \
protected: \
std::vector> property_name; \
- void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
- void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
+ void get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
+ void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
-#define IMPLEMENT_COLLECTION_COMPLEX_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name, edm_name, type) \
- void myclass::get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+#define IMPLEMENT_COLLECTION_ENTITY_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name, edm_name, type) \
+ void myclass::get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
- std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pentity->get_property_value(U(#edm_name), property_value) || !property_value) \
+ std::shared_ptr<::odata::core::odata_value> property_value; \
+ if (!pcomplex->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
{ \
- return ; \
+ return; \
} \
auto property_collection_value = static_pointer_cast<::odata::core::odata_collection_value>(property_value); \
if (!property_collection_value) \
{ \
- return ; \
+ return; \
} \
- for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); iter++) \
+ for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); ++iter) \
{ \
- auto complex_value = std::dynamic_pointer_cast<::odata::core::odata_complex_value>(*iter); \
- if (!complex_value) \
- { \
- continue ; \
+ auto entity_value = std::dynamic_pointer_cast<::odata::core::odata_entity_value>(*iter); \
+ if (!entity_value) \
+ { \
+ continue; \
} \
- property_name.push_back(create_instance_from_complex(complex_value, m_service_context)); \
+ property_name.emplace_back(create_instance_from_entity(entity_value, m_service_context)); \
} \
} \
- void myclass::set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
+ void myclass::set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
- if (!pentity || !pentity->get_value_type()) \
+ if (!pcomplex || !pcomplex->get_value_type()) \
{ \
- return ; \
+ return; \
} \
- auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pentity->get_value_type()); \
- if (!entity_type) \
+ auto complex_type = std::dynamic_pointer_cast<::odata::edm::edm_complex_type>(pcomplex->get_value_type()); \
+ if (!complex_type) \
{ \
- return ; \
+ return; \
} \
- auto edm_property = entity_type->find_property(U(#edm_name)); \
+ auto edm_property = complex_type->find_property(_XPLATSTR(#edm_name)); \
if (!edm_property) \
{ \
- return ; \
+ return; \
} \
auto property_type = edm_property->get_property_type(); \
auto collection_value_type = std::dynamic_pointer_cast<::odata::edm::edm_collection_type>(property_type); \
if (!collection_value_type) \
{ \
- return ; \
+ return; \
} \
- std::shared_ptr<::odata::core::odata_collection_value> collection_value = std::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
- for (size_t i = 0; i < property_name.size(); i++) \
+ std::shared_ptr<::odata::core::odata_collection_value> collection_value = ::odata::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
+ for (size_t i = 0; i < property_name.size(); ++i) \
{ \
- if (property_name[i]) collection_value->add_collection_value(std::dynamic_pointer_cast<::odata::core::odata_value>(property_name[i]->to_value())); \
+ if (property_name[i]) collection_value->add_collection_value(std::dynamic_pointer_cast<::odata::core::odata_value>(property_name[i]->to_value())); \
} \
- pentity->set_value(U(#edm_name), collection_value); \
+ pcomplex->set_value(_XPLATSTR(#edm_name), collection_value); \
}
#define DECLARE_ENUM_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
public: \
- const type& get_##property_name() { return property_name; } const \
+ const type& get_##property_name() const { return property_name; } \
void set_##property_name(const type& property_value) { property_name = property_value; } \
protected: \
type property_name; \
void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
- void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
+ void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
#define IMPLEMENT_ENUM_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name, edm_name, type) \
void myclass::get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
if (!pentity) \
{ \
- return ; \
+ return; \
} \
- std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pentity->get_property_value(U(#edm_name), property_value) || !property_value) \
- { \
- return ; \
+ std::shared_ptr<::odata::core::odata_value> property_value; \
+ if (!pentity->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
+ { \
+ return; \
} \
auto enum_value = std::dynamic_pointer_cast<::odata::core::odata_enum_value>(property_value); \
- if (enum_value) \
- { \
- property_name = enum_type_resolver::get_enum_type_from_string(enum_value->to_string(), type()); \
- } \
+ if (enum_value) \
+ { \
+ property_name = enum_type_resolver::get_enum_type_from_string(enum_value->to_string(), type()); \
+ } \
} \
void myclass::set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
- if (!pentity) \
- { \
- return ; \
- } \
+ if (!pentity) \
+ { \
+ return; \
+ } \
auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pentity->get_value_type()); \
if (!entity_type) \
{ \
- return ; \
+ return; \
} \
- auto edm_property = entity_type->find_property(U(#edm_name)); \
+ auto edm_property = entity_type->find_property(_XPLATSTR(#edm_name)); \
if (!edm_property) \
{ \
- return ; \
+ return; \
} \
auto property_type = edm_property->get_property_type(); \
- auto enum_value = std::make_shared<::odata::core::odata_enum_value>(property_type, enum_type_resolver::get_string_from_enum_type(property_name)); \
- pentity->set_value(U(#edm_name), enum_value); \
+ auto enum_value = ::odata::make_shared<::odata::core::odata_enum_value>(property_type, enum_type_resolver::get_string_from_enum_type(property_name)); \
+ pentity->set_value(_XPLATSTR(#edm_name), enum_value); \
}
#define DECLARE_ENUM_PROPERTY_IN_COMPLEX_MAPPING(property_name, edm_name, type) \
public: \
- const type& get_##property_name() { return property_name; } const \
+ const type& get_##property_name() const { return property_name; } \
void set_##property_name(const type& property_value) { property_name = property_value; } \
protected: \
type property_name; \
void get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
- void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
+ void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
#define IMPLEMENT_ENUM_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name, edm_name, type) \
void myclass::get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
if (!pcomplex) \
{ \
- return ; \
+ return; \
} \
- std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pcomplex->get_property_value(U(#edm_name), property_value) || !property_value) \
- { \
- return ; \
+ std::shared_ptr<::odata::core::odata_value> property_value; \
+ if (!pcomplex->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
+ { \
+ return; \
} \
auto enum_value = std::dynamic_pointer_cast<::odata::core::odata_enum_value>(property_value); \
- if (enum_value) \
- { \
- property_name = enum_type_resolver::get_enum_type_from_string(enum_value->to_string(), type()); \
- } \
+ if (enum_value) \
+ { \
+ property_name = enum_type_resolver::get_enum_type_from_string(enum_value->to_string(), type()); \
+ } \
} \
void myclass::set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
- if (!pcomplex) \
- { \
- return ; \
- } \
+ if (!pcomplex) \
+ { \
+ return; \
+ } \
auto complex_type = std::dynamic_pointer_cast<::odata::edm::edm_complex_type>(pcomplex->get_value_type()); \
if (!complex_type) \
{ \
- return ; \
+ return; \
} \
- auto edm_property = complex_type->find_property(U(#edm_name)); \
+ auto edm_property = complex_type->find_property(_XPLATSTR(#edm_name)); \
if (!edm_property) \
{ \
- return ; \
+ return; \
} \
auto property_type = edm_property->get_property_type(); \
- auto enum_value = std::make_shared<::odata::core::odata_enum_value>(property_type, enum_type_resolver::get_string_from_enum_type(property_name)); \
- pcomplex->set_value(U(#edm_name), enum_value); \
+ auto enum_value = ::odata::make_shared<::odata::core::odata_enum_value>(property_type, enum_type_resolver::get_string_from_enum_type(property_name)); \
+ pcomplex->set_value(_XPLATSTR(#edm_name), enum_value); \
}
#define DECLARE_COLLECTION_ENUM_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
public: \
- const std::vector& get_##property_name() { return property_name; } const \
+ const std::vector& get_##property_name() const { return property_name; } \
void set_##property_name(const std::vector& property_values) { property_name = property_values; } \
- void add_to_##property_name(type property_value) { property_name.push_back(property_value); } \
+ void add_to_##property_name(type property_value) { property_name.emplace_back(property_value); } \
protected: \
std::vector property_name; \
void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
- void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
+ void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
#define IMPLEMENT_COLLECTION_ENUM_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name, edm_name, type) \
void myclass::get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pentity->get_property_value(U(#edm_name), property_value) || !property_value) \
+ if (!pentity->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
{ \
- return ; \
+ return; \
} \
auto property_collection_value = static_pointer_cast<::odata::core::odata_collection_value>(property_value); \
if (!property_collection_value) \
{ \
- return ; \
+ return; \
} \
- for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); iter++) \
+ for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); ++iter) \
{ \
- auto enum_value = std::dynamic_pointer_cast<::odata::core::odata_enum_value>(*iter); \
+ auto enum_value = std::dynamic_pointer_cast<::odata::core::odata_enum_value>(*iter); \
if (!enum_value) \
- { \
- continue ; \
+ { \
+ continue; \
} \
- property_name.push_back(enum_type_resolver::get_enum_type_from_string(enum_value->to_string(), type())); \
+ property_name.emplace_back(enum_type_resolver::get_enum_type_from_string(enum_value->to_string(), type())); \
} \
} \
void myclass::set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
if (!pentity || !pentity->get_value_type()) \
{ \
- return ; \
+ return; \
} \
- auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pentity->get_value_type()); \
+ auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pentity->get_value_type()); \
if (!entity_type) \
{ \
- return ; \
+ return; \
} \
- auto edm_property = entity_type->find_property(U(#edm_name)); \
+ auto edm_property = entity_type->find_property(_XPLATSTR(#edm_name)); \
if (!edm_property) \
{ \
- return ; \
+ return; \
} \
auto property_type = edm_property->get_property_type(); \
auto collection_value_type = std::dynamic_pointer_cast<::odata::edm::edm_collection_type>(property_type); \
if (!collection_value_type) \
{ \
- return ; \
+ return; \
} \
- std::shared_ptr<::odata::core::odata_collection_value> collection_value = std::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
- for (size_t i = 0; i < property_name.size(); i++) \
+ std::shared_ptr<::odata::core::odata_collection_value> collection_value = ::odata::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
+ for (size_t i = 0; i < property_name.size(); ++i) \
{ \
- collection_value->add_collection_value(std::make_shared<::odata::core::odata_enum_value>(collection_value_type->get_element_type(), enum_type_resolver::get_string_from_enum_type(property_name[i]))); \
+ collection_value->add_collection_value(::odata::make_shared<::odata::core::odata_enum_value>(collection_value_type->get_element_type(), enum_type_resolver::get_string_from_enum_type(property_name[i]))); \
} \
- pentity->set_value(U(#edm_name), collection_value); \
+ pentity->set_value(_XPLATSTR(#edm_name), collection_value); \
}
#define DECLARE_COLLECTION_ENUM_PROPERTY_IN_COMPLEX_MAPPING(property_name, edm_name, type) \
public: \
- const std::vector& get_##property_name() { return property_name; } const \
+ const std::vector& get_##property_name() const { return property_name; } \
void set_##property_name(const std::vector& property_values) { property_name = property_values; } \
- void add_to_##property_name(type property_value) { property_name.push_back(property_value); } \
+ void add_to_##property_name(type property_value) { property_name.emplace_back(property_value); } \
protected: \
std::vector property_name; \
void get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex); \
- void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
+ void set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex);
#define IMPLEMENT_COLLECTION_ENUM_PROPERTY_IN_COMPLEX_MAPPING(myclass, property_name, edm_name, type) \
void myclass::get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pcomplex->get_property_value(U(#edm_name), property_value) || !property_value) \
+ if (!pcomplex->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
{ \
- return ; \
+ return; \
} \
auto property_collection_value = static_pointer_cast<::odata::core::odata_collection_value>(property_value); \
if (!property_collection_value) \
{ \
- return ; \
+ return; \
} \
- for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); iter++) \
+ for (auto iter = property_collection_value->get_collection_values().cbegin(); iter != property_collection_value->get_collection_values().cend(); ++iter) \
{ \
- auto enum_value = std::dynamic_pointer_cast<::odata::core::odata_enum_value>(*iter); \
+ auto enum_value = std::dynamic_pointer_cast<::odata::core::odata_enum_value>(*iter); \
if (!enum_value) \
- { \
- continue ; \
+ { \
+ continue; \
} \
- property_name.push_back(enum_type_resolver::get_enum_type_from_string(enum_value->to_string(), type())); \
+ property_name.emplace_back(enum_type_resolver::get_enum_type_from_string(enum_value->to_string(), type())); \
} \
} \
void myclass::set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
if (!pcomplex || !pcomplex->get_value_type()) \
{ \
- return ; \
+ return; \
} \
- auto complex_type = std::dynamic_pointer_cast<::odata::edm::edm_complex_type>(pcomplex->get_value_type()); \
+ auto complex_type = std::dynamic_pointer_cast<::odata::edm::edm_complex_type>(pcomplex->get_value_type()); \
if (!complex_type) \
{ \
- return ; \
+ return; \
} \
- auto edm_property = complex_type->find_property(U(#edm_name)); \
+ auto edm_property = complex_type->find_property(_XPLATSTR(#edm_name)); \
if (!edm_property) \
{ \
- return ; \
+ return; \
} \
auto property_type = edm_property->get_property_type(); \
auto collection_value_type = std::dynamic_pointer_cast<::odata::edm::edm_collection_type>(property_type); \
if (!collection_value_type) \
{ \
- return ; \
+ return; \
} \
- std::shared_ptr<::odata::core::odata_collection_value> collection_value = std::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
- for (size_t i = 0; i < property_name.size(); i++) \
+ std::shared_ptr<::odata::core::odata_collection_value> collection_value = ::odata::make_shared<::odata::core::odata_collection_value>(collection_value_type); \
+ for (size_t i = 0; i < property_name.size(); ++i) \
{ \
- collection_value->add_collection_value(std::make_shared<::odata::core::odata_enum_value>(collection_value_type->get_element_type(), enum_type_resolver::get_string_from_enum_type(property_name[i]))); \
+ collection_value->add_collection_value(::odata::make_shared<::odata::core::odata_enum_value>(collection_value_type->get_element_type(), enum_type_resolver::get_string_from_enum_type(property_name[i]))); \
} \
- pcomplex->set_value(U(#edm_name), collection_value); \
+ pcomplex->set_value(_XPLATSTR(#edm_name), collection_value); \
}
#define DECLARE_NULLABLE_ENUM_PROPERTY_IN_ENTITY_MAPPING(property_name, edm_name, type) \
public: \
- type* get_##property_name() { return property_name.get(); } const \
+ type* get_##property_name() const { return property_name.get(); } \
void set_##property_name(type property_value) \
{ \
- property_name = std::make_shared(property_value); \
+ property_name = ::odata::make_shared(property_value); \
} \
protected: \
std::shared_ptr property_name; \
void get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity); \
- void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
+ void set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity);
#define IMPLEMENT_NULLABLE_ENUM_PROPERTY_IN_ENTITY_MAPPING(myclass, property_name, edm_name, type) \
void myclass::get_##property_name##_from_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pentity->get_property_value(U(#edm_name), property_value) || !property_value) \
+ if (!pentity->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
{ \
- return ; \
+ return; \
} \
auto enum_value = std::dynamic_pointer_cast<::odata::core::odata_enum_value>(property_value); \
if (enum_value) \
{ \
- property_name = std::make_shared(enum_type_resolver::get_enum_type_from_string(enum_value->to_string(), type())); \
+ property_name = ::odata::make_shared(enum_type_resolver::get_enum_type_from_string(enum_value->to_string(), type())); \
} \
} \
void myclass::set_##property_name##_to_entity(const shared_ptr<::odata::core::odata_entity_value>& pentity) \
{ \
if (!pentity || !property_name) \
- { \
- return ; \
- } \
+ { \
+ return; \
+ } \
auto entity_type = std::dynamic_pointer_cast<::odata::edm::edm_entity_type>(pentity->get_value_type()); \
if (!entity_type) \
{ \
- return ; \
+ return; \
} \
- auto edm_property = entity_type->find_property(U(#edm_name)); \
+ auto edm_property = entity_type->find_property(_XPLATSTR(#edm_name)); \
if (!edm_property) \
{ \
- return ; \
+ return; \
} \
auto property_type = edm_property->get_property_type(); \
- auto enum_value = std::make_shared<::odata::core::odata_enum_value>(property_type, enum_type_resolver::get_string_from_enum_type(*property_name)); \
- pentity->set_value(U(#edm_name), enum_value); \
+ auto enum_value = ::odata::make_shared<::odata::core::odata_enum_value>(property_type, enum_type_resolver::get_string_from_enum_type(*property_name)); \
+ pentity->set_value(_XPLATSTR(#edm_name), enum_value); \
}
#define DECLARE_NULLABLE_ENUM_PROPERTY_IN_COMPLEX_MAPPING(property_name, edm_name, type) \
public: \
- type* get_##property_name() { return property_name.get(); } const \
+ type* get_##property_name() const { return property_name.get(); } \
void set_##property_name(type property_value) \
- { \
- property_name = std::make_shared(property_value); \
+ { \
+ property_name = ::odata::make_shared(property_value); \
} \
protected: \
std::shared_ptr property_name; \
@@ -1103,157 +1707,157 @@ protected: \
void myclass::get_##property_name##_from_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
std::shared_ptr<::odata::core::odata_value> property_value; \
- if (!pcomplex->get_property_value(U(#edm_name), property_value) || !property_value) \
+ if (!pcomplex->get_property_value(_XPLATSTR(#edm_name), property_value) || !property_value) \
{ \
- return ; \
+ return; \
} \
auto enum_value = std::dynamic_pointer_cast<::odata::core::odata_enum_value>(property_value); \
if (enum_value) \
{ \
- property_name = std::make_shared(enum_type_resolver::get_enum_type_from_string(enum_value->to_string(), type())); \
+ property_name = ::odata::make_shared(enum_type_resolver::get_enum_type_from_string(enum_value->to_string(), type())); \
} \
} \
void myclass::set_##property_name##_to_complex(const shared_ptr<::odata::core::odata_complex_value>& pcomplex) \
{ \
if (!pcomplex || !property_name) \
- { \
- return ; \
- } \
+ { \
+ return; \
+ } \
auto complex_type = std::dynamic_pointer_cast<::odata::edm::edm_complex_type>(pcomplex->get_value_type()); \
if (!complex_type) \
{ \
- return ; \
+ return; \
} \
- auto edm_property = complex_type->find_property(U(#edm_name)); \
+ auto edm_property = complex_type->find_property(_XPLATSTR(#edm_name)); \
if (!edm_property) \
{ \
- return ; \
+ return; \
} \
auto property_type = edm_property->get_property_type(); \
- auto enum_value = std::make_shared<::odata::core::odata_enum_value>(property_type, enum_type_resolver::get_string_from_enum_type(*property_name)); \
- pcomplex->set_value(U(#edm_name), enum_value); \
+ auto enum_value = ::odata::make_shared<::odata::core::odata_enum_value>(property_type, enum_type_resolver::get_string_from_enum_type(*property_name)); \
+ pcomplex->set_value(_XPLATSTR(#edm_name), enum_value); \
}
#define DECLARE_FUNCTION_ENUM_TYPE_FROM_STRING(enum_type) \
- static enum_type get_enum_type_from_string(const ::utility::string_t& enum_string, enum_type default_enum_value);
+ static enum_type get_enum_type_from_string(const ::odata::string_t& enum_string, enum_type default_enum_value);
#define DECLARE_FUNCTION_STRING_FROM_ENUM_TYPE(enum_type) \
- static ::utility::string_t get_string_from_enum_type(const enum_type& enum_value);
+ static ::odata::string_t get_string_from_enum_type(const enum_type& enum_value);
#define DECLARE_GET_ENUM_TYPE_NAMESPACE(enum_type, name_space) \
- static ::utility::string_t get_enum_type_namespace(const enum_type& enum_value); \
+ static ::odata::string_t get_enum_type_namespace(const enum_type& enum_value);
#define IMPLEMENT_GET_ENUM_TYPE_NAMESPACE(enum_type, name_space) \
- ::utility::string_t enum_type_resolver::get_enum_type_namespace(const enum_type& enum_value) \
+ ::odata::string_t enum_type_resolver::get_enum_type_namespace(const enum_type& /*enum_value*/) \
{ \
- return U(#name_space); \
+ return _XPLATSTR(#name_space); \
}
#define BGEIN_IMPLEMENT_FUNCTION_ENUM_TYPE_FROM_STRING(enum_type) \
- enum_type enum_type_resolver::get_enum_type_from_string(const ::utility::string_t& enum_string, enum_type default_enum_value) \
+ enum_type enum_type_resolver::get_enum_type_from_string(const ::odata::string_t& enum_string, enum_type default_enum_value) \
{ \
- enum_type ret = default_enum_value;
+ enum_type ret = default_enum_value;
#define ON_IMPLEMENT_FUNCTION_ENUM_TYPE_FROM_STRING(enum_value_string, enum_type) \
- if (enum_string == U(#enum_value_string)) \
+ if (enum_string == _XPLATSTR(#enum_value_string)) \
{ \
ret = enum_type; \
}
#define END_IMPLEMENT_FUNCTION_ENUM_TYPE_FROM_STRING(enum_type) \
- return ret; \
- }
+ return ret; \
+ }
#define BGEIN_IMPLEMENT_FUNCTION_STRING_FROM_ENUM_TYPE(enum_type) \
- ::utility::string_t enum_type_resolver::get_string_from_enum_type(const enum_type& enum_value) \
+ ::odata::string_t enum_type_resolver::get_string_from_enum_type(const enum_type& enum_value) \
{ \
- ::utility::string_t ret;
+ ::odata::string_t ret;
#define ON_IMPLEMENT_FUNCTION_STRING_FROM_ENUM_TYPE(enum_type, enum_value_string) \
if (enum_value == enum_type) \
{ \
- ret = U(#enum_value_string); \
+ ret = _XPLATSTR(#enum_value_string); \
}
#define END_IMPLEMENT_FUNCTION_STRING_FROM_ENUM_TYPE(enum_type) \
- return ret; \
- }
+ return ret; \
+ }
#define IMPLEMENT_EMPTY_DERIVED_TYPE_CREATOR_MAP(myclass) \
- std::unordered_map<::utility::string_t, CREATE_CALL_FOR_ENTITY> myclass::_derived_entity_creator_map;
+ std::unordered_map<::odata::string_t, CREATE_CALL_FOR_ENTITY> myclass::_derived_entity_creator_map;
#define BEGIN_IMPLEMENT_ENTITY_DERIVED_TYPE_CREATOR_MAP(myclass) \
- create_map_for_entity_type::value_type myclass::_init_creator_map_values[] = {
+ create_map_for_entity_type::value_type myclass::_init_creator_map_values[] = {
#define ON_IMPLEMENT_ENTITY_DERIVED_TYPE_CREATOR_MAP(keyname, funcname) \
- create_map_for_entity_type::value_type(U(#keyname), (CREATE_CALL_FOR_ENTITY)&create_##funcname),
+ create_map_for_entity_type::value_type(_XPLATSTR(#keyname), (CREATE_CALL_FOR_ENTITY)&create_##funcname),
#define END_IMPLEMENT_ENTITY_DERIVED_TYPE_CREATOR_MAP(myclass) \
- }; \
- std::unordered_map<::utility::string_t, CREATE_CALL_FOR_ENTITY> myclass::_derived_entity_creator_map(_init_creator_map_values, _init_creator_map_values + sizeof(_init_creator_map_values) / sizeof(create_map_for_entity_type::value_type));
+ }; \
+ std::unordered_map<::odata::string_t, CREATE_CALL_FOR_ENTITY> myclass::_derived_entity_creator_map(_init_creator_map_values, _init_creator_map_values + sizeof(_init_creator_map_values) / sizeof(create_map_for_entity_type::value_type));
#define DECLARE_DERIVED_ENTITY_CREATOR_FUNC(derivedclassname, funcname) \
- static std::shared_ptr create_##funcname(const std::shared_ptr<::odata::codegen::odata_service_context>& service_context) \
- { \
- return std::make_shared(service_context); \
- }
+ static std::shared_ptr create_##funcname(const std::shared_ptr<::odata::codegen::odata_service_context>& service_context) \
+ { \
+ return ::odata::make_shared(service_context); \
+ }
#define IMPLEMENT_COMPLEX_DERIVED_TYPE_CREATOR_MAP(myclass) \
- std::unordered_map<::utility::string_t, CREATE_CALL_FOR_COMPLEX> myclass::_derived_complex_creator_map;
+ std::unordered_map<::odata::string_t, CREATE_CALL_FOR_COMPLEX> myclass::_derived_complex_creator_map;
#define BEGIN_IMPLEMENT_COMPLEX_DERIVED_TYPE_CREATOR_MAP(myclass) \
- create_map_for_complex_type::value_type myclass::_init_creator_map_values[] = {
+ create_map_for_complex_type::value_type myclass::_init_creator_map_values[] = {
#define ON_IMPLEMENT_COMPLEX_DERIVED_TYPE_CREATOR_MAP(keyname, funcname) \
- create_map_for_complex_type::value_type(U(#keyname), (CREATE_CALL_FOR_COMPLEX)&create_##funcname),
+ create_map_for_complex_type::value_type(_XPLATSTR(#keyname), (CREATE_CALL_FOR_COMPLEX)&create_##funcname),
#define END_IMPLEMENT_COMPLEX_DERIVED_TYPE_CREATOR_MAP(myclass) \
- }; \
- std::unordered_map<::utility::string_t, CREATE_CALL_FOR_COMPLEX> myclass::_derived_complex_creator_map(_init_creator_map_values, _init_creator_map_values + sizeof(_init_creator_map_values) / sizeof(create_map_for_entity_type::value_type));
+ }; \
+ std::unordered_map<::odata::string_t, CREATE_CALL_FOR_COMPLEX> myclass::_derived_complex_creator_map(_init_creator_map_values, _init_creator_map_values + sizeof(_init_creator_map_values) / sizeof(create_map_for_entity_type::value_type));
#define DECLARE_DERIVED_COMPLEX_CREATOR_FUNC(derivedclassname, funcname) \
- static std::shared_ptr create_##funcname(const std::shared_ptr<::odata::codegen::odata_service_context>& service_context) \
- { \
- return std::make_shared(service_context); \
- }
+ static std::shared_ptr create_##funcname(const std::shared_ptr<::odata::codegen::odata_service_context>& service_context) \
+ { \
+ return ::odata::make_shared(service_context); \
+ }
#define DECLARE_GET_KEY_PROPERTY_STRING_NO_PARAM(baseclass) \
public: \
- ::utility::string_t get_key_property_string(bool with_key_name = false) \
+ ::odata::string_t get_key_property_string(bool with_key_name = false) \
{ \
return baseclass::get_key_property_string(with_key_name); \
}
#define DECLARE_GET_KEY_PROPERTY_STRING_ONE_PARAM(baseclass, Name_1, key_1) \
public: \
- ::utility::string_t get_key_property_string(bool with_key_name = false) \
+ ::odata::string_t get_key_property_string(bool with_key_name = false) \
{ \
- ::utility::stringstream_t ostr; \
- ::utility::string_t key_string = baseclass::get_key_property_string(with_key_name); \
+ ::utility::stringstream_t ostr; \
+ ::odata::string_t key_string = baseclass::get_key_property_string(with_key_name); \
if (key_string.empty()) \
{ \
- if (with_key_name) \
- ostr << U(#Name_1) << U("=") << ::utility::conversions::print_string(key_1); \
+ if (with_key_name) \
+ ostr << _XPLATSTR(#Name_1) << _XPLATSTR("=") << ::utility::conversions::print_string(key_1); \
else \
- ostr << ::utility::conversions::print_string(key_1); \
+ ostr << ::utility::conversions::print_string(key_1); \
key_string = ostr.str(); \
} \
else \
{ \
- key_string = baseclass::get_key_property_string(true); \
- ostr << U(#Name_1) << U("=") << ::utility::conversions::print_string(key_1); \
- key_string += U(",") + ostr.str(); \
+ key_string = baseclass::get_key_property_string(true); \
+ ostr << _XPLATSTR(#Name_1) << _XPLATSTR("=") << ::utility::conversions::print_string(key_1); \
+ key_string += _XPLATSTR(",") + ostr.str(); \
} \
return key_string; \
}
#define DECLARE_GET_KEY_PROPERTY_STRING_TWO_PARAM(baseclass, Name_1, key_1, Name_2, key_2) \
public: \
- ::utility::string_t get_key_property_string(bool with_key_name = false) \
+ ::odata::string_t get_key_property_string(bool /*with_key_name*/ = false) \
{ \
- ::utility::stringstream_t ostr; \
- ostr << U(#Name_1) << U("=") << ::utility::conversions::print_string(key_1) << U(",") << U(#Name_2) << U("=") + ::utility::conversions::print_string(key_2); \
- ::utility::string_t key_string = baseclass::get_key_property_string(true); \
+ ::utility::stringstream_t ostr; \
+ ostr << _XPLATSTR(#Name_1) << _XPLATSTR("=") << ::utility::conversions::print_string(key_1) << _XPLATSTR(",") << _XPLATSTR(#Name_2) << _XPLATSTR("=") + ::utility::conversions::print_string(key_2); \
+ ::odata::string_t key_string = baseclass::get_key_property_string(true); \
if (key_string.empty()) \
{ \
key_string = ostr.str(); \
@@ -1267,11 +1871,11 @@ public: \
#define DECLARE_GET_KEY_PROPERTY_STRING_THREE_PARAM(baseclass, Name_1, key_1, Name_2, key_2, Name_3, key_3) \
public: \
- ::utility::string_t get_key_property_string(bool with_key_name = false) \
+ ::odata::string_t get_key_property_string(bool /*with_key_name*/ = false) \
{ \
- ::utility::stringstream_t ostr; \
- ostr << U(#Name_1) << U("=") << ::utility::conversions::print_string(key_1) << U(",") << U(#Name_2) << U("=") << ::utility::conversions::print_string(key_2) << U(",") << U(#Name_3) << U("=") << ::utility::conversions::print_string(key_3);\
- ::utility::string_t key_string = baseclass::get_key_property_string(true); \
+ ::utility::stringstream_t ostr; \
+ ostr << _XPLATSTR(#Name_1) << _XPLATSTR("=") << ::utility::conversions::print_string(key_1) << _XPLATSTR(",") << _XPLATSTR(#Name_2) << _XPLATSTR("=") << ::utility::conversions::print_string(key_2) << _XPLATSTR(",") << _XPLATSTR(#Name_3) << _XPLATSTR("=") << ::utility::conversions::print_string(key_3);\
+ ::odata::string_t key_string = baseclass::get_key_property_string(true); \
if (key_string.empty()) \
{ \
key_string = ostr.str(); \
@@ -1285,11 +1889,11 @@ public: \
#define DECLARE_GET_KEY_PROPERTY_STRING_FOUR_PARAM(baseclass, Name_1, key_1, Name_2, key_2, Name_3, key_3, Name_4, key_4) \
public: \
- ::utility::string_t get_key_property_string(bool with_key_name = false) \
+ ::odata::string_t get_key_property_string(bool /*with_key_name*/ = false) \
{ \
- ::utility::stringstream_t ostr; \
- ostr << U(#Name_1) << U("=") << ::utility::conversions::print_string(key_1) << U(",") << U(#Name_2) << U("=") << ::utility::conversions::print_string(key_2) << U(",") << U(#Name_3) << U("=") << ::utility::conversions::print_string(key_3) << U(",") << U(#Name_4) << U("=") << ::utility::conversions::print_string(key_4);\
- ::utility::string_t key_string = baseclass::get_key_property_string(true); \
+ ::utility::stringstream_t ostr; \
+ ostr << _XPLATSTR(#Name_1) << _XPLATSTR("=") << ::utility::conversions::print_string(key_1) << _XPLATSTR(",") << _XPLATSTR(#Name_2) << _XPLATSTR("=") << ::utility::conversions::print_string(key_2) << _XPLATSTR(",") << _XPLATSTR(#Name_3) << _XPLATSTR("=") << ::utility::conversions::print_string(key_3) << _XPLATSTR(",") << _XPLATSTR(#Name_4) << _XPLATSTR("=") << ::utility::conversions::print_string(key_4);\
+ ::odata::string_t key_string = baseclass::get_key_property_string(true); \
if (key_string.empty()) \
{ \
key_string = ostr.str(); \
@@ -1308,7 +1912,7 @@ ::pplx::task funcname();
#define IMPLEMENT_OPERATION_IMPORT_P0(myclass, funcname, executor, isfunction) \
::pplx::task myclass::funcname() \
{ \
- ::utility::string_t function_query_url = U(#funcname); \
+ ::odata::string_t function_query_url = _XPLATSTR(#funcname); \
std::vector> parameters; \
return create_query(function_query_url)->execute_operation_query(parameters, isfunction); \
}
@@ -1320,9 +1924,9 @@ ::pplx::task funcname(type1 value1);
#define IMPLEMENT_OPERATION_IMPORT_P1(myclass, funcname, executor, isfunction, key1, type1, value1) \
::pplx::task myclass::funcname(type1 value1) \
{ \
- ::utility::string_t function_query_url = U(#funcname); \
+ ::odata::string_t function_query_url = _XPLATSTR(#funcname); \
std::vector> parameters; \
- parameters.push_back(std::make_shared(U(#key1), format_function_parameter(value1))); \
+ parameters.emplace_back(::odata::make_shared(_XPLATSTR(#key1), format_function_parameter(value1))); \
return create_query(function_query_url)->execute_operation_query(parameters, isfunction); \
}
@@ -1333,11 +1937,11 @@ ::pplx::task funcname(type1 value1, type2 value2
#define IMPLEMENT_OPERATION_IMPORT_P2(myclass, funcname, executor, isfunction, key1, type1, value1, key2, type2, value2) \
::pplx::task myclass::funcname(type1 value1, type2 value2) \
{ \
- ::utility::string_t function_query_url = U(#funcname); \
+ ::odata::string_t function_query_url = _XPLATSTR(#funcname); \
std::vector> parameters; \
- parameters.push_back(std::make_shared(U(#key1), format_function_parameter(value1))); \
- parameters.push_back(std::make_shared(U(#key2), format_function_parameter(value2))); \
- return create_query(function_query_url)->execute_operation_query(parameters, isfunction); \
+ parameters.emplace_back(::odata::make_shared(_XPLATSTR(#key1), format_function_parameter(value1))); \
+ parameters.emplace_back(::odata::make_shared(_XPLATSTR(#key2), format_function_parameter(value2))); \
+ return create_query(function_query_url)->execute_operation_query(parameters, isfunction); \
}
#define DECLARE_OPERATION_IMPORT_P3(myclass, funcname, executor, isfunction, key1, type1, value1, key2, type2, value2, key3, type3, value3) \
@@ -1345,14 +1949,14 @@ public: \
::pplx::task funcname(type1 value1, type2 value2, type3 value3);
#define IMPLEMENT_OPERATION_IMPORT_P3(myclass, funcname, executor, isfunction, key1, type1, value1, key2, type2, value2, key3, type3, value3) \
-::pplx::task myclass::funcname(type1 value1, type2 value2, type3 value3) \
+::pplx::task myclass::funcname(type1 value1, type2 value2, type3 value3) \
{ \
- ::utility::string_t function_query_url = U(#funcname); \
+ ::odata::string_t function_query_url = _XPLATSTR(#funcname); \
std::vector> parameters; \
- parameters.push_back(std::make_shared(U(#key1), format_function_parameter(value1))); \
- parameters.push_back(std::make_shared(U(#key2), format_function_parameter(value2))); \
- parameters.push_back(std::make_shared(U(#key3), format_function_parameter(value3))); \
- return create_query(function_query_url)->execute_operation_query(parameters, isfunction); \
+ parameters.emplace_back(::odata::make_shared(_XPLATSTR(#key1), format_function_parameter(value1))); \
+ parameters.emplace_back(::odata::make_shared(_XPLATSTR(#key2), format_function_parameter(value2))); \
+ parameters.emplace_back(::odata::make_shared(_XPLATSTR(#key3), format_function_parameter(value3))); \
+ return create_query(function_query_url)->execute_operation_query(parameters, isfunction); \
}
#define DECLARE_OPERATION_IMPORT_P4(myclass, funcname, executor, isfunction, key1, type1, value1, key2, type2, value2, key3, type3, value3, key4, type4, value4) \
@@ -1360,15 +1964,15 @@ public: \
::pplx::task funcname(type1 value1, type2 value2, type3 value3, type4 value4);
#define IMPLEMENT_OPERATION_IMPORT_P4(myclass, funcname, executor, isfunction, key1, type1, value1, key2, type2, value2, key3, type3, value3, key4, type4, value4) \
-::pplx::task myclass::funcname(type1 value1, type2 value2, type3 value3, type4 value4) \
+::pplx::task myclass::funcname(type1 value1, type2 value2, type3 value3, type4 value4) \
{ \
- ::utility::string_t function_query_url = U(#funcname); \
+ ::odata::string_t function_query_url = _XPLATSTR(#funcname); \
std::vector> parameters; \
- parameters.push_back(std::make_shared(U(#key1), format_function_parameter(value1))); \
- parameters.push_back(std::make_shared(U(#key2), format_function_parameter(value2))); \
- parameters.push_back(std::make_shared