Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major improvements and fixes to the C++ OData client library, see below: #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
423 changes: 269 additions & 154 deletions include/odata/client/odata_client.h

Large diffs are not rendered by default.

107 changes: 59 additions & 48 deletions include/odata/client/odata_client_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/// <summary>
Expand All @@ -41,64 +41,75 @@ class odata_client;
class client_options
{
public:
/// <summary>
/// Represents options used when creating an OData client instance.
/// </summary>
client_options() : m_prefer_json(true), m_verb_tunneling(false),m_json_mdlevel(U("minimal")), m_credential(nullptr)
{
}

/// <summary>
/// Sets the client to request responses formatted as JSON, when applicable
/// </summary>
client_options prefer_json(::utility::string_t mdlevel = U("minimal"))
{
m_prefer_json = true;
m_json_mdlevel = mdlevel;
return *this;
}

/// <summary>
/// Sets the client to request responses formatted as an Atom feed, when applicable
/// </summary>
client_options prefer_atom()
{
m_prefer_json = false;
m_json_mdlevel.clear();
return *this;
}

/// <summary>
/// Use verb tunneling when making non-GET/POST requests.
/// </summary>
client_options do_verb_tunneling()
{
m_verb_tunneling = true;
return *this;
}

void enable_client_credential(::utility::string_t username, ::utility::string_t password)
/// <summary>
/// Represents options used when creating an OData client instance.
/// </summary>
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<odata_client_credential>(std::move(username), std::move(password));
}

/// <summary>
/// Sets the client to request responses formatted as JSON, when applicable
/// </summary>
client_options prefer_json(::odata::string_t mdlevel = _XPLATSTR("minimal"))
{
m_prefer_json = true;
m_json_mdlevel = mdlevel;
return *this;
}

/// <summary>
/// Sets the client to request responses formatted as an Atom feed, when applicable
/// </summary>
client_options prefer_atom()
{
m_prefer_json = false;
m_json_mdlevel.clear();
return *this;
}

/// <summary>
/// Use verb tunneling when making non-GET/POST requests.
/// </summary>
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<odata_client_credential>(std::move(username), std::move(password));
}

void disable_client_credential()
{
m_credential = nullptr;
}

const std::shared_ptr<odata_client_credential>& get_credential_setting()
void set_suppress_odata_type(bool SuppressODataType)
{
m_suppress_odata_type = SuppressODataType;
}

const std::shared_ptr<odata_client_credential>& 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<odata_client_credential> m_credential;
bool m_suppress_odata_type;
};

}}
}}
Loading